Extra extra8: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
Matteus (talk | contribs)
No edit summary
 
mNo edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This is initialized to zero. The [[player]] is given this amount of damage divded by 256 (shift right by 8). If no actual damage is done, then the value is not cleared. The actual damage applied to the player is modified by [[shield_amount]].
[[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 <code>extra_extra8</code> 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 <code>extra_extra8</code> is to track the amount of drowning damage the player has taken. Drowning damage is incremented in <code>extra_extra8</code> 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 <code>extra_extra8</code> to apply the same kind of timed damage to the player.
 
If <code>extra_extra8</code> 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 <code>extra_extra8</code> 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 <code>extra_extra8</code> 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 <code>extra_extra8</code> 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.
 
[[Category:Player structure members]]

Latest revision as of 02:26, 6 February 2022

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.