feat: add trade API (AcceptTrade, CancelTrade, InitiateTrade)

AcceptTrade() locks in the trade offer via CMSG_ACCEPT_TRADE.
CancelTrade() cancels an open trade via CMSG_CANCEL_TRADE.
InitiateTrade(unit) starts a trade with a target player.

Uses existing GameHandler trade functions and TradeStatus tracking.
Enables trade addons and macro-based trade acceptance.
This commit is contained in:
Kelsi 2026-03-22 23:28:25 -07:00
parent adc1b40290
commit 397185d33c

View file

@ -5062,6 +5062,26 @@ void LuaEngine::registerCoreAPI() {
lua_pushboolean(L, 1); // isCastable
return 4;
}},
// --- Trade API ---
{"AcceptTrade", [](lua_State* L) -> int {
auto* gh = getGameHandler(L);
if (gh) gh->acceptTrade();
return 0;
}},
{"CancelTrade", [](lua_State* L) -> int {
auto* gh = getGameHandler(L);
if (gh && gh->isTradeOpen()) gh->cancelTrade();
return 0;
}},
{"InitiateTrade", [](lua_State* L) -> int {
auto* gh = getGameHandler(L);
const char* uid = luaL_checkstring(L, 1);
if (gh) {
uint64_t guid = resolveUnitGuid(gh, std::string(uid));
if (guid != 0) gh->initiateTrade(guid);
}
return 0;
}},
// --- Auction House API ---
{"GetNumAuctionItems", [](lua_State* L) -> int {
auto* gh = getGameHandler(L);