feat: fire UNIT_HEALTH/UNIT_POWER events from dedicated update packets

SMSG_HEALTH_UPDATE and SMSG_POWER_UPDATE are high-frequency WotLK
packets that update entity health/power values but weren't firing
addon events. Unit frame addons (Pitbull, oUF, SUF) depend on these
events to update health/mana bars in real-time.

Now fire UNIT_HEALTH for player/target/focus on SMSG_HEALTH_UPDATE
and UNIT_POWER on SMSG_POWER_UPDATE, matching the events already
fired from the UPDATE_OBJECT path.
This commit is contained in:
Kelsi 2026-03-21 02:26:44 -07:00
parent 55ef607093
commit d75f2c62e5

View file

@ -2160,6 +2160,14 @@ void GameHandler::handlePacket(network::Packet& packet) {
if (auto* unit = dynamic_cast<Unit*>(entity.get())) {
unit->setHealth(hp);
}
if (addonEventCallback_ && guid != 0) {
std::string unitId;
if (guid == playerGuid) unitId = "player";
else if (guid == targetGuid) unitId = "target";
else if (guid == focusGuid) unitId = "focus";
if (!unitId.empty())
addonEventCallback_("UNIT_HEALTH", {unitId});
}
break;
}
case Opcode::SMSG_POWER_UPDATE: {
@ -2177,6 +2185,14 @@ void GameHandler::handlePacket(network::Packet& packet) {
if (auto* unit = dynamic_cast<Unit*>(entity.get())) {
unit->setPowerByType(powerType, value);
}
if (addonEventCallback_ && guid != 0) {
std::string unitId;
if (guid == playerGuid) unitId = "player";
else if (guid == targetGuid) unitId = "target";
else if (guid == focusGuid) unitId = "focus";
if (!unitId.empty())
addonEventCallback_("UNIT_POWER", {unitId});
}
break;
}