From a53e1360a4e5cc422fa2df6efa4e9d7445816a44 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Thu, 5 Feb 2026 16:12:04 -0600 Subject: [PATCH] feat(ui): implement Script_UnitXP --- src/ui/game/ScriptEvents.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ui/game/ScriptEvents.cpp b/src/ui/game/ScriptEvents.cpp index f58cce5..7139e84 100644 --- a/src/ui/game/ScriptEvents.cpp +++ b/src/ui/game/ScriptEvents.cpp @@ -173,7 +173,23 @@ int32_t Script_UnitPVPName(lua_State* L) { } int32_t Script_UnitXP(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + if (!lua_isstring(L, 1)) { + luaL_error(L, "Usage: UnitXP(\"unit\")"); + return 0; + } + + auto name = lua_tostring(L, 1); + auto unit = Script_GetUnitFromName(name); + + float xp = 0.0f; + + if (unit && unit->IsA(TYPE_PLAYER)) { + xp = static_cast(unit)->GetActiveXP(); + } + + lua_pushnumber(L, xp); + + return 1; } int32_t Script_UnitXPMax(lua_State* L) {