GetAirSupply
int GetAirSupply (int playernum)
Gives the amount of tics remaining in a player's air supply.
Parameters
- playernum: Player number. This information can be obtained through PlayerNumber.
This function targets only players since monsters do not have an air supply — drowning is not implemented for them.
Return value
The duration in tics before the player will start to drown. A negative value tells the player is already drowning. Note that a negative value of 0 is possible by coincidence if the script is run at just the right tic, but is also used to mean there are no player for the given number.
Examples
This example prints the number of seconds the player has until his or her air supply runs out. It then prints a message warning the player to return for air. Set script 1 to be executed by Eyes Go Below Surface and script 2 to be executed by Eyes Go Above Surface actors placed in your 'deep water' sectors.
bool airdisplay[8];
// player dives
script 1 (void)
{
if (PlayerNumber() < 0) terminate;
airdisplay[PlayerNumber()] = true;
while (airdisplay[PlayerNumber()])
{
if (GetAirSupply(PlayerNumber()) > 0)
print(d:GetAirSupply(PlayerNumber()) / 35);
else
print(s:"You'd better go up for air!");
delay(1);
}
}
// player returns to surface - clear out the display
script 2 (void)
{
airdisplay[PlayerNumber()] = false;
}