diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index a53d70545..57d770907 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -21628,6 +21628,20 @@ bool Unit::IsInDisallowedMountForm() const return false; } +void Unit::SetUInt32Value(uint16 index, uint32 value) +{ + Object::SetUInt32Value(index, value); + + switch (index) + { + // Invalidating the cache on health change should fix an issue where the client sees dead NPCs when they are not. + // We might also need to invalidate the cache for some other fields as well. + case UNIT_FIELD_HEALTH: + InvalidateValuesUpdateCache(); + break; + } +} + std::string Unit::GetDebugInfo() const { std::stringstream sstr; diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 16dc4f605..106a35eed 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1571,6 +1571,8 @@ public: void ApplyAttackTimePercentMod(WeaponAttackType att, float val, bool apply); void ApplyCastTimePercentMod(float val, bool apply); + void SetUInt32Value(uint16 index, uint32 value); + UnitFlags GetUnitFlags() const { return UnitFlags(GetUInt32Value(UNIT_FIELD_FLAGS)); } bool HasUnitFlag(UnitFlags flags) const { return HasFlag(UNIT_FIELD_FLAGS, flags); } void SetUnitFlag(UnitFlags flags) { SetFlag(UNIT_FIELD_FLAGS, flags); }