Add IsTaunting() to Perl/Lua.

This commit is contained in:
Alex 2020-05-14 23:55:55 -04:00
parent 5f0d3e9026
commit ee55755c85
3 changed files with 32 additions and 0 deletions

View File

@ -237,6 +237,11 @@ void Lua_NPC::SetTaunting(bool t) {
self->SetTaunting(t);
}
bool Lua_NPC::IsTaunting() {
Lua_Safe_Call_Bool();
return self->IsTaunting();
}
void Lua_NPC::PickPocket(Lua_Client thief) {
Lua_Safe_Call_Void();
self->PickPocket(thief);
@ -602,6 +607,7 @@ luabind::scope lua_register_npc() {
.def("SetPetSpellID", (void(Lua_NPC::*)(int))&Lua_NPC::SetPetSpellID)
.def("GetMaxDamage", (uint32(Lua_NPC::*)(int))&Lua_NPC::GetMaxDamage)
.def("SetTaunting", (void(Lua_NPC::*)(bool))&Lua_NPC::SetTaunting)
.def("IsTaunting", (bool(Lua_NPC::*)(void))&Lua_NPC::IsTaunting)
.def("PickPocket", (void(Lua_NPC::*)(Lua_Client))&Lua_NPC::PickPocket)
.def("StartSwarmTimer", (void(Lua_NPC::*)(uint32))&Lua_NPC::StartSwarmTimer)
.def("DoClassAttacks", (void(Lua_NPC::*)(Lua_Mob))&Lua_NPC::DoClassAttacks)

View File

@ -73,6 +73,7 @@ public:
void SetPetSpellID(int id);
uint32 GetMaxDamage(int level);
void SetTaunting(bool t);
bool IsTaunting();
void PickPocket(Lua_Client thief);
void StartSwarmTimer(uint32 duration);
void DoClassAttacks(Lua_Mob target);

View File

@ -991,6 +991,30 @@ XS(XS_NPC_SetTaunting) {
XSRETURN_EMPTY;
}
XS(XS_NPC_IsTaunting); /* prototype to pass -Wmissing-prototypes */
XS(XS_NPC_IsTaunting) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: NPC::IsTaunting(THIS)");
{
NPC *THIS;
bool RETVAL;
if (sv_derived_from(ST(0), "NPC")) {
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(NPC *, tmp);
} else
Perl_croak(aTHX_ "THIS is not of type NPC");
if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->IsTaunting();
ST(0) = boolSV(RETVAL);
sv_2mortal(ST(0));
}
XSRETURN(1);
}
XS(XS_NPC_PickPocket); /* prototype to pass -Wmissing-prototypes */
XS(XS_NPC_PickPocket) {
dXSARGS;
@ -2528,6 +2552,7 @@ XS(boot_NPC) {
newXSproto(strcpy(buf, "SetPetSpellID"), XS_NPC_SetPetSpellID, file, "$$");
newXSproto(strcpy(buf, "GetMaxDamage"), XS_NPC_GetMaxDamage, file, "$$");
newXSproto(strcpy(buf, "SetTaunting"), XS_NPC_SetTaunting, file, "$$");
newXSproto(strcpy(buf, "IsTaunting"), XS_NPC_IsTaunting, file, "$");
newXSproto(strcpy(buf, "PickPocket"), XS_NPC_PickPocket, file, "$$");
newXSproto(strcpy(buf, "StartSwarmTimer"), XS_NPC_StartSwarmTimer, file, "$$");
newXSproto(strcpy(buf, "DoClassAttacks"), XS_NPC_DoClassAttacks, file, "$$");