diff options
| author | Ovah <dreadkiller@gmx.de> | 2020-09-14 19:47:51 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-02-06 00:29:15 +0100 |
| commit | c295cb9814f4c2a1878aa047cefe0cfbc7958f93 (patch) | |
| tree | 278fa921d1b7f7ae86c9639048351185663446c2 /src/server/game/Entities | |
| parent | 51622e6642e787ee68f8b38ed2382f26ca9f4b8b (diff) | |
Core/Spells: cleaned up and improved spell focusing behavior (PR #25440)
(cherry picked from commit 39a436bd658790d39d3cfa64e18f49544475dfe3)
Diffstat (limited to 'src/server/game/Entities')
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 36 |
1 files changed, 5 insertions, 31 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 8688592fc0b..04f85e9a502 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -3256,41 +3256,15 @@ void Creature::SetSpellFocus(Spell const* focusSpell, WorldObject const* target) _spellFocusInfo.Spell = focusSpell; bool const noTurnDuringCast = spellInfo->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST); + bool const turnDisabled = HasUnitFlag2(UNIT_FLAG2_CANNOT_TURN); // set target, then force send update packet to players if it changed to provide appropriate facing - ObjectGuid newTarget = target ? target->GetGUID() : ObjectGuid::Empty; + ObjectGuid newTarget = (target && !noTurnDuringCast && !turnDisabled) ? target->GetGUID() : ObjectGuid::Empty; if (GetTarget() != newTarget) - { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::Target), newTarget); - if ( // here we determine if the (relatively expensive) forced update is worth it, or whether we can afford to wait until the scheduled update tick - ( // only require instant update for spells that actually have a visual - spellInfo->GetSpellVisual() - ) && ( - !focusSpell->GetCastTime() || // if the spell is instant cast - noTurnDuringCast // client gets confused if we attempt to turn at the regularly scheduled update packet - ) - ) - { - std::vector<Player*> playersNearby; - GetPlayerListInGrid(playersNearby, GetVisibilityRange()); - for (Player* player : playersNearby) - { - // only update players that are known to the client (have already been created) - if (player->HaveAtClient(this)) - SendUpdateToPlayer(player); - } - } - } - - if (!HasUnitFlag2(UNIT_FLAG2_CANNOT_TURN)) - { - // Face the target - we need to do this before the unit state is modified for no-turn spells - if (target) - SetFacingToObject(target, false); - else if (noTurnDuringCast) - if (Unit* victim = GetVictim()) - SetFacingToObject(victim, false); // ensure orientation is correct at beginning of cast - } + // If we are not allowed to turn during cast but have a focus target, face the target + if (!turnDisabled && noTurnDuringCast && target) + SetFacingToObject(target, false); if (noTurnDuringCast) AddUnitState(UNIT_STATE_FOCUSING); |
