From 545f047cae5720bb989ce5237cb2da05bd9c37c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zieli=C5=84ski?= Date: Tue, 18 Jul 2023 09:53:14 +0200 Subject: [PATCH] Fix HoTA guard once again (cherry picked from commit 138a7c8024573f46962ad0f6e8e03ba53fa56076) --- lib/rmg/RmgObject.cpp | 10 ++++++++++ lib/rmg/modificators/ObjectManager.cpp | 2 -- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/rmg/RmgObject.cpp b/lib/rmg/RmgObject.cpp index 540463948..0106bee4f 100644 --- a/lib/rmg/RmgObject.cpp +++ b/lib/rmg/RmgObject.cpp @@ -344,6 +344,16 @@ void Object::Instance::finalize(RmgMap & map) setTemplate(terrainType->getId()); } } + if (dObject.ID == Obj::MONSTER) + { + //Make up for extra offset in HotA creature templates + auto visitableOffset = dObject.getVisitableOffset(); + auto fixedPos = getPosition(true) + visitableOffset; + vstd::abetween(fixedPos.x, visitableOffset.x, map.width() - 1); + vstd::abetween(fixedPos.y, visitableOffset.y, map.height() - 1); + int3 parentPos = getPosition(true) - getPosition(false); + setPosition(fixedPos - parentPos); + } if (dObject.isVisitable() && !map.isOnMap(dObject.visitablePos())) throw rmgException(boost::to_string(boost::format("Visitable tile %s of object %d at %s is outside the map") % dObject.visitablePos().toString() % dObject.id % dObject.pos.toString())); diff --git a/lib/rmg/modificators/ObjectManager.cpp b/lib/rmg/modificators/ObjectManager.cpp index 72315f76e..2e75c38a1 100644 --- a/lib/rmg/modificators/ObjectManager.cpp +++ b/lib/rmg/modificators/ObjectManager.cpp @@ -606,8 +606,6 @@ bool ObjectManager::addGuard(rmg::Object & object, si32 strength, bool zoneGuard auto & instance = object.addInstance(*guard); instance.setPosition(guardPos - object.getPosition()); instance.setAnyTemplate(); //terrain is irrelevant for monsters, but monsters need some template now - //Make up for extra offset in HotA creature templates - instance.setPosition(instance.getPosition() + instance.object().getVisitableOffset()); return true; }