CTakeDamageInfo damageInfo; int damageType = damageInfo.GetDamageType(); if (damageType == DMG_BURN) { // Do something if the damage type is DMG_BURN }
void Entity::TakeDamage(CTakeDamageInfo damageInfo) { int damageType = damageInfo.GetDamageType(); switch (damageType) { case DMG_BULLET: // Do something if the damage type is DMG_BULLET break; case DMG_BLAST: // Do something if the damage type is DMG_BLAST break; default: // Do something if the damage type is not recognized break; } }In this example, we define a function called TakeDamage that takes a CTakeDamageInfo object as a parameter. We then call the GetDamageType function to retrieve the type of damage, and use a switch statement to execute different blocks of code based on the damage type. In this case, we handle DMG_BULLET and DMG_BLAST, but any other damage types are handled by the default case. Package/library: Half-Life 2 Game Engine SDK.