scripted_sequence: Added support for the IDLE key. This means the setup for most sequence look and behave correct now.

This commit is contained in:
Marco Cawthorne 2020-08-02 13:09:37 +02:00
parent b9f4da2494
commit e8bafa044d
4 changed files with 44 additions and 5 deletions

View file

@ -149,8 +149,6 @@ Sentences_Init(void)
}
}
string
Sentences_ProcessSample(string sample)
{
@ -172,7 +170,6 @@ Sentences_ResetSample(void)
g_sentences_samplepath = "vox";
}
string
Sentences_GetSamples(string msg)
{

View file

@ -67,7 +67,7 @@ env_sun::postdraw(void)
vector lens_1 = project(lens_pos) - (FLARE_SIZE / 2);
makevectors(getproperty(VF_ANGLES));
vector v = normalize (lens_pos - getproperty(VF_ORIGIN));
vector v = normalize(lens_pos - getproperty(VF_ORIGIN));
float flDot = v * v_forward;
if (flDot < 0.15) {

View file

@ -35,6 +35,7 @@ enum
enum
{
SEQUENCESTATE_NONE,
SEQUENCESTATE_IDLE,
SEQUENCESTATE_ACTIVE,
SEQUENCESTATE_ENDING
};
@ -458,7 +459,10 @@ CBaseMonster::Physics(void)
input_timelength = frametime;
/* override whatever we did above with this */
if (m_iSequenceState == SEQUENCESTATE_ENDING) {
if (m_iSequenceState == SEQUENCESTATE_IDLE) {
input_angles = angles = v_angle = m_vecSequenceAngle;
SetFrame(m_flSequenceEnd);
} else if (m_iSequenceState == SEQUENCESTATE_ENDING) {
input_angles = angles = v_angle = m_vecSequenceAngle;
SetFrame(m_flSequenceEnd);
} else if (movetype == MOVETYPE_WALK) {

View file

@ -93,6 +93,7 @@ class scripted_sequence:CBaseTrigger
void(void) scripted_sequence;
virtual void(void) Trigger;
virtual void(void) InitIdle;
virtual void(void) Respawn;
};
@ -201,10 +202,47 @@ scripted_sequence::Trigger(void)
dprint(sprintf("\tEnding: %f\n", f.nextthink));
}
void
scripted_sequence::InitIdle(void)
{
CBaseMonster f;
dprint(sprintf("^2scripted_sequence::^3InitIdle^7: with spawnflags %d\n", spawnflags));
f = (CBaseMonster)find(world, CBaseEntity::m_strTargetName, m_strMonster);
/* target doesn't exist/hasn't spawned */
if (!f) {
/* time to look for a classname instead */
for (entity c = world; (c = find(c, ::classname, m_strMonster));) {
/* within radius */
if (vlen(origin - c.origin) < m_flSearchRadius) {
f = (CBaseMonster)c;
break;
}
}
/* cancel out. this trigger is broken. */
if (!f) {
dprint(sprintf("^1scripted_sequence::^3InitIdle^7: Unknown target %s\n", m_strMonster));
return;
}
}
setorigin(f, origin);
f.m_flSequenceEnd = frameforname(f.modelindex, m_strIdleAnim);
f.m_iSequenceState = SEQUENCESTATE_ENDING;
f.m_vecSequenceAngle = angles;
}
void
scripted_sequence::Respawn(void)
{
m_iEnabled = TRUE;
if (m_strIdleAnim) {
think = InitIdle;
nextthink = time + 0.1f;
}
}
void