Advertisement
Guest User

Untitled

a guest
Aug 11th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.12 KB | None | 0 0
  1. diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
  2. index f084fe547d..ba0a3cbdfb 100644
  3. --- a/src/server/game/AI/CreatureAI.cpp
  4. +++ b/src/server/game/AI/CreatureAI.cpp
  5. @@ -309,6 +309,7 @@ bool CreatureAI::_EnterEvadeMode(EvadeReason /*why*/)
  6.      me->SetLastDamagedTime(0);
  7.      me->SetCannotReachTarget(false);
  8.      me->DoNotReacquireSpellFocusTarget();
  9. +    me->SetTarget(ObjectGuid::Empty);
  10.      EngagementOver();
  11.  
  12.      return true;
  13. diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
  14. index b399af92b1..8b97d2c1f4 100644
  15. --- a/src/server/game/Entities/Creature/Creature.cpp
  16. +++ b/src/server/game/Entities/Creature/Creature.cpp
  17. @@ -3036,11 +3036,11 @@ void Creature::SetTarget(ObjectGuid guid)
  18.  
  19.  void Creature::SetSpellFocus(Spell const* focusSpell, WorldObject const* target)
  20.  {
  21. -    // already focused
  22. -    if (_spellFocusInfo.Spell)
  23. +    // Pointer validation and checking for a already existing focus
  24. +    if (_spellFocusInfo.Spell || !focusSpell)
  25.          return;
  26.  
  27. -    // Prevent dead/feigning death creatures from setting a focus target, so they won't turn
  28. +    // Prevent dead / feign death creatures from setting a focus target
  29.      if (!IsAlive() || HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH) || HasAuraType(SPELL_AURA_FEIGN_DEATH))
  30.          return;
  31.  
  32. @@ -3058,7 +3058,8 @@ void Creature::SetSpellFocus(Spell const* focusSpell, WorldObject const* target)
  33.      if (spellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE))
  34.          return;
  35.  
  36. -    if ((!target || target == this) && !focusSpell->GetCastTime()) // instant cast, untargeted (or self-targeted) spell doesn't need any facing updates
  37. +    // instant non-channeled casts and non-target spells don't need facing updates
  38. +    if (!target && (!focusSpell->GetCastTime() && !spellInfo->IsChanneled()))
  39.          return;
  40.  
  41.      // store pre-cast values for target and orientation (used to later restore)
  42. @@ -3174,6 +3175,12 @@ void Creature::ReacquireSpellFocusTarget()
  43.      _spellFocusInfo.Delay = 0;
  44.  }
  45.  
  46. +void Creature::DoNotReacquireSpellFocusTarget()
  47. +{
  48. +    _spellFocusInfo.Delay = 0;
  49. +    _spellFocusInfo.Spell = nullptr;
  50. +}
  51. +
  52.  bool Creature::IsMovementPreventedByCasting() const
  53.  {
  54.      // first check if currently a movement allowed channel is active and we're not casting
  55. diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
  56. index e853044638..fe594332f7 100644
  57. --- a/src/server/game/Entities/Creature/Creature.h
  58. +++ b/src/server/game/Entities/Creature/Creature.h
  59. @@ -341,7 +341,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
  60.  
  61.          // Handling caster facing during spellcast
  62.          void SetTarget(ObjectGuid guid) override;
  63. -        void DoNotReacquireSpellFocusTarget() { _spellFocusInfo.Delay = 0; }
  64. +        void DoNotReacquireSpellFocusTarget();
  65.          void SetSpellFocus(Spell const* focusSpell, WorldObject const* target);
  66.          bool HasSpellFocus(Spell const* focusSpell = nullptr) const override;
  67.          void ReleaseSpellFocus(Spell const* focusSpell = nullptr, bool withDelay = true);
  68. diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
  69. index 5e05fd2f91..4c2f4e8c2d 100644
  70. --- a/src/server/game/Spells/Spell.cpp
  71. +++ b/src/server/game/Spells/Spell.cpp
  72. @@ -4552,10 +4552,10 @@ void Spell::SendChannelStart(uint32 duration)
  73.      {
  74.          unitCaster->SetChannelObjectGuid(channelTarget);
  75.  
  76. -        if (channelTarget != unitCaster->GetGUID())
  77. -            if (Creature* creatureCaster = unitCaster->ToCreature())
  78. -                if (!creatureCaster->HasSpellFocus(this))
  79. -                    creatureCaster->SetSpellFocus(this, ObjectAccessor::GetWorldObject(*creatureCaster, channelTarget));
  80. +        if (Creature* creatureCaster = m_caster->ToCreature())
  81. +            if (!creatureCaster->HasSpellFocus(this))
  82. +                creatureCaster->SetSpellFocus(this,
  83. +                    ObjectAccessor::GetWorldObject(*creatureCaster, channelTarget));
  84.      }
  85.  
  86.      unitCaster->SetUInt32Value(UNIT_CHANNEL_SPELL, m_spellInfo->Id);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement