Skip to content

Commit

Permalink
Merge branch 'master' into SkillPlayerHook
Browse files Browse the repository at this point in the history
  • Loading branch information
iThorgrim authored Jan 27, 2025
2 parents 8ddcd2c + ef8d5a0 commit 2476b3a
Show file tree
Hide file tree
Showing 9 changed files with 1,107 additions and 4 deletions.
3 changes: 1 addition & 2 deletions conf/mod_eluna.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ Eluna.TraceBack = false
Eluna.ScriptPath = "lua_scripts"
Eluna.PlayerAnnounceReload = false
Eluna.RequirePaths = ""
Eluna.RequirecPaths = ""

Eluna.RequireCPaths = ""

###################################################################################################
# LOGGING SYSTEM SETTINGS
Expand Down
1 change: 1 addition & 0 deletions src/LuaEngine/ElunaIncludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "ScriptMgr.h"
#include "Spell.h"
#include "SpellAuras.h"
#include "SpellInfo.h"
#include "SpellMgr.h"
#include "TemporarySummon.h"
#include "WorldPacket.h"
Expand Down
90 changes: 90 additions & 0 deletions src/LuaEngine/LuaFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ extern "C"
#include "AchievementMethods.h"
#include "ItemTemplateMethods.h"
#include "RollMethods.h"
#include "SpellInfoMethods.h"

// DBCStores includes
#include "GemPropertiesEntryMethods.h"
Expand Down Expand Up @@ -125,6 +126,7 @@ luaL_Reg GlobalMethods[] =
{ "PrintError", &LuaGlobalFunctions::PrintError },
{ "PrintDebug", &LuaGlobalFunctions::PrintDebug },
{ "GetActiveGameEvents", &LuaGlobalFunctions::GetActiveGameEvents },
{ "GetSpellInfo", &LuaGlobalFunctions::GetSpellInfo },

// Boolean
{ "IsCompatibilityMode", &LuaGlobalFunctions::IsCompatibilityMode },
Expand Down Expand Up @@ -853,6 +855,7 @@ ElunaRegister<GameObject> GameObjectMethods[] =
{ "SetGoState", &LuaGameObject::SetGoState },
{ "SetLootState", &LuaGameObject::SetLootState },
{ "SetRespawnTime", &LuaGameObject::SetRespawnTime },
{ "SetRespawnDelay", &LuaGameObject::SetRespawnDelay },

// Boolean
{ "IsTransport", &LuaGameObject::IsTransport },
Expand Down Expand Up @@ -1081,18 +1084,28 @@ ElunaRegister<Guild> GuildMethods[] =
{ "GetMOTD", &LuaGuild::GetMOTD },
{ "GetInfo", &LuaGuild::GetInfo },
{ "GetMemberCount", &LuaGuild::GetMemberCount },
{ "GetCreatedDate", &LuaGuild::GetCreatedDate },
{ "GetTotalBankMoney", &LuaGuild::GetTotalBankMoney },

// Setters
{ "SetBankTabText", &LuaGuild::SetBankTabText },
{ "SetMemberRank", &LuaGuild::SetMemberRank },
{ "SetLeader", &LuaGuild::SetLeader },
{ "SetName", &LuaGuild::SetName },

// Other
{ "SendPacket", &LuaGuild::SendPacket },
{ "SendPacketToRanked", &LuaGuild::SendPacketToRanked },
{ "Disband", &LuaGuild::Disband },
{ "AddMember", &LuaGuild::AddMember },
{ "DeleteMember", &LuaGuild::DeleteMember },
{ "SendMessage", &LuaGuild::SendMessage },
{ "UpdateMemberData", &LuaGuild::UpdateMemberData },
{ "MassInviteToEvent", &LuaGuild::MassInviteToEvent },
{ "SwapItems", &LuaGuild::SwapItems },
{ "SwapItemsWithInventory", &LuaGuild::SwapItemsWithInventory },
{ "ResetTimes", &LuaGuild::ResetTimes },
{ "ModifyBankMoney", &LuaGuild::ModifyBankMoney },

