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.
This commit is contained in:
Kelsi 2026-03-21 08:17:38 -07:00
parent 2c6a345e32
commit e7be60c624

View file

@ -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<uint8_t>((val >> 24) & 0xFF));