From 4f699aae6e647bb5888129835ca214e2b111bb67 Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Wed, 20 Sep 2023 22:42:11 -0700 Subject: [PATCH] Monster spawning position and scripted sequence fixes. Also leave movetype of LEAVECORPSE scripted sequence entities alone or else it breaks of1a1's G-Man --- src/gs-entbase/server/scripted_sequence.qc | 2 +- src/shared/NSEntity.qc | 2 -- src/shared/NSMonster.qc | 13 +++++++++---- src/shared/NSPhysicsEntity.qc | 1 - src/shared/NSPortal.qc | 2 +- src/shared/NSProjectile.qc | 1 - src/shared/NSRenderableEntity.qc | 2 -- src/shared/NSSurfacePropEntity.qc | 2 -- src/shared/NSTalkMonster.qc | 3 +-- 9 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/gs-entbase/server/scripted_sequence.qc b/src/gs-entbase/server/scripted_sequence.qc index b0614ba8..d8ef0d3e 100644 --- a/src/gs-entbase/server/scripted_sequence.qc +++ b/src/gs-entbase/server/scripted_sequence.qc @@ -273,7 +273,7 @@ scripted_sequence::RunOnEntity(entity targ) NSLog("\tType: SS_RUN (%i)", m_iMove); return; } else if (m_iMove == SS_INSTANTANEOUS) { - setorigin(f, this.origin); + f.SetOrigin(GetOrigin()); f.DropToFloor(); NSLog("\tType: SS_INSTANTANEOUS (%i)", m_iMove); } else if (m_iMove == SS_TURNTOFACE) { diff --git a/src/shared/NSEntity.qc b/src/shared/NSEntity.qc index 9ece12b5..7e245285 100644 --- a/src/shared/NSEntity.qc +++ b/src/shared/NSEntity.qc @@ -182,8 +182,6 @@ void NSEntity::ReceiveEntity( float flNew, float flChanged ) { if ( flChanged & BASEFL_CHANGED_SIZE ) setsize( this, mins, maxs ); - - setorigin( this, origin ); } void NSEntity::postdraw( void ) { diff --git a/src/shared/NSMonster.qc b/src/shared/NSMonster.qc index 3c2ebb35..97c92dcc 100644 --- a/src/shared/NSMonster.qc +++ b/src/shared/NSMonster.qc @@ -1188,7 +1188,6 @@ NSMonster::FreeStateDead(void) DropToFloor(); RemoveFlags(FL_MONSTER); - SetMovetype(MOVETYPE_NONE); SetSolid(SOLID_CORPSE); SetState(MONSTER_DEAD); FreeState(); @@ -1678,6 +1677,14 @@ NSMonster::Hide(void) void NSMonster::Respawn(void) { + /* we need to delay the DropToFloor() by at least a frame. + otherwise they may just fall through an entity (func_wall, func_train etc.) + that came after this entity in the lump. */ + static void AdjustSpawnPos(void) { + SetOrigin(GetSpawnOrigin()); + DropToFloor(); + } + v_angle = GetSpawnAngles(); v_angle[0] = Math_FixDelta(v_angle[0]); v_angle[1] = Math_FixDelta(v_angle[1]); @@ -1698,11 +1705,9 @@ NSMonster::Respawn(void) SetMovetype(MOVETYPE_WALK); SetModel(GetSpawnModel()); SetSize(base_mins, base_maxs); - //SetOrigin(); - setorigin_safe(this, GetSpawnOrigin()); SetEyePos([0, 0, m_flEyeHeight]); + ScheduleThink(AdjustSpawnPos, 0.0f); - DropToFloor(); if (m_bWeaponStartsDrawn) { m_bWeaponDrawn = true; diff --git a/src/shared/NSPhysicsEntity.qc b/src/shared/NSPhysicsEntity.qc index 15816895..a40d4abf 100644 --- a/src/shared/NSPhysicsEntity.qc +++ b/src/shared/NSPhysicsEntity.qc @@ -297,7 +297,6 @@ NSPhysicsEntity::ReceiveEntity(float flNew, float flChanged) if (flChanged & RDENT_CHANGED_BODY) _UpdateGeomset(); - setorigin(this, origin); movetype = MOVETYPE_NONE; } #endif diff --git a/src/shared/NSPortal.qc b/src/shared/NSPortal.qc index 87b1aa8e..c7ee4c62 100644 --- a/src/shared/NSPortal.qc +++ b/src/shared/NSPortal.qc @@ -440,7 +440,7 @@ NSPortal::ReceiveEntity(float flNew, float flChanged) m_vecTargetS = v_right; m_vecTargetT = v_up; } - setorigin(this, origin); + _PortalUpdated(); drawmask = MASK_ENGINE; predraw = 0; diff --git a/src/shared/NSProjectile.qc b/src/shared/NSProjectile.qc index 0dfc4c92..bf0e910b 100644 --- a/src/shared/NSProjectile.qc +++ b/src/shared/NSProjectile.qc @@ -836,7 +836,6 @@ NSProjectile::ReceiveEntity(float flNew, float flChanged) READENTITY_COLOR(m_vecRenderColor[2], PROJ_CHANGED_RENDERCOLOR) READENTITY_COLOR(m_flRenderAmt, PROJ_CHANGED_RENDERAMT) setmodelindex(this, modelindex); - setorigin(this, origin); } #endif diff --git a/src/shared/NSRenderableEntity.qc b/src/shared/NSRenderableEntity.qc index 385b4315..e867ccc8 100644 --- a/src/shared/NSRenderableEntity.qc +++ b/src/shared/NSRenderableEntity.qc @@ -298,8 +298,6 @@ NSRenderableEntity::ReceiveEntity(float flNew, float flChanged) setsize(this, mins * scale, maxs * scale); if (flChanged & RDENT_CHANGED_BODY) _UpdateGeomset(); - - setorigin(this, origin); } /* diff --git a/src/shared/NSSurfacePropEntity.qc b/src/shared/NSSurfacePropEntity.qc index 5dadb479..71d9b04a 100644 --- a/src/shared/NSSurfacePropEntity.qc +++ b/src/shared/NSSurfacePropEntity.qc @@ -384,8 +384,6 @@ NSSurfacePropEntity::ReceiveEntity(float flNew, float flChanged) setsize(this, mins * scale, maxs * scale); if (flChanged & SRFENT_CHANGED_BODY) setcustomskin(this, "", sprintf("geomset 0 %i\ngeomset 1 %i\n", m_iBody, m_iBody)); - - setorigin(this, origin); } #endif diff --git a/src/shared/NSTalkMonster.qc b/src/shared/NSTalkMonster.qc index 2152a828..267d7596 100644 --- a/src/shared/NSTalkMonster.qc +++ b/src/shared/NSTalkMonster.qc @@ -643,6 +643,7 @@ void NSTalkMonster::Respawn(void) { super::Respawn(); + m_eFollowing = world; m_eFollowingChain = world; PlayerUse = OnPlayerUse; @@ -1026,8 +1027,6 @@ NSTalkMonster::ReceiveEntity(float flNew, float flChanged) setsize(this, mins * scale, maxs * scale); if (flChanged & MONFL_CHANGED_BODY) _UpdateGeomset(); - - setorigin(this, origin); } void