{ NULL, NULL }
};
Expand Down Expand Up @@ -1189,6 +1202,9 @@ ElunaRegister<Map> MapMethods[] =
{ "GetAreaId", &LuaMap::GetAreaId },
{ "GetHeight", &LuaMap::GetHeight },
{ "GetWorldObject", &LuaMap::GetWorldObject },
{ "GetCreatures", &LuaMap::GetCreatures },
{ "GetCreaturesByAreaId", &LuaMap::GetCreaturesByAreaId },


// Setters
{ "SetWeather", &LuaMap::SetWeather },
Expand Down Expand Up @@ -1297,6 +1313,77 @@ ElunaRegister<Roll> RollMethods[] =
{ NULL, NULL }
};

ElunaRegister<SpellInfo> SpellInfoMethods[] =
{
// Getters
{ "GetAttributes", &LuaSpellInfo::GetAttributes },
{ "GetCategory", &LuaSpellInfo::GetCategory },
{ "GetName", &LuaSpellInfo::GetName },
{ "CheckShapeshift", &LuaSpellInfo::CheckShapeshift },
{ "CheckLocation", &LuaSpellInfo::CheckLocation },
{ "CheckTarget", &LuaSpellInfo::CheckTarget },
{ "CheckExplicitTarget", &LuaSpellInfo::CheckExplicitTarget },
{ "CheckTargetCreatureType", &LuaSpellInfo::CheckTargetCreatureType },
{ "CheckTargetCreatureType", &LuaSpellInfo::CheckTargetCreatureType },
{ "GetSchoolMask", &LuaSpellInfo::GetSchoolMask },
{ "GetAllEffectsMechanicMask", &LuaSpellInfo::GetAllEffectsMechanicMask },
{ "GetEffectMechanicMask", &LuaSpellInfo::GetEffectMechanicMask },
{ "GetSpellMechanicMaskByEffectMask", &LuaSpellInfo::GetSpellMechanicMaskByEffectMask },
{ "GetEffectMechanic", &LuaSpellInfo::GetEffectMechanic },
{ "GetDispelMask", &LuaSpellInfo::GetDispelMask },
{ "GetExplicitTargetMask", &LuaSpellInfo::GetExplicitTargetMask },
{ "GetAuraState", &LuaSpellInfo::GetAuraState },
{ "GetSpellSpecific", &LuaSpellInfo::GetSpellSpecific },

// Setters

// Boolean
{ "HasAreaAuraEffect", &LuaSpellInfo::HasAreaAuraEffect },
{ "HasAttribute", &LuaSpellInfo::HasAttribute },
{ "HasAura", &LuaSpellInfo::HasAura },
{ "HasEffect", &LuaSpellInfo::HasEffect },

{ "IsAbilityLearnedWithProfession", &LuaSpellInfo::IsAbilityLearnedWithProfession },
{ "IsAbilityOfSkillType", &LuaSpellInfo::IsAbilityOfSkillType },
{ "IsAffectingArea", &LuaSpellInfo::IsAffectingArea },
{ "IsAllowingDeadTarget", &LuaSpellInfo::IsAllowingDeadTarget },
{ "IsAutocastable", &LuaSpellInfo::IsAutocastable },
{ "IsAutoRepeatRangedSpell", &LuaSpellInfo::IsAutoRepeatRangedSpell },
{ "IsBreakingStealth", &LuaSpellInfo::IsBreakingStealth },
{ "IsChanneled", &LuaSpellInfo::IsChanneled },
{ "IsCooldownStartedOnEvent", &LuaSpellInfo::IsCooldownStartedOnEvent },
{ "IsDeathPersistent", &LuaSpellInfo::IsDeathPersistent },
{ "IsExplicitDiscovery", &LuaSpellInfo::IsExplicitDiscovery },
{ "IsLootCrafting", &LuaSpellInfo::IsLootCrafting },
{ "IsMultiSlotAura", &LuaSpellInfo::IsMultiSlotAura },
{ "IsPassive", &LuaSpellInfo::IsPassive },
{ "IsPassiveStackableWithRanks", &LuaSpellInfo::IsPassiveStackableWithRanks },
{ "IsPositive", &LuaSpellInfo::IsPositive },
{ "IsPositiveEffect", &LuaSpellInfo::IsPositiveEffect },
{ "IsPrimaryProfession", &LuaSpellInfo::IsPrimaryProfession },
{ "IsPrimaryProfessionFirstRank", &LuaSpellInfo::IsPrimaryProfessionFirstRank },
{ "IsProfession", &LuaSpellInfo::IsProfession },
{ "IsProfessionOrRiding", &LuaSpellInfo::IsProfessionOrRiding },
{ "IsRangedWeaponSpell", &LuaSpellInfo::IsRangedWeaponSpell },
{ "IsRequiringDeadTarget", &LuaSpellInfo::IsRequiringDeadTarget },
{ "IsStackableWithRanks", &LuaSpellInfo::IsStackableWithRanks },
{ "IsTargetingArea", &LuaSpellInfo::IsTargetingArea },
{ "IsAffectedBySpellMods", &LuaSpellInfo::IsAffectedBySpellMods },
/* { "IsAffectedBySpellMod", &LuaSpellInfo::IsAffectedBySpellMod }, */
{ "CanPierceImmuneAura", &LuaSpellInfo::CanPierceImmuneAura },
{ "CanDispelAura", &LuaSpellInfo::CanDispelAura },
{ "IsSingleTarget", &LuaSpellInfo::IsSingleTarget },
{ "IsAuraExclusiveBySpecificWith", &LuaSpellInfo::IsAuraExclusiveBySpecificWith },
{ "IsAuraExclusiveBySpecificPerCasterWith", &LuaSpellInfo::IsAuraExclusiveBySpecificPerCasterWith },
{ "CanBeUsedInCombat", &LuaSpellInfo::CanBeUsedInCombat },

{ "NeedsComboPoints", &LuaSpellInfo::NeedsComboPoints },
{ "NeedsExplicitUnitTarget", &LuaSpellInfo::NeedsExplicitUnitTarget },
{ "NeedsToBeTriggeredByCaster", &LuaSpellInfo::NeedsToBeTriggeredByCaster },

{ NULL, NULL }
};

