EVENT INCURDAMAGE: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
One (talk | contribs)
No edit summary
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{EventTable|1=EVENT_INCURDAMAGE |2=current player|3=[[i|player->i]]|4=1 value}}
EVENT_INCURDAMAGE is a [[EDuke32_event_list|Game Event]].
EVENT_INCURDAMAGE is a [[EDuke32_event_list|Game Event]].


This [[event]] is a constantly running event that checks for any damage inflicted into 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]] is executed for each player in the map, once per tic.  


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.
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:
 
# 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. 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. Use this to define custom armor protection for the player.
# 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 01: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.