aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorccrs <ccrs@users.noreply.github.com>2017-04-27 19:40:23 +0200
committerfunjoker <funjoker109@gmail.com>2020-04-28 22:42:17 +0200
commita46286a803b41b375ed9352858c742626bb85720 (patch)
treea80fbd3f0561948d00ed01ef1054ce7eb7d21621 /src
parentacdbc681cc64dea536af7a2195a324274868838e (diff)
Core/Unit: revert 3ea46e57af
After discussion we realized, ariel and me, that Creature and Unit IsMovementPreventedByCasting() have not the same checks (order matters) (cherry picked from commit 5a2f0ce29e29d934c200f617fec6dad619fab9a5)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp20
-rw-r--r--src/server/game/Entities/Creature/Creature.h2
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp3
-rw-r--r--src/server/game/Entities/Unit/Unit.h4
4 files changed, 23 insertions, 6 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index ba948d4ede3..c844767b6ba 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -3154,6 +3154,26 @@ void Creature::ReleaseFocus(Spell const* focusSpell, bool withDelay)
m_focusDelay = (!IsPet() && withDelay) ? GameTime::GetGameTimeMS() : 0; // don't allow re-target right away to prevent visual bugs
}
+bool Creature::IsMovementPreventedByCasting() const
+{
+ // first check if currently a movement allowed channel is active and we're not casting
+ if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL])
+ {
+ if (spell->getState() != SPELL_STATE_FINISHED && spell->IsChannelActive())
+ if (spell->GetSpellInfo()->IsMoveAllowedChannel())
+ if (HasUnitState(UNIT_STATE_CASTING))
+ return true;
+ }
+
+ if (const_cast<Creature*>(this)->IsFocusing(nullptr, true))
+ return true;
+
+ if (HasUnitState(UNIT_STATE_CASTING))
+ return true;
+
+ return false;
+}
+
void Creature::StartPickPocketRefillTimer()
{
_pickpocketLootRestore = time(nullptr) + sWorld->getIntConfig(CONFIG_CREATURE_PICKPOCKET_REFILL);
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index b4eaf0e4cfa..cc5608bfc3d 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -331,6 +331,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
bool IsFocusing(Spell const* focusSpell = nullptr, bool withDelay = false) override;
void ReleaseFocus(Spell const* focusSpell = nullptr, bool withDelay = true);
+ bool IsMovementPreventedByCasting() const override;
+
// Part of Evade mechanics
time_t GetLastDamagedTime() const { return _lastDamagedTime; }
void SetLastDamagedTime(time_t val) { _lastDamagedTime = val; }
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index a9eeed7c4e6..df7273a5b2d 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -3134,9 +3134,6 @@ bool Unit::IsMovementPreventedByCasting() const
if (spell->GetSpellInfo()->IsMoveAllowedChannel())
return false;
- if (const_cast<Unit*>(this)->IsFocusing(nullptr, true))
- return false;
-
// prohibit movement for all other spell casts
return true;
}
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 5f4b0f9ac98..7f126fa2c3e 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1660,9 +1660,7 @@ class TC_GAME_API Unit : public WorldObject
uint32 GetCastSpellXSpellVisualId(SpellInfo const* spellInfo) const;
virtual bool IsFocusing(Spell const* /*focusSpell*/ = nullptr, bool /*withDelay*/ = false) { return false; }
-
- // Check if our current channel spell has attribute SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING
- bool IsMovementPreventedByCasting() const;
+ virtual bool IsMovementPreventedByCasting() const;
SpellHistory* GetSpellHistory() { return _spellHistory; }
SpellHistory const* GetSpellHistory() const { return _spellHistory; }