NSMonster: Add FramegroupForAct() and ActPlay() methods, deprecate Anim* methods.

This commit is contained in:
Marco Cawthorne 2023-06-02 19:25:49 -07:00
parent 3e8cf479c9
commit 40dc1267fa
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
2 changed files with 26 additions and 26 deletions

View File

@ -331,16 +331,16 @@ public:
nonvirtual bool InSequence(void);
/* animation cycles */
/** Overridable: Called when we need to play a fresh idle framegroup. */
/** DEPRECATED, Overridable: Called when we need to play a fresh idle framegroup. */
virtual int AnimIdle(void);
/** Overridable: Called when we need to play a fresh walking framegroup. */
/** DEPRECATED, Overridable: Called when we need to play a fresh walking framegroup. */
virtual int AnimWalk(void);
/** Overridable: Called when we need to play a fresh running framegroup. */
/** DEPRECATED, Overridable: Called when we need to play a fresh running framegroup. */
virtual int AnimRun(void);
/** Overridable: Called when we need to play a left turning animation. */
virtual int AnimTurnLeft(void);
/** Overridable: Called when we need to play a right turning animation. */
virtual int AnimTurnRight(void);
/** Overridable: Returns which framegroup to play for a given ACT. */
virtual float FramegroupForAct(float);
/** Call to play an ACT on the given NSMonster. */
nonvirtual void ActPlay(float);
/** Call to play a single animation onto it, which cannot be interrupted by movement. */
virtual void AnimPlay(float);
/** Internal use only. Run every frame to update animation parameters. */
@ -424,6 +424,7 @@ private:
bool m_bTurning;
nonvirtual void _LerpTurnToEnemy(void);
nonvirtual void _LerpTurnToPos(vector);
nonvirtual void _LerpTurnToYaw(vector);
virtual void _Alerted(void);
#endif

View File

@ -188,32 +188,33 @@ NSMonster::Restore(string strKey, string strValue)
int
NSMonster::AnimIdle(void)
{
return frameforaction(modelindex, ACT_IDLE);
return FramegroupForAct(ACT_IDLE);
}
int
NSMonster::AnimWalk(void)
{
return frameforaction(modelindex, ACT_WALK);
return FramegroupForAct(ACT_WALK);
}
int
NSMonster::AnimRun(void)
{
float runAnim = frameforaction(modelindex, ACT_RUN);
float runAnim = FramegroupForAct(ACT_RUN);
return (runAnim == -1) ? AnimWalk() : runAnim;
}
int
NSMonster::AnimTurnLeft(void)
float
NSMonster::FramegroupForAct(float actName)
{
return frameforaction(modelindex, ACT_TURN_LEFT);
float frameGroup = frameforaction(modelindex, actName);
return frameGroup;
}
int
NSMonster::AnimTurnRight(void)
void
NSMonster::ActPlay(float actName)
{
return frameforaction(modelindex, ACT_TURN_RIGHT);
AnimPlay(FramegroupForAct(actName));
}
void
@ -438,21 +439,21 @@ var float autocvar_ai_stepSize = 128;
float
NSMonster::GetWalkSpeed(void)
{
float speed = autocvar_ai_stepSize / frameduration(modelindex, AnimWalk());
float speed = autocvar_ai_stepSize / frameduration(modelindex, FramegroupForAct(ACT_WALK));
return speed;
}
float
NSMonster::GetChaseSpeed(void)
{
float speed = autocvar_ai_stepSize / frameduration(modelindex, AnimRun());
float speed = autocvar_ai_stepSize / frameduration(modelindex, FramegroupForAct(ACT_RUN));
return speed;
}
float
NSMonster::GetRunSpeed(void)
{
float speed = autocvar_ai_stepSize / frameduration(modelindex, AnimRun());
float speed = autocvar_ai_stepSize / frameduration(modelindex, FramegroupForAct(ACT_RUN));
return speed;
}
@ -478,9 +479,9 @@ NSMonster::_LerpTurnToYaw(vector turnYaw)
if (m_bTurning == false)
if (yawDiff < 0) {
SetFrame(AnimTurnRight());
SetFrame(FramegroupForAct(ACT_TURN_RIGHT));
} else {
SetFrame(AnimTurnLeft());
SetFrame(FramegroupForAct(ACT_TURN_LEFT));
}
m_bTurning = true;
@ -518,15 +519,15 @@ NSMonster::_LerpTurnToPos(vector turnPos)
void
NSMonster::_LerpTurnToEnemy(void)
{
if (!m_eEnemy)
return;
/* only continue if we're in one of the three states. */
if (GetState() != MONSTER_AIMING)
if (GetState() != MONSTER_CHASING)
if (GetState() != MONSTER_FOLLOWING)
return;
if (!m_eEnemy)
return;
_LerpTurnToPos(m_eEnemy.origin);
}
@ -688,8 +689,6 @@ NSMonster::RouteEnded(void)
void
NSMonster::WalkRoute(void)
{
vector wishAngles;
/* we're busy shooting at something, don't walk */
if (GetState() == MONSTER_AIMING && m_eEnemy) {
input_angles = vectoangles(m_eEnemy.origin - origin);