Sounds will now follow the NPCs that emit them.
This commit is contained in:
parent
e6f3df4986
commit
c42e6678ac
4 changed files with 61 additions and 22 deletions
|
@ -73,7 +73,7 @@ CBaseEntity::ProcessWordQue(void)
|
|||
return;
|
||||
}
|
||||
|
||||
sound(this, CHAN_VOICE, m_pSentenceQue[m_iSentencePos].m_strSnd, 1.0, ATTN_NORM);
|
||||
sound(this, CHAN_VOICE, m_pSentenceQue[m_iSentencePos].m_strSnd, 1.0, ATTN_NORM, 100, SOUNDFLAG_FOLLOW);
|
||||
dprint(sprintf("^2CBaseEntity::ProcessWordQue^7: Speaking %s\n", m_pSentenceQue[m_iSentencePos].m_strSnd));
|
||||
m_iSentencePos++;
|
||||
|
||||
|
|
|
@ -90,12 +90,14 @@ class CBaseMonster:CBaseEntity
|
|||
virtual void(int) Death;
|
||||
virtual void() Physics;
|
||||
virtual void() IdleNoise;
|
||||
virtual void() FreeState;
|
||||
virtual void() Gib;
|
||||
virtual void(string) Sound;
|
||||
virtual float(entity, float) SendEntity;
|
||||
virtual void() ParentUpdate;
|
||||
|
||||
/* sequences */
|
||||
virtual void() FreeState;
|
||||
|
||||
virtual void() ClearRoute;
|
||||
virtual void() CheckRoute;
|
||||
virtual void() WalkRoute;
|
||||
|
@ -176,11 +178,14 @@ void CBaseMonster::FreeState(void)
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_strRouteEnded = "";
|
||||
|
||||
if (m_iSequenceRemove) {
|
||||
Hide();
|
||||
}
|
||||
|
@ -207,14 +212,14 @@ void CBaseMonster::CheckRoute(void)
|
|||
flDist = floor( vlen( evenpos - origin ) );
|
||||
|
||||
if ( flDist < 8 ) {
|
||||
print(sprintf("^2CBaseMonster::CheckRoute^7: %s reached node\n", this.netname));
|
||||
print(sprintf("^2CBaseMonster::CheckRoute^7: %s reached node\n", this.m_strTargetName));
|
||||
m_iCurNode--;
|
||||
velocity = [0,0,0]; /* clamp friction */
|
||||
}
|
||||
|
||||
if (m_iCurNode < -1) {
|
||||
ClearRoute();
|
||||
print(sprintf("^2CBaseMonster::CheckRoute^7: %s reached end\n", this.netname));
|
||||
print(sprintf("^2CBaseMonster::CheckRoute^7: %s reached end\n", this.m_strTargetName));
|
||||
|
||||
/* mark that we've ended a sequence, if we're in one and que anim */
|
||||
if (m_iSequenceState == SEQUENCESTATE_ACTIVE) {
|
||||
|
@ -223,11 +228,12 @@ void CBaseMonster::CheckRoute(void)
|
|||
m_iSequenceState = SEQUENCESTATE_ENDING;
|
||||
think = FreeState;
|
||||
nextthink = time + duration;
|
||||
print(sprintf("^2CBaseMonster::CheckRoute^7: %s overriding anim for %f seconds (modelindex %d, frame %d)\n", this.netname, duration, modelindex, m_flSequenceEnd));
|
||||
print(sprintf("^2CBaseMonster::CheckRoute^7: %s overriding anim for %f seconds (modelindex %d, frame %d)\n", this.m_strTargetName, duration, modelindex, m_flSequenceEnd));
|
||||
} else {
|
||||
/* we still need to trigger targets */
|
||||
think = FreeState;
|
||||
nextthink = time;
|
||||
print(sprintf("^2CBaseMonster::CheckRoute^7: %s has no anim, finished sequence.\n", this.m_strTargetName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -303,10 +309,12 @@ void CBaseMonster::Physics(void)
|
|||
}
|
||||
|
||||
/* support for think/nextthink */
|
||||
if (think && nextthink > 0) {
|
||||
if (think && nextthink > 0.0) {
|
||||
if (nextthink < time) {
|
||||
print("^2CBaseMonster::Physics: Trigger think()\n");
|
||||
think();
|
||||
nextthink = 0.0f;
|
||||
think = __NULL__;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -517,10 +517,12 @@ CBaseNPC::Physics(void)
|
|||
}
|
||||
|
||||
/* support for think/nextthink */
|
||||
if (think && nextthink > 0) {
|
||||
if (think && nextthink > 0.0) {
|
||||
if (nextthink < time) {
|
||||
print("^2CBaseNPC::Physics: Trigger think()\n");
|
||||
think();
|
||||
nextthink = 0.0f;
|
||||
think = __NULL__;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,11 +98,17 @@ class scripted_sequence:CBaseTrigger
|
|||
void scripted_sequence::Trigger(void)
|
||||
{
|
||||
CBaseMonster f;
|
||||
float duration;
|
||||
|
||||
if (!m_iEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* aaaaand it's gone */
|
||||
if (!(spawnflags & SSFL_REPEATABLE)) {
|
||||
m_iEnabled = FALSE;
|
||||
}
|
||||
|
||||
print(sprintf("^2scripted_sequence::Trigger^7: with spawnflags %d\n", spawnflags));
|
||||
f = (CBaseMonster)find(world, CBaseEntity::m_strTargetName, m_strMonster);
|
||||
|
||||
|
@ -117,17 +123,22 @@ void scripted_sequence::Trigger(void)
|
|||
}
|
||||
}
|
||||
|
||||
/* cancel out. this trigger is broken. */
|
||||
if (!f) {
|
||||
print(sprintf("^1scripted_sequence::Trigger^7: Unknown target %s\n", m_strMonster));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
print(sprintf("\tName: %s\n", m_strTargetName));
|
||||
print(sprintf("\tTarget: %s\n", m_strMonster));
|
||||
print(sprintf("\tStarted: %f\n", time));
|
||||
|
||||
/* if we're told an anim, we better have it... or else. */
|
||||
if (m_strActionAnim) {
|
||||
f.m_flSequenceEnd = frameforname(f.modelindex, m_strActionAnim);
|
||||
if (f.m_flSequenceEnd == -1) {
|
||||
print(sprintf("^1scripted_sequence::Trigger^7: Framegroup %s not found!\n", m_strActionAnim));
|
||||
print(sprintf("^1ERROR: Framegroup %s not found!\n", m_strActionAnim));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -141,30 +152,48 @@ void scripted_sequence::Trigger(void)
|
|||
/* seems to be active at all times? contrary to SS_TURNTOFACE existing? */
|
||||
f.m_vecSequenceAngle = angles;
|
||||
|
||||
if (m_iMove == SS_WALK) {
|
||||
if (m_iMove == SS_NO) {
|
||||
print("\tType: SS_NO\n");
|
||||
} else if (m_iMove == SS_WALK) {
|
||||
f.NewRoute(origin);
|
||||
f.m_flSequenceSpeed = 64;
|
||||
print("\tType: SS_WALK\n");
|
||||
return;
|
||||
} else if (m_iMove == SS_RUN) {
|
||||
f.NewRoute(origin);
|
||||
f.m_flSequenceSpeed = 256;
|
||||
} else if (m_iMove == SS_NO) {
|
||||
f.m_iSequenceState = SEQUENCESTATE_ENDING;
|
||||
f.think = CBaseMonster::FreeState;
|
||||
f.nextthink = time + frameduration(f.modelindex, f.m_flSequenceEnd);
|
||||
f.m_flSequenceSpeed = 200;
|
||||
print("\tType: SS_RUN\n");
|
||||
return;
|
||||
} else if (m_iMove == SS_INSTANTANEOUS) {
|
||||
setorigin(f, this.origin);
|
||||
f.m_iSequenceState = SEQUENCESTATE_ENDING;
|
||||
f.think = CBaseMonster::FreeState;
|
||||
f.nextthink = time + frameduration(f.modelindex, f.m_flSequenceEnd);
|
||||
print("\tType: SS_INSTANTANEOUS\n");
|
||||
} else if (m_iMove == SS_TURNTOFACE) {
|
||||
f.m_iSequenceState = SEQUENCESTATE_ENDING;
|
||||
f.think = CBaseMonster::FreeState;
|
||||
f.nextthink = time + frameduration(f.modelindex, f.m_flSequenceEnd);
|
||||
print("\tType: SS_TURNTOFACE\n");
|
||||
}
|
||||
|
||||
if (!(spawnflags & SSFL_REPEATABLE)) {
|
||||
m_iEnabled = FALSE;
|
||||
/* all the non-moving targets will do this at least */
|
||||
if (m_strActionAnim) {
|
||||
duration = frameduration(f.modelindex, f.m_flSequenceEnd);
|
||||
f.nextthink = time + duration;
|
||||
print(sprintf(
|
||||
"\tAnimation: %s Duration: %f seconds (modelindex %d, frame %d)\n",
|
||||
f.m_strTargetName,
|
||||
duration,
|
||||
f.modelindex,
|
||||
f.m_flSequenceEnd
|
||||
));
|
||||
} else {
|
||||
f.nextthink = time;
|
||||
print(sprintf(
|
||||
"\t^1WARNING: %s skipping animation on script type %i\n",
|
||||
f.m_strTargetName,
|
||||
m_iMove
|
||||
));
|
||||
}
|
||||
|
||||
f.m_iSequenceState = SEQUENCESTATE_ENDING;
|
||||
f.think = CBaseMonster::FreeState;
|
||||
print(sprintf("\tEnding: %f\n", f.nextthink));
|
||||
}
|
||||
|
||||
void scripted_sequence::Respawn(void)
|
||||
|
|
Loading…
Reference in a new issue