Joined: Tue Nov 17, 2009 7:38 pm Posts: 909 Location: France
Alternate Ammo Template
Hi,
Now that we have lua on attachables multiple ammos for the same gun is quite easy to do, so I want to make that available to each and every one of you by sharing this:
function Update(self) self.Parent = MovableMan:GetMOFromID(self.RootID); if MovableMan:IsActor(self.Parent) and ToActor(self.Parent):IsPlayerControlled() and UInputMan:KeyPressed(self.AmmoKey) then if self.Mag < self.TotalMags-1 then self.Mag = self.Mag+1; else self.Mag = 0; end end self:SetNextMagazineName(self.Mags[self.Mag]); end
Save this as a .lua file.
This script should be attached to the weapon (ScriptPath = NameOfTheRTE.rte/pathtothescript/script.lua). Define your ammo like you would normally do in the ini files, same thing for the different mags, then modify lines 3 to 5 of this script by replacing nameofmag0 and nameofmag1 by the name of your mags. If you want your gun to have more than two ammo you should add lines in the following way: self.Mags[2] = "nameofmag2"; self.Mags[3] = "nameofmag3"; ...etc and change the value of self.TotalMags to the total number of mags.
The player will then be able to change ammunition by pressing a key and reloading. The key is defined line 7 (self.AmmoKey). Key number 37 is num0, if you want another key then pick one in this list:
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