ElunaRegister<GemPropertiesEntry> GemPropertiesEntryMethods[] =
{
// Getters
Expand Down Expand Up @@ -1550,6 +1637,9 @@ void RegisterFunctions(Eluna* E)
ElunaTemplate<Roll>::Register(E, "Roll");
ElunaTemplate<Roll>::SetMethods(E, RollMethods);

ElunaTemplate<SpellInfo>::Register(E, "SpellInfo");
ElunaTemplate<SpellInfo>::SetMethods(E, SpellInfoMethods);

ElunaTemplate<GemPropertiesEntry>::Register(E, "GemPropertiesEntry");
ElunaTemplate<GemPropertiesEntry>::SetMethods(E, GemPropertiesEntryMethods);

Expand Down
15 changes: 15 additions & 0 deletions src/LuaEngine/methods/GameObjectMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,5 +353,20 @@ namespace LuaGameObject
go->SetRespawnTime(respawn);
return 0;
}

/**
* Sets the respawn or despawn time for the gameobject.
*
* Respawn time is also used as despawn time depending on gameobject settings
*
* @param int32 delay = 0 : cooldown time in seconds to respawn or despawn the object. 0 means never
*/
int SetRespawnDelay(lua_State* L, GameObject* go)
{
int32 respawn = Eluna::CHECKVAL<int32>(L, 2);

go->SetRespawnDelay(respawn);
return 0;
}
};
#endif
14 changes: 14 additions & 0 deletions src/LuaEngine/methods/GlobalMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -3230,6 +3230,20 @@ namespace LuaGlobalFunctions
return 0;
}

/**
* Get the [SpellInfo] for the specified [Spell] id
*
* @param uint32 spellId : the ID of the spell
* @return [SpellInfo] spellInfo
*/
int GetSpellInfo(lua_State* L)
{
uint32 spellId = Eluna::CHECKVAL<uint32>(L, 1);
Eluna::Push(L, sSpellMgr->GetSpellInfo(spellId));
return 1;

}

