Core/Spells: Fixed logic related to movement while channeling

This commit is contained in:
Aokromes committed 2016-11-27 15:47:21 +01:00
1 parent 16d6690d01
commit 0737ea9b6e
5 files changed
+13 -10

No files matched your search

+8 -5
View File
@@ -3001,16 +3001,19 @@ int32 Unit::GetCurrentSpellCastTime(uint32 spell_id) const
return 0;
}
bool Unit::CanMoveDuringChannel() const
bool Unit::IsMovementPreventedByCasting() const
{
// 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())
if (spell->GetSpellInfo()->IsMoveAllowedChannel())
return false;
}
// prohibit movement for all other spell casts
return true;
}
+1 -1
View File
@@ -1868,7 +1868,7 @@ class TC_GAME_API Unit : public WorldObject
SpellInfo const* GetCastSpellInfo(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 m_spellHistory; }
SpellHistory const* GetSpellHistory() const { return m_spellHistory; }
@@ -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;
@@ -29,7 +29,7 @@
template<>
void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
{
if (creature->HasUnitState(UNIT_STATE_CASTING) && !creature->CanMoveDuringChannel())
if (creature->IsMovementPreventedByCasting())
{
creature->CastStop();
return;
@@ -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();