Core/Spells: Set UNIT_FIELD_TARGET to current spell cast target for proper facing the target
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -85,7 +85,7 @@ ConfusedMovementGenerator<T>::Initialize(T &unit)
|
||||
}
|
||||
}
|
||||
|
||||
unit.SetUInt64Value(UNIT_FIELD_TARGET, 0);
|
||||
unit.SetTarget(0);
|
||||
unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
|
||||
unit.CastStop();
|
||||
unit.StopMoving();
|
||||
@@ -170,7 +170,7 @@ ConfusedMovementGenerator<T>::Finalize(T &unit)
|
||||
unit.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
|
||||
unit.ClearUnitState(UNIT_STAT_CONFUSED);
|
||||
if (unit.GetTypeId() == TYPEID_UNIT && unit.getVictim())
|
||||
unit.SetUInt64Value(UNIT_FIELD_TARGET, unit.getVictim()->GetGUID());
|
||||
unit.SetTarget(unit.getVictim()->GetGUID());
|
||||
}
|
||||
|
||||
template void ConfusedMovementGenerator<Player>::Initialize(Player &player);
|
||||
|
||||
@@ -304,7 +304,7 @@ FleeingMovementGenerator<T>::Initialize(T &owner)
|
||||
owner.CastStop();
|
||||
owner.AddUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING);
|
||||
owner.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
|
||||
owner.SetUInt64Value(UNIT_FIELD_TARGET, 0);
|
||||
owner.SetTarget(0);
|
||||
owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
|
||||
if (Unit* fright = ObjectAccessor::GetUnit(owner, i_frightGUID))
|
||||
@@ -353,7 +353,7 @@ FleeingMovementGenerator<T>::Finalize(T &owner)
|
||||
owner.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
|
||||
owner.ClearUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING);
|
||||
if (owner.GetTypeId() == TYPEID_UNIT && owner.getVictim())
|
||||
owner.SetUInt64Value(UNIT_FIELD_TARGET, owner.getVictim()->GetGUID());
|
||||
owner.SetTarget(owner.getVictim()->GetGUID());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
||||
@@ -489,22 +489,6 @@ void WorldSession::HandleZoneUpdateOpcode(WorldPacket & recv_data)
|
||||
//GetPlayer()->SendInitWorldStates(true, newZone);
|
||||
}
|
||||
|
||||
void WorldSession::HandleSetTargetOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
uint64 guid;
|
||||
recv_data >> guid;
|
||||
|
||||
_player->SetUInt32Value(UNIT_FIELD_TARGET, uint32(guid));
|
||||
|
||||
// update reputation list if need
|
||||
Unit* unit = ObjectAccessor::GetUnit(*_player, guid);
|
||||
if (!unit)
|
||||
return;
|
||||
|
||||
if (FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->getFaction()))
|
||||
_player->GetReputationMgr().SetVisible(factionTemplateEntry);
|
||||
}
|
||||
|
||||
void WorldSession::HandleSetSelectionOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
uint64 guid;
|
||||
|
||||
@@ -326,7 +326,7 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket & recv_data)
|
||||
sLog->outDetail("WORLD: CMSG_NPC_TEXT_QUERY ID '%u'", textID);
|
||||
|
||||
recv_data >> guid;
|
||||
GetPlayer()->SetUInt64Value(UNIT_FIELD_TARGET, guid);
|
||||
GetPlayer()->SetSelection(guid);
|
||||
|
||||
GossipText const* pGossip = sObjectMgr->GetGossipText(textID);
|
||||
|
||||
|
||||
@@ -467,7 +467,6 @@ class WorldSession
|
||||
void HandleTogglePvP(WorldPacket& recvPacket);
|
||||
|
||||
void HandleZoneUpdateOpcode(WorldPacket& recvPacket);
|
||||
void HandleSetTargetOpcode(WorldPacket& recvPacket);
|
||||
void HandleSetSelectionOpcode(WorldPacket& recvPacket);
|
||||
void HandleStandStateChangeOpcode(WorldPacket& recvPacket);
|
||||
void HandleEmoteOpcode(WorldPacket& recvPacket);
|
||||
|
||||
@@ -528,7 +528,7 @@ m_caster(Caster), m_spellValue(new SpellValue(m_spellInfo))
|
||||
|
||||
// Determine if spell can be reflected back to the caster
|
||||
// Patch 1.2 notes: Spell Reflection no longer reflects abilities
|
||||
m_canReflect = m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && !(m_spellInfo->Attributes & SPELL_ATTR0_ABILITY)
|
||||
m_canReflect = m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && !(m_spellInfo->Attributes & SPELL_ATTR0_ABILITY)
|
||||
&& !(m_spellInfo->AttributesEx & SPELL_ATTR1_CANT_BE_REFLECTED) && !(m_spellInfo->Attributes & SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY)
|
||||
&& !IsPassiveSpell(m_spellInfo) && !IsPositiveSpell(m_spellInfo->Id);
|
||||
|
||||
@@ -2944,6 +2944,12 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
|
||||
m_caster->SetCurrentCastedSpell(this);
|
||||
SendSpellStart();
|
||||
|
||||
// set target for proper facing
|
||||
if (m_casttime && !m_IsTriggeredSpell)
|
||||
if (uint64 target = m_targets.GetUnitTargetGUID())
|
||||
if (m_caster->GetGUID() != target && m_caster->GetTypeId() == TYPEID_UNIT)
|
||||
m_caster->FocusTarget(this, target);
|
||||
|
||||
TriggerGlobalCooldown();
|
||||
|
||||
//item: first cast may destroy item and second cast causes crash
|
||||
@@ -3578,6 +3584,9 @@ void Spell::finish(bool ok)
|
||||
((Puppet*)charm)->UnSummon();
|
||||
}
|
||||
|
||||
if (m_caster->GetTypeId() == TYPEID_UNIT)
|
||||
m_caster->ReleaseFocus(this);
|
||||
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user