MNoya / Element-TD

Element Tower Defense
http://www.eletd.com
64 stars 22 forks source link

Flamethrower damage applied twice OnDeath? #458

Closed biax closed 7 years ago

biax commented 8 years ago

Noya, could you check the logic of flamethrower tower? I think it applies napalm damage twice (on death)

vladmarica commented 8 years ago

Are you referring to this loop?

for _,creep in pairs(creeps) do
    local damage = ApplyAbilityDamageFromModifiers(unit.napalmDamage, self.tower)
    local damage_done = DamageEntity(creep, self.tower, damage)
end

This only applies the damage once to each creep. ApplyAbilityDamageFromModifiers doesn't deal damage, it simply calculate and returns it. This loop could be optimized, however, since there is no need to recalculate the damage for each creep since it will be the same each time.

biax commented 8 years ago

Upon death of unit (rather than triggered by duration) I see that the damage is mentioned twice. However it's extremely difficult to calculate whether the damage has actually been applied twice.

MNoya commented 7 years ago

Yeah currently in the [flamethrower ability file] there's both OnDeath and OnDestroy, if the creep dies it will call both events, so the OnNapalmCreepDied method will be called twice.

We should first copy the whole code to another method definition (OnNapalmDestroy or similar) while changing the datadriven ability to call this new name.

In OnNapalmDestroy, only do the effect if the unit is alive.

biax commented 7 years ago

Fixed.