EVENT INCURDAMAGE: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
Line 12: Line 12:
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:
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:


# 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.
# 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. Use this to modify how drowning damage is applied to the player.
# 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.
# 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. Use this to define custom armor protection for the player.
# Player's playing with a controller will no longer experience any damage rumble if [[RETURN]] is set to -1.
# Players playing with a controller will no longer experience any damage rumble if [[RETURN]] is set to -1. Currently, there is no way to restore this functionality if [[RETURN]] is set to -1, but there may be a CON command to customize controller rumble in future releases.


[[Category:Events]]
[[Category:Events]]

Latest revision as of 02:28, 6 February 2022

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. Use this to modify how drowning damage is applied to the player.
  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. Use this to define custom armor protection for the player.
  3. Players playing with a controller will no longer experience any damage rumble if RETURN is set to -1. Currently, there is no way to restore this functionality if RETURN is set to -1, but there may be a CON command to customize controller rumble in future releases.