This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-06-17 06:20:23

halogameaccount
Scratcher
Registered: 2009-06-11
Posts: 61

Ammo system

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)


http://img200.imageshack.us/img200/9692/signatureatx.png

Offline

 

#2 2009-06-17 06:37:02

Mike_W
Scratcher
Registered: 2009-02-05
Posts: 100+

Re: Ammo system

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

 

#3 2009-06-17 06:39:33

halogameaccount
Scratcher
Registered: 2009-06-11
Posts: 61

Re: Ammo system

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


http://img200.imageshack.us/img200/9692/signatureatx.png

Offline

 

#4 2009-06-17 07:04:55

halogameaccount
Scratcher
Registered: 2009-06-11
Posts: 61

Re: Ammo system

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)


http://img200.imageshack.us/img200/9692/signatureatx.png

Offline

 

#5 2009-06-20 04:39:38

halogameaccount
Scratcher
Registered: 2009-06-11
Posts: 61

Re: Ammo system

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


http://img200.imageshack.us/img200/9692/signatureatx.png

Offline

 

#6 2009-06-20 05:36:44

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Ammo system

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.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#7 2009-06-20 05:43:00

halogameaccount
Scratcher
Registered: 2009-06-11
Posts: 61

Re: Ammo system

Thank you, you explained that well. That did help...a lot!


http://img200.imageshack.us/img200/9692/signatureatx.png

Offline

 

Board footer