From e1e53ee06e4b88d2f3804cfa53812e2e14d709a3 Mon Sep 17 00:00:00 2001 From: Shauren Date: Fri, 1 Mar 2024 18:38:49 +0100 Subject: Core/Creatures: Fixed sparring --- src/server/game/Entities/Creature/Creature.cpp | 8 ++++---- src/server/game/Entities/Creature/Creature.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/server') diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 75512b14b3a..68e3fa69839 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -683,7 +683,7 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/, InitializeMovementCapabilities(); LoadCreaturesAddon(); - LoadCreaturesSparringHealth(); + LoadCreaturesSparringHealth(true); LoadTemplateImmunities(cInfo->CreatureImmunitiesId); GetThreatManager().EvaluateSuppressed(); @@ -1145,7 +1145,7 @@ bool Creature::Create(ObjectGuid::LowType guidlow, Map* map, uint32 entry, Posit } LoadCreaturesAddon(); - LoadCreaturesSparringHealth(); + LoadCreaturesSparringHealth(true); //! Need to be called after LoadCreaturesAddon - MOVEMENTFLAG_HOVER is set there m_positionZ += GetHoverOffset(); @@ -2794,10 +2794,10 @@ bool Creature::LoadCreaturesAddon() return true; } -void Creature::LoadCreaturesSparringHealth() +void Creature::LoadCreaturesSparringHealth(bool force /*= false*/) { if (std::vector const* templateValues = sObjectMgr->GetCreatureTemplateSparringValues(GetCreatureTemplate()->Entry)) - if (std::find(templateValues->begin(), templateValues->end(), _sparringHealthPct) != templateValues->end()) // only re-randomize sparring value if it was loaded from template (not when set to custom value from script) + if (force || std::find(templateValues->begin(), templateValues->end(), _sparringHealthPct) != templateValues->end()) // only re-randomize sparring value if it was loaded from template (not when set to custom value from script) _sparringHealthPct = Trinity::Containers::SelectRandomContainerElement(*templateValues); } diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index ee15cefd924..bb4f7973168 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -88,7 +88,7 @@ class TC_GAME_API Creature : public Unit, public GridObject, public Ma static Creature* CreateCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap = true, bool allowDuplicate = false); bool LoadCreaturesAddon(); - void LoadCreaturesSparringHealth(); + void LoadCreaturesSparringHealth(bool force = false); void SelectLevel(); void UpdateLevelDependantStats(); void SelectWildBattlePetLevel(); -- cgit v1.2.3