Jump to content

function Combat:DoAreaAttack has a bug


Rickzzs
  • DLC VERSION - IMPORTANT!: Vanilla - NO DLC, Reign of Giants, Shipwrecked, Hamlet Pending

Here is a version of mine:

function Combat:DoAreaAttack(target, range, weapon, validfn, stimuli, excludetags)
        local hitcount = 0
        local x, y, z = target.Transform:GetWorldPosition()
        local ents = TheSim:FindEntities(x, y, z, range, nil, excludetags
            or {"falling", "FX", "NOCLICK", "DECOR", "INLIMBO", "notarget", "invisible", "noattack"})
        for i, ent in ipairs(ents) do
            if ent.components.combat and ent ~= target and ent ~= self.inst and self:CanAreaHitTarget(ent)
                and (not validfn or validfn(ent)) then
                self.inst:PushEvent("onareaattackother", {target = ent, weapon = weapon, stimuli = stimuli})
                ent.components.combat:GetAttacked(self.inst, self:CalcDamage(ent, weapon, self.areahitdamagepercent),
                    weapon, stimuli)
                hitcount = hitcount + 1
            end
        end
        return hitcount
    end

Steps to Reproduce

Look at components/combat.lua and find DoAreaAttack pushing wrong event with target=target, rather than target=ent




User Feedback


There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...