From 9a1271805a3c41850fa8759ed5079c667900cf22 Mon Sep 17 00:00:00 2001 From: Kinglykrab Date: Mon, 21 Dec 2015 15:43:56 -0500 Subject: [PATCH] Added GetMeleeMitigation() to Perl and Lua for Mobs (Clients/NPCs). --- changelog.txt | 2 ++ zone/lua_mob.cpp | 8 +++++++- zone/lua_mob.h | 1 + zone/mob.cpp | 8 ++++++++ zone/mob.h | 1 + zone/perl_mob.cpp | 28 ++++++++++++++++++++++++++++ 6 files changed, 47 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 2ce2a68ad..74b6ab113 100644 --- a/changelog.txt +++ b/changelog.txt @@ -6,6 +6,8 @@ Natedog: Updated item table fields and added a few missing fields for evolving i items in your shared bank. (but item field located on items table) -NYI - SkillModMax: Max skill point modification from the percent mods. EX: 100% 2HSlashing (Max 50) - can only increase 2hslash by 50 MAX! (item field located though) +Kinglykrab: Added GetMeleeMitigation() for NPCs and Clients in Perl and Lua. + - This allows you to check total item, spell, and AA melee mitigation contribution. == 12/19/2015 == Kinglykrab: Added many methods to Perl and Lua, list below: diff --git a/zone/lua_mob.cpp b/zone/lua_mob.cpp index 469e8cb2f..46b6b4a9b 100644 --- a/zone/lua_mob.cpp +++ b/zone/lua_mob.cpp @@ -1976,6 +1976,11 @@ bool Lua_Mob::IsAmnesiad() { return self->IsAmnesiad(); } +int32 Lua_Mob::GetMeleeMitigation() { + Lua_Safe_Call_Int(); + return self->GetMeleeMitigation(); +} + luabind::scope lua_register_mob() { return luabind::class_("Mob") .def(luabind::constructor<>()) @@ -2317,7 +2322,8 @@ luabind::scope lua_register_mob() { .def("IsPet", (bool(Lua_Mob::*)(void))&Lua_Mob::IsPet) .def("HasPet", (bool(Lua_Mob::*)(void))&Lua_Mob::HasPet) .def("IsSilenced", (bool(Lua_Mob::*)(void))&Lua_Mob::IsSilenced) - .def("IsAmnesiad", (bool(Lua_Mob::*)(void))&Lua_Mob::IsAmnesiad); + .def("IsAmnesiad", (bool(Lua_Mob::*)(void))&Lua_Mob::IsAmnesiad) + .def("GetMeleeMitigation", (int32(Lua_Mob::*)(void))&Lua_Mob::GetMeleeMitigation); } luabind::scope lua_register_special_abilities() { diff --git a/zone/lua_mob.h b/zone/lua_mob.h index c7530e391..4009ae2fa 100644 --- a/zone/lua_mob.h +++ b/zone/lua_mob.h @@ -377,6 +377,7 @@ public: bool HasPet(); bool IsSilenced(); bool IsAmnesiad(); + int32 GetMeleeMitigation(); }; #endif diff --git a/zone/mob.cpp b/zone/mob.cpp index 6e778f004..e28ccefcc 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -5682,3 +5682,11 @@ void Mob::SetCurrentSpeed(int in){ } } } + +int32 Mob::GetMeleeMitigation() { + int32 mitigation = 0; + mitigation += spellbonuses.MeleeMitigationEffect; + mitigation += itembonuses.MeleeMitigationEffect; + mitigation += aabonuses.MeleeMitigationEffect; + return mitigation; +} \ No newline at end of file diff --git a/zone/mob.h b/zone/mob.h index d02e0f089..8fc7e7f08 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -752,6 +752,7 @@ public: inline bool GetInvul(void) { return invulnerable; } inline void SetExtraHaste(int Haste) { ExtraHaste = Haste; } virtual int GetHaste(); + int32 GetMeleeMitigation(); uint8 GetWeaponDamageBonus(const Item_Struct* weapon, bool offhand = false); uint16 GetDamageTable(SkillUseTypes skillinuse); diff --git a/zone/perl_mob.cpp b/zone/perl_mob.cpp index 2b2442fe6..40077c2c5 100644 --- a/zone/perl_mob.cpp +++ b/zone/perl_mob.cpp @@ -8981,6 +8981,33 @@ XS(XS_Mob_IsAmnesiad) { XSRETURN(1); } +XS(XS_Mob_GetMeleeMitigation); +XS(XS_Mob_GetMeleeMitigation) { + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Mob::GetMeleeMitigation(THIS)"); + { + Mob* THIS; + int32 RETVAL; + dXSTARG; + + if (sv_derived_from(ST(0), "Mob")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(Mob*, tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type Mob"); + + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + RETVAL = THIS->GetMeleeMitigation(); + XSprePUSH; + PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + #ifdef __cplusplus extern "C" #endif @@ -9313,6 +9340,7 @@ XS(boot_Mob) newXSproto(strcpy(buf, "HasPet"), XS_Mob_HasPet, file, "$"); newXSproto(strcpy(buf, "IsSilenced"), XS_Mob_IsSilenced, file, "$"); newXSproto(strcpy(buf, "IsAmnesiad"), XS_Mob_IsAmnesiad, file, "$"); + newXSproto(strcpy(buf, "GetMeleeMitigation"), XS_Mob_GetMeleeMitigation, file, "$"); XSRETURN_YES; }