Data Realms Fan Forums http://45.55.195.193/ |
|
Script: Delay on weapon switch? [Solved] http://45.55.195.193/viewtopic.php?f=75&t=25561 |
Page 1 of 1 |
Author: | Gotcha! [ Sun Sep 18, 2011 2:10 pm ] |
Post subject: | Script: Delay on weapon switch? [Solved] |
Hello people, Could anyone somehow change this script in a way that it takes 2 seconds for it to change to the other weapon? Code: function SteyrAUGSwitchMain(actor) local gun = ToAHuman(actor).EquippedItem; if gun ~= nil then gun.Sharpness = 1; end end function SteyrAUGSwitchAlt(actor) local gun = ToAHuman(actor).EquippedItem; if gun ~= nil then gun.Sharpness = 2; end end function Create(self) self.weaponNameTable = {"Steyr AUG", "Steyr AUG Alt Fire"}; self.weaponClassTable = {"HDFirearm", "HDFirearm"}; self.switchPhase = 0; end function Update(self) if self.Sharpness ~= 0 then if self.switchPhase == 0 then local actor = MovableMan:GetMOFromID(self.RootID); if MovableMan:IsActor(actor) then self.parent = ToAHuman(actor); if self.weaponClassTable[self.Sharpness] == "HDFirearm" then local switchGun = ToActor(self.parent):AddInventoryItem(CreateHDFirearm(self.weaponNameTable[self.Sharpness])); elseif self.weaponClassTable[self.Sharpness] == "TDExplosive" then local switchGun = ToActor(self.parent):AddInventoryItem(CreateTDExplosive(self.weaponNameTable[self.Sharpness])); elseif self.weaponClassTable[self.Sharpness] == "HeldDevice" then local switchGun = ToActor(self.parent):AddInventoryItem(CreateHeldDevice(self.weaponNameTable[self.Sharpness])); end ToActor(self.parent):GetController():SetState(Controller.WEAPON_DROP,true); self.switchPhase = 1; else self.Sharpness = 0; end else if MovableMan:IsActor(self.parent) then if ToActor(self.parent):IsInventoryEmpty() == false then ToActor(self.parent):GetController():SetState(Controller.WEAPON_CHANGE_PREV,true); end end self.ToDelete = true; end end end |
Author: | CaveCricket48 [ Sun Sep 18, 2011 2:25 pm ] |
Post subject: | Re: Script: Delay on weapon switch? |
Try: Code: function SteyrAUGSwitchMain(actor) local gun = ToAHuman(actor).EquippedItem; if gun ~= nil then gun.Sharpness = 1; end end function SteyrAUGSwitchAlt(actor) local gun = ToAHuman(actor).EquippedItem; if gun ~= nil then gun.Sharpness = 2; end end function Create(self) self.weaponNameTable = {"Steyr AUG", "Steyr AUG Alt Fire"}; self.weaponClassTable = {"HDFirearm", "HDFirearm"}; self.switchPhase = 0; self.switchTimer = Timer(); self.flipTimer = false; self.switchDelay = 2000; -- This is the time delay end function Update(self) if self.Sharpness ~= 0 then if self.flipTimer == false then self.flipTimer = true; self.switchTimer:Reset(); end if self.switchTimer:IsPastSimMS(self.switchDelay) then if self.switchPhase == 0 then local actor = MovableMan:GetMOFromID(self.RootID); if MovableMan:IsActor(actor) then self.parent = ToAHuman(actor); if self.weaponClassTable[self.Sharpness] == "HDFirearm" then local switchGun = ToActor(self.parent):AddInventoryItem(CreateHDFirearm(self.weaponNameTable[self.Sharpness])); elseif self.weaponClassTable[self.Sharpness] == "TDExplosive" then local switchGun = ToActor(self.parent):AddInventoryItem(CreateTDExplosive(self.weaponNameTable[self.Sharpness])); elseif self.weaponClassTable[self.Sharpness] == "HeldDevice" then local switchGun = ToActor(self.parent):AddInventoryItem(CreateHeldDevice(self.weaponNameTable[self.Sharpness])); end ToActor(self.parent):GetController():SetState(Controller.WEAPON_DROP,true); self.switchPhase = 1; else self.Sharpness = 0; end else if MovableMan:IsActor(self.parent) then if ToActor(self.parent):IsInventoryEmpty() == false then ToActor(self.parent):GetController():SetState(Controller.WEAPON_CHANGE_PREV,true); end end self.ToDelete = true; end end end end Also, lol: |
Author: | Gotcha! [ Sun Sep 18, 2011 3:07 pm ] |
Post subject: | Re: Script: Delay on weapon switch? |
Strange, there's no difference. Also, no error messages. Also: Wow, for a moment there I felt pretty 1337. *feels warm and fuzzy* |
Author: | CaveCricket48 [ Sun Sep 18, 2011 3:24 pm ] |
Post subject: | Re: Script: Delay on weapon switch? |
It seems to work for me. Also, do you have your weapons' sharpness set to 0 in INI? |
Author: | Gotcha! [ Sun Sep 18, 2011 3:58 pm ] |
Post subject: | Re: Script: Delay on weapon switch? |
No. Did so now, but no change though. Well, it works for you so I must be forgetting something somewhere. Thanks. No. Did so now, but no change though. Well, it works for you so I must be forgetting something somewhere. Thanks. Edit: Nope, didn't forget anything, except that I have one less 'end' at the end. But if I add one then the console tells me it did not expect one. Code: function SteyrAUGSwitchMain(actor) local gun = ToAHuman(actor).EquippedItem; if gun ~= nil then gun.Sharpness = 1; end end function SteyrAUGSwitchAlt(actor) local gun = ToAHuman(actor).EquippedItem; if gun ~= nil then gun.Sharpness = 2; end end function Create(self) self.weaponNameTable = {"Steyr AUG", "Steyr AUG Alt Fire"}; self.weaponClassTable = {"HDFirearm", "HDFirearm"}; self.switchPhase = 0; self.BurstTimer = Timer() self.switchTimer = Timer(); self.flipTimer = false; self.switchDelay = 2000; end function Update(self) if self.Sharpness ~= 0 then if self.flipTimer == false then self.flipTimer = true; self.switchTimer:Reset(); end if self.switchPhase == 0 then local actor = MovableMan:GetMOFromID(self.RootID); if MovableMan:IsActor(actor) then self.parent = ToAHuman(actor); if self.weaponClassTable[self.Sharpness] == "HDFirearm" then local switchGun = ToActor(self.parent):AddInventoryItem(CreateHDFirearm(self.weaponNameTable[self.Sharpness])); elseif self.weaponClassTable[self.Sharpness] == "TDExplosive" then local switchGun = ToActor(self.parent):AddInventoryItem(CreateTDExplosive(self.weaponNameTable[self.Sharpness])); elseif self.weaponClassTable[self.Sharpness] == "HeldDevice" then local switchGun = ToActor(self.parent):AddInventoryItem(CreateHeldDevice(self.weaponNameTable[self.Sharpness])); end ToActor(self.parent):GetController():SetState(Controller.WEAPON_DROP,true); self.switchPhase = 1; else self.Sharpness = 0; end else if MovableMan:IsActor(self.parent) then if ToActor(self.parent):IsInventoryEmpty() == false then ToActor(self.parent):GetController():SetState(Controller.WEAPON_CHANGE_PREV,true); end end self.ToDelete = true; end end if self:IsActivated() and self.Magazine then if not self.burst then self.burst = self.Magazine.RoundCount self.BurstTimer:Reset() elseif self.burst - 3 >= self.Magazine.RoundCount then self:Deactivate() if self.BurstTimer:IsPastSimMS(400) then self.burst = nil end end else self.burst = nil end end |
Author: | CaveCricket48 [ Sun Sep 18, 2011 4:16 pm ] | ||
Post subject: | Re: Script: Delay on weapon switch? | ||
Here's the RTE I have with the modifications, perhaps I missed something in my post.
|
Author: | Gotcha! [ Sun Sep 18, 2011 4:52 pm ] |
Post subject: | Re: Script: Delay on weapon switch? |
Yeah, found the missing line. It works now. Thanks. During the 2 second changing period the actor is still allowed to fire his gun. Is it also possible to add a line in there that would somehow 'jam' the gun during those two seconds? |
Author: | CaveCricket48 [ Sun Sep 18, 2011 6:06 pm ] | ||
Post subject: | Re: Script: Delay on weapon switch? | ||
Here you go.
|
Author: | Gotcha! [ Sun Sep 18, 2011 6:34 pm ] |
Post subject: | Re: Script: Delay on weapon switch? |
Thaaaanks! Works like a charm. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |