From c7e25beaf1479224fde396a78c0e98e59f952869 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 20 Mar 2026 11:56:59 -0700 Subject: [PATCH] feat: fire PLAYER_MONEY, PLAYER_DEAD, PLAYER_ALIVE addon events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fire more gameplay events to Lua addons: - PLAYER_MONEY — when gold/silver/copper changes (both CREATE and VALUES paths) - PLAYER_DEAD — on forced death (SMSG_FORCED_DEATH_UPDATE) - PLAYER_ALIVE — when ghost flag clears (player resurrected) Total addon events: 19 (2 world + 12 chat + 5 gameplay). --- src/game/game_handler.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 7710d80f..4180ca76 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -2633,6 +2633,7 @@ void GameHandler::handlePacket(network::Packet& packet) { // Server forces player into dead state (GM command, scripted event, etc.) playerDead_ = true; if (ghostStateCallback_) ghostStateCallback_(false); // dead but not ghost yet + if (addonEventCallback_) addonEventCallback_("PLAYER_DEAD", {}); addSystemChatMessage("You have been killed."); LOG_INFO("SMSG_FORCED_DEATH_UPDATE: player force-killed"); packet.setReadPos(packet.getSize()); @@ -12000,8 +12001,11 @@ void GameHandler::applyUpdateObjectBlock(const UpdateBlock& block, bool& newItem } } else if (key == ufCoinage) { + uint64_t oldMoney = playerMoneyCopper_; playerMoneyCopper_ = val; LOG_DEBUG("Money set from update fields: ", val, " copper"); + if (val != oldMoney && addonEventCallback_) + addonEventCallback_("PLAYER_MONEY", {}); } else if (ufHonor != 0xFFFF && key == ufHonor) { playerHonorPoints_ = val; @@ -12450,8 +12454,11 @@ void GameHandler::applyUpdateObjectBlock(const UpdateBlock& block, bool& newItem } } else if (key == ufCoinage) { + uint64_t oldM = playerMoneyCopper_; playerMoneyCopper_ = val; LOG_DEBUG("Money updated via VALUES: ", val, " copper"); + if (val != oldM && addonEventCallback_) + addonEventCallback_("PLAYER_MONEY", {}); } else if (ufHonorV != 0xFFFF && key == ufHonorV) { playerHonorPoints_ = val; @@ -12522,6 +12529,7 @@ void GameHandler::applyUpdateObjectBlock(const UpdateBlock& block, bool& newItem corpseGuid_ = 0; corpseReclaimAvailableMs_ = 0; LOG_INFO("Player resurrected (PLAYER_FLAGS ghost cleared)"); + if (addonEventCallback_) addonEventCallback_("PLAYER_ALIVE", {}); if (ghostStateCallback_) ghostStateCallback_(false); } }