From c1584da9ccdd6f6a757b2d508d679f908e1ed313 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Sun, 5 Feb 2023 22:52:52 -0500 Subject: [PATCH] [Quest API] Default ScaleNPC to always scale. (#2818) * [Quest API] Default ScaleNPC to always scale. # Notes - ScaleNPC will now always override stats, with the option to override special abilities. * Update npc_scale_manager.h --- zone/lua_npc.cpp | 11 ++------ zone/lua_npc.h | 3 +- zone/npc.cpp | 4 +-- zone/npc.h | 2 +- zone/npc_scale_manager.cpp | 56 +++++++++++++++++++------------------- zone/npc_scale_manager.h | 2 +- zone/perl_npc.cpp | 10 ++----- 7 files changed, 37 insertions(+), 51 deletions(-) diff --git a/zone/lua_npc.cpp b/zone/lua_npc.cpp index 7baec86a5..51e36ad66 100644 --- a/zone/lua_npc.cpp +++ b/zone/lua_npc.cpp @@ -761,16 +761,10 @@ void Lua_NPC::ScaleNPC(uint8 npc_level) self->ScaleNPC(npc_level); } -void Lua_NPC::ScaleNPC(uint8 npc_level, bool always_scale_stats) +void Lua_NPC::ScaleNPC(uint8 npc_level, bool override_special_abilities) { Lua_Safe_Call_Void(); - self->ScaleNPC(npc_level, always_scale_stats); -} - -void Lua_NPC::ScaleNPC(uint8 npc_level, bool always_scale_stats, bool always_scale_special_abilities) -{ - Lua_Safe_Call_Void(); - self->ScaleNPC(npc_level, always_scale_stats, always_scale_special_abilities); + self->ScaleNPC(npc_level, true, override_special_abilities); } luabind::scope lua_register_npc() { @@ -887,7 +881,6 @@ luabind::scope lua_register_npc() { .def("SaveGuardSpot", (void(Lua_NPC::*)(float,float,float,float))&Lua_NPC::SaveGuardSpot) .def("ScaleNPC", (void(Lua_NPC::*)(uint8))&Lua_NPC::ScaleNPC) .def("ScaleNPC", (void(Lua_NPC::*)(uint8,bool))&Lua_NPC::ScaleNPC) - .def("ScaleNPC", (void(Lua_NPC::*)(uint8,bool,bool))&Lua_NPC::ScaleNPC) .def("SendPayload", (void(Lua_NPC::*)(int))&Lua_NPC::SendPayload) .def("SendPayload", (void(Lua_NPC::*)(int,std::string))&Lua_NPC::SendPayload) .def("SetCopper", (void(Lua_NPC::*)(uint32))&Lua_NPC::SetCopper) diff --git a/zone/lua_npc.h b/zone/lua_npc.h index ca8dafb1c..1763a33b3 100644 --- a/zone/lua_npc.h +++ b/zone/lua_npc.h @@ -173,8 +173,7 @@ public: bool IsLDoNTrapDetected(); void SetLDoNTrapDetected(bool is_detected); void ScaleNPC(uint8 npc_level); - void ScaleNPC(uint8 npc_level, bool always_scale_stats); - void ScaleNPC(uint8 npc_level, bool always_scale_stats, bool always_scale_special_abilities); + void ScaleNPC(uint8 npc_level, bool override_special_abilities); }; #endif diff --git a/zone/npc.cpp b/zone/npc.cpp index 979c74752..50ef41376 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -3691,7 +3691,7 @@ void NPC::ReloadSpells() { AI_AddNPCSpellsEffects(GetNPCSpellsEffectsID()); } -void NPC::ScaleNPC(uint8 npc_level, bool always_scale_stats, bool always_scale_special_abilities) { +void NPC::ScaleNPC(uint8 npc_level, bool always_scale, bool override_special_abilities) { if (GetLevel() != npc_level) { SetLevel(npc_level); RecalculateSkills(); @@ -3699,7 +3699,7 @@ void NPC::ScaleNPC(uint8 npc_level, bool always_scale_stats, bool always_scale_s } npc_scale_manager->ResetNPCScaling(this); - npc_scale_manager->ScaleNPC(this, always_scale_stats, always_scale_special_abilities); + npc_scale_manager->ScaleNPC(this, always_scale, override_special_abilities); } bool NPC::IsGuard() diff --git a/zone/npc.h b/zone/npc.h index 35073de55..fc3eb0f0a 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -531,7 +531,7 @@ public: inline bool IsSkipAutoScale() const { return skip_auto_scale; } - void ScaleNPC(uint8 npc_level, bool always_scale_stats = false, bool always_scale_special_abilities = false); + void ScaleNPC(uint8 npc_level, bool always_scale = false, bool override_special_abilities = false); void RecalculateSkills(); void ReloadSpells(); diff --git a/zone/npc_scale_manager.cpp b/zone/npc_scale_manager.cpp index 7224f5fd4..f19b8fe08 100644 --- a/zone/npc_scale_manager.cpp +++ b/zone/npc_scale_manager.cpp @@ -28,8 +28,8 @@ */ void NpcScaleManager::ScaleNPC( NPC *npc, - bool stats_always_scale, - bool special_abilities_always_scale + bool always_scale, + bool override_special_abilities ) { if (npc->IsSkipAutoScale() || npc->GetNPCTypeID() == 0) { @@ -53,84 +53,84 @@ void NpcScaleManager::ScaleNPC( return; } - if (stats_always_scale || (npc->GetAC() == 0 && is_auto_scaled)) { + if (always_scale || (npc->GetAC() == 0 && is_auto_scaled)) { npc->ModifyNPCStat("ac", std::to_string(scale_data.ac)); } - if (stats_always_scale || npc->GetMaxHP() == 0) { + if (always_scale || npc->GetMaxHP() == 0) { npc->ModifyNPCStat("max_hp", std::to_string(scale_data.hp)); npc->Heal(); } - if (stats_always_scale || npc->GetAccuracyRating() == 0) { + if (always_scale || npc->GetAccuracyRating() == 0) { npc->ModifyNPCStat("accuracy", std::to_string(scale_data.accuracy)); } - if (stats_always_scale || npc->GetSlowMitigation() == 0) { + if (always_scale || npc->GetSlowMitigation() == 0) { npc->ModifyNPCStat("slow_mitigation", std::to_string(scale_data.slow_mitigation)); } - if (stats_always_scale || npc->GetATK() == 0) { + if (always_scale || npc->GetATK() == 0) { npc->ModifyNPCStat("atk", std::to_string(scale_data.attack)); } - if (stats_always_scale || npc->GetSTR() == 0) { + if (always_scale || npc->GetSTR() == 0) { npc->ModifyNPCStat("str", std::to_string(scale_data.strength)); } - if (stats_always_scale || npc->GetSTA() == 0) { + if (always_scale || npc->GetSTA() == 0) { npc->ModifyNPCStat("sta", std::to_string(scale_data.stamina)); } - if (stats_always_scale || npc->GetDEX() == 0) { + if (always_scale || npc->GetDEX() == 0) { npc->ModifyNPCStat("dex", std::to_string(scale_data.dexterity)); } - if (stats_always_scale || npc->GetAGI() == 0) { + if (always_scale || npc->GetAGI() == 0) { npc->ModifyNPCStat("agi", std::to_string(scale_data.agility)); } - if (stats_always_scale || npc->GetINT() == 0) { + if (always_scale || npc->GetINT() == 0) { npc->ModifyNPCStat("int", std::to_string(scale_data.intelligence)); } - if (stats_always_scale || npc->GetWIS() == 0) { + if (always_scale || npc->GetWIS() == 0) { npc->ModifyNPCStat("wis", std::to_string(scale_data.wisdom)); } - if (stats_always_scale || npc->GetCHA() == 0) { + if (always_scale || npc->GetCHA() == 0) { npc->ModifyNPCStat("cha", std::to_string(scale_data.charisma)); } - if (stats_always_scale || npc->GetMR() == 0) { + if (always_scale || npc->GetMR() == 0) { npc->ModifyNPCStat("mr", std::to_string(scale_data.magic_resist)); } - if (stats_always_scale || npc->GetCR() == 0) { + if (always_scale || npc->GetCR() == 0) { npc->ModifyNPCStat("cr", std::to_string(scale_data.cold_resist)); } - if (stats_always_scale || npc->GetFR() == 0) { + if (always_scale || npc->GetFR() == 0) { npc->ModifyNPCStat("fr", std::to_string(scale_data.fire_resist)); } - if (stats_always_scale || npc->GetPR() == 0) { + if (always_scale || npc->GetPR() == 0) { npc->ModifyNPCStat("pr", std::to_string(scale_data.poison_resist)); } - if (stats_always_scale || npc->GetDR() == 0) { + if (always_scale || npc->GetDR() == 0) { npc->ModifyNPCStat("dr", std::to_string(scale_data.disease_resist)); } - if (stats_always_scale || (npc->GetCorrup() == 0 && is_auto_scaled)) { + if (always_scale || (npc->GetCorrup() == 0 && is_auto_scaled)) { npc->ModifyNPCStat("cor", std::to_string(scale_data.corruption_resist)); } - if (stats_always_scale || (npc->GetPhR() == 0 && is_auto_scaled)) { + if (always_scale || (npc->GetPhR() == 0 && is_auto_scaled)) { npc->ModifyNPCStat("phr", std::to_string(scale_data.physical_resist)); } - if (stats_always_scale || npc->GetMinDMG() == 0) { + if (always_scale || npc->GetMinDMG() == 0) { int min_dmg = scale_data.min_dmg; if (RuleB(Combat, UseNPCDamageClassLevelMods)) { int32 class_level_damage_mod = GetClassLevelDamageMod(npc->GetLevel(), npc->GetClass()); @@ -142,7 +142,7 @@ void NpcScaleManager::ScaleNPC( npc->ModifyNPCStat("min_hit", std::to_string(min_dmg)); } - if (stats_always_scale || npc->GetMaxDMG() == 0) { + if (always_scale || npc->GetMaxDMG() == 0) { int max_dmg = scale_data.max_dmg; if (RuleB(Combat, UseNPCDamageClassLevelMods)) { int32 class_level_damage_mod = GetClassLevelDamageMod(npc->GetLevel(), npc->GetClass()); @@ -154,23 +154,23 @@ void NpcScaleManager::ScaleNPC( npc->ModifyNPCStat("max_hit", std::to_string(max_dmg)); } - if (stats_always_scale || (npc->GetHPRegen() == 0 && is_auto_scaled)) { + if (always_scale || (npc->GetHPRegen() == 0 && is_auto_scaled)) { npc->ModifyNPCStat("hp_regen", std::to_string(scale_data.hp_regen_rate)); } - if (stats_always_scale || npc->GetAttackDelay() == 0) { + if (always_scale || npc->GetAttackDelay() == 0) { npc->ModifyNPCStat("attack_delay", std::to_string(scale_data.attack_delay)); } - if (stats_always_scale || npc->GetSpellScale() == 0) { + if (always_scale || npc->GetSpellScale() == 0) { npc->ModifyNPCStat("spell_scale", std::to_string(scale_data.spell_scale)); } - if (stats_always_scale || npc->GetHealScale() == 0) { + if (always_scale || npc->GetHealScale() == 0) { npc->ModifyNPCStat("heal_scale", std::to_string(scale_data.heal_scale)); } - if (special_abilities_always_scale || (!npc->HasSpecialAbilities() && is_auto_scaled)) { + if (override_special_abilities || (!npc->HasSpecialAbilities() && is_auto_scaled)) { npc->ModifyNPCStat("special_abilities", scale_data.special_abilities); } diff --git a/zone/npc_scale_manager.h b/zone/npc_scale_manager.h index eae4ca881..0a185bdc2 100644 --- a/zone/npc_scale_manager.h +++ b/zone/npc_scale_manager.h @@ -86,7 +86,7 @@ public: "special_abilities" }; - void ScaleNPC(NPC* npc, bool always_scale_stats = false, bool always_scale_special_abilities = false); + void ScaleNPC(NPC* npc, bool always_scale = false, bool override_special_abilities = false); void ResetNPCScaling(NPC* npc); bool IsAutoScaled(NPC* npc); bool LoadScaleData(); diff --git a/zone/perl_npc.cpp b/zone/perl_npc.cpp index 6f098b7bf..851f5f726 100644 --- a/zone/perl_npc.cpp +++ b/zone/perl_npc.cpp @@ -750,14 +750,9 @@ void Perl_NPC_ScaleNPC(NPC* self, uint8 npc_level) return self->ScaleNPC(npc_level); } -void Perl_NPC_ScaleNPC(NPC* self, uint8 npc_level, bool always_scale_stats) +void Perl_NPC_ScaleNPC(NPC* self, uint8 npc_level, bool override_special_abilities) { - return self->ScaleNPC(npc_level, always_scale_stats); -} - -void Perl_NPC_ScaleNPC(NPC* self, uint8 npc_level, bool always_scale_stats, bool always_scale_special_abilities) -{ - return self->ScaleNPC(npc_level, always_scale_stats, always_scale_special_abilities); + return self->ScaleNPC(npc_level, override_special_abilities); } void perl_register_npc() @@ -884,7 +879,6 @@ void perl_register_npc() package.add("SaveGuardSpot", (void(*)(NPC*, float, float, float, float))&Perl_NPC_SaveGuardSpot); package.add("ScaleNPC", (void(*)(NPC*, uint8))&Perl_NPC_ScaleNPC); package.add("ScaleNPC", (void(*)(NPC*, uint8, bool))&Perl_NPC_ScaleNPC); - package.add("ScaleNPC", (void(*)(NPC*, uint8, bool, bool))&Perl_NPC_ScaleNPC); package.add("SendPayload", (void(*)(NPC*, int))&Perl_NPC_SendPayload); package.add("SendPayload", (void(*)(NPC*, int, std::string))&Perl_NPC_SendPayload); package.add("SetCopper", &Perl_NPC_SetCopper);