From 63cab45adfb5ea0baee972bb267b3a431074774f Mon Sep 17 00:00:00 2001 From: WinterSolstice8 <60417494+wintersolstice8@users.noreply.github.com> Date: Tue, 3 Feb 2026 18:20:35 -0700 Subject: [PATCH] [core] Teleport pets on player cutscene teleport --- src/map/packets/c2s/0x05c_eventendxzy.cpp | 36 +++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/map/packets/c2s/0x05c_eventendxzy.cpp b/src/map/packets/c2s/0x05c_eventendxzy.cpp index de1fb333ff7..1a2ec33e00f 100644 --- a/src/map/packets/c2s/0x05c_eventendxzy.cpp +++ b/src/map/packets/c2s/0x05c_eventendxzy.cpp @@ -21,8 +21,11 @@ #include "0x05c_eventendxzy.h" +#include "ai/ai_container.h" +#include "enmity_container.h" #include "entities/charentity.h" #include "lua/luautils.h" +#include "notoriety_container.h" #include "packets/s2c/0x052_eventucoff.h" #include "packets/s2c/0x05b_wpos.h" #include "packets/s2c/0x065_wpos2.h" @@ -50,9 +53,11 @@ void GP_CLI_COMMAND_EVENTENDXZY::process(MapSession* PSession, CCharEntity* PCha PChar->SetLocalVar("noPosUpdate", 0); + position_t newPos = PChar->loc.p; + if (updatePosition) { - position_t newPos = { + newPos = { x, y, z, @@ -65,7 +70,34 @@ void GP_CLI_COMMAND_EVENTENDXZY::process(MapSession* PSession, CCharEntity* PCha } else { - PChar->pushPacket(PChar, PChar->loc.p, POSMODE::CLEAR); + PChar->pushPacket(PChar, newPos, POSMODE::CLEAR); + } + + auto* PPet = PChar->PPet; + + if (PPet && !PPet->isDead()) + { + PPet->loc.p = newPos; + + PPet->PAI->Disengage(); + + // clear all enmity towards a charmed mob when it is teleported + // use two loops to avoid modifying the container while iterating over it + std::list mobsToPacify; + + // first collect the mobs with hate towards the formerly charmed mob + for (auto* entityWithEnmity : *PPet->PNotorietyContainer) + { + if (auto* mobToPacify = dynamic_cast(entityWithEnmity)) + { + mobsToPacify.emplace_back(mobToPacify); + } + } + // then remove the formerly charmed mob from those mobs enmity containers + for (const auto* mobToPacify : mobsToPacify) + { + mobToPacify->PEnmityContainer->Clear(PPet->id); + } } PChar->pushPacket(PChar, GP_SERV_COMMAND_EVENTUCOFF_MODE::EventRecvPending);