diff options
author | Shauren <shauren.trinity@gmail.com> | 2023-03-12 13:20:25 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2023-03-12 13:20:25 +0100 |
commit | 91e7401e64dcc2883f7a42c5e382f901c58b9d00 (patch) | |
tree | ab9a7b842367495d8eb1bfc5c9d9203541e20c42 | |
parent | ebf799c0f696ec88be66795d4ad0a20fa5ce5e92 (diff) |
Core/Creatures: Allow turning off experience gain from creatures by scripts
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 10 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 1 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 3314996c539..423d4ae2ec7 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -579,6 +579,11 @@ bool Creature::InitEntry(uint32 entry, CreatureData const* data /*= nullptr*/) for (uint8 i = 0; i < MAX_CREATURE_SPELLS; ++i) m_spells[i] = GetCreatureTemplate()->spells[i]; + _staticFlags.ApplyFlag(CREATURE_STATIC_FLAG_NO_XP, cinfo->type == CREATURE_TYPE_CRITTER + || IsPet() + || IsTotem() + || cinfo->flags_extra & CREATURE_FLAG_EXTRA_NO_XP); + return true; } @@ -3431,10 +3436,7 @@ void Creature::ClearTextRepeatGroup(uint8 textGroup) bool Creature::CanGiveExperience() const { - return !IsCritter() - && !IsPet() - && !IsTotem() - && !(GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP); + return !_staticFlags.HasFlag(CREATURE_STATIC_FLAG_NO_XP); } bool Creature::IsEngaged() const diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index af4c4b4517d..f71a6e07e81 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -379,6 +379,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma bool IsEscorted() const; bool CanGiveExperience() const; + void SetCanGiveExperience(bool xpEnabled) { _staticFlags.ApplyFlag(CREATURE_STATIC_FLAG_NO_XP, !xpEnabled); } bool IsEngaged() const override; void AtEngage(Unit* target) override; |