EVENT INCURDAMAGE: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
m The function this event is placed in has to be one of the worst in the whole engine, jesus christ
mNo edit summary
Line 4: Line 4:
This [[event]] is executed for each player in the map, once per tic.  
This [[event]] is executed for each player in the map, once per tic.  


It is a constantly running event that checks for any damage inflicted onto the player, and if the player is wearing any armor[SHIELD], any damage received will have '''(20+RAND[30])'''% of the damage dealt to the armor and the rest dealt to the player's health until the armor runs out.
This event runs constantly as long as the player's health is greater than 0. It is placed at the start of the function <code>P_IncurDamage()</code> which serves 3 purposes:


If "setvar [[RETURN]] -1" is placed in this event, armor will not work in the normal manner, and it will allow you to make your own formula for armor.
# The function applies damage to the player accumulated in the variable [[extra_extra8]], only used for drowning damage in default Duke3D.
# It computes the damage reduction while the player has armor.
# 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:
 
# 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.
# 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.
# Player's playing with a controller will no longer experience any damage rumble if [[RETURN]] is set to -1.


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

Revision as of 14:01, 5 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.
  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.