Forged Alliance Forever Forged Alliance Forever Forums 2017-01-10T03:19:03+02:00 /feed.php?f=41&t=13740 2017-01-10T03:19:03+02:00 2017-01-10T03:19:03+02:00 /viewtopic.php?t=13740&p=141818#p141818 <![CDATA[Re: Weapon-Triggered activation/deactivation code]]> Statistics: Posted by Dudekahedron — 10 Jan 2017, 03:19


]]>
2017-01-08T19:03:08+02:00 2017-01-08T19:03:08+02:00 /viewtopic.php?t=13740&p=141746#p141746 <![CDATA[Re: Weapon-Triggered activation/deactivation code]]>
Dudekahedron wrote:
I've abandoned this approach, anything within the weapon's function/class (whatever it is) is limited in functionality. It won't accept animations or sliders, only rotations... So I'm using a Scathis-script like approach now.
gg



Scathis really uses one barrel for all firing events and just cycles thru the aninamtion per each shot fired.

Statistics: Posted by Resin_Smoker — 08 Jan 2017, 19:03


]]>
2016-12-29T05:30:07+02:00 2016-12-29T05:30:07+02:00 /viewtopic.php?t=13740&p=141358#p141358 <![CDATA[Re: Weapon-Triggered activation/deactivation code]]> gg

Statistics: Posted by Dudekahedron — 29 Dec 2016, 05:30


]]>
2016-12-28T20:45:51+02:00 2016-12-28T20:45:51+02:00 /viewtopic.php?t=13740&p=141347#p141347 <![CDATA[Re: Weapon-Triggered activation/deactivation code]]>
Code:
INFO: Fire gun1!
INFO: Gun1 deactivated
WARNING: Error running lua script: ...nce\mods\thedairyfarm\units\secret\secret_script.lua(45): attempt to call method `SetWeaponEnabledByLabel' (a nil value)
         stack traceback:
            ...nce\mods\thedairyfarm\units\secret\secret_script.lua(45): in function <...nce\mods\thedairyfarm\units\secret\secret_script.lua:39>


Which kind of suggests to me that the weapon cannot be disabled from within itself?
heeelllppp

Statistics: Posted by Dudekahedron — 28 Dec 2016, 20:45


]]>
2016-12-28T20:36:03+02:00 2016-12-28T20:36:03+02:00 /viewtopic.php?t=13740&p=141346#p141346 <![CDATA[Re: Weapon-Triggered activation/deactivation code]]> I get an error now, which is partly helpful i guess:
Code:
WARNING: Error running lua script: ...nce\mods\thedairyfarm\units\secret\secret_script.lua(42): attempt to call method `PlayAnim' (a nil value)
         stack traceback:
            ...nce\mods\thedairyfarm\units\secret\secret_script.lua(42): in function <...nce\mods\thedairyfarm\units\secret\secret_script.lua:39>


The code now:

Code:
    Weapons = {
       Gun1 = Class(SecretWeapon) {
            OnWeaponFired = function(self)
                SecretWeapon.OnWeaponFired()
                self:ForkThread(self.GunSwap)
                LOG('Fire gun1!')
            end,

            GunSwap = function(self)
                self.Reload1 = CreateAnimator(self) --************
                self.Trash:Add(self.Reload1)
                self.Reload1:PlayAnim('/mods/TheDairyFarm/units/secret/secret_Reload1.sca', true):SetRate(1)
                WaitSeconds(self.Reload1:GetAnimationTime())
                LOG('Gun1 deactivated')
                self:SetWeaponEnabledByLabel('Gun1', false)
                LOG('Gun2 activated')
                self:SetWeaponEnabledByLabel('Gun2', true)
                self:GetWeaponManipulatorByLabel('Gun1'):SetHeadingPitch(self:GetWeaponManipulatorByLabel('Gun2'):GetHeadingPitch())
            end,
       },

That's duplicated for Gun2 and Gun3, but it never gets past the starred line

Statistics: Posted by Dudekahedron — 28 Dec 2016, 20:36


]]>
2016-12-28T19:33:54+02:00 2016-12-28T19:33:54+02:00 /viewtopic.php?t=13740&p=141345#p141345 <![CDATA[Weapon-Triggered activation/deactivation code]]> Me needing help again!
I have a unit with three unique weapons that I would like to activate/deactivate based on what fired last. Ideally so they fire consecutively after each other.
Ie Gun1 fires, deactivates, an animation occurs to 'set up' Gun2, then Gun2 fires, etc.

This is what I have currently, except the guns never swap:
Code:
    OnCreate = function(self)
        SecretUnit.OnCreate(self)
        self:SetWeaponEnabledByLabel('Gun2', false)
        self:SetWeaponEnabledByLabel('Gun3', false)
    end,

    Weapons = {
       Gun1 = Class(Secret1) {
            OnFire = function(self)
                self:Fire()
                Secret1.OnFire()
            end,
          Fire = function(self)
                self:SetWeaponEnabledByLabel('Gun1', false)
                self.Reload1 = CreateAnimator(self)
                self.Reload1:PlayAnim(self:GetBlueprint().Display.AnimationReload1, true):SetRate(1)
                self.Trash:Add(self.Reload1)
                self:SetWeaponEnabledByLabel('Gun2', true)
                self:GetWeaponManipulatorByLabel('Gun1'):SetHeadingPitch(self:GetWeaponManipulatorByLabel('Gun2'):GetHeadingPitch())
            end,
       },

        Gun2 = Class(Secret2) {
            OnFire = function(self)
                self:Fire()
                Secret2.OnFire()
            end,

            Fire = function(self)
                self:SetWeaponEnabledByLabel('Gun2', false)
                self.Reload2 = CreateAnimator(self)
                self.Reload2:PlayAnim(self:GetBlueprint().Display.AnimationReload2, true):SetRate(1)
                self.Trash:Add(self.Reload2)
                self:SetWeaponEnabledByLabel('Gun3', true)
                self:GetWeaponManipulatorByLabel('Gun2'):SetHeadingPitch(self:GetWeaponManipulatorByLabel('Gun3'):GetHeadingPitch())
            end,
        },

        Gun3 = Class(Secret3) {
            OnFire = function(self)
                self:Fire()
                Secret3.OnFire()
            end,

            Fire = function(self)
                self:SetWeaponEnabledByLabel('Gun3', false)
                self.Reload3 = CreateAnimator(self)
                self.Reload3:PlayAnim(self:GetBlueprint().Display.AnimationReload3, true):SetRate(1)
                self.Trash:Add(self.Reload2)
                self:SetWeaponEnabledByLabel('Gun1', true)
                self:GetWeaponManipulatorByLabel('Gun3'):SetHeadingPitch(self:GetWeaponManipulatorByLabel('Gun1'):GetHeadingPitch())
            end,
        },
    },


I threw in some LOG('words') in there, and it seems like the OnFire function is never actually called, what function should I be using?

Thanks!!

Statistics: Posted by Dudekahedron — 28 Dec 2016, 19:33


]]>