NSMonster: add InSequence() method. Fix scripted sequences.
PMove: use self.mins instead of PHY_HULL_MINS when testing friction. disable friction for monsters for now, as it can break some scripted sequences.
This commit is contained in:
parent
d7418151f0
commit
dc1cbc5da8
5 changed files with 42 additions and 14 deletions
|
@ -263,6 +263,7 @@ class NSMonster:NSNavAI
|
|||
virtual void(void) RouteEnded;
|
||||
virtual void(void) WalkRoute;
|
||||
virtual int(void) GetSequenceState;
|
||||
virtual bool(void) InSequence;
|
||||
|
||||
/* animation cycles */
|
||||
float m_flAnimTime;
|
||||
|
|
|
@ -561,6 +561,12 @@ NSMonster::GetSequenceState(void)
|
|||
return m_iSequenceState;
|
||||
}
|
||||
|
||||
bool
|
||||
NSMonster::InSequence(void)
|
||||
{
|
||||
return (GetSequenceState() == SEQUENCESTATE_NONE) ? false : true;
|
||||
}
|
||||
|
||||
void
|
||||
NSMonster::RunAI(void)
|
||||
{
|
||||
|
@ -587,25 +593,26 @@ NSMonster::Physics(void)
|
|||
|
||||
/* we're ending a scripted sequence, so play its animation */
|
||||
if (GetSequenceState() == SEQUENCESTATE_ENDING) {
|
||||
input_angles[1] = m_vecSequenceAngle[1];
|
||||
angles[1] = input_angles[1] = m_vecSequenceAngle[1];
|
||||
SetFrame(m_flSequenceEnd);
|
||||
} else {
|
||||
/* if still alive... */
|
||||
if (GetState() != MONSTER_DEAD) {
|
||||
/* not in a sequence */
|
||||
if (GetSequenceState() == SEQUENCESTATE_NONE) {
|
||||
if (IsAlive()) {
|
||||
/* only run AI functions when not in a scripted sequence */
|
||||
if (InSequence() == false) {
|
||||
RunAI();
|
||||
}
|
||||
|
||||
AnimationUpdate();
|
||||
}
|
||||
|
||||
if (InAnimation() == false) {
|
||||
/* suppress movement when playing an animation outside
|
||||
a scripted sequence */
|
||||
if (InAnimation() == true && InSequence() == false) {
|
||||
input_movevalues = [0,0,0];
|
||||
} else {
|
||||
CheckRoute();
|
||||
WalkRoute();
|
||||
} else {
|
||||
input_movevalues = [0,0,0];
|
||||
|
||||
}
|
||||
|
||||
hitcontentsmaski = CONTENTBITS_MONSTER;
|
||||
|
|
|
@ -42,6 +42,9 @@ class NSTalkMonster:NSMonster
|
|||
vector m_vecLastUserPos;
|
||||
float m_flChangePath;
|
||||
float m_flTraceTime;
|
||||
float m_flFollowSpeedChanged;
|
||||
float m_flFollowSpeed;
|
||||
|
||||
|
||||
/* sentences identifiers */
|
||||
string m_talkAnswer; /* random answer to whenever a question is asked */
|
||||
|
|
|
@ -387,11 +387,22 @@ NSTalkMonster::FollowPlayer(void)
|
|||
if (flPlayerDist > 1024) {
|
||||
m_eFollowing = world;
|
||||
} else if (flPlayerDist > 64) {
|
||||
/* we only allow speed changes every second, avoid jitter */
|
||||
if (m_flFollowSpeedChanged < time) {
|
||||
float flNextSpeed = GetChaseSpeed();
|
||||
|
||||
/* if we're close enough, we ought to walk */
|
||||
if (flPlayerDist > 256)
|
||||
input_movevalues[0] = GetChaseSpeed();
|
||||
else
|
||||
input_movevalues[0] = GetWalkSpeed();
|
||||
if (flPlayerDist < 256)
|
||||
flNextSpeed = GetWalkSpeed();
|
||||
|
||||
/* only update the timer when speed changed */
|
||||
if (flNextSpeed != m_flFollowSpeed) {
|
||||
m_flFollowSpeed = flNextSpeed;
|
||||
m_flFollowSpeedChanged = time + 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
input_movevalues[0] = m_flFollowSpeed;
|
||||
|
||||
other = world;
|
||||
traceline(origin, m_eFollowingChain.origin, MOVE_OTHERONLY, this);
|
||||
|
|
|
@ -227,6 +227,12 @@ PMoveCustom_AccelFriction(float move_time, float premove, vector wish_dir, float
|
|||
float flFriction;
|
||||
vector vecTemp;
|
||||
|
||||
/* friction does not apply to monsters right now */
|
||||
if (self.flags & FL_MONSTER) {
|
||||
self.velocity = wish_dir * wish_speed;
|
||||
return;
|
||||
}
|
||||
|
||||
flApplyFriction = serverkeyfloat("phy_friction");
|
||||
|
||||
/* per frame basis friction modifier */
|
||||
|
@ -246,7 +252,7 @@ PMoveCustom_AccelFriction(float move_time, float premove, vector wish_dir, float
|
|||
on the other hand edge friction is probably not that important. */
|
||||
|
||||
// if the leading edge is over a dropoff, increase friction
|
||||
vecTemp = self.origin + normalize(vecTemp) * 16 + [0,0,1] * PHY_HULL_MIN[2];
|
||||
vecTemp = self.origin + normalize(vecTemp) * 16 + [0,0,1] * self.mins[2];
|
||||
traceline(vecTemp, vecTemp + [0,0,-34], TRUE, self);
|
||||
|
||||
// apply friction
|
||||
|
|
Loading…
Reference in a new issue