decreasing health for every turn

tdhddewar92
24 Nov 2012, 21:53
Hi again

I posted a couple days ago, but need help on one more thing, that is a decreasing health system.

I want the health to begin at 100, and every time a person enters a command, it decreases by 1, and to end the game when it reaches 0.

May be obvious, but I've tried numerous times and still can't get it to work, maybe it's just my inexperience.

Any help would be v. appreciated.

Tom

jaynabonne
25 Nov 2012, 05:01
I have attached an updated version. There were a few things wrong:

1) SInce "health" is a member attribute of the player, you need to say "player.health" not just "health".
2) Your timer was also called "health". I renamed it "healthTimer".
3) Your "you lost" message was outside the "if". It's now inside.
4) DecreaseHealth decreases the player health by the amount you give it. Since you passed -1, it decreased it by -1... which actually increased it by 1. I changed it to DecreaseHealth(1) to have it decrease by 1 each time.

You have it set up as a timer, with a period of 2 seconds. If you want the health to decrease on each turn, then you should set up a turn script instead.