Garry's Mod Wiki

CTakeDamageInfo

A class used to store and modify all the data concerning a damage event. An empty CTakeDamageInfo object can be created with DamageInfo

List of hooks that this object is passed to:

List of functions that use this object:

Methods

CTakeDamageInfo:AddDamage( number damageIncrease )
Increases the damage by damageIncrease.
number CTakeDamageInfo:GetAmmoType()
Returns the ammo type used by the weapon that inflicted the damage.
Entity CTakeDamageInfo:GetAttacker()
Returns the attacker ( character who originated the attack ), for example a player or an NPC that shot the weapon.
number CTakeDamageInfo:GetBaseDamage()
Returns the initial unmodified by skill level ( game. GetSkillLevel ) damage.
number CTakeDamageInfo:GetDamage()
Returns the total damage.
number CTakeDamageInfo:GetDamageBonus()
Gets the current bonus damage.
number CTakeDamageInfo:GetDamageCustom()
Gets the custom damage type. This is used by Day of Defeat: Source and Team Fortress 2 for extended damage info, but isn't used in Garry's Mod by default.
Vector CTakeDamageInfo:GetDamageForce()
Returns a vector representing the damage force. Can be set with CTakeDamageInfo:SetDamageForce.
Vector CTakeDamageInfo:GetDamagePosition()
Returns the position where the damage was or is going to be applied to. Can be set using CTakeDamageInfo:SetDamagePosition.
number CTakeDamageInfo:GetDamageType()
Returns a bitflag which indicates the damage type(s) of the damage. Consider using CTakeDamageInfo:IsDamageType instead. Value returned by this function can contain multiple damage types.
Entity CTakeDamageInfo:GetInflictor()
Returns the inflictor of the damage. This is not necessarily a weapon. For hitscan weapons this is the weapon. For projectile weapons this is the projectile. For a more reliable method of getting the weapon that damaged an entity, use GetAttacker with GetActiveWeapon.
number CTakeDamageInfo:GetMaxDamage()
Returns the maximum damage. See CTakeDamageInfo:SetMaxDamage
Vector CTakeDamageInfo:GetReportedPosition()
Returns the initial, unmodified position where the damage occured.
boolean CTakeDamageInfo:IsBulletDamage()
Returns true if the damage was caused by a bullet.
boolean CTakeDamageInfo:IsDamageType( number dmgType )
Returns whenever the damageinfo contains the damage type specified.
boolean CTakeDamageInfo:IsExplosionDamage()
Returns whenever the damageinfo contains explosion damage.
boolean CTakeDamageInfo:IsFallDamage()
Returns whenever the damageinfo contains fall damage.
CTakeDamageInfo:ScaleDamage( number scale )
Scales the damage by the given value.
CTakeDamageInfo:SetAmmoType( number ammoType )
Changes the ammo type used by the weapon that inflicted the damage.
CTakeDamageInfo:SetAttacker( Entity ent )
Sets the attacker ( character who originated the attack ) of the damage, for example a player or an NPC.
CTakeDamageInfo:SetBaseDamage( number )
Sets the initial unmodified by skill level ( game. GetSkillLevel ) damage. This function will not update or touch CTakeDamageInfo:GetDamage.
CTakeDamageInfo:SetDamage( number damage )
Sets the amount of damage.
CTakeDamageInfo:SetDamageBonus( number damage )
Sets the bonus damage. Bonus damage isn't automatically applied, so this will have no outer effect by default.
CTakeDamageInfo:SetDamageCustom( number DamageType )
Sets the custom damage type. This is used by Day of Defeat: Source and Team Fortress 2 for extended damage info, but isn't used in Garry's Mod by default.
CTakeDamageInfo:SetDamageForce( Vector force )
Sets the directional force of the damage. This function seems to have no effect on player knockback. To disable knockback entirely, see EFL_NO_DAMAGE_FORCES or use workaround example below.
CTakeDamageInfo:SetDamagePosition( Vector pos )
Sets the position of where the damage gets applied to.
CTakeDamageInfo:SetDamageType( number type )
Sets the damage type.
CTakeDamageInfo:SetInflictor( Entity inflictor )
Sets the inflictor of the damage for example a weapon. For hitscan/bullet weapons this should the weapon. For projectile ( rockets, etc ) weapons this should be the projectile.
CTakeDamageInfo:SetMaxDamage( number maxDamage )
Sets the maximum damage this damage event can cause.
CTakeDamageInfo:SetReportedPosition( Vector pos )
Sets the origin of the damage.
CTakeDamageInfo:SubtractDamage( number damage )
Subtracts the specified amount from the damage.