CBaseMonster: Add FALLING flag, and FallNoise() method so monsters/npcs can

specify what to do/play when they start falling.
This commit is contained in:
Marco Cawthorne 2021-09-17 00:41:58 +02:00
parent 56e07c3f06
commit 211a28692b
Signed by: eukara
GPG key ID: C196CD8BA993248A
4 changed files with 24 additions and 6 deletions

View file

@ -36,7 +36,8 @@ typedef enumflags
MSF_WAITFORSCRIPT,
MSF_PREDISASTER,
MSF_FADECORPSE,
MSF_MULTIPLAYER
MSF_MULTIPLAYER,
MSF_FALLING
} monsterFlag_t;
/* movement states */
@ -139,6 +140,7 @@ class CBaseMonster:CBaseEntity
virtual void(void) Death;
virtual void(void) Physics;
virtual void(void) IdleNoise;
virtual void(void) FallNoise;
virtual void(void) Gib;
virtual void(string) Sound;
virtual void(string, string) SpawnKey;

View file

@ -56,10 +56,14 @@ CBaseMonster::Gib(void)
Hide();
}
void
CBaseMonster::FallNoise(void)
{
}
void
CBaseMonster::IdleNoise(void)
{
}
int
@ -462,6 +466,15 @@ CBaseMonster::Physics(void)
}
}
if (velocity[2] < -100) {
if (!(m_iFlags & MSF_FALLING))
FallNoise();
m_iFlags |= MSF_FALLING;
} else {
m_iFlags &= ~MSF_FALLING;
}
/* support for think/nextthink */
if (think && nextthink > 0.0f) {
if (nextthink < time) {

View file

@ -24,7 +24,6 @@ enumflags
MONSTER_USED,
MONSTER_FEAR,
MONSTER_METPLAYER,
MONSTER_FALLING,
MONSTER_CANFOLLOW
};

View file

@ -416,10 +416,14 @@ CBaseNPC::Physics(void)
SetOrigin(origin);
}
if (!(flags & FL_ONGROUND) && velocity[2] < -100) {
m_iFlags |= MONSTER_FALLING;
if (velocity[2] < -100) {
if (!(m_iFlags & MSF_FALLING)) {
FallNoise();
}
m_iFlags |= MSF_FALLING;
} else {
m_iFlags &= ~MONSTER_FALLING;
m_iFlags &= ~MSF_FALLING;
}
/* support for think/nextthink */