ApplyDamageFactors
Jump to navigation
Jump to search
Note: This should not be confused with ApplyDamageFactor. |
clearscope static int ApplyDamageFactors (class<Inventory> itemcls, Name damagetype, int damage, int defdamage)
Usage
Returns the value passed to damage after adjustment, which is done by multiplying it with the chosen damage factor from the specified item class. If the chosen damage factor does not exist among the item's damage factors, damage is returned as is. If the item does not define any damage factors, the function returns the value passed to defdamage without any adjustments.
This function is generally used as part of set ups to adjust the damage an actor receives or inflicts.
Parameters
- class<Inventory> itemcls
- The item class from which to get the damage factors.
- Name damagetype
- The desired damage factor, referenced by its damage type.
- int damage
- The value to multiply the damage factor with.
- int defdamage
- The fall-back value to return if the item does not define any damage factors.
Examples
PowerDamage (and powerups based on it) uses this function when modifying the damage its owner deals, so that damage types could be specified in the powerup:
override void ModifyDamage (int damage, Name damageType, out int newdamage, bool passive, Actor inflictor, Actor source, int flags) { if (!passive && damage > 0) { newdamage = max(1, ApplyDamageFactors(GetClass(), damageType, damage, damage * 4)); if (Owner != null && newdamage > damage) { Owner.A_StartSound(ActiveSound, CHAN_AUTO, CHANF_DEFAULT, 1.0, ATTN_NONE); } } }