[Quest API] Add GetHealScale() and GetSpellScale() to Perl and Lua. (#1515)

This commit is contained in:
Kinglykrab 2021-09-03 20:47:33 -04:00 committed by GitHub
parent e1df72d64d
commit 119018cf41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 1 deletions

View File

@ -606,6 +606,18 @@ uint16 Lua_NPC::GetFirstSlotByItemID(uint32 item_id)
return self->GetFirstSlotByItemID(item_id);
}
float Lua_NPC::GetHealScale()
{
Lua_Safe_Call_Real();
return self->GetHealScale();
}
float Lua_NPC::GetSpellScale()
{
Lua_Safe_Call_Real();
return self->GetSpellScale();
}
luabind::scope lua_register_npc() {
return luabind::class_<Lua_NPC, Lua_Mob>("NPC")
.def(luabind::constructor<>())
@ -726,7 +738,9 @@ luabind::scope lua_register_npc() {
.def("HasItem", (bool(Lua_NPC::*)(uint32))&Lua_NPC::HasItem)
.def("CountItem", (uint16(Lua_NPC::*)(uint32))&Lua_NPC::CountItem)
.def("GetItemIDBySlot", (uint32(Lua_NPC::*)(uint16))&Lua_NPC::GetItemIDBySlot)
.def("GetFirstSlotByItemID", (uint16(Lua_NPC::*)(uint32))&Lua_NPC::GetFirstSlotByItemID);
.def("GetFirstSlotByItemID", (uint16(Lua_NPC::*)(uint32))&Lua_NPC::GetFirstSlotByItemID)
.def("GetHealScale", (float(Lua_NPC::*)(void))&Lua_NPC::GetHealScale)
.def("GetSpellScale", (float(Lua_NPC::*)(void))&Lua_NPC::GetSpellScale);
}
#endif

View File

@ -144,6 +144,8 @@ public:
uint16 CountItem(uint32 item_id);
uint32 GetItemIDBySlot(uint16 slot_id);
uint16 GetFirstSlotByItemID(uint32 item_id);
float GetHealScale();
float GetSpellScale();
};
#endif

View File

@ -1812,6 +1812,40 @@ XS(XS_NPC_GetFirstSlotByItemID) {
XSRETURN(1);
}
XS(XS_NPC_GetHealScale);
XS(XS_NPC_GetHealScale) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: NPC::GetHealScale(THIS)"); // @categories Stats and Attributes
{
NPC *THIS;
float healscale;
dXSTARG;
VALIDATE_THIS_IS_NPC;
healscale = THIS->GetHealScale();
XSprePUSH;
PUSHn((double) healscale);
}
XSRETURN(1);
}
XS(XS_NPC_GetSpellScale);
XS(XS_NPC_GetSpellScale) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: NPC::GetSpellScale(THIS)"); // @categories Stats and Attributes
{
NPC *THIS;
float spellscale;
dXSTARG;
VALIDATE_THIS_IS_NPC;
spellscale = THIS->GetSpellScale();
XSprePUSH;
PUSHn((double) spellscale);
}
XSRETURN(1);
}
#ifdef __cplusplus
extern "C"
#endif
@ -1934,6 +1968,8 @@ XS(boot_NPC) {
newXSproto(strcpy(buf, "CountItem"), XS_NPC_CountItem, file, "$$");
newXSproto(strcpy(buf, "GetItemIDBySlot"), XS_NPC_GetItemIDBySlot, file, "$$");
newXSproto(strcpy(buf, "GetFirstSlotByItemID"), XS_NPC_GetFirstSlotByItemID, file, "$$");
newXSproto(strcpy(buf, "GetHealScale"), XS_NPC_GetHealScale, file, "$");
newXSproto(strcpy(buf, "GetSpellScale"), XS_NPC_GetSpellScale, file, "$");
XSRETURN_YES;
}