From 31b46efcac53ed2d17d580c06afac9527fec7bfc Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Fri, 26 Sep 2014 06:56:42 -0400 Subject: [PATCH] Clean up of perl based NPC spell scaling functions. Added Perl - $npc->GetSpellFocusDMG(), $npc->GetSpellFocusHeal() --- zone/effects.cpp | 4 ++-- zone/npc.h | 8 +++++++ zone/perl_npc.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/zone/effects.cpp b/zone/effects.cpp index 10748c0e1..7822d2e5e 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -56,7 +56,7 @@ int32 NPC::GetActSpellDamage(uint16 spell_id, int32 value, Mob* target) { value -= target->GetFcDamageAmtIncoming(this, spell_id)/spells[spell_id].buffduration; } - value += dmg*SpellFocusDMG/100; + value += dmg*GetSpellFocusDMG()/100; if (AI_HasSpellsEffects()){ int16 chance = 0; @@ -275,7 +275,7 @@ int32 NPC::GetActSpellHealing(uint16 spell_id, int32 value, Mob* target) { //Scale all NPC spell healing via SetSpellFocusHeal(value) - value += value*SpellFocusHeal/100; + value += value*GetSpellFocusHeal()/100; if (target) { value += target->GetFocusIncoming(focusFcHealAmtIncoming, SE_FcHealAmtIncoming, this, spell_id); diff --git a/zone/npc.h b/zone/npc.h index b23522bee..228ce7cf3 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -387,6 +387,12 @@ public: inline void SetHealScale(float amt) { healscale = amt; } inline float GetHealScale() { return healscale; } + + inline void SetSpellFocusDMG(int32 NewSpellFocusDMG) {SpellFocusDMG = NewSpellFocusDMG;} + inline int32 GetSpellFocusDMG() const { return SpellFocusDMG;} + + inline void SetSpellFocusHeal(int32 NewSpellFocusHeal) {SpellFocusHeal = NewSpellFocusHeal;} + inline int32 GetSpellFocusHeal() const {return SpellFocusHeal;} uint32 GetSpawnKillCount(); int GetScore(); @@ -452,6 +458,8 @@ protected: uint32 npc_mana; float spellscale; float healscale; + int32 SpellFocusDMG; + int32 SpellFocusHeal; //pet crap: uint16 pet_spell_id; diff --git a/zone/perl_npc.cpp b/zone/perl_npc.cpp index dcc66b886..0ea8a5340 100644 --- a/zone/perl_npc.cpp +++ b/zone/perl_npc.cpp @@ -1991,6 +1991,32 @@ XS(XS_NPC_SetSpellFocusDMG) XSRETURN_EMPTY; } +XS(XS_NPC_GetSpellFocusDMG); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NPC_GetSpellFocusDMG) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: NPC::GetSpellFocusDMG(THIS)"); + { + NPC * THIS; + int32 RETVAL; + dXSTARG; + + 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->GetSpellFocusDMG(); + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + XS(XS_NPC_SetSpellFocusHeal); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_SetSpellFocusHeal) { @@ -2015,6 +2041,32 @@ XS(XS_NPC_SetSpellFocusHeal) XSRETURN_EMPTY; } +XS(XS_NPC_GetSpellFocusHeal); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NPC_GetSpellFocusHeal) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: NPC::GetSpellFocusHeal(THIS)"); + { + NPC * THIS; + int32 RETVAL; + dXSTARG; + + 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->GetSpellFocusHeal(); + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + XS(XS_NPC_GetSlowMitigation); /* prototype to pass -Wmissing-prototypes */ XS(XS_NPC_GetSlowMitigation) { @@ -2286,6 +2338,8 @@ XS(boot_NPC) newXSproto(strcpy(buf, "RemoveAISpell"), XS_NPC_RemoveSpellFromNPCList, file, "$$"); newXSproto(strcpy(buf, "SetSpellFocusDMG"), XS_NPC_SetSpellFocusDMG, file, "$$"); newXSproto(strcpy(buf, "SetSpellFocusHeal"), XS_NPC_SetSpellFocusHeal, file, "$$"); + newXSproto(strcpy(buf, "GetSpellFocusDMG"), XS_NPC_GetSpellFocusDMG, file, "$"); + newXSproto(strcpy(buf, "GetSpellFocusHeal"), XS_NPC_GetSpellFocusHeal, file, "$"); newXSproto(strcpy(buf, "GetSlowMitigation"), XS_NPC_GetAttackSpeed, file, "$"); newXSproto(strcpy(buf, "GetAttackSpeed"), XS_NPC_GetSlowMitigation, file, "$"); newXSproto(strcpy(buf, "GetAccuracyRating"), XS_NPC_GetAccuracyRating, file, "$");