From 8ebf1f4cda4686d9c624b0c3b1942f3bd3e91b01 Mon Sep 17 00:00:00 2001 From: iThorgrim <125808072+iThorgrim@users.noreply.github.com> Date: Sat, 1 Feb 2025 22:08:16 +0100 Subject: [PATCH 01/13] feat(LuaEngine/PlayerMethods): add GetHomebind, GetSpells and TeleportTo (#232) Co-authored-by: 55Honey <71938210+55Honey@users.noreply.github.com> --- src/LuaEngine/LuaFunctions.cpp | 3 ++ src/LuaEngine/methods/PlayerMethods.h | 76 ++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index 70d79b6244..592a9f6cb9 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -567,6 +567,8 @@ ElunaRegister PlayerMethods[] = { "SetPlayerLock", &LuaPlayer::SetPlayerLock }, { "SetGender", &LuaPlayer::SetGender }, { "SetSheath", &LuaPlayer::SetSheath }, + { "GetHomebind", &LuaPlayer::GetHomebind }, + { "GetSpells", &LuaPlayer::GetSpells }, // Boolean { "HasTankSpec", &LuaPlayer::HasTankSpec }, @@ -737,6 +739,7 @@ ElunaRegister PlayerMethods[] = { "SendCinematicStart", &LuaPlayer::SendCinematicStart }, { "SendMovieStart", &LuaPlayer::SendMovieStart }, { "UpdatePlayerSetting", &LuaPlayer::UpdatePlayerSetting }, + { "TeleportTo", &LuaPlayer::TeleportTo }, { NULL, NULL } }; diff --git a/src/LuaEngine/methods/PlayerMethods.h b/src/LuaEngine/methods/PlayerMethods.h index b0d3c298ae..5bf717f3ce 100644 --- a/src/LuaEngine/methods/PlayerMethods.h +++ b/src/LuaEngine/methods/PlayerMethods.h @@ -3913,5 +3913,79 @@ namespace LuaPlayer player->RemovePet(player->GetPet(), (PetSaveMode)mode, returnreagent); return 0; }*/ + + /** + * Returns the [Player] spells list + * + * @return table playerSpells + */ + int GetSpells(lua_State* L, Player* player) + { + std::list list; + lua_createtable(L, list.size(), 0); + int tbl = lua_gettop(L); + uint32 i = 0; + + PlayerSpellMap spellMap = player->GetSpellMap(); + for (PlayerSpellMap::const_iterator itr = spellMap.begin(); itr != spellMap.end(); ++itr) + { + SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first); + Eluna::Push(L, spellInfo->Id); + lua_rawseti(L, tbl, ++i); + } + + lua_settop(L, tbl); + return 1; + } + + /** + * Returns the [Player] homebind location. + * + * @return table homebind : a table containing the player's homebind information: + * - uint32 mapId: The ID of the map where the player is bound. + * - float x: The X coordinate of the homebind location. + * - float y: The Y coordinate of the homebind location. + * - float z: The Z coordinate of the homebind location. + */ + int GetHomebind(lua_State* L, Player* player) + { + lua_newtable(L); + lua_pushinteger(L, player->m_homebindMapId); + lua_setfield(L, -2, "mapId"); + + lua_pushnumber(L, player->m_homebindX); + lua_setfield(L, -2, "x"); + + lua_pushnumber(L, player->m_homebindY); + lua_setfield(L, -2, "y"); + + lua_pushnumber(L, player->m_homebindZ); + lua_setfield(L, -2, "z"); + + return 1; + } + + /** + * Teleports [Player] to a predefined location based on the teleport name. + * + * @param string tele : The name of the predefined teleport location. + */ + int TeleportTo(lua_State* L, Player* player) + { + std::string tele = Eluna::CHECKVAL(L, 2); + const GameTele* game_tele = sObjectMgr->GetGameTele(tele); + + MapEntry const* map = sMapStore.LookupEntry(game_tele->mapId); + + if (player->IsInFlight()) + { + player->GetMotionMaster()->MovementExpired(); + player->m_taxi.ClearTaxiDestinations(); + } + + player->TeleportTo(game_tele->mapId, game_tele->position_x, game_tele->position_y, game_tele->position_z, game_tele->orientation); + return 0; + } }; -#endif \ No newline at end of file +#endif + From 0fda6f8d2557ba91d490bb0c556060db2e6571d9 Mon Sep 17 00:00:00 2001 From: iThorgrim <125808072+iThorgrim@users.noreply.github.com> Date: Sat, 1 Feb 2025 22:09:44 +0100 Subject: [PATCH 02/13] feat(LuaEngine/UnitMethods): add GetThreat, ClearThreat, ResetAllThreat methods (#234) --- src/LuaEngine/LuaFunctions.cpp | 3 +++ src/LuaEngine/methods/UnitMethods.h | 36 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index 592a9f6cb9..aa617ed846 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -321,6 +321,7 @@ ElunaRegister UnitMethods[] = // {"GetVehicle", &LuaUnit::GetVehicle}, // :GetVehicle() - UNDOCUMENTED - Gets the Vehicle kit of the vehicle the unit is on { "GetMovementType", &LuaUnit::GetMovementType }, { "GetAttackers", &LuaUnit::GetAttackers }, + { "GetThreat", &LuaUnit::GetThreat }, // Setters { "SetFaction", &LuaUnit::SetFaction }, @@ -454,6 +455,8 @@ ElunaRegister UnitMethods[] = { "DealHeal", &LuaUnit::DealHeal }, { "AddThreat", &LuaUnit::AddThreat }, { "ModifyThreatPct", &LuaUnit::ModifyThreatPct }, + { "ClearThreat", &LuaUnit::ClearThreat }, + { "ResetAllThreat", &LuaUnit::ResetAllThreat }, { NULL, NULL } }; diff --git a/src/LuaEngine/methods/UnitMethods.h b/src/LuaEngine/methods/UnitMethods.h index 529dc51b11..51fa341ab6 100644 --- a/src/LuaEngine/methods/UnitMethods.h +++ b/src/LuaEngine/methods/UnitMethods.h @@ -2714,5 +2714,41 @@ namespace LuaUnit Eluna::Push(L, summon); return 1; }*/ + + /** + * Clear the threat of a [Unit] in the threat list. + * + * @param [Unit] target + */ + int ClearThreat(lua_State* L, Unit* unit) + { + Unit* target = Eluna::CHECKOBJ(L, 2); + + unit->GetThreatMgr().ClearThreat(target); + return 0; + } + + /** + * Resets the [Unit]'s threat list, setting all threat targets' threat to 0. + */ + int ResetAllThreat(lua_State* /*L*/, Unit* unit) + { + unit->GetThreatMgr().ResetAllThreat(); + return 0; + } + + /** + * Returns the threat of a [Unit]. + * + * @param [Unit] target + * @return float threat + */ + int GetThreat(lua_State* L, Unit* unit) + { + Unit* target = Eluna::CHECKOBJ(L, 2); + + Eluna::Push(L, unit->GetThreatMgr().GetThreat(target)); + return 1; + } }; #endif From dee3a1ad8e19821b41742f17fe7464fdf6d3fc0a Mon Sep 17 00:00:00 2001 From: 55Honey <71938210+55Honey@users.noreply.github.com> Date: Sat, 1 Feb 2025 22:49:10 +0100 Subject: [PATCH 03/13] fix: comment unused parameter (#250) --- src/LuaEngine/methods/GuildMethods.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LuaEngine/methods/GuildMethods.h b/src/LuaEngine/methods/GuildMethods.h index b86f1ab2be..4172ea2dd8 100644 --- a/src/LuaEngine/methods/GuildMethods.h +++ b/src/LuaEngine/methods/GuildMethods.h @@ -382,7 +382,7 @@ namespace LuaGuild /** * Resets the number of item withdraw in all tab's for all [Guild] members. */ - int ResetTimes(lua_State* L, Guild* guild) + int ResetTimes(lua_State* /*L*/, Guild* guild) { guild->ResetTimes(); return 0; From a261c1c596be524a327e06671edb2a5099261845 Mon Sep 17 00:00:00 2001 From: Peter Malina Date: Sun, 2 Feb 2025 09:55:43 +0000 Subject: [PATCH 04/13] fix(LuaEngine/CreatureMethods): reputation rewards refactored by AC (#251) --- src/LuaEngine/methods/CreatureMethods.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LuaEngine/methods/CreatureMethods.h b/src/LuaEngine/methods/CreatureMethods.h index 5614647555..0d126fb006 100644 --- a/src/LuaEngine/methods/CreatureMethods.h +++ b/src/LuaEngine/methods/CreatureMethods.h @@ -47,7 +47,7 @@ namespace LuaCreature */ int IsReputationGainDisabled(lua_State* L, Creature* creature) { - Eluna::Push(L, creature->IsReputationGainDisabled()); + Eluna::Push(L, creature->IsReputationRewardDisabled()); return 1; } @@ -984,7 +984,7 @@ namespace LuaCreature { bool disable = Eluna::CHECKVAL(L, 2, true); - creature->SetDisableReputationGain(disable); + creature->SetReputationRewardDisabled(disable); return 0; } From f3e62467d256cc6ef48471dc603a967d354d1002 Mon Sep 17 00:00:00 2001 From: iThorgrim <125808072+iThorgrim@users.noreply.github.com> Date: Wed, 5 Feb 2025 14:28:45 +0100 Subject: [PATCH 05/13] chore:LuaEngine/GuildMethods): Fix doc generation (#246) Co-authored-by: 55Honey <71938210+55Honey@users.noreply.github.com> --- src/LuaEngine/methods/GuildMethods.h | 50 ++++++++++++++-------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/LuaEngine/methods/GuildMethods.h b/src/LuaEngine/methods/GuildMethods.h index 4172ea2dd8..bd6f8fd01b 100644 --- a/src/LuaEngine/methods/GuildMethods.h +++ b/src/LuaEngine/methods/GuildMethods.h @@ -257,8 +257,8 @@ namespace LuaGuild * GUILD_MEMBER_DATA_LEVEL = 1 * }; * - * @param [Player] player = plkayer you need to update data - * @param [GuildMemberData] dataid = data you need to update + * @param [Player] player : plkayer you need to update data + * @param [GuildMemberData] dataid : data you need to update * @param uint32 value */ int UpdateMemberData(lua_State* L, Guild* guild) @@ -274,10 +274,10 @@ namespace LuaGuild /** * Send message to [Guild] from specific [Player]. * - * @param [Player] player = the [Player] is the author of the message - * @param bool officierOnly = send message only on officier channel - * @param string msg = the message you need to send - * @param uint32 lang = language the [Player] will speak + * @param [Player] player : the [Player] is the author of the message + * @param bool officierOnly : send message only on officier channel + * @param string msg : the message you need to send + * @param uint32 lang : language the [Player] will speak */ int SendMessage(lua_State* L, Guild* guild) { @@ -293,10 +293,10 @@ namespace LuaGuild /** * Invites [Guild] members to events based on level and rank filters. * - * @param Player player = who sends the invitation - * @param minLevel = the required min level - * @param maxLevel = the required max level - * @param minRank = the required min rank + * @param Player player : who sends the invitation + * @param minLevel : the required min level + * @param maxLevel : the required max level + * @param minRank : the required min rank */ int MassInviteToEvent(lua_State* L, Guild* guild) { @@ -312,12 +312,12 @@ namespace LuaGuild /** * Swap item from a specific tab and slot [Guild] bank to another one. * - * @param [Player] player = who Swap the item - * @param uint8 tabId = source tab id - * @param uint8 slotId = source slot id - * @param uint8 destTabId = destination tab id - * @param uint8 destSlotId = destination slot id - * @param uint8 splitedAmount = if the item is stackable, how much should be swaped + * @param [Player] player : who Swap the item + * @param uint8 tabId : source tab id + * @param uint8 slotId : source slot id + * @param uint8 destTabId : destination tab id + * @param uint8 destSlotId : destination slot id + * @param uint8 splitedAmount : if the item is stackable, how much should be swaped */ int SwapItems(lua_State* L, Guild* guild) { @@ -335,13 +335,13 @@ namespace LuaGuild /** * Swap an item from a specific tab and location in the [guild] bank to the bags and locations in the inventory of a specific [player] and vice versa. * - * @param [Player] player = who Swap the item - * @param bool toChar = the item goes to the [Player]'s inventory or comes from the [Player]'s inventory - * @param uint8 tabId = tab id - * @param uint8 slotId = slot id - * @param uint8 playerBag = bag id - * @param uint8 playerSlotId = slot id - * @param uint32 splitedAmount = if the item is stackable, how much should be swaped + * @param [Player] player : who Swap the item + * @param bool toChar : the item goes to the [Player]'s inventory or comes from the [Player]'s inventory + * @param uint8 tabId : tab id + * @param uint8 slotId : slot id + * @param uint8 playerBag : bag id + * @param uint8 playerSlotId : slot id + * @param uint32 splitedAmount : if the item is stackable, how much should be swaped */ int SwapItemsWithInventory(lua_State* L, Guild* guild) { @@ -391,8 +391,8 @@ namespace LuaGuild /** * Modify the [Guild] bank money. You can deposit or withdraw. * - * @param uint64 amount = amount to add or remove - * @param bool add = true (add money) | false (withdraw money) + * @param uint64 amount : amount to add or remove + * @param bool add : true (add money) | false (withdraw money) * @return bool is_applied */ int ModifyBankMoney(lua_State* L, Guild* guild) From 4ffa5f3900e16acc92c3b334ad88b65543f99b8c Mon Sep 17 00:00:00 2001 From: Morten Date: Wed, 5 Feb 2025 14:29:24 +0100 Subject: [PATCH 06/13] chore(LuaEngine): added comments to SpellEntryMethods. (#243) Co-authored-by: 55Honey <71938210+55Honey@users.noreply.github.com> --- src/LuaEngine/methods/SpellEntryMethods.h | 361 ++++++++++++++++++++++ 1 file changed, 361 insertions(+) diff --git a/src/LuaEngine/methods/SpellEntryMethods.h b/src/LuaEngine/methods/SpellEntryMethods.h index df5b2666ba..2070549574 100644 --- a/src/LuaEngine/methods/SpellEntryMethods.h +++ b/src/LuaEngine/methods/SpellEntryMethods.h @@ -9,78 +9,143 @@ namespace LuaSpellEntry { + /** + * Returns the ID of the [SpellEntry]. + * + * @return uint32 id + */ int GetId(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->Id); return 1; } + /** + * Returns the category ID for the [SpellEntry]. + * + * @return uint32 categoryId + */ int GetCategory(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->Category); return 1; } + /** + * Returns the dispel ID for the [SpellEntry]. + * + * @return uint32 dispelId + */ int GetDispel(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->Dispel); return 1; } + /** + * Returns the mechanic ID for the [SpellEntry]. + * + * @return uint32 mechanicId + */ int GetMechanic(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->Mechanic); return 1; } + /** + * Returns the attribute bitflags for the [SpellEntry]. + * + * @return uint32 attribute : bitmask, but returned as uint32 + */ int GetAttributes(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->Attributes); return 1; } + /** + * Returns the attributeEx bitflags for the [SpellEntry]. + * + * @return uint32 attributeEx : bitmask, but returned as uint32 + */ int GetAttributesEx(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->AttributesEx); return 1; } + /** + * Returns the attributeEx2 bitflags for the [SpellEntry]. + * + * @return uint32 attributeEx2 : bitmask, but returned as uint32 + */ int GetAttributesEx2(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->AttributesEx2); return 1; } + /** + * Returns the attributeEx3 bitflags for the [SpellEntry]. + * + * @return uint32 attributeEx3 : bitmask, but returned as uint32 + */ int GetAttributesEx3(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->AttributesEx3); return 1; } + /** + * Returns the attributeEx4 bitflags for the [SpellEntry]. + * + * @return uint32 attributeEx4 : bitmask, but returned as uint32 + */ int GetAttributesEx4(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->AttributesEx4); return 1; } + /** + * Returns the attributeEx5 bitflags for the [SpellEntry]. + * + * @return uint32 attributeEx5 : bitmask, but returned as uint32 + */ int GetAttributesEx5(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->AttributesEx5); return 1; } + /** + * Returns the attributeEx6 bitflags for the [SpellEntry]. + * + * @return uint32 attributeEx6 : bitmask, but returned as uint32 + */ int GetAttributesEx6(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->AttributesEx6); return 1; } + /** + * Returns the attributeEx7 bitflags for the [SpellEntry]. + * + * @return uint32 attributeEx7 : bitmask, but returned as uint32 + */ int GetAttributesEx7(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->AttributesEx7); return 1; } + /** + * Returns the stance bitflags for the [SpellEntry]. + * + * @return uint32 stance : bitmask, but returned as uint32 + */ int GetStances(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->Stances); @@ -93,12 +158,22 @@ namespace LuaSpellEntry return 1; } + /** + * Returns the target bitmasks for the [SpellEntry]. + * + * @return uint32 target : bitmasks, but returned as uint32. + */ int GetTargets(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->Targets); return 1; } + /** + * Returns the target creature type bitmasks for the [SpellEntry]. + * + * @return uint32 targetCreatureType : bitmasks, but returned as uint32. + */ int GetTargetCreatureType(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->TargetCreatureType); @@ -171,12 +246,22 @@ namespace LuaSpellEntry return 1; } + /** + * Returns the recovery time for the [SpellEntry]. + * + * @return uint32 recoveryTime + */ int GetRecoveryTime(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->RecoveryTime); return 1; } + /** + * Returns the category recovery time for the [SpellEntry]. + * + * @return uint32 categoryRecoveryTime : in milliseconds, returned as uint32 + */ int GetCategoryRecoveryTime(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->CategoryRecoveryTime); @@ -207,90 +292,165 @@ namespace LuaSpellEntry return 1; } + /** + * Returns the proc chance of [SpellEntry]. + * + * @return uint32 procChance + */ int GetProcChance(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->ProcChance); return 1; } + /** + * Returns the proc charges of [SpellEntry]. + * + * @return uint32 procCharges + */ int GetProcCharges(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->ProcCharges); return 1; } + /** + * Returns the max level for the [SpellEntry]. + * + * @return uint32 maxLevel : the [SpellEntry] max level. + */ int GetMaxLevel(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->MaxLevel); return 1; } + /** + * Returns the base level required for the [SpellEntry]. + * + * @return uint32 baseLevel + */ int GetBaseLevel(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->BaseLevel); return 1; } + /** + * Returns the spell level for the [SpellEntry]. + * + * @return uint32 spellLevel + */ int GetSpellLevel(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->SpellLevel); return 1; } + /** + * Returns the duration index for the [SpellEntry]. + * + * @return uint32 durationIndex + */ int GetDurationIndex(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->DurationIndex); return 1; } + /** + * Returns the power type ID for the [SpellEntry]. + * + * @return uint32 powerTypeId + */ int GetPowerType(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->PowerType); return 1; } + /** + * Returns the mana cost for the [SpellEntry]. + * + * @return uint32 manaCost + */ int GetManaCost(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->ManaCost); return 1; } + /** + * Returns the mana cost per level for [SpellEntry]. + * + * @return uint32 manaCostPerLevel + */ int GetManaCostPerlevel(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->ManaCostPerlevel); return 1; } + /** + * Returns the mana per second for [SpellEntry]. + * + * @return uint32 manaPerSecond + */ int GetManaPerSecond(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->ManaPerSecond); return 1; } + /** + * Returns the mana per second per level for [SpellEntry]. + * + * @return uint32 manaPerSecondPerLevel + */ int GetManaPerSecondPerLevel(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->ManaPerSecondPerLevel); return 1; } + /** + * Returns the range index for [SpellEntry]. + * + * @return uint32 rangeIndex + */ int GetRangeIndex(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->RangeIndex); return 1; } + /** + * Returns speed for [SpellEntry]. + * + * @return uint32 speed + */ int GetSpeed(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->Speed); return 1; } + /** + * Returns the stack amount for [SpellEntry]. + * + * @return uint32 stackAmount + */ int GetStackAmount(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->StackAmount); return 1; } + /** + * Returns a table with all totem values for [SpellEntry]. + * + * @return table totem + */ int GetTotem(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -307,6 +467,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all reagent values for [SpellEntry]. + * + * @return table reagent + */ int GetReagent(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -323,6 +488,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all reagent count values for [SpellEntry]. + * + * @return table reagentCount + */ int GetReagentCount(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -339,24 +509,44 @@ namespace LuaSpellEntry return 1; } + /** + * Returns the equipped item class ID for [SpellEntry]. + * + * @return uint32 equippedItemClassId + */ int GetEquippedItemClass(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->EquippedItemClass); return 1; } + /** + * Returns the equipped item sub class masks for [SpellEntry]. + * + * @return uint32 equippedItemSubClassMasks : bitmasks, returned as uint32. + */ int GetEquippedItemSubClassMask(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->EquippedItemSubClassMask); return 1; } + /** + * Returns the equipped item inventory type masks for [SpellEntry]. + * + * @return uint32 equippedItemInventoryTypeMasks : bitmasks, returned as uint32. + */ int GetEquippedItemInventoryTypeMask(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->EquippedItemInventoryTypeMask); return 1; } + /** + * Returns a table with all spell effect IDs for [SpellEntry]. + * + * @return table effect + */ int GetEffect(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -373,6 +563,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect die sides values for [SpellEntry]. + * + * @return table effectDieSides + */ int GetEffectDieSides(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -389,6 +584,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect real points per level values for [SpellEntry]. + * + * @return table effectRealPointsPerLevel + */ int GetEffectRealPointsPerLevel(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -405,6 +605,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect base points values for [SpellEntry]. + * + * @return table effectBasePoints + */ int GetEffectBasePoints(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -421,6 +626,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect mechanic IDs for [SpellEntry]. + * + * @return table effectMechanic + */ int GetEffectMechanic(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -437,6 +647,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect implicit target a IDs for [SpellEntry]. + * + * @return table effectImplicitTargetA + */ int GetEffectImplicitTargetA(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -453,6 +668,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect implicit target b IDs for [SpellEntry]. + * + * @return table effectImplicitTargetB + */ int GetEffectImplicitTargetB(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -469,6 +689,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect radius index for [SpellEntry]. + * + * @return table effectRadiusIndex + */ int GetEffectRadiusIndex(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -485,6 +710,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect apply aura IDs for [SpellEntry]. + * + * @return table effectApplyAura + */ int GetEffectApplyAuraName(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -501,6 +731,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect amplitude values for [SpellEntry]. + * + * @return table effectAmplitude + */ int GetEffectAmplitude(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -517,6 +752,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect value multiplier for [SpellEntry]. + * + * @return table effectValueMultiplier + */ int GetEffectValueMultiplier(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -533,6 +773,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect chain target values for [SpellEntry]. + * + * @return table effectChainTarget + */ int GetEffectChainTarget(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -549,6 +794,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect item type values for [SpellEntry]. + * + * @return table effectItemType + */ int GetEffectItemType(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -565,6 +815,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect misc value A for [SpellEntry]. + * + * @return table effectMiscValueA + */ int GetEffectMiscValue(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -581,6 +836,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect misc value B for [SpellEntry]. + * + * @return table effectMiscValueB + */ int GetEffectMiscValueB(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -597,6 +857,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect trigger spell for [SpellEntry]. + * + * @return table effectTriggerSpell + */ int GetEffectTriggerSpell(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -613,6 +878,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with all effect points per combo point of [SpellEntry] + * + * @return table effectPointsPerComboPoint : returns a table containing all the effect points per combo point values of [SpellEntry] + */ int GetEffectPointsPerComboPoint(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -645,6 +915,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with both spell visuals of [SpellEntry] + * + * @return table spellVisuals : returns a table containing both spellVisuals for [SpellEntry]. + */ int GetSpellVisual(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -661,24 +936,44 @@ namespace LuaSpellEntry return 1; } + /** + * Returns the spell icon ID for the [SpellEntry]. + * + * @return uint32 spellIconId + */ int GetSpellIconID(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->SpellIconID); return 1; } + /** + * Returns the active icon ID for the [SpellEntry]. + * + * @return uint32 activeIconId + */ int GetActiveIconID(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->ActiveIconID); return 1; } + /** + * Returns the spell Priority for the [SpellEntry]. + * + * @return uint32 spellPriority + */ int GetSpellPriority(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->SpellPriority); return 1; } + /** + * Returns a table of the [SpellEntry] names of all locals. + * + * @return table spellNames + */ int GetSpellName(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -695,6 +990,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table of the [SpellEntry] ranks. + * + * @return table spellRanks + */ int GetRank(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -711,30 +1011,51 @@ namespace LuaSpellEntry return 1; } + /** + * Returns the mana cost percentage of [SpellEntry]. + * + * @return uint32 manaCostPercentage : the mana cost in percentage, returned as uint32. + */ int GetManaCostPercentage(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->ManaCostPercentage); return 1; } + /** + * Returns the global cooldown time value for [SpellEntry]. + * + * @return uint32 globalCooldownTime + */ int GetStartRecoveryCategory(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->StartRecoveryCategory); return 1; } + /** + * Returns the global cooldown category value for [SpellEntry]. + * + * @return uint32 globalCooldownCategory + */ int GetStartRecoveryTime(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->StartRecoveryTime); return 1; } + /** + * Returns the max target level value for [SpellEntry]. + * + * @return uint32 maxTargetLevel + */ int GetMaxTargetLevel(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->MaxTargetLevel); return 1; } + int GetSpellFamilyName(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->SpellFamilyName); @@ -747,24 +1068,44 @@ namespace LuaSpellEntry return 1; } + /** + * Returns the max affected targets value [SpellEntry]. + * + * @return uint32 maxAffectedTargets + */ int GetMaxAffectedTargets(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->MaxAffectedTargets); return 1; } + /** + * Returns the spell damage type ID [SpellEntry]. + * + * @return uint32 spellDamageTypeId + */ int GetDmgClass(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->DmgClass); return 1; } + /** + * Returns the prevention type ID [SpellEntry]. + * + * @return uint32 preventionTypeId + */ int GetPreventionType(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->PreventionType); return 1; } + /** + * Returns a table with all effect damage multiplier values [SpellEntry]. + * + * @return table effectDamageMultipliers + */ int GetEffectDamageMultiplier(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -781,6 +1122,11 @@ namespace LuaSpellEntry return 1; } + /** + * Returns a table with totem categories IDs [SpellEntry]. + * + * @return table totemCategory + */ int GetTotemCategory(lua_State* L, SpellEntry* entry) { lua_newtable(L); @@ -803,18 +1149,33 @@ namespace LuaSpellEntry return 1; } + /** + * Returns the school mask of [SpellEntry]. + * + * @return uint32 schoolMask : bitmask, returned as uint32. + */ int GetSchoolMask(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->SchoolMask); return 1; } + /** + * Returns the rune cost id for the [SpellEntry]. + * + * @return uint32 runeCostId + */ int GetRuneCostID(lua_State* L, SpellEntry* entry) { Eluna::Push(L, entry->RuneCostID); return 1; } + /** + * Returns a table with all effect bonus multiplier values [SpellEntry]. + * + * @return table effectBonusMultipliers + */ int GetEffectBonusMultiplier(lua_State* L, SpellEntry* entry) { lua_newtable(L); From 364c03e5cf6841958a3a5ddddae15e4c15e75eca Mon Sep 17 00:00:00 2001 From: iThorgrim <125808072+iThorgrim@users.noreply.github.com> Date: Wed, 5 Feb 2025 14:30:20 +0100 Subject: [PATCH 07/13] feat(LuaEngine/ItemTemplateMethods): add GetIcon method (#241) Co-authored-by: 55Honey <71938210+55Honey@users.noreply.github.com> --- src/LuaEngine/LuaFunctions.cpp | 1 + src/LuaEngine/methods/ItemTemplateMethods.h | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index aa617ed846..843a6c9e94 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -966,6 +966,7 @@ ElunaRegister ItemTemplateMethods[] = { "GetAllowableRace", &LuaItemTemplate::GetAllowableRace }, { "GetItemLevel", &LuaItemTemplate::GetItemLevel }, { "GetRequiredLevel", &LuaItemTemplate::GetRequiredLevel }, + { "GetIcon", &LuaItemTemplate::GetIcon }, { NULL, NULL } }; diff --git a/src/LuaEngine/methods/ItemTemplateMethods.h b/src/LuaEngine/methods/ItemTemplateMethods.h index 66980c9adf..b7ffe3dfa0 100644 --- a/src/LuaEngine/methods/ItemTemplateMethods.h +++ b/src/LuaEngine/methods/ItemTemplateMethods.h @@ -196,6 +196,22 @@ namespace LuaItemTemplate Eluna::Push(L, itemTemplate->RequiredLevel); return 1; } + + /** + * Returns the icon is used by this [ItemTemplate]. + * + * @return string itemIcon + */ + int GetIcon(lua_State* L, ItemTemplate* itemTemplate) + { + uint32 display_id = itemTemplate->DisplayInfoID; + + ItemDisplayInfoEntry const* displayInfo = sItemDisplayInfoStore.LookupEntry(display_id); + const char* icon = displayInfo->inventoryIcon; + + Eluna::Push(L, icon); + return 1; + } } #endif From 7621ace9fed510f018aea59ac46a916c15cc29cf Mon Sep 17 00:00:00 2001 From: iThorgrim <125808072+iThorgrim@users.noreply.github.com> Date: Wed, 5 Feb 2025 14:31:12 +0100 Subject: [PATCH 08/13] feat(LuaEngine/GlobalMethods): add GetGossipMenuOptionLocale, GetMapEntrance (#233) Co-authored-by: 55Honey <71938210+55Honey@users.noreply.github.com> --- src/LuaEngine/LuaFunctions.cpp | 2 + src/LuaEngine/methods/GlobalMethods.h | 79 +++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index 843a6c9e94..90201ffe4e 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -126,6 +126,8 @@ luaL_Reg GlobalMethods[] = { "PrintError", &LuaGlobalFunctions::PrintError }, { "PrintDebug", &LuaGlobalFunctions::PrintDebug }, { "GetActiveGameEvents", &LuaGlobalFunctions::GetActiveGameEvents }, + { "GetGossipMenuOptionLocale", &LuaGlobalFunctions::GetGossipMenuOptionLocale }, + { "GetMapEntrance", &LuaGlobalFunctions::GetMapEntrance }, { "GetSpellInfo", &LuaGlobalFunctions::GetSpellInfo }, // Boolean diff --git a/src/LuaEngine/methods/GlobalMethods.h b/src/LuaEngine/methods/GlobalMethods.h index b3321cc8ae..fef9e06faa 100644 --- a/src/LuaEngine/methods/GlobalMethods.h +++ b/src/LuaEngine/methods/GlobalMethods.h @@ -3231,6 +3231,85 @@ namespace LuaGlobalFunctions } /** + * Gets the localized OptionText and BoxText for a specific gossip menu option. + * If the text for the specified locale is not found, it returns the default text. + * + * @param uint32 menuId : The ID of the gossip menu. + * @param uint32 optionId : The ID of the gossip menu option. + * @param uint8 locale : The locale to retrieve the text for. 0 represents the default locale. + * + * @return string, string : The localized OptionText and BoxText for the gossip menu option, or the default text if no localization is found. + */ + int GetGossipMenuOptionLocale(lua_State* L) + { + uint32 menuId = Eluna::CHECKVAL(L, 1); + uint32 optionId = Eluna::CHECKVAL(L, 2); + uint8 locale = Eluna::CHECKVAL(L, 3); + + std::string strOptionText; + std::string strBoxText; + + if (locale != DEFAULT_LOCALE) + { + if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, optionId))) + { + ObjectMgr::GetLocaleString(gossipMenuLocale->OptionText, LocaleConstant(locale), strOptionText); + ObjectMgr::GetLocaleString(gossipMenuLocale->BoxText, LocaleConstant(locale), strBoxText); + } + } + + if (strOptionText.empty() || strBoxText.empty()) + { + GossipMenuItemsMapBounds bounds = sObjectMgr->GetGossipMenuItemsMapBounds(menuId); + for (auto itr = bounds.first; itr != bounds.second; ++itr) + { + if (itr->second.OptionID == optionId) + { + if (strOptionText.empty()) + strOptionText = itr->second.OptionText; + if (strBoxText.empty()) + strBoxText = itr->second.BoxText; + break; + } + } + } + + Eluna::Push(L, strOptionText); + Eluna::Push(L, strBoxText); + return 2; + } + + /** + * Return the entrance position (x, y, z, o) of the specified dungeon map id + * + * @param uint32 mapId + * + * return uint32 pos_x + * return uint32 pos_y + * return uint32 pos_z + * return uint32 pos_o + * + */ + int GetMapEntrance(lua_State* L) + { + uint32 mapId = Eluna::CHECKVAL(L, 1); + AreaTriggerTeleport const* at = sObjectMgr->GetMapEntranceTrigger(mapId); + + if (!at) + { + lua_pushnil(L); + return 1; + } + + Eluna::Push(L, at->target_X); + Eluna::Push(L, at->target_Y); + Eluna::Push(L, at->target_Z); + Eluna::Push(L, at->target_Orientation); + + return 5; + } + + /** * Get the [SpellInfo] for the specified [Spell] id * * @param uint32 spellId : the ID of the spell From b799efd331f9203f08b49edfa76af3dbed9f3f2d Mon Sep 17 00:00:00 2001 From: iThorgrim <125808072+iThorgrim@users.noreply.github.com> Date: Wed, 5 Feb 2025 18:11:00 +0100 Subject: [PATCH 09/13] chore(doxygen): fix documentation generation (#253) --- src/LuaEngine/methods/GuildMethods.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/LuaEngine/methods/GuildMethods.h b/src/LuaEngine/methods/GuildMethods.h index bd6f8fd01b..87ab13a84c 100644 --- a/src/LuaEngine/methods/GuildMethods.h +++ b/src/LuaEngine/methods/GuildMethods.h @@ -294,9 +294,9 @@ namespace LuaGuild * Invites [Guild] members to events based on level and rank filters. * * @param Player player : who sends the invitation - * @param minLevel : the required min level - * @param maxLevel : the required max level - * @param minRank : the required min rank + * @param uint32 minLevel : the required min level + * @param uint32 maxLevel : the required max level + * @param uint32 minRank : the required min rank */ int MassInviteToEvent(lua_State* L, Guild* guild) { From d869057fe4a809baab3fd204cda641d9a74b4737 Mon Sep 17 00:00:00 2001 From: iThorgrim <125808072+iThorgrim@users.noreply.github.com> Date: Wed, 5 Feb 2025 18:14:24 +0100 Subject: [PATCH 10/13] feat(LuaEngine/PlayerMethods): BonusTalent methods (#235) Co-authored-by: IntelligentQuantum --- src/LuaEngine/LuaFunctions.cpp | 4 +++ src/LuaEngine/methods/PlayerMethods.h | 50 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index 90201ffe4e..77cdc68c08 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -539,6 +539,7 @@ ElunaRegister PlayerMethods[] = { "GetShieldBlockValue", &LuaPlayer::GetShieldBlockValue }, { "GetPlayerSettingValue", &LuaPlayer::GetPlayerSettingValue }, { "GetTrader", &LuaPlayer::GetTrader }, + { "GetBonusTalentCount", &LuaPlayer::GetBonusTalentCount }, // Setters { "AdvanceSkillsToMax", &LuaPlayer::AdvanceSkillsToMax }, @@ -572,6 +573,9 @@ ElunaRegister PlayerMethods[] = { "SetPlayerLock", &LuaPlayer::SetPlayerLock }, { "SetGender", &LuaPlayer::SetGender }, { "SetSheath", &LuaPlayer::SetSheath }, + { "SetBonusTalentCount", &LuaPlayer::SetBonusTalentCount }, + { "AddBonusTalent", &LuaPlayer::AddBonusTalent }, + { "RemoveBonusTalent", &LuaPlayer::RemoveBonusTalent }, { "GetHomebind", &LuaPlayer::GetHomebind }, { "GetSpells", &LuaPlayer::GetSpells }, diff --git a/src/LuaEngine/methods/PlayerMethods.h b/src/LuaEngine/methods/PlayerMethods.h index 5bf717f3ce..5501182704 100644 --- a/src/LuaEngine/methods/PlayerMethods.h +++ b/src/LuaEngine/methods/PlayerMethods.h @@ -3914,6 +3914,30 @@ namespace LuaPlayer return 0; }*/ + /** + * Set bonus talent count to a specific count for the [Player] + * + * @param uint32 value : bonus talent points + */ + int SetBonusTalentCount(lua_State* L, Player* player) + { + uint32 value = Eluna::CHECKVAL(L, 2); + + player->SetBonusTalentCount(value); + return 0; + } + + /** + * Get bonus talents count from the [Player] + * + * @return uint32 bonusTalent + */ + int GetBonusTalentCount(lua_State* L, Player* player) + { + Eluna::Push(L, player->GetBonusTalentCount()); + return 1; + } + /** * Returns the [Player] spells list * @@ -3938,6 +3962,32 @@ namespace LuaPlayer return 1; } + /** + * Add bonus talents count to the [Player] + * + * @param uint32 count = count of bonus talent + */ + int AddBonusTalent(lua_State* L, Player* player) + { + uint32 count = Eluna::CHECKVAL(L, 2); + + player->AddBonusTalent(count); + return 0; + } + + /** + * Remove bonus talents count to the [Player] + * + * @param uint32 count = count of bonus talent + */ + int RemoveBonusTalent(lua_State* L, Player* player) + { + uint32 count = Eluna::CHECKVAL(L, 2); + + player->RemoveBonusTalent(count); + return 0; + } + /** * Returns the [Player] homebind location. * From ccfcc5f86f4b1e904839a6a921c807226ce34b67 Mon Sep 17 00:00:00 2001 From: sudlud Date: Sat, 8 Feb 2025 07:04:58 +0100 Subject: [PATCH 11/13] Update PlayerMethods.h - remove unused variable to fix core build (#255) --- src/LuaEngine/methods/PlayerMethods.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/LuaEngine/methods/PlayerMethods.h b/src/LuaEngine/methods/PlayerMethods.h index 5501182704..2f64078b72 100644 --- a/src/LuaEngine/methods/PlayerMethods.h +++ b/src/LuaEngine/methods/PlayerMethods.h @@ -4025,8 +4025,6 @@ namespace LuaPlayer std::string tele = Eluna::CHECKVAL(L, 2); const GameTele* game_tele = sObjectMgr->GetGameTele(tele); - MapEntry const* map = sMapStore.LookupEntry(game_tele->mapId); - if (player->IsInFlight()) { player->GetMotionMaster()->MovementExpired(); From 7511f38eab824dbb2392a81337d55e44d0698fc4 Mon Sep 17 00:00:00 2001 From: iThorgrim <125808072+iThorgrim@users.noreply.github.com> Date: Sat, 8 Feb 2025 07:33:43 +0100 Subject: [PATCH 12/13] Feat(LuaEngine/PlayerHooks): Add OnCanPlayerResurrect (#236) --- src/ElunaLuaEngine_SC.cpp | 5 +++++ src/LuaEngine/Hooks.h | 1 + src/LuaEngine/LuaEngine.h | 1 + src/LuaEngine/hooks/PlayerHooks.cpp | 8 ++++++++ src/LuaEngine/methods/GlobalMethods.h | 2 ++ 5 files changed, 17 insertions(+) diff --git a/src/ElunaLuaEngine_SC.cpp b/src/ElunaLuaEngine_SC.cpp index 9016ab89ab..decd6de8cc 100644 --- a/src/ElunaLuaEngine_SC.cpp +++ b/src/ElunaLuaEngine_SC.cpp @@ -812,6 +812,11 @@ class Eluna_PlayerScript : public PlayerScript { sEluna->OnCreatureKilledByPet(player, killed); } + + bool CanPlayerResurrect(Player* player) override + { + return sEluna->CanPlayerResurrect(player); + } }; class Eluna_ServerScript : public ServerScript diff --git a/src/LuaEngine/Hooks.h b/src/LuaEngine/Hooks.h index fb537a85a0..70e668ec63 100644 --- a/src/LuaEngine/Hooks.h +++ b/src/LuaEngine/Hooks.h @@ -221,6 +221,7 @@ namespace Hooks PLAYER_EVENT_ON_GROUP_ROLL_REWARD_ITEM = 56, // (event, player, item, count, voteType, roll) PLAYER_EVENT_ON_BG_DESERTION = 57, // (event, player, type) PLAYER_EVENT_ON_PET_KILL = 58, // (event, player, killer) + PLAYER_EVENT_ON_CAN_RESURRECT = 59, // (event, player) PLAYER_EVENT_COUNT }; diff --git a/src/LuaEngine/LuaEngine.h b/src/LuaEngine/LuaEngine.h index 11aad1086c..ffce5e84da 100644 --- a/src/LuaEngine/LuaEngine.h +++ b/src/LuaEngine/LuaEngine.h @@ -451,6 +451,7 @@ class ELUNA_GAME_API Eluna void OnGroupRollRewardItem(Player* player, Item* item, uint32 count, RollVote voteType, Roll* roll); void OnBattlegroundDesertion(Player* player, const BattlegroundDesertionType type); void OnCreatureKilledByPet(Player* player, Creature* killed); + bool CanPlayerResurrect(Player* player); /* Vehicle */ void OnInstall(Vehicle* vehicle); diff --git a/src/LuaEngine/hooks/PlayerHooks.cpp b/src/LuaEngine/hooks/PlayerHooks.cpp index 62a5d63159..f8ff479e55 100644 --- a/src/LuaEngine/hooks/PlayerHooks.cpp +++ b/src/LuaEngine/hooks/PlayerHooks.cpp @@ -706,3 +706,11 @@ void Eluna::OnCreatureKilledByPet(Player* player, Creature* killed) Push(killed); CallAllFunctions(PlayerEventBindings, key); } + +bool Eluna::CanPlayerResurrect(Player* player) +{ + START_HOOK_WITH_RETVAL(PLAYER_EVENT_ON_CAN_RESURRECT, true); + Push(player); + return CallAllFunctionsBool(PlayerEventBindings, key); +} + diff --git a/src/LuaEngine/methods/GlobalMethods.h b/src/LuaEngine/methods/GlobalMethods.h index fef9e06faa..e4c2f3c139 100644 --- a/src/LuaEngine/methods/GlobalMethods.h +++ b/src/LuaEngine/methods/GlobalMethods.h @@ -716,6 +716,8 @@ namespace LuaGlobalFunctions * PLAYER_EVENT_ON_CAN_GROUP_INVITE = 55, // (event, player, memberName) - Can return false to prevent inviting * PLAYER_EVENT_ON_GROUP_ROLL_REWARD_ITEM = 56, // (event, player, item, count, voteType, roll) * PLAYER_EVENT_ON_BG_DESERTION = 57, // (event, player, type) + * PLAYER_EVENT_ON_PET_KILL = 58, // (event, player, killer) + * PLAYER_EVENT_ON_CAN_RESURRECT = 59, // (event, player) * }; * * From f3c59a02b8b8f16ad6974f7044a028984a4028a4 Mon Sep 17 00:00:00 2001 From: sudlud Date: Sat, 8 Feb 2025 11:37:37 +0100 Subject: [PATCH 13/13] fix(CI): re-enable -Werror compile flag (#256) --- .github/workflows/core-build-base.yml | 2 ++ src/LuaEngine/lmarshal.cpp | 2 +- src/LuaEngine/methods/MapMethods.h | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/core-build-base.yml b/.github/workflows/core-build-base.yml index 846d9592c7..5d1d0d137b 100644 --- a/.github/workflows/core-build-base.yml +++ b/.github/workflows/core-build-base.yml @@ -58,6 +58,8 @@ jobs: -DCMAKE_BUILD_TYPE="Release" \ -DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \ -DCMAKE_C_COMPILER_LAUNCHER="ccache" \ + -DCMAKE_C_FLAGS="-Werror" \ + -DCMAKE_CXX_FLAGS="-Werror" \ -DLUA_VERSION=${{ inputs.lua_version }} make -j$(nproc) cd .. diff --git a/src/LuaEngine/lmarshal.cpp b/src/LuaEngine/lmarshal.cpp index 796c6bb3fa..a0e962e008 100644 --- a/src/LuaEngine/lmarshal.cpp +++ b/src/LuaEngine/lmarshal.cpp @@ -204,7 +204,7 @@ static void mar_encode_value(lua_State *L, mar_Buffer *buf, int val, size_t *idx } else { mar_Buffer rec_buf; - unsigned int i; + unsigned char i; lua_Debug ar; lua_pop(L, 1); /* pop nil */ diff --git a/src/LuaEngine/methods/MapMethods.h b/src/LuaEngine/methods/MapMethods.h index a2a269aeea..eed59bb068 100644 --- a/src/LuaEngine/methods/MapMethods.h +++ b/src/LuaEngine/methods/MapMethods.h @@ -358,13 +358,13 @@ namespace LuaMap */ int GetCreaturesByAreaId(lua_State* L, Map* map) { - uint32 areaId = Eluna::CHECKVAL(L, 2, -1); + int32 areaId = Eluna::CHECKVAL(L, 2, -1); std::vector filteredCreatures; for (const auto& pair : map->GetCreatureBySpawnIdStore()) { Creature* creature = pair.second; - if (areaId == -1 || creature->GetAreaId() == areaId) + if (areaId == -1 || creature->GetAreaId() == (uint32)areaId) { filteredCreatures.push_back(creature); }