Skip to content

Commit

Permalink
m_iInmuneDamage bit variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikk155 committed Apr 3, 2024
1 parent 5ce53bb commit b7b850b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
6 changes: 6 additions & 0 deletions entitydata/BaseClass.json
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,12 @@
}
}
},
"m_iInmuneDamage":
{
"title": "Inmune to damage bits",
"type": "integer",
"description": "Set the bits of damage that this entity is inmune to, for example set 2 and this entity won't take any damage from bullets, see <a href=\"../features/damage_bits.html\">Damage Bits</a>"
},
"CCustomModels":
{
"model_replacement_filename":
Expand Down
2 changes: 1 addition & 1 deletion entitydata/SolidClass/func_breakable.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"atributes":
{
"base": "Angles, Global, Breakable, Target, FireTargets, CBaseDelay, CReplacemetFile, rendersettings, _minlight, ZHLT",
"base": "Angles, Global, Breakable, m_iInmuneDamage, Target, FireTargets, CBaseDelay, CReplacemetFile, rendersettings, _minlight, ZHLT",
"title": "Breakable Object"
},
"spawnflags":
Expand Down
2 changes: 1 addition & 1 deletion entitydata/SolidClass/func_pushable.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"atributes":
{
"base": "Angles, Global, Breakable, Target, FireTargets, CBaseDelay, CReplacemetFile, rendersettings, _minlight, ZHLT",
"base": "Angles, Global, Breakable, m_iInmuneDamage, Target, FireTargets, CBaseDelay, CReplacemetFile, rendersettings, _minlight, ZHLT",
"title": "Pushable object"
},
"size":
Expand Down
2 changes: 2 additions & 0 deletions src/game/server/entities/CBaseEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,8 @@ class SINGLE_INHERITANCE CBaseEntity

int m_appearflag_notin = (int)appearflags::DEFAULT;
int m_appearflag_onlyin = (int)appearflags::DEFAULT;

int m_iInmuneDamage = 0;
};

inline bool FNullEnt(CBaseEntity* ent) { return (ent == nullptr) || FNullEnt(ent->edict()); }
Expand Down
6 changes: 5 additions & 1 deletion src/game/server/entities/NPCs/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,12 @@ bool CBaseMonster::TakeDamage(CBaseEntity* inflictor, CBaseEntity* attacker, flo
float flTake;
Vector vecDir;

if( 0 == pev->takedamage || FBitSet( pev->flags, FL_GODMODE ) )
if( pev->takedamage == DAMAGE_NO
|| FBitSet( pev->flags, FL_GODMODE )
|| ( m_iInmuneDamage > 0 && ( bitsDamageType & m_iInmuneDamage ) != 0 ) )
{
return false;
}

if (!IsAlive())
{
Expand Down
12 changes: 11 additions & 1 deletion src/game/server/entities/cbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,11 @@ bool CBaseEntity::RequiredKeyValue(KeyValueData* pkvd)
}
}
}
else if( FStrEq( pkvd->szKeyName, "m_iInmuneDamage" ) )
{
m_iInmuneDamage = atoi( pkvd->szValue );
return true;
}

return false;
}
Expand Down Expand Up @@ -719,8 +724,13 @@ bool CBaseEntity::TakeDamage(CBaseEntity* inflictor, CBaseEntity* attacker, floa
{
Vector vecTemp;

if (0 == pev->takedamage)
if( pev->takedamage == DAMAGE_NO
|| FBitSet( pev->flags, FL_GODMODE )
|| ( m_iInmuneDamage > 0 && ( bitsDamageType & m_iInmuneDamage ) != 0 ) )
{
return false;
}


// UNDONE: some entity types may be immune or resistant to some bitsDamageType

Expand Down

0 comments on commit b7b850b

Please sign in to comment.