feat: fire PLAYER_ENTER_COMBAT and PLAYER_LEAVE_COMBAT events

Fire PLAYER_ENTER_COMBAT when the player's auto-attack starts
(SMSG_ATTACKSTART) and PLAYER_LEAVE_COMBAT when auto-attack stops.
These events are distinct from PLAYER_REGEN_DISABLED/ENABLED — they
specifically track physical melee combat state and are used by
combat-aware addons for weapon swing timers and attack state tracking.
This commit is contained in:
Kelsi 2026-03-21 02:31:59 -07:00
parent 60904e2e15
commit 760c6a2790

View file

@ -16043,6 +16043,8 @@ void GameHandler::stopAutoAttack() {
socket->send(packet);
}
LOG_INFO("Stopping auto-attack");
if (addonEventCallback_)
addonEventCallback_("PLAYER_LEAVE_COMBAT", {});
}
void GameHandler::addCombatText(CombatTextEntry::Type type, int32_t amount, uint32_t spellId, bool isPlayerSource, uint8_t powerType,
@ -16164,6 +16166,8 @@ void GameHandler::handleAttackStart(network::Packet& packet) {
autoAttacking = true;
autoAttackRetryPending_ = false;
autoAttackTarget = data.victimGuid;
if (addonEventCallback_)
addonEventCallback_("PLAYER_ENTER_COMBAT", {});
} else if (data.victimGuid == playerGuid && data.attackerGuid != 0) {
hostileAttackers_.insert(data.attackerGuid);
autoTargetAttacker(data.attackerGuid);