Poisoning the player (SOLVED)

Hello,
In one of my games I intend that the player can be possibly poisoned by an object like a giant viper. I tried to run a turn script which, every 10 turns, if the player object had the flag "poisoned", would be supposed to take one hitpoint away. Instead, it waits 10 turns and then takes away 1 hitpoint per turn continually. Can anyone help with this?


If you show your code, we could probably tell you where the problem is.

However, from your description, I'd expect the turnscript to look something like this:

if (GetBoolean (game.pov, "poisoned")) {
  if (this.turns = 10) {
    this.turns = 1
    game.pov.health = game.pov.health - 1
  }
  else {
    this.turns = this.turns + 1
  }
}
else {
  // reset the turn counting if the player isn't poisoned
  this.turns = 0
}

Thank you, my problem has been solved.


I figured it makes sense to make the turn counter an attribute of the turnscript rather than the player, because it's a little more organised. A lot of people don't seem to know you can do that; so figured it's good to point it out. this refers to the element the script belongs to; and you can still put attributes on it if it's a turnscript or a command. So it's a good place to store information related to a particular script.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums