Posted By
|
Message
|
tetsuya_shino
Registered 12/08/2004
Points 491
|
22nd December, 2009 at 07:47:26 -
Greetings. I have a bit of a problem. I'm sure the answer is simple but it's giving me a slight headache thinking about it. Here it goes; I have have 2 counters. 'rounds in gun' and 'spare clips' Now lets say the hero has a gun that can hold 16 shots (rounds in gun). When he fires the last, 16th shot. The gun is out of ammo and he can't fire agaun unless he presses the reload button and he has an extra clip (spare clips). This is the current system and it works perfectly. It uses two global values.
However, I want to change it so I just have one 'ammo' counter that would display how many bullets you have. (And thus, only use one global value). Lets say the 'ammo' = 100 and the hero has the same 16 shot gun as above. I want to be able to keep the player from firing a 17th shot unless they hit the reload button first. How would I code something like that?
n/a
|
Strife Administrator
Der Dairy Crick
Registered 21/11/2002
Points 2305
|
22nd December, 2009 at 10:59:51 -
You could start by using an equation like this:
(Player's ammo count) mod 16
The "mod" expression will divide the player's ammo by 16 and give you the remainder. From here, you could tell the game that whenever Ammo mod 16 = 0, the player has exhausted the current clip of ammo and must reload.
|
nim
Registered 17/05/2002
Points 7233
|
22nd December, 2009 at 15:08:42 -
Store the total number of bullets in Global Value A and derive the other values from that. As Spaceman Strife said, you can use Global Value A mod 16. You can calculate the remaining clips by using floor(Global Value A/16) (actually you probably don't need to use "floor" as MMF does this automatically, but it's good practice)
Example (MMF2): http://rapidshare.com/files/324412376/bullets.mfa.html
//
|
tetsuya_shino
Registered 12/08/2004
Points 491
|
22nd December, 2009 at 23:53:22 -
Thank you for the replies. However, I'm not using MMF, but rather TGF. Does it also have this mod feature?
n/a
|
nim
Registered 17/05/2002
Points 7233
|
23rd December, 2009 at 06:15:40 -
I honestly can't remember. Try it! If not, there's the Advanced Math Object.
//
|
|
|