SHA-1: 8d16a79dea4c0100d36e13b068c42499a3a48154
* Core/Spells: Rename SpellAttr4 to use official attribute names * Corrected implementation of SPELL_ATTR4_CLASS_TRIGGER_ONLY_ON_TARGET * Implemented SPELL_ATTR4_NO_HELPFUL_THREAT * Implemented SPELL_ATTR4_NO_PARTIAL_IMMUNITY * Implemented SPELL_ATTR4_ALLOW_PROC_WHILE_SITTING * Implemented SPELL_ATTR4_USE_FACING_FROM_SPELL * Implemented SPELL_ATTR4_BOUNCY_CHAIN_MISSILES * Implemented SPELL_ATTR4_AURA_NEVER_BOUNCES * Implemented SPELL_ATTR4_AURA_BOUNCE_FAILS_SPELL * Implemented SPELL_ATTR4_AURA_IS_BUFF * Implemented SPELL_ATTR5_MELEE_CHAIN_TARGETING * Implemented SpellEffectAttributes::ChainFromInitialTarget
This commit is contained in:
1 parent
62b8db9f6e
commit
a7dc339a6a
16 files changed
+162
-163
No files matched your search
@@ -628,7 +628,7 @@ m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerO
|
||||
if (info->HasAttribute(SPELL_ATTR2_DO_NOT_REPORT_SPELL_FAILURE))
|
||||
_triggeredCastFlags = TriggerCastFlags(uint32(_triggeredCastFlags) | TRIGGERED_DONT_REPORT_CAST_ERROR);
|
||||
|
||||
if (info->HasAttribute(SPELL_ATTR4_CAN_CAST_WHILE_CASTING))
|
||||
if (info->HasAttribute(SPELL_ATTR4_ALLOW_CAST_WHILE_CASTING))
|
||||
_triggeredCastFlags = TriggerCastFlags(uint32(_triggeredCastFlags) | TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_CAST_DIRECTLY);
|
||||
|
||||
m_CastItem = nullptr;
|
||||
@@ -1723,14 +1723,22 @@ void Spell::SelectImplicitChainTargets(SpellEffIndex effIndex, SpellImplicitTarg
|
||||
|
||||
std::list<WorldObject*> targets;
|
||||
SearchChainTargets(targets, maxTargets - 1, target, targetType.GetObjectType(), targetType.GetCheckType()
|
||||
, m_spellInfo->Effects[effIndex].ImplicitTargetConditions, targetType.GetTarget() == TARGET_UNIT_TARGET_CHAINHEAL_ALLY);
|
||||
, m_spellInfo->Effects[effIndex], targetType.GetTarget() == TARGET_UNIT_TARGET_CHAINHEAL_ALLY);
|
||||
|
||||
// Chain primary target is added earlier
|
||||
CallScriptObjectAreaTargetSelectHandlers(targets, effIndex, targetType);
|
||||
|
||||
Position const* losPosition = m_spellInfo->HasAttribute(SPELL_ATTR2_CHAIN_FROM_CASTER) ? m_caster : target;
|
||||
|
||||
for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
|
||||
{
|
||||
if (Unit* unit = (*itr)->ToUnit())
|
||||
AddUnitTarget(unit, effMask, false);
|
||||
AddUnitTarget(unit, effMask, false, true, losPosition);
|
||||
|
||||
if (!m_spellInfo->HasAttribute(SPELL_ATTR2_CHAIN_FROM_CASTER))
|
||||
losPosition = *itr;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2012,7 +2020,7 @@ void Spell::SearchAreaTargets(std::list<WorldObject*>& targets, float range, Pos
|
||||
SearchTargets<Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellAreaTargetCheck> > (searcher, containerTypeMask, m_caster, position, range);
|
||||
}
|
||||
|
||||
void Spell::SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTargets, WorldObject* target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, ConditionContainer* condList, bool isChainHeal)
|
||||
void Spell::SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTargets, WorldObject* target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, SpellEffectInfo const& spellEffectInfo, bool isChainHeal)
|
||||
{
|
||||
// max dist for jump target selection
|
||||
float jumpRadius = 0.0f;
|
||||
@@ -2037,31 +2045,28 @@ void Spell::SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTar
|
||||
break;
|
||||
}
|
||||
|
||||
// chain lightning/heal spells and similar - allow to jump at larger distance and go out of los
|
||||
bool isBouncingFar = (m_spellInfo->HasAttribute(SPELL_ATTR4_AREA_TARGET_CHAIN)
|
||||
|| m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_NONE
|
||||
|| m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC);
|
||||
|
||||
// max dist which spell can reach
|
||||
float searchRadius = jumpRadius;
|
||||
if (isBouncingFar)
|
||||
searchRadius *= chainTargets;
|
||||
float searchRadius = [&]()
|
||||
{
|
||||
if (m_spellInfo->HasAttribute(SPELL_ATTR2_CHAIN_FROM_CASTER))
|
||||
return GetMinMaxRange(false).second;
|
||||
|
||||
return jumpRadius * chainTargets;
|
||||
}();
|
||||
|
||||
WorldObject* chainSource = m_spellInfo->HasAttribute(SPELL_ATTR2_CHAIN_FROM_CASTER) ? m_caster : target;
|
||||
std::list<WorldObject*> tempTargets;
|
||||
SearchAreaTargets(tempTargets, searchRadius, chainSource, m_caster, objectType, selectType, condList);
|
||||
SearchAreaTargets(tempTargets, searchRadius, chainSource, m_caster, objectType, selectType, spellEffectInfo.ImplicitTargetConditions);
|
||||
tempTargets.remove(target);
|
||||
|
||||
// remove targets which are always invalid for chain spells
|
||||
// for some spells allow only chain targets in front of caster (swipe for example)
|
||||
if (!isBouncingFar)
|
||||
if (m_spellInfo->HasAttribute(SPELL_ATTR5_MELEE_CHAIN_TARGETING))
|
||||
{
|
||||
for (std::list<WorldObject*>::iterator itr = tempTargets.begin(); itr != tempTargets.end();)
|
||||
tempTargets.remove_if([&](WorldObject* object)
|
||||
{
|
||||
std::list<WorldObject*>::iterator checkItr = itr++;
|
||||
if (!m_caster->HasInArc(static_cast<float>(M_PI), *checkItr))
|
||||
tempTargets.erase(checkItr);
|
||||
}
|
||||
return !m_caster->HasInArc(static_cast<float>(M_PI), object);
|
||||
});
|
||||
}
|
||||
|
||||
while (chainTargets)
|
||||
@@ -2092,7 +2097,7 @@ void Spell::SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTar
|
||||
{
|
||||
if (foundItr == tempTargets.end())
|
||||
{
|
||||
if ((!isBouncingFar || chainSource->IsWithinDist(*itr, jumpRadius)) && chainSource->IsWithinLOSInMap(*itr, LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::M2))
|
||||
if (chainSource->IsWithinDist(*itr, jumpRadius) && chainSource->IsWithinLOSInMap(*itr, LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::M2))
|
||||
foundItr = itr;
|
||||
}
|
||||
else if (chainSource->GetDistanceOrder(*itr, *foundItr) && chainSource->IsWithinLOSInMap(*itr, LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::M2))
|
||||
@@ -2275,23 +2280,38 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
|
||||
|
||||
// Spell have speed - need calculate incoming time
|
||||
// Incoming time is zero for self casts. At least I think so.
|
||||
if (m_spellInfo->Speed > 0.0f && m_caster != target)
|
||||
if (m_caster != target)
|
||||
{
|
||||
// calculate spell incoming interval
|
||||
/// @todo this is a hack
|
||||
float dist = m_caster->GetDistance(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
|
||||
float hitDelay = 0.f;
|
||||
WorldObject const* missileSource = m_caster;
|
||||
if (m_spellInfo->HasAttribute(SPELL_ATTR4_BOUNCY_CHAIN_MISSILES))
|
||||
{
|
||||
auto previousTargetItr = std::find_if(m_UniqueTargetInfo.rbegin(), m_UniqueTargetInfo.rend(), [effectMask](TargetInfo const& target)
|
||||
{
|
||||
return (target.EffectMask & effectMask) != 0;
|
||||
});
|
||||
if (previousTargetItr != std::rend(m_UniqueTargetInfo))
|
||||
{
|
||||
hitDelay = 0.0f; // this is not the first target in chain, LaunchDelay was already included
|
||||
|
||||
if (dist < 5.0f)
|
||||
dist = 5.0f;
|
||||
if (WorldObject* previousTarget = ObjectAccessor::GetWorldObject(*m_caster, previousTargetItr->TargetGUID))
|
||||
missileSource = previousTarget;
|
||||
|
||||
if (!m_spellInfo->HasAttribute(SPELL_ATTR9_SPECIAL_DELAY_CALCULATION))
|
||||
targetInfo.TimeDelay = uint64(std::floor(dist / m_spellInfo->Speed * 1000.0f));
|
||||
else
|
||||
targetInfo.TimeDelay = uint64(m_spellInfo->Speed * 1000.0f);
|
||||
targetInfo.TimeDelay += previousTargetItr->TimeDelay;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate minimum incoming time
|
||||
if (!m_delayMoment || m_delayMoment > targetInfo.TimeDelay)
|
||||
m_delayMoment = targetInfo.TimeDelay;
|
||||
if (m_spellInfo->HasAttribute(SPELL_ATTR9_SPECIAL_DELAY_CALCULATION))
|
||||
hitDelay += m_spellInfo->Speed;
|
||||
else if (m_spellInfo->Speed > 0.0f)
|
||||
{
|
||||
// calculate spell incoming interval
|
||||
/// @todo this is a hack
|
||||
float dist = std::max(missileSource->GetDistance(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ()), 5.0f);
|
||||
hitDelay += dist / m_spellInfo->Speed;
|
||||
}
|
||||
|
||||
targetInfo.TimeDelay += uint64(std::floor(hitDelay * 1000.0f));
|
||||
}
|
||||
else
|
||||
targetInfo.TimeDelay = 0ULL;
|
||||
@@ -2312,6 +2332,10 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
|
||||
else
|
||||
targetInfo.ReflectResult = SPELL_MISS_NONE;
|
||||
|
||||
// Calculate minimum incoming time
|
||||
if (targetInfo.TimeDelay && (!m_delayMoment || m_delayMoment > targetInfo.TimeDelay))
|
||||
m_delayMoment = targetInfo.TimeDelay;
|
||||
|
||||
// Add target to list
|
||||
m_UniqueTargetInfo.emplace_back(std::move(targetInfo));
|
||||
}
|
||||
@@ -2736,7 +2760,7 @@ void Spell::TargetInfo::DoDamageAndTriggers(Spell* spell)
|
||||
if (caster->GetTypeId() == TYPEID_PLAYER && (procSpellType & (PROC_SPELL_TYPE_DAMAGE | PROC_SPELL_TYPE_NO_DMG_HEAL)))
|
||||
{
|
||||
if (spell->m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MELEE || spell->m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_RANGED)
|
||||
if (!spell->m_spellInfo->HasAttribute(SPELL_ATTR0_CANCELS_AUTO_ATTACK_COMBAT) && !spell->m_spellInfo->HasAttribute(SPELL_ATTR4_CANT_TRIGGER_ITEM_SPELLS))
|
||||
if (!spell->m_spellInfo->HasAttribute(SPELL_ATTR0_CANCELS_AUTO_ATTACK_COMBAT) && !spell->m_spellInfo->HasAttribute(SPELL_ATTR4_SUPPRESS_WEAPON_PROCS))
|
||||
caster->ToPlayer()->CastItemCombatSpell(*spellDamageInfo);
|
||||
}
|
||||
}
|
||||
@@ -2792,7 +2816,7 @@ void Spell::TargetInfo::DoDamageAndTriggers(Spell* spell)
|
||||
}
|
||||
|
||||
// Needs to be called after dealing damage/healing to not remove breaking on damage auras
|
||||
spell->DoTriggersOnSpellHit(_spellHitTarget, EffectMask);
|
||||
spell->DoTriggersOnSpellHit(_spellHitTarget);
|
||||
}
|
||||
|
||||
if (_enablePVP)
|
||||
@@ -3072,7 +3096,7 @@ void Spell::DoSpellEffectHit(Unit* unit, uint8 effIndex, TargetInfo& hitInfo)
|
||||
_spellAura = nullptr;
|
||||
}
|
||||
|
||||
void Spell::DoTriggersOnSpellHit(Unit* unit, uint8 effMask)
|
||||
void Spell::DoTriggersOnSpellHit(Unit* unit)
|
||||
{
|
||||
// handle SPELL_AURA_ADD_TARGET_TRIGGER auras
|
||||
// this is executed after spell proc spells on target hit
|
||||
@@ -3083,7 +3107,7 @@ void Spell::DoTriggersOnSpellHit(Unit* unit, uint8 effMask)
|
||||
int32 _duration = 0;
|
||||
for (auto i = m_hitTriggerSpells.begin(); i != m_hitTriggerSpells.end(); ++i)
|
||||
{
|
||||
if (CanExecuteTriggersOnHit(effMask, i->triggeredByAura) && roll_chance_i(i->chance))
|
||||
if (CanExecuteTriggersOnHit(unit, i->triggeredByAura) && roll_chance_i(i->chance))
|
||||
{
|
||||
m_caster->CastSpell(unit, i->triggeredSpell->Id, true);
|
||||
TC_LOG_DEBUG("spells", "Spell %d triggered spell %d by SPELL_AURA_ADD_TARGET_TRIGGER aura", m_spellInfo->Id, i->triggeredSpell->Id);
|
||||
@@ -3626,7 +3650,7 @@ void Spell::_cast(bool skipCheck)
|
||||
SendSpellGo();
|
||||
|
||||
// Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells
|
||||
if ((m_spellInfo->Speed > 0.0f && !m_spellInfo->IsChanneled()) || m_spellInfo->HasAttribute(SPELL_ATTR4_UNK4))
|
||||
if ((m_spellInfo->Speed > 0.0f && !m_spellInfo->IsChanneled()) || m_spellInfo->HasAttribute(SPELL_ATTR4_NO_HARMFUL_THREAT))
|
||||
{
|
||||
// Remove used for cast item if need (it can be already nullptr after TakeReagents call
|
||||
// in case delayed spell remove item at cast delay start
|
||||
@@ -6429,7 +6453,10 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
|
||||
}
|
||||
|
||||
// check if target already has the same type, but more powerful aura
|
||||
if (!nonAuraEffectMask && (approximateAuraEffectMask & (1 << i)) && !m_spellInfo->IsTargetingArea())
|
||||
if (!m_spellInfo->HasAttribute(SPELL_ATTR4_AURA_NEVER_BOUNCES)
|
||||
&& (!nonAuraEffectMask || m_spellInfo->HasAttribute(SPELL_ATTR4_AURA_BOUNCE_FAILS_SPELL))
|
||||
&& (approximateAuraEffectMask & (1 << i))
|
||||
&& !m_spellInfo->IsTargetingArea())
|
||||
if (Unit* target = m_targets.GetUnitTarget())
|
||||
if (!target->IsHighestExclusiveAuraEffect(m_spellInfo, AuraType(m_spellInfo->Effects[i].ApplyAuraName),
|
||||
m_spellInfo->Effects[i].CalcValue(m_caster, &m_spellValue->EffectBasePoints[i]), approximateAuraEffectMask, false))
|
||||
@@ -6725,11 +6752,11 @@ SpellCastResult Spell::CheckArenaAndRatedBattlegroundCastRules() const
|
||||
if (isRatedBattleground && m_spellInfo->HasAttribute(SPELL_ATTR9_USABLE_IN_RATED_BATTLEGROUNDS))
|
||||
return SPELL_CAST_OK;
|
||||
|
||||
if (isArena && m_spellInfo->HasAttribute(SPELL_ATTR4_USABLE_IN_ARENA))
|
||||
if (isArena && m_spellInfo->HasAttribute(SPELL_ATTR4_IGNORE_DEFAULT_ARENA_RESTRICTIONS))
|
||||
return SPELL_CAST_OK;
|
||||
|
||||
// check NOT_USABLE attributes
|
||||
if (m_spellInfo->HasAttribute(SPELL_ATTR4_NOT_USABLE_IN_ARENA_OR_RATED_BG))
|
||||
if (m_spellInfo->HasAttribute(SPELL_ATTR4_NOT_IN_ARENA_OR_RATED_BATTLEGROUND))
|
||||
return isArena ? SPELL_FAILED_NOT_IN_ARENA : SPELL_FAILED_NOT_IN_RATED_BATTLEGROUND;
|
||||
|
||||
if (isArena && m_spellInfo->HasAttribute(SPELL_ATTR9_NOT_USABLE_IN_ARENA))
|
||||
@@ -8381,15 +8408,20 @@ bool Spell::CheckScriptEffectImplicitTargets(uint32 effIndex, uint32 effIndexToC
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Spell::CanExecuteTriggersOnHit(uint8 effMask, SpellInfo const* triggeredByAura) const
|
||||
bool Spell::CanExecuteTriggersOnHit(Unit* unit, SpellInfo const* triggeredByAura) const
|
||||
{
|
||||
bool only_on_caster = (triggeredByAura && triggeredByAura->HasAttribute(SPELL_ATTR4_PROC_ONLY_ON_CASTER));
|
||||
// If triggeredByAura has SPELL_ATTR4_PROC_ONLY_ON_CASTER then it can only proc on a cast spell with TARGET_UNIT_CASTER
|
||||
for (uint8 i = 0;i < MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if ((effMask & (1 << i)) && (!only_on_caster || (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_UNIT_CASTER)))
|
||||
return true;
|
||||
}
|
||||
bool onlyOnTarget = (triggeredByAura && (triggeredByAura->HasAttribute(SPELL_ATTR4_CLASS_TRIGGER_ONLY_ON_TARGET)));
|
||||
if (!onlyOnTarget)
|
||||
return true;
|
||||
|
||||
// If triggeredByAura has SPELL_ATTR4_CLASS_TRIGGER_ONLY_ON_TARGET then it can only proc on either noncaster units...
|
||||
if (unit != m_caster)
|
||||
return true;
|
||||
|
||||
// ... or caster if it is the only target
|
||||
if (m_UniqueTargetInfo.size() == 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user