From e7be60c624984f27a9d04018d8b7e67a66d5ca98 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 21 Mar 2026 08:17:38 -0700 Subject: [PATCH] feat: fire UNIT_FACTION event when unit faction template changes Fire UNIT_FACTION for player/target/focus when UNIT_FIELD_FACTIONTEMPLATE updates. Covers PvP flag toggling, mind control faction swaps, and any server-side faction changes. Used by nameplate addons to update hostility coloring and by PvP addons tracking faction state. --- src/game/game_handler.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 14b79d94..5c2582a2 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -11904,7 +11904,17 @@ void GameHandler::applyUpdateObjectBlock(const UpdateBlock& block, bool& newItem } else if (key == ufMaxHealth) { unit->setMaxHealth(val); } else if (key == ufLevel) { unit->setLevel(val); - } else if (key == ufFaction) { unit->setFactionTemplate(val); } + } else if (key == ufFaction) { + unit->setFactionTemplate(val); + if (addonEventCallback_) { + std::string uid; + if (block.guid == playerGuid) uid = "player"; + else if (block.guid == targetGuid) uid = "target"; + else if (block.guid == focusGuid) uid = "focus"; + if (!uid.empty()) + addonEventCallback_("UNIT_FACTION", {uid}); + } + } else if (key == ufFlags) { unit->setUnitFlags(val); } else if (key == ufBytes0) { unit->setPowerType(static_cast((val >> 24) & 0xFF));