mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Spells: Fixed logic related to movement while channeling
Closes #18289
(cherry picked from commit 90a5811701)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user