I search for solutions in this order: Past Code, Unreal Source, Wiki, BUF, groups.yahoo, google, screaming at monitor. – RegularX

Difference between revisions of "Legacy:Taking Damage"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
m (spell fix)
m (another spell fix)
 
Line 18: Line 18:
 
If <tt>bIsPlayer</tt> is <tt>False</tt> there are also two possibilities:
 
If <tt>bIsPlayer</tt> is <tt>False</tt> there are also two possibilities:
 
# The attacker is either a parent class or a subclass of the damaged Pawn. The actual damage is multiplied by the lower value of either <tt>1 - ReducedDamagePct</tt> (a Pawn class property) or <tt>0.35</tt>.
 
# The attacker is either a parent class or a subclass of the damaged Pawn. The actual damage is multiplied by the lower value of either <tt>1 - ReducedDamagePct</tt> (a Pawn class property) or <tt>0.35</tt>.
# The Pawn's <tt>ReducedDamageType</tt> property has the value <tt>'All'</tt> or is equal to the DamagepType parameter. The actual damage is multiplied by <tt>1 - ReducedDamagePct</tt>.
+
# The Pawn's <tt>ReducedDamageType</tt> property has the value <tt>'All'</tt> or is equal to the DamageType parameter. The actual damage is multiplied by <tt>1 - ReducedDamagePct</tt>.
  
 
Then the registered damage [[Legacy:Mutator|mutators]] are allowed to further adjust the damage (even if it is already 0) through their <tt>MutatorTakeDamage</tt> function.<br>
 
Then the registered damage [[Legacy:Mutator|mutators]] are allowed to further adjust the damage (even if it is already 0) through their <tt>MutatorTakeDamage</tt> function.<br>

Latest revision as of 13:31, 9 September 2015

The DamageType class in UT's Class Hierarchy creates quite some confusion. It was intended to contain more specific information about how this kind of damage acts. However the TakeDamage and HurtRadius functions (these are used to damage Actors) only take a variable of type Name which cannot be used to access classes like the DamageType subclasses.

How do damage types work?[edit]

Damage types are passed as the last parameter of the TakeDamage function:

function TakeDamage (int Damage, Pawn InstigatedBy, vector HitLocation, vector Momentum, name DamageType)

Usually the DamageType parameter isn't used unless the damaged actor is a Pawn. In that case several other actors have the opportunity to reduce the amount of damage the Pawn receives.

First the current GameInfo (UT)'s ReduceDamage function is called. This function returns 0 if the player is in a zone with bNeutralZone = True. Otherwise multiplies the damage by 1.5 if the game runs in Hardcore or Turbo mode and also by the DamageScaling property of the Pawn who was responsible for the damage. In team games the friendly fire scaling is also applied here. Custom GameInfo subclasses could also reduce the damage based on the damage type.

The next step depends on the Pawn's bIsPlayer property. If it is True then there are three possibilities:

  1. The Pawn's ReducedDamageType property has the value 'All'. In this case the actual damage is set to 0.
  2. The Pawn's inventory list is not empty. The first Inventory (UT) item gets a ReduceDamage call. The items create a temporary list of armor items sorted by the items' armor priorities based on the damage type and reduce the damage. As long as the damage is not 0 the next item in that list may reduce the damage through the ArmorAbsorbDamage function. (see Armor Damage Absorption for details)
  3. The Pawn's inventory list is empty. The damage remains unchanged.

If bIsPlayer is False there are also two possibilities:

  1. The attacker is either a parent class or a subclass of the damaged Pawn. The actual damage is multiplied by the lower value of either 1 - ReducedDamagePct (a Pawn class property) or 0.35.
  2. The Pawn's ReducedDamageType property has the value 'All' or is equal to the DamageType parameter. The actual damage is multiplied by 1 - ReducedDamagePct.

Then the registered damage mutators are allowed to further adjust the damage (even if it is already 0) through their MutatorTakeDamage function.

Now the damage can be applied.

If the health now goes below 0 the Pawn's Died function is called. Again the damage type is passed as a parameter:

function Died (Pawn Killer, name DamageType, vector HitLocation)

The first thing this function does is ask the mutators if the Pawn may die by calling the PreventDeath function of the game type's BaseMutator. If it returns True the Pawn will not die. If it returns False the Killed function is called on all Pawns (including this one) and the GameInfo.

The GameInfo's Killed function is responsible for displaying all those kill-related messages. It also call's the GameInfo's ScoreKill function which in turn calls the ScoreKill function of the BaseMutator.

Special damage type death messages[edit]

Suicides[edit]

A kill is considered as a suicide if either the killer is None or killer and victim are the same Pawn.

'Fell' 
"<killed player's name> left a small crater."
'Eradicated' 
"<killed player's name> was blown up."
'Drowned' 
"<killed player's name> forgot to come up for air."
'Burned' 
"<killed player's name> was incinerated."
'Corroded' 
"<killed player's name> was slimed."
'Mortared' 
"<killed player's name> was blown up by a mortar."
(any other) 
"<killed player's name> killed his/her own dumb self."

Player vs player kills[edit]

(Both the killer and the victim have bIsPlayer = True.)

If the damage type is not listed here, the DeathMessage of the weapon the killer currently has selected will be used. If the killer has no weapon (e.g. when he is dead) the message will empty.

'SpecialDamage' 
The LevelInfo's SpecialDamageString is used as death message.

In UT:[edit]

'RedeemerDeath' 
"<victim's player name> was vaporized by <killer's player name>'s Redeemer!!"
'RocketDeath', 'GrenadeDeath' 
"<victim's player name> was smacked down by <killer's player name>'s Rocket Launcher!!"
'Eradicated' 
"<victim's player name> was eradicated by the unholy power of <killer's player name>!!"
'Gibbed' 
"<victim's player name> was telefragged by <killer's player name>!"

Related topics[edit]