Fix Apache not firing trigger targets

Resolves ValveSoftware/halflife#3262
This commit is contained in:
Sam V 2022-03-15 13:16:11 +01:00
parent 765c1f5654
commit 398591dce4

View file

@ -124,6 +124,7 @@ void CApache::Spawn()
pev->flags |= FL_MONSTER;
pev->takedamage = DAMAGE_AIM;
pev->health = gSkillData.apacheHealth;
pev->max_health = pev->health;
m_flFieldOfView = -0.707; // 270 degrees
@ -135,15 +136,17 @@ void CApache::Spawn()
if ((pev->spawnflags & SF_WAITFORTRIGGER) != 0)
{
SetThink(&CApache::NullThink);
SetUse(&CApache::StartupUse);
}
else
{
SetThink(&CApache::HuntThink);
SetTouch(&CApache::FlyTouch);
pev->nextthink = gpGlobals->time + 1.0;
}
pev->nextthink = gpGlobals->time + 1.0;
m_iRockets = 10;
}
@ -176,6 +179,7 @@ void CApache::Precache()
void CApache::NullThink()
{
StudioFrameAdvance();
FCheckAITrigger();
pev->nextthink = gpGlobals->time + 0.5;
}
@ -201,6 +205,7 @@ void CApache::Killed(entvars_t* pevAttacker, int iGib)
pev->nextthink = gpGlobals->time + 0.1;
pev->health = 0;
pev->takedamage = DAMAGE_NO;
pev->deadflag = DEAD_DYING;
if ((pev->spawnflags & SF_NOWRECKAGE) != 0)
{
@ -222,6 +227,8 @@ void CApache::DyingThink()
// still falling?
if (m_flNextRocket > gpGlobals->time)
{
FCheckAITrigger();
// random explosions
MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, pev->origin);
WRITE_BYTE(TE_EXPLOSION); // This just makes a dynamic light now
@ -458,8 +465,20 @@ void CApache::HuntThink()
{
Look(4092);
m_hEnemy = BestVisibleEnemy();
//If i have an enemy i'm in combat, otherwise i'm patrolling.
if (m_hEnemy != nullptr)
{
m_MonsterState = MONSTERSTATE_COMBAT;
}
else
{
m_MonsterState = MONSTERSTATE_ALERT;
}
}
Listen();
// generic speed up
if (m_flGoalSpeed < 800)
m_flGoalSpeed += 5;
@ -581,6 +600,8 @@ void CApache::HuntThink()
}
}
}
FCheckAITrigger();
}
@ -910,7 +931,32 @@ bool CApache::TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float
*/
// ALERT( at_console, "%.0f\n", flDamage );
return CBaseEntity::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType);
const bool result = CBaseEntity::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType);
//Are we damaged at all?
if (pev->health < pev->max_health)
{
//Took some damage.
SetConditions(bits_COND_LIGHT_DAMAGE);
if (pev->health < (pev->max_health / 2))
{
//Seriously damaged now.
SetConditions(bits_COND_HEAVY_DAMAGE);
}
else
{
//Maybe somebody healed us somehow (trigger_hurt with negative damage?), clear this.
ClearConditions(bits_COND_HEAVY_DAMAGE);
}
}
else
{
//Maybe somebody healed us somehow (trigger_hurt with negative damage?), clear this.
ClearConditions(bits_COND_LIGHT_DAMAGE);
}
return result;
}