From 9e5fe87d1037fbfd20c07b8c5360d6a048f8cfe3 Mon Sep 17 00:00:00 2001 From: WinterSolstice8 <60417494+wintersolstice8@users.noreply.github.com> Date: Sat, 31 Jan 2026 19:34:14 -0700 Subject: [PATCH] [core] Add accessor to get set blue spells on PC --- src/map/lua/lua_baseentity.cpp | 31 +++++++++++++++++++++++++++++++ src/map/lua/lua_baseentity.h | 1 + 2 files changed, 32 insertions(+) diff --git a/src/map/lua/lua_baseentity.cpp b/src/map/lua/lua_baseentity.cpp index 245fe4702a0..1ee9ea378ad 100644 --- a/src/map/lua/lua_baseentity.cpp +++ b/src/map/lua/lua_baseentity.cpp @@ -11006,6 +11006,36 @@ void CLuaBaseEntity::delSpell(uint16 spellID, const sol::optional& p } } +/************************************************************************ + * Function: getSetBlueSpells() + * Purpose : Retrieves a players set BLU spell list (in the form of IDs) + * Example : local spells = player:getSetBlueSpells() + * Notes : + ************************************************************************/ + +auto CLuaBaseEntity::getSetBlueSpells() -> sol::table +{ + auto spellList = lua.create_table(); + + if (m_PBaseEntity->objtype != TYPE_PC) + { + ShowWarning("Invalid entity type calling getSetBlueSpells (%s).", m_PBaseEntity->getName()); + return spellList; + } + + auto* PChar = static_cast(m_PBaseEntity); + + for (auto spellId : PChar->m_SetBlueSpells) + { + if (spellId != 0) + { + spellList.add(spellId + 0x200); // 0x200 magic offset also in blueutils + } + } + + return spellList; +} + /************************************************************************ * Function: recalculateSkillsTable() * Purpose : Recalculates skill tables to get new values and calculations @@ -19956,6 +19986,7 @@ void CLuaBaseEntity::Register() SOL_REGISTER("hasSpell", CLuaBaseEntity::hasSpell); SOL_REGISTER("canLearnSpell", CLuaBaseEntity::canLearnSpell); SOL_REGISTER("delSpell", CLuaBaseEntity::delSpell); + SOL_REGISTER("getSetBlueSpells", CLuaBaseEntity::getSetBlueSpells); SOL_REGISTER("recalculateSkillsTable", CLuaBaseEntity::recalculateSkillsTable); SOL_REGISTER("recalculateAbilitiesTable", CLuaBaseEntity::recalculateAbilitiesTable); diff --git a/src/map/lua/lua_baseentity.h b/src/map/lua/lua_baseentity.h index 73bd4a47662..60ce5eb3eeb 100644 --- a/src/map/lua/lua_baseentity.h +++ b/src/map/lua/lua_baseentity.h @@ -553,6 +553,7 @@ class CLuaBaseEntity bool hasSpell(uint16 spellID); uint32 canLearnSpell(uint16 spellID); void delSpell(uint16 spellID, const sol::optional& paramTable); + auto getSetBlueSpells() -> sol::table; void recalculateSkillsTable(); void recalculateAbilitiesTable();