Core/Creatures: Fixed sparring

Port From (https://github.com/TrinityCore/TrinityCore/commit/e1e53ee06e4b88d2f3804cfa53812e2e14d709a3)
This commit is contained in:
hondacrx
2024-03-04 11:40:40 -05:00
parent f6aaf9df69
commit fecf1c32fa
+4 -4
View File
@@ -402,7 +402,7 @@ namespace Game.Entities
InitializeMovementCapabilities(); InitializeMovementCapabilities();
LoadCreaturesAddon(); LoadCreaturesAddon();
LoadCreaturesSparringHealth(); LoadCreaturesSparringHealth(true);
LoadTemplateImmunities(cInfo.CreatureImmunitiesId); LoadTemplateImmunities(cInfo.CreatureImmunitiesId);
GetThreatManager().EvaluateSuppressed(); GetThreatManager().EvaluateSuppressed();
@@ -866,7 +866,7 @@ namespace Game.Entities
} }
LoadCreaturesAddon(); LoadCreaturesAddon();
LoadCreaturesSparringHealth(); LoadCreaturesSparringHealth(true);
//! Need to be called after LoadCreaturesAddon - MOVEMENTFLAG_HOVER is set there //! Need to be called after LoadCreaturesAddon - MOVEMENTFLAG_HOVER is set there
posZ += GetHoverOffset(); posZ += GetHoverOffset();
@@ -2562,10 +2562,10 @@ namespace Game.Entities
return true; return true;
} }
public void LoadCreaturesSparringHealth() public void LoadCreaturesSparringHealth(bool force = false)
{ {
var templateValues = Global.ObjectMgr.GetCreatureTemplateSparringValues(GetCreatureTemplate().Entry); var templateValues = Global.ObjectMgr.GetCreatureTemplateSparringValues(GetCreatureTemplate().Entry);
if (!templateValues.Empty()) if (force || !templateValues.Empty())
{ {
if (templateValues.Contains(_sparringHealthPct)) // only re-randomize sparring value if it was loaded from template (not when set to custom value from script) if (templateValues.Contains(_sparringHealthPct)) // only re-randomize sparring value if it was loaded from template (not when set to custom value from script)
_sparringHealthPct = templateValues.SelectRandom(); _sparringHealthPct = templateValues.SelectRandom();