EVENT INCURDAMAGE

From EDukeWiki
Revision as of 14:01, 5 February 2022 by Doom64hunter (talk | contribs)
Jump to navigation Jump to search
Event ID player# THISACTOR RETURN
EVENT_INCURDAMAGE current player player->i 1 value

EVENT_INCURDAMAGE is a Game Event.

This event is executed for each player in the map, once per tic.

This event runs constantly as long as the player's health is greater than 0. It is placed at the start of the function P_IncurDamage() which serves 3 purposes:

  1. The function applies damage to the player accumulated in the variable extra_extra8, only used for drowning damage in default Duke3D.
  2. It computes the damage reduction while the player has armor.
  3. It performs controller rumble when the player takes damage.

Setting RETURN to a nonzero value will abort the function early, and will therefore skip applying the three effects described above. In particular, this has the following effects:

  1. Each tic, the game will subtract the value stored in extra_extra8, divided by 256, from the player's current health. By default, the engine only uses this for drowning damage. Therefore, setting RETURN to -1 will prevent the player from taking drowning damage, as long as RETURN is a nonzero value. Note however, that the damage will still be accumulated in extra_extra8, and is not reset to 0 automatically. As soon as RETURN is set back to 0, all accumulated damage will be subtracted from the player, thus potentially killing him instantly.
  2. If the player takes damage, the engine will take the difference between extra and last_extra, and apply the reduction granted through armor that the player has. It will deal (20+RAND[30])% of the damage to the armor, with the rest being dealt to the player's health until the armor runs out. If RETURN is set to -1, the damage reduction for armor will not be applied, and the armor cannot take any damage, thus essentially disabling the armor.
  3. Player's playing with a controller will no longer experience any damage rumble if RETURN is set to -1.