mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 12:31:31 +00:00
[Quest API] Add AddAISpellEffect(spell_effect_id, base_value, limit_value, max_value) and RemoveAISpellEffect(spell_effect_id) to Lua. (#1981)
- Add npc:AddAISpellEffect(spell_effect_id, base_value, limit_value, max_value) to Lua. - Add npc:RemoveAISpellEffect(spell_effect_id) to Lua.
This commit is contained in:
parent
79f250da2d
commit
f65a6d2761
@ -635,6 +635,24 @@ Lua_NPC_Loot_List Lua_NPC::GetLootList(lua_State* L) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Lua_NPC::AddAISpellEffect(int spell_effect_id, int base_value, int limit_value, int max_value)
|
||||||
|
{
|
||||||
|
Lua_Safe_Call_Void();
|
||||||
|
self->AddSpellEffectToNPCList(spell_effect_id, base_value, limit_value, max_value, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lua_NPC::RemoveAISpellEffect(int spell_effect_id)
|
||||||
|
{
|
||||||
|
Lua_Safe_Call_Void();
|
||||||
|
self->RemoveSpellEffectFromNPCList(spell_effect_id, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Lua_NPC::HasAISpellEffect(int spell_effect_id)
|
||||||
|
{
|
||||||
|
Lua_Safe_Call_Bool();
|
||||||
|
return self->HasAISpellEffect(spell_effect_id);
|
||||||
|
}
|
||||||
|
|
||||||
luabind::scope lua_register_npc() {
|
luabind::scope lua_register_npc() {
|
||||||
return luabind::class_<Lua_NPC, Lua_Mob>("NPC")
|
return luabind::class_<Lua_NPC, Lua_Mob>("NPC")
|
||||||
.def(luabind::constructor<>())
|
.def(luabind::constructor<>())
|
||||||
@ -642,6 +660,7 @@ luabind::scope lua_register_npc() {
|
|||||||
.def("AI_SetRoambox", (void(Lua_NPC::*)(float,float,float,float,float,uint32,uint32))&Lua_NPC::AI_SetRoambox)
|
.def("AI_SetRoambox", (void(Lua_NPC::*)(float,float,float,float,float,uint32,uint32))&Lua_NPC::AI_SetRoambox)
|
||||||
.def("AddAISpell", (void(Lua_NPC::*)(int,int,int,int,int,int))&Lua_NPC::AddAISpell)
|
.def("AddAISpell", (void(Lua_NPC::*)(int,int,int,int,int,int))&Lua_NPC::AddAISpell)
|
||||||
.def("AddAISpell", (void(Lua_NPC::*)(int,int,int,int,int,int,int,int))&Lua_NPC::AddAISpell)
|
.def("AddAISpell", (void(Lua_NPC::*)(int,int,int,int,int,int,int,int))&Lua_NPC::AddAISpell)
|
||||||
|
.def("AddAISpellEffect", (void(Lua_NPC::*)(int,int,int,int))&Lua_NPC::AddAISpellEffect)
|
||||||
.def("AddCash", (void(Lua_NPC::*)(int,int,int,int))&Lua_NPC::AddCash)
|
.def("AddCash", (void(Lua_NPC::*)(int,int,int,int))&Lua_NPC::AddCash)
|
||||||
.def("AddItem", (void(Lua_NPC::*)(int,int))&Lua_NPC::AddItem)
|
.def("AddItem", (void(Lua_NPC::*)(int,int))&Lua_NPC::AddItem)
|
||||||
.def("AddItem", (void(Lua_NPC::*)(int,int,bool))&Lua_NPC::AddItem)
|
.def("AddItem", (void(Lua_NPC::*)(int,int,bool))&Lua_NPC::AddItem)
|
||||||
@ -711,6 +730,7 @@ luabind::scope lua_register_npc() {
|
|||||||
.def("GetSwarmOwner", (int(Lua_NPC::*)(void))&Lua_NPC::GetSwarmOwner)
|
.def("GetSwarmOwner", (int(Lua_NPC::*)(void))&Lua_NPC::GetSwarmOwner)
|
||||||
.def("GetSwarmTarget", (int(Lua_NPC::*)(void))&Lua_NPC::GetSwarmTarget)
|
.def("GetSwarmTarget", (int(Lua_NPC::*)(void))&Lua_NPC::GetSwarmTarget)
|
||||||
.def("GetWaypointMax", (int(Lua_NPC::*)(void))&Lua_NPC::GetWaypointMax)
|
.def("GetWaypointMax", (int(Lua_NPC::*)(void))&Lua_NPC::GetWaypointMax)
|
||||||
|
.def("HasAISpellEffect", (bool(Lua_NPC::*)(int))&Lua_NPC::HasAISpellEffect)
|
||||||
.def("HasItem", (bool(Lua_NPC::*)(uint32))&Lua_NPC::HasItem)
|
.def("HasItem", (bool(Lua_NPC::*)(uint32))&Lua_NPC::HasItem)
|
||||||
.def("IsAnimal", (bool(Lua_NPC::*)(void))&Lua_NPC::IsAnimal)
|
.def("IsAnimal", (bool(Lua_NPC::*)(void))&Lua_NPC::IsAnimal)
|
||||||
.def("IsGuarding", (bool(Lua_NPC::*)(void))&Lua_NPC::IsGuarding)
|
.def("IsGuarding", (bool(Lua_NPC::*)(void))&Lua_NPC::IsGuarding)
|
||||||
@ -726,6 +746,7 @@ luabind::scope lua_register_npc() {
|
|||||||
.def("PickPocket", (void(Lua_NPC::*)(Lua_Client))&Lua_NPC::PickPocket)
|
.def("PickPocket", (void(Lua_NPC::*)(Lua_Client))&Lua_NPC::PickPocket)
|
||||||
.def("RecalculateSkills", (void(Lua_NPC::*)(void))&Lua_NPC::RecalculateSkills)
|
.def("RecalculateSkills", (void(Lua_NPC::*)(void))&Lua_NPC::RecalculateSkills)
|
||||||
.def("RemoveAISpell", (void(Lua_NPC::*)(int))&Lua_NPC::RemoveAISpell)
|
.def("RemoveAISpell", (void(Lua_NPC::*)(int))&Lua_NPC::RemoveAISpell)
|
||||||
|
.def("RemoveAISpellEffect", (void(Lua_NPC::*)(int))&Lua_NPC::RemoveAISpellEffect)
|
||||||
.def("RemoveCash", (void(Lua_NPC::*)(void))&Lua_NPC::RemoveCash)
|
.def("RemoveCash", (void(Lua_NPC::*)(void))&Lua_NPC::RemoveCash)
|
||||||
.def("RemoveItem", (void(Lua_NPC::*)(int))&Lua_NPC::RemoveItem)
|
.def("RemoveItem", (void(Lua_NPC::*)(int))&Lua_NPC::RemoveItem)
|
||||||
.def("RemoveItem", (void(Lua_NPC::*)(int,int))&Lua_NPC::RemoveItem)
|
.def("RemoveItem", (void(Lua_NPC::*)(int,int))&Lua_NPC::RemoveItem)
|
||||||
|
|||||||
@ -149,6 +149,9 @@ public:
|
|||||||
float GetHealScale();
|
float GetHealScale();
|
||||||
float GetSpellScale();
|
float GetSpellScale();
|
||||||
Lua_NPC_Loot_List GetLootList(lua_State* L);
|
Lua_NPC_Loot_List GetLootList(lua_State* L);
|
||||||
|
void AddAISpellEffect(int spell_effect_id, int base_value, int limit_value, int max_value);
|
||||||
|
void RemoveAISpellEffect(int spell_effect_id);
|
||||||
|
bool HasAISpellEffect(int spell_effect_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -2799,6 +2799,17 @@ void NPC::RemoveSpellEffectFromNPCList(uint16 iSpellEffectID, bool apply_bonus)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NPC::HasAISpellEffect(uint16 spell_effect_id)
|
||||||
|
{
|
||||||
|
for (const auto& spell_effect : AIspellsEffects) {
|
||||||
|
if (spell_effect.spelleffectid == spell_effect_id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsSpellEffectInList(DBnpcspellseffects_Struct* spelleffect_list, uint16 iSpellEffectID, int32 base_value, int32 limit, int32 max_value) {
|
bool IsSpellEffectInList(DBnpcspellseffects_Struct* spelleffect_list, uint16 iSpellEffectID, int32 base_value, int32 limit, int32 max_value) {
|
||||||
for (uint32 i=0; i < spelleffect_list->numentries; i++) {
|
for (uint32 i=0; i < spelleffect_list->numentries; i++) {
|
||||||
if (spelleffect_list->entries[i].spelleffectid == iSpellEffectID && spelleffect_list->entries[i].base_value == base_value
|
if (spelleffect_list->entries[i].spelleffectid == iSpellEffectID && spelleffect_list->entries[i].base_value == base_value
|
||||||
|
|||||||
@ -452,6 +452,7 @@ public:
|
|||||||
void AddSpellEffectToNPCList(uint16 iSpellEffectID, int32 base_value, int32 limit, int32 max_value, bool apply_bonus = false);
|
void AddSpellEffectToNPCList(uint16 iSpellEffectID, int32 base_value, int32 limit, int32 max_value, bool apply_bonus = false);
|
||||||
void RemoveSpellFromNPCList(uint16 spell_id);
|
void RemoveSpellFromNPCList(uint16 spell_id);
|
||||||
void RemoveSpellEffectFromNPCList(uint16 iSpellEffectID, bool apply_bonus = false);
|
void RemoveSpellEffectFromNPCList(uint16 iSpellEffectID, bool apply_bonus = false);
|
||||||
|
bool HasAISpellEffect(uint16 spell_effect_id);
|
||||||
Timer *GetRefaceTimer() const { return reface_timer; }
|
Timer *GetRefaceTimer() const { return reface_timer; }
|
||||||
const uint32 GetAltCurrencyType() const { return NPCTypedata->alt_currency_type; }
|
const uint32 GetAltCurrencyType() const { return NPCTypedata->alt_currency_type; }
|
||||||
|
|
||||||
|
|||||||
@ -1849,14 +1849,14 @@ XS(XS_NPC_AddAISpellEffect); /* prototype to pass -Wmissing-prototypes */
|
|||||||
XS(XS_NPC_AddAISpellEffect) {
|
XS(XS_NPC_AddAISpellEffect) {
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
if (items != 5)
|
if (items != 5)
|
||||||
Perl_croak(aTHX_ "Usage: NPC::AddAISpellEffect(THIS, spell_effect id, base_value, limit_value, max_value)"); // @categories Spells and Disciplines
|
Perl_croak(aTHX_ "Usage: NPC::AddAISpellEffect(THIS, int spell_effect_id, int base_value, int limit_value, int max_value)"); // @categories Spells and Disciplines
|
||||||
{
|
{
|
||||||
NPC *THIS;
|
NPC *THIS;
|
||||||
|
|
||||||
int spell_effect_id = (int)SvIV(ST(1));
|
int spell_effect_id = (int) SvIV(ST(1));
|
||||||
int base_value = (int)SvIV(ST(2));
|
int base_value = (int) SvIV(ST(2));
|
||||||
int limit_value = (int)SvIV(ST(3));
|
int limit_value = (int) SvIV(ST(3));
|
||||||
int max_value = (int)SvIV(ST(4));
|
int max_value = (int) SvIV(ST(4));
|
||||||
|
|
||||||
VALIDATE_THIS_IS_NPC;
|
VALIDATE_THIS_IS_NPC;
|
||||||
THIS->AddSpellEffectToNPCList(spell_effect_id, base_value, limit_value, max_value, true);
|
THIS->AddSpellEffectToNPCList(spell_effect_id, base_value, limit_value, max_value, true);
|
||||||
@ -1868,16 +1868,32 @@ XS(XS_NPC_RemoveAISpellEffect); /* prototype to pass -Wmissing-prototypes */
|
|||||||
XS(XS_NPC_RemoveAISpellEffect) {
|
XS(XS_NPC_RemoveAISpellEffect) {
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
if (items != 2)
|
if (items != 2)
|
||||||
Perl_croak(aTHX_ "Usage: NPC::RemoveAISpellEffect(THIS, int spelleffect_id)"); // @categories Spells and Disciplines
|
Perl_croak(aTHX_ "Usage: NPC::RemoveAISpellEffect(THIS, int spell_effect_id)"); // @categories Spells and Disciplines
|
||||||
{
|
{
|
||||||
NPC *THIS;
|
NPC *THIS;
|
||||||
int spell_effect_id = (int)SvIV(ST(1));
|
int spell_effect_id = (int) SvIV(ST(1));
|
||||||
VALIDATE_THIS_IS_NPC;
|
VALIDATE_THIS_IS_NPC;
|
||||||
THIS->RemoveSpellEffectFromNPCList(spell_effect_id, true);
|
THIS->RemoveSpellEffectFromNPCList(spell_effect_id, true);
|
||||||
}
|
}
|
||||||
XSRETURN_EMPTY;
|
XSRETURN_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XS(XS_NPC_HasAISpellEffect); /* prototype to pass -Wmissing-prototypes */
|
||||||
|
XS(XS_NPC_HasAISpellEffect) {
|
||||||
|
dXSARGS;
|
||||||
|
if (items != 2)
|
||||||
|
Perl_croak(aTHX_ "Usage: NPC::HasAISpellEffect(THIS, int spell_effect_id)"); // @categories Spells and Disciplines
|
||||||
|
{
|
||||||
|
NPC *THIS;
|
||||||
|
bool has_spell_effect = false;
|
||||||
|
int spell_effect_id = (int) SvIV(ST(1));
|
||||||
|
VALIDATE_THIS_IS_NPC;
|
||||||
|
has_spell_effect = THIS->HasAISpellEffect(spell_effect_id);
|
||||||
|
ST(0) = boolSV(has_spell_effect);
|
||||||
|
sv_2mortal(ST(0));
|
||||||
|
}
|
||||||
|
XSRETURN(1);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
@ -1959,6 +1975,7 @@ XS(boot_NPC) {
|
|||||||
newXSproto(strcpy(buf, "GetSwarmOwner"), XS_NPC_GetSwarmOwner, file, "$");
|
newXSproto(strcpy(buf, "GetSwarmOwner"), XS_NPC_GetSwarmOwner, file, "$");
|
||||||
newXSproto(strcpy(buf, "GetSwarmTarget"), XS_NPC_GetSwarmTarget, file, "$");
|
newXSproto(strcpy(buf, "GetSwarmTarget"), XS_NPC_GetSwarmTarget, file, "$");
|
||||||
newXSproto(strcpy(buf, "GetWaypointMax"), XS_NPC_GetWaypointMax, file, "$");
|
newXSproto(strcpy(buf, "GetWaypointMax"), XS_NPC_GetWaypointMax, file, "$");
|
||||||
|
newXSproto(strcpy(buf, "HasAISpellEffect"), XS_NPC_HasAISpellEffect, file, "$$");
|
||||||
newXSproto(strcpy(buf, "HasItem"), XS_NPC_HasItem, file, "$$");
|
newXSproto(strcpy(buf, "HasItem"), XS_NPC_HasItem, file, "$$");
|
||||||
newXSproto(strcpy(buf, "IsAnimal"), XS_NPC_IsAnimal, file, "$");
|
newXSproto(strcpy(buf, "IsAnimal"), XS_NPC_IsAnimal, file, "$");
|
||||||
newXSproto(strcpy(buf, "IsGuarding"), XS_NPC_IsGuarding, file, "$");
|
newXSproto(strcpy(buf, "IsGuarding"), XS_NPC_IsGuarding, file, "$");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user