Core/Spells: Properly send autorepeat cancel packet to self and fix some problems with autoshot (#18918)
Port TrinityCore Commit: https://github.com/TrinityCore/TrinityCore/commit/67000a7826c2f29e5d61272abf3d3d6ea194fc9a
This commit is contained in:
@@ -7453,7 +7453,7 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
CancelAutoRepeat cancelAutoRepeat = new CancelAutoRepeat();
|
CancelAutoRepeat cancelAutoRepeat = new CancelAutoRepeat();
|
||||||
cancelAutoRepeat.Guid = target.GetGUID(); // may be it's target guid
|
cancelAutoRepeat.Guid = target.GetGUID(); // may be it's target guid
|
||||||
SendMessageToSet(cancelAutoRepeat, false);
|
SendMessageToSet(cancelAutoRepeat, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void BuildCreateUpdateBlockForPlayer(UpdateData data, Player target)
|
public override void BuildCreateUpdateBlockForPlayer(UpdateData data, Player target)
|
||||||
|
|||||||
@@ -2788,7 +2788,7 @@ namespace Game.Entities
|
|||||||
Spell spell = m_currentSpells.LookupByKey(spellType);
|
Spell spell = m_currentSpells.LookupByKey(spellType);
|
||||||
if (spell != null
|
if (spell != null
|
||||||
&& (withDelayed || spell.getState() != SpellState.Delayed)
|
&& (withDelayed || spell.getState() != SpellState.Delayed)
|
||||||
&& (withInstant || spell.GetCastTime() > 0))
|
&& (withInstant || spell.GetCastTime() > 0 || spell.getState() == SpellState.Casting))
|
||||||
{
|
{
|
||||||
// for example, do not let self-stun aura interrupt itself
|
// for example, do not let self-stun aura interrupt itself
|
||||||
if (!spell.IsInterruptable())
|
if (!spell.IsInterruptable())
|
||||||
|
|||||||
@@ -1814,20 +1814,22 @@ namespace Game.Entities
|
|||||||
|
|
||||||
void _UpdateAutoRepeatSpell()
|
void _UpdateAutoRepeatSpell()
|
||||||
{
|
{
|
||||||
|
SpellInfo autoRepeatSpellInfo = m_currentSpells[CurrentSpellTypes.AutoRepeat].m_spellInfo;
|
||||||
|
|
||||||
// check "realtime" interrupts
|
// check "realtime" interrupts
|
||||||
// don't cancel spells which are affected by a SPELL_AURA_CAST_WHILE_WALKING effect
|
// don't cancel spells which are affected by a SPELL_AURA_CAST_WHILE_WALKING effect
|
||||||
if (((IsTypeId(TypeId.Player) && ToPlayer().isMoving()) || IsNonMeleeSpellCast(false, false, true, GetCurrentSpell(CurrentSpellTypes.AutoRepeat).m_spellInfo.Id == 75)) &&
|
if (((IsTypeId(TypeId.Player) && ToPlayer().isMoving()) || IsNonMeleeSpellCast(false, false, true, autoRepeatSpellInfo.Id == 75)) &&
|
||||||
!HasAuraTypeWithAffectMask(AuraType.CastWhileWalking, m_currentSpells[CurrentSpellTypes.AutoRepeat].m_spellInfo))
|
!HasAuraTypeWithAffectMask(AuraType.CastWhileWalking, autoRepeatSpellInfo))
|
||||||
{
|
{
|
||||||
// cancel wand shoot
|
// cancel wand shoot
|
||||||
if (m_currentSpells[CurrentSpellTypes.AutoRepeat].m_spellInfo.Id != 75)
|
if (autoRepeatSpellInfo.Id != 75)
|
||||||
InterruptSpell(CurrentSpellTypes.AutoRepeat);
|
InterruptSpell(CurrentSpellTypes.AutoRepeat);
|
||||||
m_AutoRepeatFirstCast = true;
|
m_AutoRepeatFirstCast = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply delay (Auto Shot (spellID 75) not affected)
|
// apply delay (Auto Shot (spellID 75) not affected)
|
||||||
if (m_AutoRepeatFirstCast && getAttackTimer(WeaponAttackType.RangedAttack) < 500 && m_currentSpells[CurrentSpellTypes.AutoRepeat].m_spellInfo.Id != 75)
|
if (m_AutoRepeatFirstCast && getAttackTimer(WeaponAttackType.RangedAttack) < 500 && autoRepeatSpellInfo.Id != 75)
|
||||||
setAttackTimer(WeaponAttackType.RangedAttack, 500);
|
setAttackTimer(WeaponAttackType.RangedAttack, 500);
|
||||||
m_AutoRepeatFirstCast = false;
|
m_AutoRepeatFirstCast = false;
|
||||||
|
|
||||||
@@ -1835,14 +1837,19 @@ namespace Game.Entities
|
|||||||
if (isAttackReady(WeaponAttackType.RangedAttack))
|
if (isAttackReady(WeaponAttackType.RangedAttack))
|
||||||
{
|
{
|
||||||
// Check if able to cast
|
// Check if able to cast
|
||||||
if (m_currentSpells[CurrentSpellTypes.AutoRepeat].CheckCast(true) != SpellCastResult.SpellCastOk)
|
SpellCastResult result = m_currentSpells[CurrentSpellTypes.AutoRepeat].CheckCast(true);
|
||||||
|
if (result != SpellCastResult.SpellCastOk)
|
||||||
{
|
{
|
||||||
InterruptSpell(CurrentSpellTypes.AutoRepeat);
|
if (autoRepeatSpellInfo.Id != 75)
|
||||||
|
InterruptSpell(CurrentSpellTypes.AutoRepeat);
|
||||||
|
else if (GetTypeId() == TypeId.Player)
|
||||||
|
Spell.SendCastResult(ToPlayer(), autoRepeatSpellInfo, m_currentSpells[CurrentSpellTypes.AutoRepeat].m_SpellVisual, m_currentSpells[CurrentSpellTypes.AutoRepeat].m_castId, result);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we want to shoot
|
// we want to shoot
|
||||||
Spell spell = new Spell(this, m_currentSpells[CurrentSpellTypes.AutoRepeat].m_spellInfo, TriggerCastFlags.FullMask);
|
Spell spell = new Spell(this, autoRepeatSpellInfo, TriggerCastFlags.FullMask);
|
||||||
spell.prepare(m_currentSpells[CurrentSpellTypes.AutoRepeat].m_targets);
|
spell.prepare(m_currentSpells[CurrentSpellTypes.AutoRepeat].m_targets);
|
||||||
|
|
||||||
// all went good, reset attack
|
// all went good, reset attack
|
||||||
|
|||||||
Reference in New Issue
Block a user