fix(Core/Spells): Updates autoshoot spell target in case of clientside target change. (#6257)

- Closes #5206
- Closes https://github.com/chromiecraft/chromiecraft/issues/322
This commit is contained in:
UltraNix
2021-06-11 15:30:58 +02:00
committed by GitHub
parent d062f5a233
commit 42019c09b1

View File

@@ -543,6 +543,24 @@ void WorldSession::HandleSetSelectionOpcode(WorldPacket& recv_data)
recv_data >> guid;
_player->SetSelection(guid);
// Change target of current autoshoot spell
if (guid)
{
if (Spell* autoReapeatSpell = _player->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL))
{
if (autoReapeatSpell->m_targets.GetUnitTargetGUID() != guid)
{
if (Unit* unit = ObjectAccessor::GetUnit(*_player, guid))
{
if (unit->IsAlive() && !_player->IsFriendlyTo(unit) && unit->isTargetableForAttack(true, _player))
{
autoReapeatSpell->m_targets.SetUnitTarget(unit);
}
}
}
}
}
}
void WorldSession::HandleStandStateChangeOpcode(WorldPacket& recv_data)