Login  Register
 



Post new topicReply to topic
 
Author Message
 PostPosted: 02 Sep, 2011 
 
User avatar

Joined: 25 Mar, 2010
Posts: 1495
Offline
BUG FIX on the Cybran ACU OverCharge Ability Hook.

http://pastebin.com/raw.php?i=GSuvC0Sa

local prevOnAbility = OnAbility

Code:
OnAbility = function(unit, abilityBp, state)
   prevOnAbility(unit, abilityBp, state)
    if EntityCategoryContains(categories.CYBRAN, unit) then
        if state == "activate" then
            local subMainWeapon = unit:GetSecondaryWeaponLabel()
            if unit.SecondaryWeaponLabel then
                unit:SetWeaponEnabledByLabel( subMainWeapon, false)
            end
        elseif state == "deactivate" or state == "interrupt" then
            local subMainWeapon = unit:GetSecondaryWeaponLabel()  -- pulls the weapon so that it can be turned back on.
            if unit.SecondaryWeaponLabel then
                unit:SetWeaponEnabledByLabel(subMainWeapon, true)
            end
        end
    end
end


Would the following work as well or do I need to call it each time I flip it's on/off switch?
Code:
OnAbility = function(unit, abilityBp, state)
    local subMainWeapon = unit:GetSecondaryWeaponLabel()  -- pulls the weapon so that it can be turned back on.

   prevOnAbility(unit, abilityBp, state)
    if EntityCategoryContains(categories.CYBRAN, unit) then
        if state == "activate" then
            if unit.SecondaryWeaponLabel then
                unit:SetWeaponEnabledByLabel( subMainWeapon, false)
            end
        elseif state == "deactivate" or state == "interrupt" then
            if unit.SecondaryWeaponLabel then
                unit:SetWeaponEnabledByLabel(subMainWeapon, true)
            end
        end
    end
end


Thanks Hollow for doing the play testing that found this.

_________________
Yeah Toast!


Last edited by Bastilean on 16 Sep, 2011, edited 2 times in total.

Top
 Profile  
 PostPosted: 03 Sep, 2011 
 
User avatar

Joined: 19 Jul, 2009
Posts: 2972
Offline
Er, why aren't you just using unit.SecondaryWeaponLabel? How is that being set, and what is it being set to? If it's set to the weapon's actual label string, there's no need for the other thing you're trying to do.

Is GetSecondaryWeaponLabel an actual defined function in that unit's script? For that matter, is it in every ACU's script? Because if not, then your script will run into problems, because you'll be trying to call a function that doesn't exist.


Top
 Profile  
 PostPosted: 03 Sep, 2011 
 
User avatar

Joined: 25 Mar, 2010
Posts: 1495
Offline
Mithy wrote:
Bastilean wrote:
Based on your comments LoD rewrote and I tested:
Cybran ACU script hook
Over Charge script hook

That should work. The function to return self.SecondaryWeaponLabel is somewhat extraneous, since you're already looking directly for the value in the ability script - there's no reason you can't just use unit.SecondaryWeaponLabel directly, if and when it exists.



Mithy wrote:
Is GetSecondaryWeaponLabel an actual defined function in that unit's script? For that matter, is it in every ACU's script? Because if not, then your script will run into problems, because you'll be trying to call a function that doesn't exist.
Actually I was until I added this little number:
Code:
if EntityCategoryContains(categories.CYBRAN, unit) then

_________________
Yeah Toast!


Top
 Profile  
 PostPosted: 03 Sep, 2011 
 
User avatar

Joined: 19 Jul, 2009
Posts: 2972
Offline
Point stands, you only need this:
Code:
            if unit.SecondaryWeaponLabel then
                unit:SetWeaponEnabledByLabel(unit.SecondaryWeaponLabel, false)
            end
..no category check or anything else, because only a Cybran ACU with the nanobot upgrade will meet that condition. It can be moved up one level as well, e.g.:
Code:
        if unit.SecondaryWeaponLabel then
            if state == 'activate' then
                unit:SetWeaponEnabledByLabel(unit.SecondaryWeaponLabel, false)
            else
                unit:SetWeaponEnabledByLabel(unit.SecondaryWeaponLabel, true)
            end
        end


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