Extra extra8

From EDukeWiki
Jump to navigation Jump to search

extra_extra8 tracks fractional, or timed damage which is to be applied to the player once the stored value is greater or equal to 256. This value is initialized to zero at map start, and is reset to 0 every time the damage is applied to the player's health.

Internally, the value of extra_extra8 is right shifted by 8, and then subtracted from the player's HP. Therefore, a value of 256 is equal to 1 unit of HP.

The only current hardcoded use for extra_extra8 is to track the amount of drowning damage the player has taken. Drowning damage is incremented in extra_extra8 by 32 each tic, hence the player will have his health subtracted by 1 every 8 tics.

In the beta versions this was also used for burning damage when the player is set on fire. Mods can apply a similar increment to extra_extra8 to apply the same kind of timed damage to the player.

If extra_extra8 is greater than 256, then the damage applied through this variable will also be modified by shield_amount.

It is possible to prevent applying the damage accumulated in extra_extra8 by setting RETURN to -1 in the EVENT_INCURDAMAGE event. This will not prevent the damage from being accumulated in the variable, therefore this makes it possible to modify how drowning damage is applied to the player.

Negative Values

IMPORTANT: Setting extra_extra8 to a negative value will not work as expected!

Negative values cause the player to be healed by at least 1 HP each tic. This occurs because right shifting a negative value will result in -1, not 0, if the absolute value of extra_extra8 is smaller than 256.

Due to a quirk in the engine, it will also not be reset to 0 after the healing is applied either, as such the healing will be continuous.