Core/Spells: Fixed logic related to movement while channeling

Closes #18289

(cherry picked from commit 90a5811701)
This commit is contained in:
Shauren
2016-11-24 20:22:47 +01:00
committed by joschiwald
parent 052422d165
commit 27cdd4b257
5 changed files with 16 additions and 12 deletions

View File

@@ -3018,15 +3018,19 @@ int32 Unit::GetCurrentSpellCastTime(uint32 spell_id) const
return 0;
}
bool Unit::CanMoveDuringChannel() const
bool Unit::IsMovementPreventedByCasting() const
{
if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL])
{
if (spell->getState() != SPELL_STATE_FINISHED && spell->IsChannelActive())
if (!spell->GetSpellInfo()->IsMoveAllowedChannel())
return false;
}
// can always move when not casting
if (!HasUnitState(UNIT_STATE_CASTING))
return false;
// channeled spells during channel stage (after the initial cast timer) allow movement with a specific spell attribute
if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL])
if (spell->getState() != SPELL_STATE_FINISHED && spell->IsChannelActive())
if (spell->GetSpellInfo()->IsMoveAllowedChannel())
return false;
// prohibit movement for all other spell casts
return true;
}

View File

@@ -1556,7 +1556,7 @@ class TC_GAME_API Unit : public WorldObject
uint32 GetCastSpellXSpellVisualId(SpellInfo const* spellInfo) const;
// Check if our current channel spell has attribute SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING
bool CanMoveDuringChannel() const;
bool IsMovementPreventedByCasting() const;
SpellHistory* GetSpellHistory() { return _spellHistory; }
SpellHistory const* GetSpellHistory() const { return _spellHistory; }

View File

@@ -38,7 +38,7 @@ void FleeingMovementGenerator<T>::_setTargetLocation(T* owner)
if (owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED))
return;
if (owner->HasUnitState(UNIT_STATE_CASTING) && !owner->CanMoveDuringChannel())
if (owner->IsMovementPreventedByCasting())
{
owner->CastStop();
return;

View File

@@ -30,7 +30,7 @@
template<>
void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
{
if (creature->HasUnitState(UNIT_STATE_CASTING) && !creature->CanMoveDuringChannel())
if (creature->IsMovementPreventedByCasting())
{
creature->CastStop();
return;

View File

@@ -36,7 +36,7 @@ void TargetedMovementGeneratorMedium<T, D>::_setTargetLocation(T* owner, bool up
if (owner->HasUnitState(UNIT_STATE_NOT_MOVE))
return;
if (owner->HasUnitState(UNIT_STATE_CASTING) && !owner->CanMoveDuringChannel())
if (owner->IsMovementPreventedByCasting())
return;
if (owner->GetTypeId() == TYPEID_UNIT && !i_target->isInAccessiblePlaceFor(owner->ToCreature()))
@@ -149,7 +149,7 @@ bool TargetedMovementGeneratorMedium<T, D>::DoUpdate(T* owner, uint32 time_diff)
}
// prevent movement while casting spells with cast time or channel time
if (owner->HasUnitState(UNIT_STATE_CASTING) && !owner->CanMoveDuringChannel())
if (owner->IsMovementPreventedByCasting())
{
if (!owner->IsStopped())
owner->StopMoving();