Skip to content

Commit

Permalink
feat(LuaEngine/SpellInfo): add SpellInfo class and methods (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
iThorgrim authored Jan 25, 2025
1 parent 54484b7 commit 0d35a87
Show file tree
Hide file tree
Showing 4 changed files with 836 additions and 0 deletions.
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
76 changes: 76 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 @@ -1307,6 +1309,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 @@ -1560,6 +1633,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
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
Loading

0 comments on commit 0d35a87

Please sign in to comment.