/**
* Returns the instance of the specified DBC (DatabaseClient) store.
*
Expand Down
172 changes: 172 additions & 0 deletions src/LuaEngine/methods/GuildMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,177 @@ namespace LuaGuild
guild->ChangeMemberRank(player->GET_GUID(), newRank);
return 0;
}

/**
* Sets the new name of the specified [Guild].
*
* @param string name : new name of this guild
*/
int SetName(lua_State* L, Guild* guild)
{
std::string name = Eluna::CHECKVAL<std::string>(L, 2);

guild->SetName(name);
return 0;
}

/**
* Update [Player] data in [Guild] member list.
*
* enum GuildMemberData
* {
* GUILD_MEMBER_DATA_ZONEID = 0
* GUILD_MEMBER_DATA_LEVEL = 1
* };
*
* @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)
{
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
uint8 dataid = Eluna::CHECKVAL<uint8>(L, 3);
uint32 value = Eluna::CHECKVAL<uint32>(L, 4);

guild->UpdateMemberData(player, dataid, value);
return 0;
}

/**
* 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
*/
int SendMessage(lua_State* L, Guild* guild)
{
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
bool officierOnly = Eluna::CHECKVAL<bool>(L, 3, false);
std::string msg = Eluna::CHECKVAL<std::string>(L, 4);
uint32 language = Eluna::CHECKVAL<uint32>(L, 5, false);

guild->BroadcastToGuild(player->GetSession(), officierOnly, msg, language);
return 0;
}

/**
* 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
*/
int MassInviteToEvent(lua_State* L, Guild* guild)
{
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
uint32 minLevel = Eluna::CHECKVAL<uint32>(L, 3);
uint32 maxLevel = Eluna::CHECKVAL<uint32>(L, 4);
uint32 minRank = Eluna::CHECKVAL<uint32>(L, 5);

guild->MassInviteToEvent(player->GetSession(), minLevel, maxLevel, minRank);
return 0;
}

/**
* 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
*/
int SwapItems(lua_State* L, Guild* guild)
{
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
uint8 tabId = Eluna::CHECKVAL<uint32>(L, 3);
uint8 slotId = Eluna::CHECKVAL<uint32>(L, 4);
uint8 destTabId = Eluna::CHECKVAL<uint32>(L, 5);
uint8 destSlotId = Eluna::CHECKVAL<uint32>(L, 6);
uint32 splitedAmount = Eluna::CHECKVAL<uint32>(L, 7);

guild->SwapItems(player, tabId, slotId, destTabId, destSlotId, splitedAmount);
return 0;
}

/**
* 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
*/
int SwapItemsWithInventory(lua_State* L, Guild* guild)
{
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
bool toChar = Eluna::CHECKVAL<bool>(L, 3, false);
uint8 tabId = Eluna::CHECKVAL<uint8>(L, 4);
uint8 slotId = Eluna::CHECKVAL<uint8>(L, 5);
uint8 playerBag = Eluna::CHECKVAL<uint8>(L, 6);
uint8 playerSlotId = Eluna::CHECKVAL<uint8>(L, 7);
uint32 splitedAmount = Eluna::CHECKVAL<uint32>(L, 8);

guild->SwapItemsWithInventory(player, toChar, tabId, slotId, playerBag, playerSlotId, splitedAmount);
return 0;
}

/**
* Return the total bank money.
*
* @return number totalBankMoney
*/
int GetTotalBankMoney(lua_State* L, Guild* guild)
{
Eluna::Push(L, guild->GetTotalBankMoney());
return 1;
}

/**
* Return the created date.
*
* @return uint64 created date
*/
int GetCreatedDate(lua_State* L, Guild* guild)
{
Eluna::Push(L, guild->GetCreatedDate());
return 1;
}

/**
* Resets the number of item withdraw in all tab's for all [Guild] members.
*/
int ResetTimes(lua_State* L, Guild* guild)
{
guild->ResetTimes();
return 0;
}

/**
* 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)
* @return bool is_applied
*/
int ModifyBankMoney(lua_State* L, Guild* guild)
{
uint64 amount = Eluna::CHECKVAL<uint64>(L, 2);
bool add = Eluna::CHECKVAL<bool>(L, 2);

CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
Eluna::Push(L, guild->ModifyBankMoney(trans, amount, add));

CharacterDatabase.CommitTransaction(trans);
return 1;
}
};
#endif
Loading

0 comments on commit 2476b3a

Please sign in to comment.