Skip to content

Commit

Permalink
Merge branch 'master' into ElunaConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
55Honey authored Feb 9, 2025
2 parents ca03d7f + f3c59a0 commit d885854
Show file tree
Hide file tree
Showing 15 changed files with 678 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/core-build-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..
Expand Down
5 changes: 5 additions & 0 deletions src/ElunaLuaEngine_SC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/LuaEngine/Hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
1 change: 1 addition & 0 deletions src/LuaEngine/LuaEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,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);
Expand Down
13 changes: 13 additions & 0 deletions src/LuaEngine/LuaFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -321,6 +323,7 @@ ElunaRegister<Unit> 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 },
Expand Down Expand Up @@ -454,6 +457,8 @@ ElunaRegister<Unit> UnitMethods[] =
{ "DealHeal", &LuaUnit::DealHeal },
{ "AddThreat", &LuaUnit::AddThreat },
{ "ModifyThreatPct", &LuaUnit::ModifyThreatPct },
{ "ClearThreat", &LuaUnit::ClearThreat },
{ "ResetAllThreat", &LuaUnit::ResetAllThreat },

{ NULL, NULL }
};
Expand Down Expand Up @@ -534,6 +539,7 @@ ElunaRegister<Player> PlayerMethods[] =
{ "GetShieldBlockValue", &LuaPlayer::GetShieldBlockValue },
{ "GetPlayerSettingValue", &LuaPlayer::GetPlayerSettingValue },
{ "GetTrader", &LuaPlayer::GetTrader },
{ "GetBonusTalentCount", &LuaPlayer::GetBonusTalentCount },

// Setters
{ "AdvanceSkillsToMax", &LuaPlayer::AdvanceSkillsToMax },
Expand Down Expand Up @@ -567,6 +573,11 @@ ElunaRegister<Player> 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 },

// Boolean
{ "HasTankSpec", &LuaPlayer::HasTankSpec },
Expand Down Expand Up @@ -737,6 +748,7 @@ ElunaRegister<Player> PlayerMethods[] =
{ "SendCinematicStart", &LuaPlayer::SendCinematicStart },
{ "SendMovieStart", &LuaPlayer::SendMovieStart },
{ "UpdatePlayerSetting", &LuaPlayer::UpdatePlayerSetting },
{ "TeleportTo", &LuaPlayer::TeleportTo },

{ NULL, NULL }
};
Expand Down Expand Up @@ -960,6 +972,7 @@ ElunaRegister<ItemTemplate> ItemTemplateMethods[] =
{ "GetAllowableRace", &LuaItemTemplate::GetAllowableRace },
{ "GetItemLevel", &LuaItemTemplate::GetItemLevel },
{ "GetRequiredLevel", &LuaItemTemplate::GetRequiredLevel },
{ "GetIcon", &LuaItemTemplate::GetIcon },
{ NULL, NULL }
};

Expand Down
8 changes: 8 additions & 0 deletions src/LuaEngine/hooks/PlayerHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,3 +702,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);
}

2 changes: 1 addition & 1 deletion src/LuaEngine/lmarshal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
4 changes: 2 additions & 2 deletions src/LuaEngine/methods/CreatureMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -984,7 +984,7 @@ namespace LuaCreature
{
bool disable = Eluna::CHECKVAL<bool>(L, 2, true);

creature->SetDisableReputationGain(disable);
creature->SetReputationRewardDisabled(disable);
return 0;
}

Expand Down
81 changes: 81 additions & 0 deletions src/LuaEngine/methods/GlobalMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
* };
* </pre>
*
Expand Down Expand Up @@ -3231,6 +3233,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<uint32>(L, 1);
uint32 optionId = Eluna::CHECKVAL<uint32>(L, 2);
uint8 locale = Eluna::CHECKVAL<uint8>(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<uint32>(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
Expand Down
52 changes: 26 additions & 26 deletions src/LuaEngine/methods/GuildMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
{
Expand All @@ -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 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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions src/LuaEngine/methods/ItemTemplateMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/LuaEngine/methods/MapMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,13 @@ namespace LuaMap
*/
int GetCreaturesByAreaId(lua_State* L, Map* map)
{
uint32 areaId = Eluna::CHECKVAL<uint32>(L, 2, -1);
int32 areaId = Eluna::CHECKVAL<int32>(L, 2, -1);
std::vector<Creature*> 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);
}
Expand Down
Loading

0 comments on commit d885854

Please sign in to comment.