Is it possIble to make a gun unreloadable unless being used by a specific actor? And when that actor uses it, the gun gets infinite ammo. (fed from an ammo box on his back) I know it will undoubtedly involve lua, I just can't find an example of it ever being done before.
Thanks in advance!
Wed Feb 21, 2018 9:13 pm
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13143 Location: Here
Re: Actor specific infinite ammo?
Relevant stuff - If your script is on a gun:
Get the actor carrying it -
Code:
local actor = MovableMan:GetMOFromID(self.RootID); if MovableMan:IsActor(actor) then -- do stuff -- end
Do stuff if we have a magazine in the gun -
Code:
if self.Magazine ~= nil then -- do stuff -- end
Setting ammo amount -
Code:
if self.Magazine ~= nil then self.Magazine.RoundCount = 100; end
I don't think you can make a gun unreloadable, but you can give the gun a script that constantly deletes new magazines after the first one is spent. Then, stop deleting them when the gun is used by the correct actor (check its PresetName).
-1 RoundCount on magazines is used to give them infinite ammo, but I believe there might've been issues with changing RoundCount from infinite to finite, or vice versa. I don't remember, something to test.
Wed Feb 21, 2018 11:58 pm
gridbull
Joined: Sun Sep 17, 2017 11:17 pm Posts: 35
Re: Actor specific infinite ammo?
Sounds good, I'll write something up and test it out, then post the results here. Thanks for the advice, as always.
I don't think you can make a gun unreloadable, but you can give the gun a script that constantly deletes new magazines after the first one is spent. Then, stop deleting them when the gun is used by the correct actor (check its PresetName).
You might also be able to constantly set the actor's control state reloading to false, though I seem to recall issues trying to force some states (such as movement) off from items rather than from the actor whose state is being set.
Thu Feb 22, 2018 5:28 pm
gridbull
Joined: Sun Sep 17, 2017 11:17 pm Posts: 35
Re: Actor specific infinite ammo?
I wonder, is it a better idea to put the script in the actor instead of he gun, and set the gun's innate ammo max to zero.
Thu Feb 22, 2018 9:04 pm
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13143 Location: Here
Re: Actor specific infinite ammo?
Probably doesn't matter too much what the script is attached to.
Also testing out what Bad Boy mentioned could simplify some things if you can prevent the reloading action.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum