Fixed a think() bug with scripted_sequences.

This commit is contained in:
Marco Cawthorne 2020-03-30 10:00:37 +02:00
parent c42e6678ac
commit 2658e93683
3 changed files with 20 additions and 16 deletions

View file

@ -175,17 +175,20 @@ void CBaseMonster::FreeState(void)
/* trigger when required */
if (m_strRouteEnded) {
for (entity t = world; (t = find(t, CBaseTrigger::m_strTargetName, m_strRouteEnded));) {
CBaseTrigger trigger = (CBaseTrigger)t;
if (trigger.Trigger != __NULL__) {
print(sprintf("^2CBaseMonster::FreeState^7: %s triggered %f\n", m_strRouteEnded, time));
trigger.Trigger();
}
CBaseTrigger trigger;
trigger = (CBaseTrigger)find(trigger, CBaseTrigger::m_strTargetName, m_strRouteEnded);
if (!trigger) {
print(sprintf("^1CBaseMonster::FreeState^7: %s doesn't exist. Won't trigger\n", m_strRouteEnded));
}
if (trigger.Trigger != __NULL__) {
print(sprintf("^2CBaseMonster::FreeState^7: %s triggered %f\n", m_strRouteEnded, time));
trigger.Trigger();
} else {
print(sprintf("^1CBaseMonster::FreeState^7: %s not a valid trigger\n", m_strRouteEnded));
}
}
m_strRouteEnded = "";
if (m_iSequenceRemove) {
Hide();
}
@ -311,10 +314,9 @@ void CBaseMonster::Physics(void)
/* support for think/nextthink */
if (think && nextthink > 0.0) {
if (nextthink < time) {
nextthink = 0.0f;
print("^2CBaseMonster::Physics: Trigger think()\n");
think();
nextthink = 0.0f;
think = __NULL__;
}
}
}

View file

@ -519,10 +519,9 @@ CBaseNPC::Physics(void)
/* support for think/nextthink */
if (think && nextthink > 0.0) {
if (nextthink < time) {
print("^2CBaseNPC::Physics: Trigger think()\n");
think();
nextthink = 0.0f;
think = __NULL__;
print("^2CBaseMonster::Physics: Trigger think()\n");
think();
}
}
}

View file

@ -118,7 +118,7 @@ void scripted_sequence::Trigger(void)
for (entity c = world; (c = find(c, ::classname, m_strMonster));) {
/* within radius */
if (vlen(origin - c.origin) < m_flSearchRadius) {
f = c;
f = (CBaseMonster)c;
break;
}
}
@ -144,7 +144,10 @@ void scripted_sequence::Trigger(void)
}
/* entity to trigger after sequence ends */
f.m_strRouteEnded = m_strTarget;
if (m_strTarget) {
print(sprintf("\tTrigger when finished: %s\n", m_strTarget));
f.m_strRouteEnded = m_strTarget;
}
/* mark the state */
f.m_iSequenceState = SEQUENCESTATE_ACTIVE;
@ -177,7 +180,7 @@ void scripted_sequence::Trigger(void)
f.nextthink = time + duration;
print(sprintf(
"\tAnimation: %s Duration: %f seconds (modelindex %d, frame %d)\n",
f.m_strTargetName,
m_strActionAnim,
duration,
f.modelindex,
f.m_flSequenceEnd