[Quest API] Add corpse->GetLootList() and npc->GetLootList() to Perl and Lua. (#1529)

* [Quest API] Add corpse->GetLootList() and npc->GetLootList() to Perl and Lua.
- Add $corpse->GetLootList() to Perl.
- Add $npc->GetLootList() to Perl.
- Add corpse:GetLootList() to Lua.
- Add npc:GetLootList() to Lua.

Returns an array of item IDs for use with corpse and NPC methods such as HasItem(item_id), CountItem(item_id), and GetFirstSlotByItemID(item_id).

* Categories.

* Modify Lua to use classes.
This commit is contained in:
Kinglykrab
2021-09-12 23:38:38 -04:00
committed by GitHub
parent 97dcba70cf
commit 56b9b6f2c4
11 changed files with 148 additions and 8 deletions
+24
View File
@@ -1846,6 +1846,29 @@ XS(XS_NPC_GetSpellScale) {
XSRETURN(1);
}
XS(XS_NPC_GetLootList);
XS(XS_NPC_GetLootList) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: NPC::GetLootList(THIS)"); // @categories Script Utility
{
NPC *THIS;
VALIDATE_THIS_IS_NPC;
auto npc_items = THIS->GetLootList();
auto item_count = npc_items.size();
if (item_count > 0) {
EXTEND(sp, item_count);
for (int index = 0; index < item_count; ++index) {
ST(index) = sv_2mortal(newSVuv(npc_items[index]));
}
XSRETURN(item_count);
}
SV* return_value = &PL_sv_undef;
ST(0) = return_value;
XSRETURN(1);
}
}
#ifdef __cplusplus
extern "C"
#endif
@@ -1970,6 +1993,7 @@ XS(boot_NPC) {
newXSproto(strcpy(buf, "GetFirstSlotByItemID"), XS_NPC_GetFirstSlotByItemID, file, "$$");
newXSproto(strcpy(buf, "GetHealScale"), XS_NPC_GetHealScale, file, "$");
newXSproto(strcpy(buf, "GetSpellScale"), XS_NPC_GetSpellScale, file, "$");
newXSproto(strcpy(buf, "GetLootList"), XS_NPC_GetLootList, file, "$");
XSRETURN_YES;
}