[FA] BUG FIX AirUnit Class missing OnKilled Callback
I was working on Air Units + triple checking the OnKilled function that didn't seem to work correctly despite my
BUG FIX (see my post for the CBFP v4)
I quickly remaked that AIR Units do NOT call OnKilled everytime.
Look at
defaultunits.lua :
Code:
AirUnit = Class(MobileUnit) {
<code>
OnKilled = function(self, instigator, type, overkillRatio)
local bp = self:GetBlueprint()
if (self:GetCurrentLayer() == 'Air' and Random() < self.DestroyNoFallRandomChance) then
self.CreateUnitAirDestructionEffects( self, 1.0 )
self:DestroyTopSpeedEffects()
self:DestroyBeamExhaust()
self.OverKillRatio = overkillRatio
self:PlayUnitSound('Killed')
self:DoUnitCallbacks('OnKilled')
self:OnKilledVO()
if instigator and IsUnit(instigator) then
instigator:OnKilledUnit(self)
end
else
self.DeathBounce = 1
if instigator and IsUnit(instigator) then
instigator:OnKilledUnit(self)
end
MobileUnit.OnKilled(self, instigator, type, overkillRatio)
end
end,
}
We can see clearly that
MobileUnit.OnKilled is called only within the ELSE statement.
WHY that ? I dunno, ask gently GPG Devs
MobileUnit.OnKilled should be called from outside of the IF THEN statements in any case.So I moved it like this (my bug fix) :
Code:
AirUnit = Class(MobileUnit) {
<code>
OnKilled = function(self, instigator, type, overkillRatio)
local bp = self:GetBlueprint()
if (self:GetCurrentLayer() == 'Air' and Random() < self.DestroyNoFallRandomChance) then
self.CreateUnitAirDestructionEffects( self, 1.0 )
self:DestroyTopSpeedEffects()
self:DestroyBeamExhaust()
self.OverKillRatio = overkillRatio
self:PlayUnitSound('Killed')
self:DoUnitCallbacks('OnKilled')
self:OnKilledVO()
if instigator and IsUnit(instigator) then
instigator:OnKilledUnit(self)
end
else
self.DeathBounce = 1
if instigator and IsUnit(instigator) then
instigator:OnKilledUnit(self)
end
--# WRONG PLACE ! -> MobileUnit.OnKilled(self, instigator, type, overkillRatio)
end
MobileUnit.OnKilled(self, instigator, type, overkillRatio)
end,
}
Now AirUnits seem to better Rest in Peace !
