Core/Spells: Set UNIT_FIELD_TARGET to current spell cast target for proper facing the target

This commit is contained in:
Shauren
2011-07-15 12:33:03 +02:00
parent 944fb4c1b7
commit 1e3c23a4e8
27 changed files with 125 additions and 96 deletions
@@ -1489,7 +1489,7 @@ void Creature::setDeathState(DeathState s)
if (sWorld->getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY) || isWorldBoss())
SaveRespawnTime();
SetUInt64Value(UNIT_FIELD_TARGET, 0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
SetTarget(0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
setActive(false);
+12 -9
View File
@@ -235,6 +235,9 @@ m_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE), m_HostileRefManager(this)
m_duringRemoveFromWorld = false;
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
_focusSpell = NULL;
_targetLocked = false;
}
////////////////////////////////////////////////////////////
@@ -9579,7 +9582,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
m_attacking->_addAttacker(this);
// Set our target
SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID());
SetTarget(victim->GetGUID());
if (meleeAttack)
AddUnitState(UNIT_STAT_MELEE_ATTACKING);
@@ -9621,7 +9624,7 @@ bool Unit::AttackStop()
m_attacking = NULL;
// Clear our target
SetUInt64Value(UNIT_FIELD_TARGET, 0);
SetTarget(0);
ClearUnitState(UNIT_STAT_MELEE_ATTACKING);
@@ -14334,7 +14337,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag,
// no more charges to use, prevent proc
if (useCharges && !i->aura->GetCharges())
continue;
bool takeCharges = false;
SpellEntry const* spellInfo = i->aura->GetSpellProto();
uint32 Id = i->aura->GetId();
@@ -15729,7 +15732,7 @@ void Unit::SetStunned(bool apply)
{
if (apply)
{
SetUInt64Value(UNIT_FIELD_TARGET, 0);
SetTarget(0);
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
// MOVEMENTFLAG_ROOT cannot be used in conjunction with
@@ -15755,7 +15758,7 @@ void Unit::SetStunned(bool apply)
else
{
if (isAlive() && getVictim())
SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID());
SetTarget(getVictim()->GetGUID());
// don't remove UNIT_FLAG_STUNNED for pet when owner is mounted (disabled pet's interface)
Unit* pOwner = GetOwner();
@@ -15830,7 +15833,7 @@ void Unit::SetFeared(bool apply)
{
if (apply)
{
SetUInt64Value(UNIT_FIELD_TARGET, 0);
SetTarget(0);
Unit* caster = NULL;
Unit::AuraEffectList const& fearAuras = GetAuraEffectsByType(SPELL_AURA_MOD_FEAR);
@@ -15847,7 +15850,7 @@ void Unit::SetFeared(bool apply)
if (GetMotionMaster()->GetCurrentMovementGeneratorType() == FLEEING_MOTION_TYPE)
GetMotionMaster()->MovementExpired();
if (getVictim())
SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID());
SetTarget(getVictim()->GetGUID());
}
}
@@ -15859,7 +15862,7 @@ void Unit::SetConfused(bool apply)
{
if (apply)
{
SetUInt64Value(UNIT_FIELD_TARGET, 0);
SetTarget(0);
GetMotionMaster()->MoveConfused();
}
else
@@ -15869,7 +15872,7 @@ void Unit::SetConfused(bool apply)
if (GetMotionMaster()->GetCurrentMovementGeneratorType() == CONFUSED_MOTION_TYPE)
GetMotionMaster()->MovementExpired();
if (getVictim())
SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID());
SetTarget(getVictim()->GetGUID());
}
}
+34
View File
@@ -2128,6 +2128,37 @@ class Unit : public WorldObject
TempSummon* ToTempSummon() { if (isSummon()) return reinterpret_cast<TempSummon*>(this); else return NULL; }
const TempSummon* ToTempSummon() const { if (isSummon()) return reinterpret_cast<const TempSummon*>(this); else return NULL; }
void SetTarget(uint64 guid)
{
if (!_targetLocked)
SetUInt64Value(UNIT_FIELD_TARGET, guid);
}
void FocusTarget(Spell const* focusSpell, uint64 target)
{
// already focused
if (_focusSpell)
return;
_focusSpell = focusSpell;
_targetLocked = true;
SetUInt64Value(UNIT_FIELD_TARGET, target);
}
void ReleaseFocus(Spell const* focusSpell)
{
// focused to something else
if (focusSpell != _focusSpell)
return;
_focusSpell = NULL;
_targetLocked = false;
if (Unit* victim = getVictim())
SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID());
else
SetUInt64Value(UNIT_FIELD_TARGET, 0);
}
protected:
explicit Unit ();
@@ -2244,6 +2275,9 @@ class Unit : public WorldObject
bool m_cleanupDone; // lock made to not add stuff after cleanup before delete
bool m_duringRemoveFromWorld; // lock made to not add stuff after begining removing from world
Spell const* _focusSpell;
bool _targetLocked; // locks the target during spell cast for proper facing
};
namespace Trinity