Skip to content

Commit

Permalink
Add 'Ignore Armor' flag for trigger_hurt and trigger_hurt_remote
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed Oct 19, 2023
1 parent 4b3b80e commit 3cbef6c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 17 additions & 6 deletions dlls/triggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#define SF_TRIGGER_HURT_CLIENTONLYTOUCH 32// only clients may touch this trigger.
#define SF_TRIGGER_HURT_AFFECT_NON_MOVING_MONSTERS 64 // hack to affect non-moving monsters
#define SF_TRIGGER_HURT_FULL_DAMAGE_EVERY_HALF_SECOND 128
#define SF_TRIGGER_HURT_IGNORE_ARMOR 256

extern DLL_GLOBAL BOOL g_fGameOver;

Expand Down Expand Up @@ -981,15 +982,21 @@ class CTriggerHurt : public CBaseTrigger
void EXPORT HurtNonMovingMonstersThink( void );
bool CanHurt( CBaseEntity* pOther );

int DmgGibFlag() {
int DamageType() const {
int damageType = m_bitsDamageInflict;
switch (pev->impulse) {
case 1:
return DMG_ALWAYSGIB;
damageType = DMG_ALWAYSGIB;
break;
case 2:
return DMG_NEVERGIB;
damageType = DMG_NEVERGIB;
break;
default:
return 0;
break;
}
if (pev->spawnflags & SF_TRIGGER_HURT_IGNORE_ARMOR)
damageType |= DMG_IGNORE_ARMOR;
return damageType;
}
};

Expand Down Expand Up @@ -1417,7 +1424,7 @@ void CTriggerHurt::HurtNonMovingMonsters()
if (flDmg < 0)
pMonster->TakeHealth( this, -flDmg, m_bitsDamageInflict );
else
pMonster->TakeDamage( pev, pev, flDmg, m_bitsDamageInflict|DmgGibFlag() );
pMonster->TakeDamage( pev, pev, flDmg, DamageType() );
}
}
}
Expand Down Expand Up @@ -1589,7 +1596,7 @@ void CTriggerHurt::HurtTouch( CBaseEntity *pOther )
if (pev->dmg_save > 0) {
fldmg = Q_max(Q_min(pOther->pev->health - pev->dmg_save, fldmg), 0.0f);
}
pOther->TakeDamage( pev, pev, fldmg, m_bitsDamageInflict|DmgGibFlag() );
pOther->TakeDamage( pev, pev, fldmg, DamageType() );
}

// Store pain time so we can get all of the other entities on this frame
Expand Down Expand Up @@ -5067,6 +5074,8 @@ void CTriggerChangeClass::Affect(CBaseEntity *pEntity, USE_TYPE useType)
#define SF_TRIGGER_HURT_REMOTE_CONSTANT 2
#define SF_TRIGGER_HURT_REMOTE_STARTON 4

#define SF_TRIGGER_HURT_REMOTE_IGNORE_ARMOR 256

class CTriggerHurtRemote : public CPointEntity
{
public:
Expand Down Expand Up @@ -5098,6 +5107,8 @@ class CTriggerHurtRemote : public CPointEntity
default:
break;
}
if (pev->spawnflags & SF_TRIGGER_HURT_REMOTE_IGNORE_ARMOR)
damageType |= DMG_IGNORE_ARMOR;
return damageType;
}
float Delay() const { return pev->frags ? pev->frags : 0.1; }
Expand Down
2 changes: 2 additions & 0 deletions fgd/halflife.fgd
Original file line number Diff line number Diff line change
Expand Up @@ -7522,6 +7522,7 @@
32:"TouchClientOnly" : 0
64:"Affect non-moving NPC's" : 0 : "Uses entity's bounding box to find and hurt non-moving monsters. Will produce wrong results on non-cuboid brush shapes."
128:"Full dmg every 0.5 seconds" : 0 : "Do full damage (or healing) instead of halving the value. Recommended to use with odd values."
256:"Ignore Armor" : 0
]
master(string) : "Master"
dmg(integer) : "Damage" : 10 : "The damage is applied every 0.5 seconds. Negative value means healing. The value is getting halved, unless 'Full dmg every 0.5 seconds' spawnflag is set."
Expand All @@ -7537,6 +7538,7 @@
1 : "Instant Kill" : 0
2 : "Constant" : 0
4 : "Start On" : 0
256:"Ignore Armor" : 0
]
target(string) : "Target [LE]"
targetclass(string) : "Target Class" : : "If specified, all entities with the given class will be affected. This is independent from Target, which means the entity might cause damage twice to the same entity if Target is class of Target Class."
Expand Down

0 comments on commit 3cbef6c

Please sign in to comment.