[NPC Scaling] Recalculate Skills and Reload Spells on Level Change (#2416)

* [NPC Scaling] Recalculate Skills and Reload Spells on Level Change

- Add $npc->ReloadSpells() to Perl.
- Add npc:ReloadSpells() to Lua.

Previously, you would you have to manually call RecalculateSkills() after you scale the NPC, now the call is built in to the scaling.

Spells did not reload when NPCs were scaled, causing them to continue to use their low/high level spells depending upon which way their level had been scaled, this has been adding to the scaling method. This will make NPCs properly use their level-based spells.

RecalculateSkills() and ReloadSpells() can still be used manually if people scale using something other than the source scaling method. Having this functionality built in to the scaling itself just makes more sense to me. Open to any  ideas or thoughts.

* Reload spell effects, too.
This commit is contained in:
Kinglykrab
2022-09-03 12:06:33 -04:00
committed by GitHub
parent 402d742def
commit 5134a0e43b
5 changed files with 23 additions and 0 deletions
+8
View File
@@ -3643,10 +3643,18 @@ void NPC::RecalculateSkills()
}
}
void NPC::ReloadSpells() {
AI_AddNPCSpells(GetNPCSpellsID());
AI_AddNPCSpellsEffects(GetNPCSpellsEffectsID());
}
void NPC::ScaleNPC(uint8 npc_level) {
if (GetLevel() != npc_level) {
SetLevel(npc_level);
RecalculateSkills();
ReloadSpells();
}
npc_scale_manager->ResetNPCScaling(this);
npc_scale_manager->ScaleNPC(this);
}