aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp4
-rw-r--r--src/server/game/Entities/Unit/Unit.h2
-rw-r--r--src/server/game/Spells/Spell.cpp21
-rw-r--r--src/server/game/Spells/Spell.h4
-rw-r--r--src/server/game/Spells/SpellEffects.cpp2
5 files changed, 17 insertions, 16 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index d412b619be7..94cdf8c3118 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -3015,7 +3015,7 @@ void Unit::SetCurrentCastSpell(Spell* pSpell)
pSpell->m_selfContainer = &(m_currentSpells[pSpell->GetCurrentContainer()]);
}
-void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool withInstant)
+void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool withInstant, SpellCastResult result, Optional<SpellCastResult> resultOther /*= {}*/)
{
//TC_LOG_DEBUG("entities.unit", "Interrupt spell for unit {}.", GetEntry());
Spell* spell = m_currentSpells[spellType];
@@ -3033,7 +3033,7 @@ void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool wi
ToPlayer()->SendAutoRepeatCancel(this);
if (spell->getState() != SPELL_STATE_FINISHED)
- spell->cancel();
+ spell->cancel(result, resultOther);
else
{
m_currentSpells[spellType] = nullptr;
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 970d55a274a..a969ee0214f 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1460,7 +1460,7 @@ class TC_GAME_API Unit : public WorldObject
void SetChannelObjectGuid(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, guid); }
void SetCurrentCastSpell(Spell* pSpell);
- void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed = true, bool withInstant = true);
+ void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed = true, bool withInstant = true, SpellCastResult result = SPELL_FAILED_INTERRUPTED, Optional<SpellCastResult> resultOther = {});
void FinishSpell(CurrentSpellTypes spellType, bool ok = true);
// set withDelayed to true to account delayed spells as cast
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 208da4685c2..24e70e7aff7 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -3234,7 +3234,7 @@ SpellCastResult Spell::prepare(SpellCastTargets const& targets, AuraEffect const
return SPELL_CAST_OK;
}
-void Spell::cancel()
+void Spell::cancel(SpellCastResult result /*= SPELL_FAILED_INTERRUPTED*/, Optional<SpellCastResult> resultOther /*= {}*/)
{
if (m_spellState == SPELL_STATE_FINISHED)
return;
@@ -3247,10 +3247,11 @@ void Spell::cancel()
{
case SPELL_STATE_PREPARING:
CancelGlobalCooldown();
- SendCastResult(SPELL_FAILED_INTERRUPTED);
+ SendCastResult(result);
+ SendInterrupted(result, resultOther);
break;
case SPELL_STATE_DELAYED:
- SendInterrupted(SPELL_FAILED_INTERRUPTED);
+ SendInterrupted(result, resultOther);
break;
case SPELL_STATE_CASTING:
for (TargetInfo const& targetInfo : m_UniqueTargetInfo)
@@ -3259,7 +3260,7 @@ void Spell::cancel()
unit->RemoveOwnedAura(m_spellInfo->Id, m_originalCasterGUID, 0, AURA_REMOVE_BY_CANCEL);
SendChannelUpdate(0);
- SendInterrupted(SPELL_FAILED_INTERRUPTED);
+ SendInterrupted(result, resultOther);
m_appliedMods.clear();
break;
@@ -3355,7 +3356,7 @@ void Spell::_cast(bool skipCheck)
auto cleanupSpell = [this, modOwner](SpellCastResult res, uint32* p1 = nullptr, uint32* p2 = nullptr)
{
SendCastResult(res, p1, p2);
- SendInterrupted(0);
+ SendInterrupted(res);
if (modOwner)
modOwner->SetSpellModTakingSpell(this, false);
@@ -3431,7 +3432,7 @@ void Spell::_cast(bool skipCheck)
// Spell may be finished after target map check
if (m_spellState == SPELL_STATE_FINISHED)
{
- SendInterrupted(0);
+ SendInterrupted(SPELL_FAILED_DONT_REPORT);
if (modOwner)
modOwner->SetSpellModTakingSpell(this, false);
@@ -4618,20 +4619,20 @@ void Spell::ExecuteLogEffectResurrect(uint8 effIndex, Unit* target)
*m_effectExecuteData[effIndex] << target->GetPackGUID();
}
-void Spell::SendInterrupted(uint8 result)
+void Spell::SendInterrupted(SpellCastResult result, Optional<SpellCastResult> resultOther /*= {}*/)
{
- WorldPacket data(SMSG_SPELL_FAILURE, (8+4+1));
+ WorldPacket data(SMSG_SPELL_FAILURE, 8 + 1 + 4 + 1);
data << m_caster->GetPackGUID();
data << uint8(m_cast_count);
data << uint32(m_spellInfo->Id);
data << uint8(result);
m_caster->SendMessageToSet(&data, true);
- data.Initialize(SMSG_SPELL_FAILED_OTHER, (8+4));
+ data.Initialize(SMSG_SPELL_FAILED_OTHER, 8 + 1 + 4 + 1);
data << m_caster->GetPackGUID();
data << uint8(m_cast_count);
data << uint32(m_spellInfo->Id);
- data << uint8(result);
+ data << uint8(resultOther.value_or(result));
m_caster->SendMessageToSet(&data, true);
}
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index 29b5fb3b105..23b73deddeb 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -312,7 +312,7 @@ class TC_GAME_API Spell
GameObject* SearchSpellFocus();
SpellCastResult prepare(SpellCastTargets const& targets, AuraEffect const* triggeredByAura = nullptr);
- void cancel();
+ void cancel(SpellCastResult result = SPELL_FAILED_INTERRUPTED, Optional<SpellCastResult> resultOther = {});
void update(uint32 difftime);
void cast(bool skipCheck = false);
void finish(bool ok = true);
@@ -383,7 +383,7 @@ class TC_GAME_API Spell
void ExecuteLogEffectSummonObject(uint8 effIndex, WorldObject* obj);
void ExecuteLogEffectUnsummonObject(uint8 effIndex, WorldObject* obj);
void ExecuteLogEffectResurrect(uint8 effIndex, Unit* target);
- void SendInterrupted(uint8 result);
+ void SendInterrupted(SpellCastResult result, Optional<SpellCastResult> resultOther = {});
void SendChannelUpdate(uint32 time);
void SendChannelStart(uint32 duration);
void SendResurrectRequest(Player* target);
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 51c729a37a2..be1fefa8a51 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -3360,7 +3360,7 @@ void Spell::EffectInterruptCast()
PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_HIT, PROC_HIT_INTERRUPT, nullptr, nullptr, nullptr);
}
ExecuteLogEffectInterruptCast(effectInfo->EffectIndex, unitTarget, curSpellInfo->Id);
- unitTarget->InterruptSpell(CurrentSpellTypes(i), false);
+ unitTarget->InterruptSpell(CurrentSpellTypes(i), false, false, SPELL_FAILED_INTERRUPTED_COMBAT, SPELL_FAILED_DONT_REPORT);
}
}
}