From 424fcf07929c6af3fabed2b374aa90e473333032 Mon Sep 17 00:00:00 2001 From: "ALLEN-PC\\acj30" Date: Fri, 24 Nov 2023 10:29:02 -0600 Subject: [PATCH] Add extra trace to npc_create for NPCs which should use bbox instead of hull (e.g. npc_rollermine) --- sp/src/game/server/ai_concommands.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sp/src/game/server/ai_concommands.cpp b/sp/src/game/server/ai_concommands.cpp index e004dca1..6c4370d9 100644 --- a/sp/src/game/server/ai_concommands.cpp +++ b/sp/src/game/server/ai_concommands.cpp @@ -477,6 +477,20 @@ public: AI_TraceHull( baseNPC->GetAbsOrigin(), vUpBit, baseNPC->GetHullMins(), baseNPC->GetHullMaxs(), MASK_NPCSOLID, baseNPC, COLLISION_GROUP_NONE, &tr ); + + // NEW: For vphysics/flying entities, do a second attempt which teleports based on bounding box + if ( (baseNPC->GetMoveType() == MOVETYPE_VPHYSICS || baseNPC->CapabilitiesGet() & bits_CAP_MOVE_FLY) && (tr.startsolid || tr.fraction < 1.0) ) + { + vUpBit.z += baseNPC->BoundingRadius(); + baseNPC->Teleport( &vUpBit, NULL, NULL ); + UTIL_DropToFloor( baseNPC, MASK_NPCSOLID ); + + Vector vUpBit2 = vUpBit; + vUpBit2.z += 1; + AI_TraceHull( vUpBit, vUpBit2, baseNPC->CollisionProp()->OBBMins(), baseNPC->CollisionProp()->OBBMaxs(), + MASK_NPCSOLID, baseNPC, COLLISION_GROUP_NONE, &tr ); + } + if ( tr.startsolid || (tr.fraction < 1.0) ) { baseNPC->SUB_Remove();