aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2016-02-02 20:36:39 +0100
committerTreeston <treeston.mmoc@gmail.com>2016-02-02 20:36:39 +0100
commitd5868a7db31a13ac147a66a25cb4c3a6b8a93f8a (patch)
tree5399b81b9f33ce5cbaa6b522049add79ec5e6fa2 /src
parent9d932e7f0c831615474bfc6c54d4027215d2c1b5 (diff)
parent132be2d25a3766c1ef2099fb65ef3cbcdf9705ae (diff)
Merge pull request #16345 from Trisjdc/creature_flag_reset_on_respawn
Core/Creatures: Reset unit flags/dynamic flags on Creature::SetDeathState(JUST_RESPAWNED)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 31320e4d65e..7558929296d 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -1604,13 +1604,29 @@ void Creature::setDeathState(DeathState s)
UpdateMovementFlags();
- CreatureTemplate const* cinfo = GetCreatureTemplate();
- SetUInt32Value(UNIT_NPC_FLAGS, cinfo->npcflag);
ClearUnitState(uint32(UNIT_STATE_ALL_STATE & ~UNIT_STATE_IGNORE_PATHFINDING));
- SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool));
+
+ if (!IsPet())
+ {
+ CreatureData const* creatureData = GetCreatureData();
+ CreatureTemplate const* cinfo = GetCreatureTemplate();
+
+ uint32 npcflag, unit_flags, dynamicflags;
+ ObjectMgr::ChooseCreatureFlags(cinfo, npcflag, unit_flags, dynamicflags, creatureData);
+
+ SetUInt32Value(UNIT_NPC_FLAGS, npcflag);
+ SetUInt32Value(UNIT_FIELD_FLAGS, unit_flags);
+ SetUInt32Value(UNIT_DYNAMIC_FLAGS, dynamicflags);
+
+ RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
+
+ SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool));
+
+ if (creatureData && GetPhaseMask() != creatureData->phaseMask)
+ SetPhaseMask(creatureData->phaseMask, false);
+ }
+
Motion_Initialize();
- if (GetCreatureData() && GetPhaseMask() != GetCreatureData()->phaseMask)
- SetPhaseMask(GetCreatureData()->phaseMask, false);
Unit::setDeathState(ALIVE);
LoadCreaturesAddon();
}