From 2c91d1db6ec1f2b00281f840ec2ef3b2cc92dc68 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Fri, 11 May 2018 00:14:24 -0500 Subject: [PATCH] Make sure NPC's don't open keyed or lockpick enabled doors - also make sure we are opening doors and not platforms above or below --- zone/mob_ai.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 1685e933e..2efb80cc7 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1058,16 +1058,29 @@ void Mob::AI_Process() { auto &door_list = entity_list.GetDoorsList(); for (auto itr : door_list) { - Doors* door = itr.second; + Doors *door = itr.second; - if (door->IsDoorOpen()) { + if (door->GetKeyItem()) continue; - } - float distance = DistanceSquared(this->m_Position, door->GetPosition()); + if (door->GetLockpick()) + continue; + + if (door->IsDoorOpen()) + continue; + + float distance = DistanceSquared(this->m_Position, door->GetPosition()); float distance_scan_door_open = 20; if (distance <= (distance_scan_door_open * distance_scan_door_open)) { + + /** + * Make sure we're opening a door within height relevance and not platforms + * above or below + */ + if (std::abs(this->m_Position.z - door->GetPosition().z) > 10) + continue; + door->ForceOpen(this); } }