How do I make an attribute that goes down and will start dealing damage to the player if it runs out.

I'm making a game where your stuck inside a mine, and an idea I had is while outside a specific room, every turn the player will lose O2 and regain it when inside the specific room (for my case it is the bedroom). I'm new to this, and can't find the piece of code that will let me do that. I also want the player to start taking damage every turn if their O2 is 0.

PS: I am using the built in player health.


You probably want to use a turnscript. Turnscripts are a simple way to deal with anything you want to happen every turn.

You'd have a script something like:

if (Contains, (bedroom, game.pov)) {
  game.pov.oxygen = 30
}
else {
  game.pov.oxygen  = game.pov.oxygen - 1
  if (game.pov.oxygen < 1) {
    game.pov.health = game.pov.health - 1
  }
}

That seems simple enough. If the player is in bedroom, their oxygen attribute is reset to 30; anywhere else it is reduced by 1. If it's 0 or less, their health is reduced by 1 as well.

You can use different numbers if you prefer. Or you could make it a random amount by changing either (or both) of the lines to something like:

  game.pov.oxygen = game.pov.oxygen - GetRandomInt (1, 3)

which reduces the oxygen by 1, 2, or 3 points at random each turn.


Log in to post a reply.

Support

Forums