From cdccb53a9f492a06ad5db461a05e9c3fb6fce375 Mon Sep 17 00:00:00 2001 From: meatspace Date: Sat, 8 Aug 2026 15:01:50 -0500 Subject: [PATCH] Allow NPCs to open func_door entities --- sp/src/game/server/ai_basenpc.cpp | 10 ++++++++++ sp/src/game/server/ai_navigator.h | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/sp/src/game/server/ai_basenpc.cpp b/sp/src/game/server/ai_basenpc.cpp index f087f8a40e0..0c24167a49f 100644 --- a/sp/src/game/server/ai_basenpc.cpp +++ b/sp/src/game/server/ai_basenpc.cpp @@ -13947,6 +13947,16 @@ bool CAI_BaseNPC::OnObstructingDoor( AILocalMoveGoal_t *pMoveGoal, { if ( distClear < 0.1 ) { +#ifdef MAPBASE + if ((CapabilitiesGet() & bits_CAP_AUTO_DOORS) && !pDoor->m_bLocked && !pDoor->HasSpawnFlags(SF_DOOR_NONPCS)) + { + // Tell the door to open + m_flMoveWaitFinished = OpenDoorAndWait(pDoor); + *pResult = AIMR_OK; + GetNavigator()->NoteOpeningDoor(); + } + else +#endif // MAPBASE *pResult = AIMR_BLOCKED_ENTITY; } else diff --git a/sp/src/game/server/ai_navigator.h b/sp/src/game/server/ai_navigator.h index a2100943c62..491b0b0d485 100644 --- a/sp/src/game/server/ai_navigator.h +++ b/sp/src/game/server/ai_navigator.h @@ -494,7 +494,12 @@ class CAI_Navigator : public CAI_Component, // -------------------------------- virtual AIMoveResult_t MoveEnact( const AILocalMoveGoal_t &baseMove ); - + +#ifdef MAPBASE +public: + void NoteOpeningDoor() { OnNewGoal(); } +#endif // MAPBASE + protected: // made this virtual so strider can implement hover behavior with a navigator virtual void MoveCalcBaseGoal( AILocalMoveGoal_t *pMoveGoal);