From 305cb9a81a1567759e4e3b3adcc4c6ba0b128df7 Mon Sep 17 00:00:00 2001 From: Shauren Date: Tue, 20 Feb 2024 22:26:29 +0100 Subject: Core/Creatures: Prevent resetting creature sparring health thresholds on evade if it was changed to a custom value by a script --- src/server/game/Entities/Creature/Creature.cpp | 3 ++- src/server/game/Entities/Creature/Creature.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index d99fef678d2..c11fad802bd 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2821,7 +2821,8 @@ bool Creature::LoadCreaturesAddon() void Creature::LoadCreaturesSparringHealth() { if (std::vector const* templateValues = sObjectMgr->GetCreatureTemplateSparringValues(GetCreatureTemplate()->Entry)) - _sparringHealthPct = Trinity::Containers::SelectRandomContainerElement(*templateValues); + 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) + _sparringHealthPct = Trinity::Containers::SelectRandomContainerElement(*templateValues); } /// Send a message to LocalDefense channel for players opposition team in the zone diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 480cf06e148..dfdc30681f5 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -403,6 +403,7 @@ class TC_GAME_API Creature : public Unit, public GridObject, public Ma bool IsThreatFeedbackDisabled() const { return _staticFlags.HasFlag(CREATURE_STATIC_FLAG_3_NO_THREAT_FEEDBACK); } void SetNoThreatFeedback(bool noThreatFeedback) { _staticFlags.ApplyFlag(CREATURE_STATIC_FLAG_3_NO_THREAT_FEEDBACK, noThreatFeedback); } + void OverrideSparringHealthPct(float healthPct) { _sparringHealthPct = healthPct; } void OverrideSparringHealthPct(std::vector const& healthPct); float GetSparringHealthPct() const { return _sparringHealthPct; } uint32 CalculateDamageForSparring(Unit* attacker, uint32 damage); -- cgit v1.2.3