Skip to content

Commit

Permalink
Core/Creatures: Reset unit flags/dynamic flags on Creature::SetDeathS…
Browse files Browse the repository at this point in the history
…tate(JUST_RESPAWNED)

(cherry picked from commit 132be2d)
  • Loading branch information
Trisjdc authored and Shauren committed Apr 2, 2016
1 parent 0466de4 commit a51ec98
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/server/game/Entities/Creature/Creature.cpp
Expand Up @@ -1631,10 +1631,26 @@ void Creature::setDeathState(DeathState s)

UpdateMovementFlags();

CreatureTemplate const* cinfo = GetCreatureTemplate();
SetUInt64Value(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();

uint64 npcflag;
uint32 unit_flags, dynamicflags;
ObjectMgr::ChooseCreatureFlags(cinfo, npcflag, unit_flags, dynamicflags, creatureData);

SetUInt64Value(UNIT_NPC_FLAGS, npcflag);
SetUInt32Value(UNIT_FIELD_FLAGS, unit_flags);
SetUInt32Value(OBJECT_DYNAMIC_FLAGS, dynamicflags);

RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);

SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool));
}

Motion_Initialize();
Unit::setDeathState(ALIVE);
LoadCreaturesAddon();
Expand Down Expand Up @@ -2641,12 +2657,12 @@ bool Creature::FocusTarget(Spell const* focusSpell, WorldObject const* target)
SetGuidValue(UNIT_FIELD_TARGET, newTarget);
if (target)
SetFacingToObject(target);

if ( // here we determine if the (relatively expensive) forced update is worth it, or whether we can afford to wait until the scheduled update tick
( // only require instant update for spells that actually have a visual
focusSpell->GetSpellInfo()->SpellVisual[0] ||
focusSpell->GetSpellInfo()->SpellVisual[1]
) && (
) && (
!focusSpell->GetCastTime() || // if the spell is instant cast
focusSpell->GetSpellInfo()->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST) // client gets confused if we attempt to turn at the regularly scheduled update packet
)
Expand Down

0 comments on commit a51ec98

Please sign in to comment.