SetAirSupply

From ZDoom Wiki
Jump to: navigation, search

bool SetAirSupply (int playernum, int tics)


Sets the amount of tics remaining in a player's air supply.

Parameters

  • playernum: Player number. This information can be obtained through PlayerNumber.
  • tics: the desired duration in tics before the player will start to drown.

This function targets only players since monsters do not have an air supply — drowning is not implemented for them.

Return value

The function returns TRUE if a player's air supply was successfully altered, FALSE if there are no players for this number.

Examples

This script checks the player's health and gives the player an air supply bonus when above 100 health. It should be executed from an Eyes Go Below Surface actor. The extra air is calculated as a percentage of the players health above 100 where 100 health adds 0% and 200 health adds 100% (giving 700 for 100 health, 1050 for 150 health, up to 1400 for 200 health).

script 1 (void)
{
  int health, air;
  health = GetActorProperty(0, APROP_HEALTH);
  air = GetAirSupply(PlayerNumber());
  
  if (health > 100 && air <= 700)
  {
    air = 700 * (health - 100) / 100 + 700;
    SetAirSupply(PlayerNumber(), air);
  }
  else if (health <= 100 && air > 700)
  {
    SetAirSupply(PlayerNumber(), 700);
  }
}