scripted_sequence & NSMonster: support for spawnflags LEAVECORPSE. Also safely position monsters upon spawning to avoid them getting stuck in the floor.

This commit is contained in:
Marco Cawthorne 2023-09-20 20:54:13 -07:00
parent f5308f6e08
commit 5f7ea594b8
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
3 changed files with 24 additions and 5 deletions

View File

@ -302,7 +302,9 @@ scripted_sequence::RunOnEntity(entity targ)
f.m_iSequenceState = SEQUENCESTATE_ENDING; f.m_iSequenceState = SEQUENCESTATE_ENDING;
if (HasSpawnFlags(SSFL_NOSCRIPTMOVE)) if (HasSpawnFlags(SSFL_LEAVECORPSE))
f.SetThink(NSMonster::FreeStateDead);
else if (HasSpawnFlags(SSFL_NOSCRIPTMOVE))
f.SetThink(NSMonster::FreeState); f.SetThink(NSMonster::FreeState);
else else
f.SetThink(NSMonster::FreeStateMoved); f.SetThink(NSMonster::FreeStateMoved);
@ -312,7 +314,6 @@ scripted_sequence::RunOnEntity(entity targ)
/* make sure we're forgetting about enemies and attack states in sequence */ /* make sure we're forgetting about enemies and attack states in sequence */
f.m_eEnemy = __NULL__; f.m_eEnemy = __NULL__;
f.m_iMState = MONSTER_IDLE; f.m_iMState = MONSTER_IDLE;
} }
void void

View File

@ -386,6 +386,8 @@ public:
virtual void FreeState(void); virtual void FreeState(void);
/** Internal use only. Called when a sequence is done. */ /** Internal use only. Called when a sequence is done. */
virtual void FreeStateMoved(void); virtual void FreeStateMoved(void);
/** Internal use only. Called when a sequence is done and we leave a corpse. */
virtual void FreeStateDead(void);
/** Internal use only. Called when a movement route is done. */ /** Internal use only. Called when a movement route is done. */
virtual void RouteEnded(void); virtual void RouteEnded(void);
/** Internal use only. Called every frame to progress through a route. */ /** Internal use only. Called every frame to progress through a route. */

View File

@ -1177,6 +1177,23 @@ NSMonster::FreeStateMoved(void)
FreeState(); FreeState();
} }
void
NSMonster::FreeStateDead(void)
{
vector new_origin;
new_origin = gettaginfo(this, 1);
NSMonster_Log("^2%s::^3FreeStateMoved^7: moved to %v", classname, new_origin);
SetOrigin(new_origin);
DropToFloor();
RemoveFlags(FL_MONSTER);
SetMovetype(MOVETYPE_NONE);
SetSolid(SOLID_CORPSE);
SetState(MONSTER_DEAD);
FreeState();
}
void void
NSMonster::RouteEnded(void) NSMonster::RouteEnded(void)
{ {
@ -1681,7 +1698,8 @@ NSMonster::Respawn(void)
SetMovetype(MOVETYPE_WALK); SetMovetype(MOVETYPE_WALK);
SetModel(GetSpawnModel()); SetModel(GetSpawnModel());
SetSize(base_mins, base_maxs); SetSize(base_mins, base_maxs);
SetOrigin(GetSpawnOrigin()); //SetOrigin();
setorigin_safe(this, GetSpawnOrigin());
SetEyePos([0, 0, m_flEyeHeight]); SetEyePos([0, 0, m_flEyeHeight]);
DropToFloor(); DropToFloor();
@ -2060,8 +2078,6 @@ NSMonster::ReceiveEntity(float flNew, float flChanged)
setsize(this, mins * scale, maxs * scale); setsize(this, mins * scale, maxs * scale);
if (flChanged & MONFL_CHANGED_BODY) if (flChanged & MONFL_CHANGED_BODY)
_UpdateGeomset(); _UpdateGeomset();
setorigin(this, origin);
} }
void void