From 26d374d52a113f76f04ca7b9a08dbe321b1b4633 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 10 May 2021 02:05:46 -0400 Subject: [PATCH] [Quest API] Add IsRaidTarget() to Perl and Lua (#1347) - Add $npc->IsRaidTarget() to Perl. - Add npc:IsRaidTarget() to Lua. --- zone/lua_npc.cpp | 9 ++++++++- zone/lua_npc.h | 1 + zone/perl_npc.cpp | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/zone/lua_npc.cpp b/zone/lua_npc.cpp index 32d268fb5..c47870653 100644 --- a/zone/lua_npc.cpp +++ b/zone/lua_npc.cpp @@ -564,6 +564,12 @@ void Lua_NPC::ScaleNPC(uint8 npc_level) self->ScaleNPC(npc_level); } +bool Lua_NPC::IsRaidTarget() +{ + Lua_Safe_Call_Bool(); + return self->IsRaidTarget(); +} + luabind::scope lua_register_npc() { return luabind::class_("NPC") .def(luabind::constructor<>()) @@ -677,7 +683,8 @@ luabind::scope lua_register_npc() { .def("GetRawAC", (int(Lua_NPC::*)(void))&Lua_NPC::GetRawAC) .def("GetAvoidanceRating", &Lua_NPC::GetAvoidanceRating) .def("RecalculateSkills", (void(Lua_NPC::*)(void))&Lua_NPC::RecalculateSkills) - .def("ScaleNPC", (void(Lua_NPC::*)(uint8))&Lua_NPC::ScaleNPC); + .def("ScaleNPC", (void(Lua_NPC::*)(uint8))&Lua_NPC::ScaleNPC) + .def("IsRaidTarget", (bool(Lua_NPC::*)(void))&Lua_NPC::IsRaidTarget); } #endif diff --git a/zone/lua_npc.h b/zone/lua_npc.h index 042a114ef..00c4623cb 100644 --- a/zone/lua_npc.h +++ b/zone/lua_npc.h @@ -137,6 +137,7 @@ public: void SetSimpleRoamBox(float box_size, float move_distance, int move_delay); void RecalculateSkills(); void ScaleNPC(uint8 npc_level); + bool IsRaidTarget(); }; #endif diff --git a/zone/perl_npc.cpp b/zone/perl_npc.cpp index 223207787..99cd83b86 100644 --- a/zone/perl_npc.cpp +++ b/zone/perl_npc.cpp @@ -1725,6 +1725,22 @@ XS(XS_NPC_ScaleNPC) { XSRETURN_EMPTY; } +XS(XS_NPC_IsRaidTarget); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NPC_IsRaidTarget) { + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: NPC::IsRaidTarget(THIS)"); // @categories Stats and Attributes + { + NPC *THIS; + bool is_raid_target; + VALIDATE_THIS_IS_NPC; + is_raid_target = THIS->IsRaidTarget(); + ST(0) = boolSV(is_raid_target); + sv_2mortal(ST(0)); + } + XSRETURN(1); +} + #ifdef __cplusplus extern "C" #endif @@ -1842,6 +1858,7 @@ XS(boot_NPC) { newXSproto(strcpy(buf, "SetSimpleRoamBox"), XS_NPC_SetSimpleRoamBox, file, "$$;$$"); newXSproto(strcpy(buf, "RecalculateSkills"), XS_NPC_RecalculateSkills, file, "$"); newXSproto(strcpy(buf, "ScaleNPC"), XS_NPC_ScaleNPC, file, "$$"); + newXSproto(strcpy(buf, "IsRaidTarget"), XS_NPC_IsRaidTarget, file, "$"); XSRETURN_YES; }