Hi,
I need help setting up an ammo system for my halo game. I have multiple weapons with each having a variable called weapon. Like Pistol=0, Assault Rifle=1, Sniper=2, Shotgun=3, Rocket Launcher=4, Plasma Pistol=6, Plasma Rifle=7, Needler=8, Frag Grenade=9, Plasma Grenade=10. I want Each to have a different ammo and clip size.
For example I want assault rifle (weapon 1) to have 352 rounds and 32 in clip. I have pick-upable ammo as well for each weapon so when I pick up ammo I want it to go into the clip and any left over ammunition to go into the rounds. Need help..
Last edited by halogameaccount (2009-06-20 08:08:03)

Offline
clips = round (rounds/32)
extra rounds = mod round 32
if rounds > 32
change clips by one
change rounds by -32
Sorry I can block it all out - checking web sites before I go to work.
Offline
Mike_W wrote:
clips = round (rounds/32)
extra rounds = mod round 32
if rounds > 32
change clips by one
change rounds by -32
Sorry I can block it all out - checking web sites before I go to work.
Thank you ill try that out

Offline
I dont know what to put in mod and how to implement that into my script. After work could you explain it more or create a quick scratch example.
Last edited by halogameaccount (2009-06-17 07:06:17)

Offline
Bump, I still need help. So, if anyone can explain a good way to do it.

Offline
Okay, when you pick up ammo, you need to increment both Clips and Rounds, as I understand it
Define some variables:
Pick_Up_Ammo - the number of rounds you just picked up
Rounds_Per_Clip - the number of rounds in a clip for the weapon
Clips - the number of full clips for the weapon
Rounds - the number of left over rounds for the weapon (not in a clip)
Then, you can get the number of full clips by dividing the amount of ammo you just picked up by the number of rounds per clip and getting rid of any fractional remainder. You can use the ROUND function to do that like this:
CHANGE Clips by ROUND ( (Pick_Up_Ammo / Rounds per Clip) - 0.5 )
You can get the number of left over rounds by using the MOD function that gives the remainder of a division like this
CHANGE Rounds by Pick_Up Ammo MOD Rounds_per_Clip
I hope that helps some.
Offline
Thank you, you explained that well. That did help...a lot!

Offline