Determines the amount of damage of a specific type dealt to an object.

int GetDamageDealtByType(
    int nDamageType





Returns the amount of damage of type nDamageType that has been dealt to the caller. When called from the OnDamaged event, this function returns only the damage which was caused during that event.

The base weapon damage is the base damage delivered by the weapon before any additional types of damage (e.g. fire) have been added. Use DAMAGE_TYPE_BASE_WEAPON, in the 1.64 patch, to get this. Previously, you couldn't get this amount of damage.


This only works with EffectDamage, as detailed below.

It must be noted that this function returns -1 if no damage of that type occured.

Because of this, do not use this line, it will never work;


And this line will always be true, as it mearly does the opposite of the above:


This would be the correct way:

if(GetDamageDealtByType(DAMAGE_TYPE_PIERCING) != -1)

Or even better, look at the example for a valid way of using this function to see if we were damaged of a cirtain type of damage.

Known Bugs

EffectDamage() now isn't the only thing that affects this function. It can return DAMAGE_TYPE_BASE_WEAPON for any physical weapon damage done *before* additional energy (fire etc.) damage done by that same weapon.

The issue with DAMAGE_TYPE_SONIC is fixed in 1.64.

The Description for this function previously noted (at version 1.64):
"nDamageType can be assigned to OR-ed values from the constant group DAMAGE_TYPE_*."
This is known not to work in version 1.69.




// If we had any fire damage applied to us, we will say some catchline.
void main()
    if(GetDamageDealtByType(DAMAGE_TYPE_FIRE) >= 1)
         // Obviously a high-strung-evangilist voiceset helps.
         SpeakString("Hey, baby, I'm on FIIIREEEEE!");

See Also

categories: Action on Object Functions
constants: DAMAGE_TYPE_* Constants

 author: Tom Cassiotis, editors: Jasperre, Ken Cotterill, Kookoo, additional contributors: Peter Westergaard, Jassper, Undivine, NetRacer56, Ryan Workman, Dan Wyman, Jasperre, bug finder: AlizarinCrimson