Login  Register
 



Post new topicReply to topic
 
Author Message
 PostPosted: 03 Mar, 2010 
 
User avatar

Joined: 11 Apr, 2007
Posts: 1915
Offline
[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 :lol:

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 ! :P

_________________
Console Plus - Solo A.C.U. - Experimental Wars Image


Last edited by Manimal on 03 Mar, 2010, edited 3 times in total.

Top
 Profile  
 PostPosted: 03 Mar, 2010 
 
User avatar

Joined: 11 Apr, 2007
Posts: 1915
Offline
accidental double post. please delete

_________________
Console Plus - Solo A.C.U. - Experimental Wars Image


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic



Quick Tools

Search for:
Jump to:  

© 2002-2010 Gas Powered Games Corp. All Rights Reserved. Gas Powered Games is the exclusive trademark of Gas Powered Games Corp.
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
 
Home| Games | Company | News & Press | Support
  Terms of Use   |    Copyright Information   |    Privacy Policy