DamageInfo#

DamageInfo is a specific, data type, though of instance var used in rSquirrel by Respawn to store information about an attack in one variable.

Most commonly you will find damageinfo as an argument in a kill or damage callback. Respawn made some helper functions that help us extract or set certain stats in a damageinfo

Getter functions#

int DamageInfo_GetDamageSourceIdentifier(var damageInfo)#

returns the eDamageSourceId

damageSourceId is an int that references an enum and can be used to identify what source damage came from.

damageSourceId is mostly found as an argument in some kill and damage related functions. Respawn has created a function that will attempt to localise the damageSourceId inputed. To add your own custom damageSourceID , see: Custom Damage Source IDs

Other useful functions can be found in the damageinfo section of this page and in Entities

GetObitFromdamageSourceId is a global function that attempts to localise the damageSourceId inputed, if it cannot get a localised string it will simply return the localisation string of the source.

float DamageInfo_GetDamage(var damageInfo)#

returns the damage inflicted to the target

vector DamageInfo_GetDamagePosition(var damageInfo)#
vector DamageInfo_GetDamageForce(var damageInfo)#
unknown DamageInfo_GetDamageFlags(var damageInfo)#
var DamageInfo_GetDamageWeaponName(var damageInfo)#

While this returns a var it can be casted to a string with expect string( DamageInfo_GetDamageWeaponName( damageInfo ) )

entity DamageInfo_GetWeapon(var damageInfo)#
entity DamageInfo_GetAttacker(var damageInfo)#
entity DamageInfo_GetInflictor(var damageInfo)#
int DamageInfo_GetCustomDamageType(var damageInfo)#
int DamageInfo_GetHitBox(var damageInfo)#
int DamageInfo_GetHitGroup(var damageInfo)#
float DamageInfo_GetDistFromAttackOrigin(var damageInfo)#
float GetCriticalScaler(entity ent, var damageInfo)#
int DamageInfo_GetDamageType(damageInfo)#

Setter functions#

void DamageInfo_SetDamage(damageInfo, float damage)#
void DamageInfo_SetDeathPackage(damageInfo, string type)#
void DamageInfo_SetDamageForce(damageInfo, vector force)#
void DamageInfo_SetForceKill(var damageInfo, bool)#
void DamageInfo_SetCustomDamageType(damageInfo, damageType)#

Helper functions#

Server only#

bool HeavyArmorCriticalHitRequired(var damageInfo)#
bool CritWeaponInDamageInfo(var damageInfo)#
float GetCriticalScaler(ent, damageInfo)#

Global#

bool IsValidHeadShot(var damageInfo = null, entity victim = null, entity attacker = null, entity weapon = null, int hitGroup = -1, float attackDist = -1.0, entity inflictor = null)#
bool IsMaxRangeShot(damageInfo)#
bool IsMidRangeShot(damageInfo)#
bool IsInstantDeath(var damageInfo)#
bool IsTitanCrushDamage(damageInfo)#
bool IsSuicide(entity attacker, entity victim, int damageSourceId)#
string GetObitFromdamageSourceId(int damageSourceId)#

Extracting information#

You are able to get additional information about the damage dealt useing damageTypes, you can get those either directly or with the DamageInfo_GetDamageType( damageInfo ). You are then able to check for certain information using the damageFlags

Damage flags

List of all Damage flags

Variable name

Value

DF_GIB

1

DF_DISSOLVE

2

DF_INSTANT

3

DF_NO_SELF_DAMAGE

4

DF_IMPACT

5

DF_BYPASS_SHIELD

6

DF_RAGDOLL

7

DF_TITAN_STEP

8

DF_RADIUS_DAMAGE

9

DF_ELECTRICAL

10

DF_BULLET

11

DF_EXPLOSION

12

DF_MELEE

13

DF_NO_INDICATOR

14

DF_KNOCK_BACK

15

DF_STOPS_TITAN_REGEN

16

DF_DISMEMBERMENT

17

DF_MAX_RANGE

18

DF_SHIELD_DAMAGE

19

DF_CRITICAL

20

DF_SKIP_DAMAGE_PROT

21

DF_HEADSHOT

22

DF_VORTEX_REFIRE

23

DF_RODEO

24

DF_BURN_CARD_WEAPON

25

DF_KILLSHOT

26

DF_SHOTGUN

27

DF_SKIPS_DOOMED_STATE

28

DF_DOOMED_HEALTH_LOSS

29

DF_DOOM_PROTECTED

30

DF_DOOM_FATALITY

31

DF_NO_HITBEEP

32

Damage types
global enum damageTypes
{
    gibs                                = (DF_GIB)
    largeCaliberExp             = (DF_BULLET | DF_GIB | DF_EXPLOSION)
    gibBullet                   = (DF_BULLET | DF_GIB)
    instant                             = (DF_INSTANT)
    dissolve                    = (DF_DISSOLVE)
    projectileImpact    = (DF_GIB)
    pinkMist                    = (DF_GIB) //If updated from DF_GIB, change the DF_GIB in Arc Cannon to match.
    ragdoll                             = (DF_RAGDOLL)
    titanStepCrush              = (DF_TITAN_STEP)
    arcCannon                   = (DF_DISSOLVE | DF_GIB | DF_ELECTRICAL )
    electric                    = (DF_ELECTRICAL) //Only increases Vortex Shield decay for bullet weapons atm.
    explosive                   = (DF_RAGDOLL | DF_EXPLOSION )
    bullet                              = (DF_BULLET)
    largeCaliber                = (DF_BULLET | DF_KNOCK_BACK)
    shotgun                             = (DF_BULLET | DF_GIB | DF_SHOTGUN )
    titanMelee                  = (DF_MELEE | DF_RAGDOLL)
    titanBerserkerMelee = (DF_MELEE | DF_RAGDOLL)
    titanEjectExplosion = (DF_GIB | DF_EXPLOSION)
    dissolveForce               = (DF_DISSOLVE | DF_KNOCK_BACK | DF_EXPLOSION)
    rodeoBatteryRemoval = (DF_RODEO | DF_EXPLOSION | DF_STOPS_TITAN_REGEN )
}

Now you can check for any of these by using the bitwise and operator &

bool isHeadshot = bool( damageType & DF_HEADSHOT )

you can also combine two with the bitwise or operator | like this:

bool isHeadshotWithShotgun = bool( damageType & DF_HEADSHOT ) | bool( damageType & DF_SHOTGUN )