NSMonster: Add GetWalk/Run/ChaseSpeed methods to override movement speeds

of each monster class that's based upon it.
This commit is contained in:
Marco Cawthorne 2022-01-25 20:07:25 -08:00
parent f0a8fa0889
commit 92bb821ad9
Signed by: eukara
GPG Key ID: C196CD8BA993248A
4 changed files with 36 additions and 17 deletions

View File

@ -206,12 +206,12 @@ scripted_sequence::RunOnEntity(entity targ)
dprint("\tType: SS_NO\n");
} else if (m_iMove == SS_WALK) {
f.NewRoute(origin);
f.m_flSequenceSpeed = 64;
f.m_flSequenceSpeed = f.GetWalkSpeed();
dprint("\tType: SS_WALK\n");
return;
} else if (m_iMove == SS_RUN) {
f.NewRoute(origin);
f.m_flSequenceSpeed = 200;
f.m_flSequenceSpeed = f.GetRunSpeed();
dprint("\tType: SS_RUN\n");
return;
} else if (m_iMove == SS_INSTANTANEOUS) {

View File

@ -183,8 +183,6 @@ class NSMonster:NSSurfacePropEntity
vector base_maxs;
float base_health;
float m_flChaseSpeed;
/* sequences */
string m_strRouteEnded;
int m_iSequenceRemove;
@ -203,7 +201,6 @@ class NSMonster:NSSurfacePropEntity
/* attack/alliance system */
entity m_eEnemy;
float m_flFOV;
float m_flAttackThink;
int m_iMState;
vector m_vecLKPos; /* last-known pos */
@ -238,6 +235,11 @@ class NSMonster:NSSurfacePropEntity
virtual void(void) SeeThink;
virtual float(void) SeeFOV;
/* movement */
virtual float(void) GetWalkSpeed;
virtual float(void) GetChaseSpeed;
virtual float(void) GetRunSpeed;
/* attack system */
virtual void(void) AttackDraw;
virtual void(void) AttackHolster;

View File

@ -183,6 +183,27 @@ NSMonster::SeeThink(void)
}
}
}
float
NSMonster::GetWalkSpeed(void)
{
return 64;
}
float
NSMonster::GetChaseSpeed(void)
{
return 240;
}
float
NSMonster::GetRunSpeed(void)
{
return 140;
}
void
NSMonster::AttackThink(void)
{
@ -415,7 +436,7 @@ NSMonster::WalkRoute(void)
} else if (m_iMState == MONSTER_CHASING) {
/* we've got 'em in our sights, just need to walk closer */
endangles = vectoangles(m_eEnemy.origin - origin);
input_movevalues = [m_flChaseSpeed, 0, 0];
input_movevalues = [GetChaseSpeed(), 0, 0];
m_vecTurnAngle[1] = endangles[1];
} else
return;
@ -518,12 +539,13 @@ NSMonster::Physics(void)
input_movevalues = [0,0,0];
} else {
float spvel = vlen(velocity);
float midspeed = GetWalkSpeed() + ((GetRunSpeed() - GetWalkSpeed()) * 0.5f);
if (spvel < 5) {
SetFrame(AnimIdle());
} else if (spvel <= 140) {
} else if (spvel < midspeed) {
SetFrame(AnimWalk());
} else /*if (spvel <= 240)*/ {
} else {
SetFrame(AnimRun());
}
}
@ -925,12 +947,6 @@ NSMonster::NSMonster(void)
#endif
super::NSSurfacePropEntity();
#ifdef SERVER
/* give us a 65 degree view cone */
m_flFOV = 1.0 / 65;
m_flChaseSpeed = 140;
#endif
}
#ifdef CLIENT

View File

@ -378,7 +378,7 @@ NSTalkMonster::FollowPlayer(void)
if (vlen(m_eFollowingChain.origin - origin) > 1024) {
m_eFollowing = world;
} else if (vlen(m_eFollowingChain.origin - origin) > 64) {
input_movevalues[0] = m_flChaseSpeed;
input_movevalues[0] = GetChaseSpeed();
other = world;
traceline(origin, m_eFollowingChain.origin, MOVE_OTHERONLY, this);
@ -497,12 +497,13 @@ NSTalkMonster::Physics(void)
input_movevalues = [0,0,0];
} else {
spvel = vlen(velocity);
float midspeed = GetWalkSpeed() + ((GetRunSpeed() - GetWalkSpeed()) * 0.5f);
if (spvel < 5) {
SetFrame(AnimIdle());
} else if (spvel <= 140) {
} else if (spvel < midspeed) {
SetFrame(AnimWalk());
} else if (spvel <= 240) {
} else {
SetFrame(AnimRun());
}
}