Core/Spells: Creature spellcast facing rework:

- Fixes creatures turning just before a spellcast finishes and smacking players with supposedly-unavoidable damage. Fixes and closes #15393, #10803, and probably others.
- Fixes visual effects not lining up with the correct target for spells that have their visual aligned with the caster's orientation (examples: Anub'rekhan Impale, Ingvar's Smash/Dark Smash, etc.). Fixes and closes #2947 and probably a bunch of others, including the aforementioned #15393 and #10803.
- Creatures' displayed target now properly matches the unit they are targeting with spells for a split second (blizzlike). This is necessary to get proper client-side orientation.
This commit is contained in:
treeston committed 2016-01-13 18:35:44 +01:00
1 parent 1d9d03b289
commit f481ae1048
8 files changed
+179 -38

No files matched your search

+17 -6
View File
@@ -223,7 +223,8 @@ Unit::Unit(bool isWorldObject) :
for (uint8 i = 0; i < MAX_STATS; ++i)
m_createStats[i] = 0.0f;
m_attacking = NULL;
m_attacking = nullptr;
m_shouldReacquireTarget = false;
m_modMeleeHitChance = 0.0f;
m_modRangedHitChance = 0.0f;
m_modSpellHitChance = 0.0f;
@@ -238,7 +239,7 @@ Unit::Unit(bool isWorldObject) :
for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
m_speed_rate[i] = 1.0f;
m_charmInfo = NULL;
m_charmInfo = nullptr;
_redirectThreadInfo = RedirectThreatInfo();
@@ -1956,6 +1957,9 @@ void Unit::AttackerStateUpdate (Unit* victim, WeaponAttackType attType, bool ext
if (attType != BASE_ATTACK && attType != OFF_ATTACK)
return; // ignore ranged case
if (GetTypeId() == TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
SetFacingToObject(victim); // update client side facing to face the target (prevents visual glitches when casting untargeted spells)
// melee attack spell cast at main hand attack only - no normal melee dmg dealt
if (attType == BASE_ATTACK && m_currentSpells[CURRENT_MELEE_SPELL] && !extra)
m_currentSpells[CURRENT_MELEE_SPELL]->cast();
@@ -8956,6 +8960,12 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
if (HasAuraType(SPELL_AURA_MOD_UNATTACKABLE))
RemoveAurasByType(SPELL_AURA_MOD_UNATTACKABLE);
if (m_shouldReacquireTarget)
{
SetTarget(victim->GetGUID());
m_shouldReacquireTarget = false;
}
if (m_attacking)
{
if (m_attacking == victim)
@@ -9041,7 +9051,7 @@ bool Unit::AttackStop()
Unit* victim = m_attacking;
m_attacking->_removeAttacker(this);
m_attacking = NULL;
m_attacking = nullptr;
// Clear our target
SetTarget(ObjectGuid::Empty);
@@ -12705,7 +12715,7 @@ Unit* Creature::SelectVictim()
// next-victim-selection algorithm and evade mode are called
// threat list sorting etc.
Unit* target = NULL;
Unit* target = nullptr;
// First checking if we have some taunt on us
AuraEffectList const& tauntAuras = GetAuraEffectsByType(SPELL_AURA_MOD_TAUNT);
if (!tauntAuras.empty())
@@ -12773,7 +12783,8 @@ Unit* Creature::SelectVictim()
if (target && _IsTargetAcceptable(target) && CanCreatureAttack(target))
{
SetInFront(target);
if(!IsFocusing())
SetInFront(target);
return target;
}
@@ -17558,7 +17569,7 @@ void Unit::SetFacingTo(float ori)
init.Launch();
}
void Unit::SetFacingToObject(WorldObject* object)
void Unit::SetFacingToObject(WorldObject const* object)
{
// never face when already moving
if (!IsStopped())