trigger_hurt: Fix the broken use once flag (e.g. crossfire bunker fix)
This commit is contained in:
parent
182e8b9e74
commit
5e660e9399
1 changed files with 36 additions and 28 deletions
|
@ -12,7 +12,7 @@
|
|||
#define SF_HURT_FIREONPLAYER 16 // Only call UseTarget functions when it's a player
|
||||
#define SF_HURT_TOUCHPLAYER 32 // Only hurt players
|
||||
|
||||
class trigger_hurt : CBaseTrigger
|
||||
class trigger_hurt:CBaseTrigger
|
||||
{
|
||||
float m_flNextTrigger;
|
||||
int m_iDamage;
|
||||
|
@ -24,64 +24,72 @@ class trigger_hurt : CBaseTrigger
|
|||
virtual void() Respawn;
|
||||
};
|
||||
|
||||
void trigger_hurt :: Trigger ( void )
|
||||
void trigger_hurt::Trigger(void)
|
||||
{
|
||||
if ( solid != SOLID_NOT ) {
|
||||
|
||||
|
||||
if (solid != SOLID_NOT) {
|
||||
#ifdef GS_DEVELOPER
|
||||
print("trigger_hurt: de-activated.\n");
|
||||
#endif
|
||||
solid = SOLID_NOT;
|
||||
touch = __NULL__;
|
||||
} else {
|
||||
#ifdef GS_DEVELOPER
|
||||
print("trigger_hurt: activated.\n");
|
||||
#endif
|
||||
solid = SOLID_TRIGGER;
|
||||
touch = Touch;
|
||||
}
|
||||
}
|
||||
|
||||
void trigger_hurt :: Touch ( void )
|
||||
void trigger_hurt::Touch(void)
|
||||
{
|
||||
if ( m_flNextTrigger > time ) {
|
||||
if (m_flNextTrigger > time) {
|
||||
return;
|
||||
} else if ( other.takedamage == DAMAGE_NO ) {
|
||||
} else if (other.takedamage == DAMAGE_NO) {
|
||||
return;
|
||||
} else if ( ( spawnflags & SF_HURT_TOUCHPLAYER ) && !( other.flags & FL_CLIENT ) ) {
|
||||
} else if ((spawnflags & SF_HURT_TOUCHPLAYER) && !(other.flags & FL_CLIENT)) {
|
||||
return;
|
||||
} else if ( ( spawnflags & SF_HURT_NOPLAYERS ) && ( other.flags & FL_CLIENT ) ) {
|
||||
} else if ((spawnflags & SF_HURT_NOPLAYERS) && (other.flags & FL_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( spawnflags & SF_HURT_FIREONPLAYER ) {
|
||||
if ( other.flags & FL_CLIENT ) {
|
||||
if ( m_flDelay > 0 ) {
|
||||
CBaseTrigger::UseTargets_Delay( m_flDelay );
|
||||
if (spawnflags & SF_HURT_FIREONPLAYER) {
|
||||
if (other.flags & FL_CLIENT) {
|
||||
if (m_flDelay > 0) {
|
||||
CBaseTrigger::UseTargets_Delay(m_flDelay);
|
||||
} else {
|
||||
CBaseTrigger::UseTargets();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( m_flDelay > 0 ) {
|
||||
CBaseTrigger::UseTargets_Delay( m_flDelay );
|
||||
if (m_flDelay > 0) {
|
||||
CBaseTrigger::UseTargets_Delay(m_flDelay);
|
||||
} else {
|
||||
CBaseTrigger::UseTargets();
|
||||
}
|
||||
}
|
||||
|
||||
Damage_Apply( other, this, m_iDamage, other.origin, FALSE );
|
||||
//Damage_Apply( other, world, m_iDamage, DAMAGE_BLEED, WEAPON_NONE );
|
||||
|
||||
Damage_Apply(other, this, m_iDamage, other.origin, FALSE);
|
||||
|
||||
// Shut it down if used once
|
||||
if ( spawnflags & SF_HURT_ONCE ) {
|
||||
solid = SOLID_NOT;
|
||||
touch = __NULL__;
|
||||
if (spawnflags & SF_HURT_ONCE) {
|
||||
Trigger();
|
||||
}
|
||||
|
||||
m_flNextTrigger = time + 0.5;
|
||||
}
|
||||
|
||||
void trigger_hurt :: Respawn ( void )
|
||||
void trigger_hurt::Respawn(void)
|
||||
{
|
||||
#ifdef GS_DEVELOPER
|
||||
alpha = 0.5f;
|
||||
#endif
|
||||
|
||||
if ( spawnflags & SF_HURT_OFF ) {
|
||||
m_flNextTrigger = 0;
|
||||
|
||||
if (spawnflags & SF_HURT_OFF) {
|
||||
solid = SOLID_NOT;
|
||||
touch = __NULL__;
|
||||
} else {
|
||||
|
@ -90,23 +98,23 @@ void trigger_hurt :: Respawn ( void )
|
|||
}
|
||||
}
|
||||
|
||||
void trigger_hurt :: trigger_hurt ( void )
|
||||
void trigger_hurt::trigger_hurt(void)
|
||||
{
|
||||
for ( int i = 1; i < ( tokenize( __fullspawndata ) - 1 ); i += 2 ) {
|
||||
switch ( argv( i ) ) {
|
||||
for (int i = 1; i < (tokenize(__fullspawndata) - 1); i += 2) {
|
||||
switch (argv(i)) {
|
||||
case "dmg":
|
||||
m_iDamage = stoi( argv( i + 1 ) );
|
||||
m_iDamage = stoi(argv(i+1));
|
||||
break;
|
||||
case "wait":
|
||||
case "delay":
|
||||
m_flDelay = stof( argv( i + 1 ) );
|
||||
m_flDelay = stof(argv(i+1));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
trigger_hurt::Respawn();
|
||||
CBaseEntity::CBaseEntity();
|
||||
CBaseTrigger::InitBrushTrigger();
|
||||
trigger_hurt::Respawn();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue