Skip to content

Commit

Permalink
Implement SPELL_ATTR_EX4_TRIGGERD, this allows you to cast WE's Freez…
Browse files Browse the repository at this point in the history
…e without cancelling its Waterbolt. Thanks to dr.tenma!

Signed-off-by: lovelol <tifxoxo@web.de>
  • Loading branch information
lovelol authored and Phatcat committed Aug 11, 2016
1 parent 912d8c8 commit 8f4738e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/game/SharedDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ enum SpellAttributesEx4
SPELL_ATTR_EX4_UNK4 = 0x00000010,// 4 This will no longer cause guards to attack on use??
SPELL_ATTR_EX4_UNK5 = 0x00000020,// 5
SPELL_ATTR_EX4_NOT_STEALABLE = 0x00000040,// 6 although such auras might be dispellable, they cannot be stolen
SPELL_ATTR_EX4_UNK7 = 0x00000080,// 7
SPELL_ATTR_EX4_TRIGGERED = 0x00000080,// 7 spells forced to be triggered
SPELL_ATTR_EX4_STACK_DOT_MODIFIER = 0x00000100,// 8 no effect on non DoTs?
SPELL_ATTR_EX4_UNK9 = 0x00000200,// 9
SPELL_ATTR_EX4_SPELL_VS_EXTEND_COST = 0x00000400,// 10 Rogue Shiv have this flag
Expand Down
27 changes: 16 additions & 11 deletions src/game/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,9 @@ Spell::Spell(Unit* caster, SpellEntry const* info, bool triggered, ObjectGuid or
m_castPositionX = m_castPositionY = m_castPositionZ = 0;
m_TriggerSpells.clear();
m_preCastSpells.clear();
m_IsTriggeredSpell = triggered;
m_IsTriggeredSpell = bool(triggered || info->HasAttribute(SPELL_ATTR_EX4_TRIGGERED));
// m_AreaAura = false;
m_CastItem = nullptr;

unitTarget = nullptr;
itemTarget = nullptr;
gameObjTarget = nullptr;
Expand Down Expand Up @@ -5194,6 +5193,12 @@ SpellCastResult Spell::CheckCast(bool strict)
SpellCastResult castResult = CheckItems();
if (castResult != SPELL_CAST_OK)
return castResult;

// Triggered spells also have range check
// TODO: determine if there is some flag to enable/disable the check
castResult = CheckRange(strict);
if (castResult != SPELL_CAST_OK)
return castResult;
}

// check spell focus object
Expand Down Expand Up @@ -5471,7 +5476,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// spell different for friends and enemies
// hart version required facing
if (m_targets.getUnitTarget() && !m_caster->IsFriendlyTo(m_targets.getUnitTarget()) && !m_caster->HasInArc(M_PI_F, m_targets.getUnitTarget()))
return SPELL_FAILED_UNIT_NOT_INFRONT;
return !m_IsTriggeredSpell ? SPELL_FAILED_UNIT_NOT_INFRONT : SPELL_FAILED_DONT_REPORT;
}
// Fire Nova
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_SHAMAN && m_spellInfo->SpellIconID == 33)
Expand Down Expand Up @@ -6155,7 +6160,7 @@ SpellCastResult Spell::CheckPetCast(Unit* target)
if (!m_caster->isAlive())
return SPELL_FAILED_CASTER_DEAD;

if (m_caster->IsNonMeleeSpellCasted(false)) // prevent spellcast interruption by another spellcast
if (!m_spellInfo->HasAttribute(SPELL_ATTR_EX4_TRIGGERED) && m_caster->IsNonMeleeSpellCasted(false)) //prevent spellcast interruption by another spellcast
return SPELL_FAILED_SPELL_IN_PROGRESS;
if (m_caster->isInCombat() && IsNonCombatSpell(m_spellInfo))
return SPELL_FAILED_AFFECTING_COMBAT;
Expand Down Expand Up @@ -6476,21 +6481,21 @@ SpellCastResult Spell::CheckRange(bool strict)
float dist = m_caster->GetCombatDistance(target, m_spellInfo->rangeIndex == SPELL_RANGE_IDX_COMBAT);

if (dist > max_range)
return SPELL_FAILED_OUT_OF_RANGE;
return !m_IsTriggeredSpell ? SPELL_FAILED_OUT_OF_RANGE : SPELL_FAILED_DONT_REPORT;
if (min_range && dist < min_range)
return SPELL_FAILED_TOO_CLOSE;
if (m_caster->GetTypeId() == TYPEID_PLAYER &&
(m_spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc(M_PI_F, target))
return SPELL_FAILED_UNIT_NOT_INFRONT;
return !m_IsTriggeredSpell ? SPELL_FAILED_TOO_CLOSE : SPELL_FAILED_DONT_REPORT;
if (m_caster->GetTypeId() == TYPEID_PLAYER
&& (m_spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc( M_PI_F, target))
return !m_IsTriggeredSpell ? SPELL_FAILED_UNIT_NOT_INFRONT : SPELL_FAILED_DONT_REPORT;
}

// TODO verify that such spells really use bounding radius
if (m_targets.m_targetMask == TARGET_FLAG_DEST_LOCATION && m_targets.m_destX != 0 && m_targets.m_destY != 0 && m_targets.m_destZ != 0)
{
if (!m_caster->IsWithinDist3d(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, max_range))
return SPELL_FAILED_OUT_OF_RANGE;
return !m_IsTriggeredSpell ? SPELL_FAILED_OUT_OF_RANGE : SPELL_FAILED_DONT_REPORT;
if (min_range && m_caster->IsWithinDist3d(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, min_range))
return SPELL_FAILED_TOO_CLOSE;
return !m_IsTriggeredSpell ? SPELL_FAILED_TOO_CLOSE : SPELL_FAILED_DONT_REPORT;
}

return SPELL_CAST_OK;
Expand Down

0 comments on commit 8f4738e

Please sign in to comment.