Ammunition min and max limits

DaibusshiDaibusshi Member Posts: 47
edited November -1 in Working with GS (Mac)
I am having a little trouble with ammunition/reloading min and max limits:

I have a shooting gallery-type game with what starts as a 12-bullet queue:
NEW ATTRIBUTE: bullets / 12 / interger

The ammo queue is displayed as bullet icons in the game. With each shot during gameplay, a bullet disappears from the ammo queue, as it should:
CHANGE ATTRIBUTE: (game.bullets) to (game.bullets)-1

Now, instead of one big master "reload" actor resetting to 12, I have multiple "reload" actors which appear randomly, and each time a highlighted reloading actor is clicked, it only adds 3 bullets at a time:
CHANGE ATTRIBUTE: (game.bullets) to (game.bullets)+3

The +3/reload is essential to the gameplay challenge. The thing is, if I keep clicking on the highlighted "reload" actors, it keeps adding bullets to the queue after it has reached 12 (like a limitless game score). The bullets go to 15, 18, then off the screen to forever if I keep clicking. How do I LIMIT the bullets to 12, no matter how many times the +3/reload actor is clicked?

And, conversely, I have the same problem with ammo minimums. How do I disable firing after the queue is depleted to 0? Right now, it keeps firing after reaching "0", AND also goes into negative intergers with each shot, because of the CHANGE ATTRIBUTE: "-1". And of course it'll go to minus forever if I keep clicking. I want to disable firing when the queue is at zero bullets.

Any help would be appreciated!

-D

Comments

  • JeffreyShimaneJeffreyShimane Member Posts: 372
    You need to add rules to set the min and max:

    Min:
    Create a boolean game attribute called ShootToggle (default value = true). Modify your shooting logic to only allow shooting when ShootToggle is true.

    If game.bullets <= 0, change attribute game.ShootToggle to false
    Otherwise change attribute game.ShootToggle to true

    Max:
    If game.bullets > 9, change attribute game.bullets to 12
    Otherwise, game.bullets to game.bullets+3

    - Jeff
  • DaibusshiDaibusshi Member Posts: 47
    Thanks for the lightning response, Jeff! I'll give that a whirl and we'll see how it goes!
  • DaibusshiDaibusshi Member Posts: 47
    Spot on advice, mate! Worked like a charm. Big thank you comin' your way in the credits.
Sign In or Register to comment.