Extra extra8: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
Line 1: Line 1:
This variable tracks additional, fractional damage which is to be applied to the player. This value is initialized to zero.
[[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.


The damage will only be applied as soon as the stored value is greater or equal to 256. If this is the case, the value will be reset to 0.  
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 hardcoded use for [[extra_extra8]] is to track the amount of drowning damage the player has taken.
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.  


The value is used in the function <code>P_IncurDamage</code>, which corresponds to the event [[EVENT_INCURDAMAGE]]. If [[extra_extra8]] is negative, it will heal the player, but [[extra_extra8]] will not be reset to 0.
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.


The actual damage applied to the player is modified by [[shield_amount]]. This behavior can be intercepted in the [[EVENT_INCURDAMAGE]] [[events|event]]
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]]
[[Category:Player structure members]]

Latest revision as of 01: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.