*(awe)some changes to triggering spell/aura effects:
*do not use original caster for trigger spell/trigger spell with value effects *correct caster selection for force cast/trigger spell/trigger spell with value spell effects --HG-- branch : trunk
This commit is contained in:
@@ -1971,21 +1971,6 @@ Unit* AuraEffect::GetTriggerTarget(Unit * target) const
|
||||
return target;
|
||||
}
|
||||
|
||||
Unit* AuraEffect::GetTriggerCaster(Unit * target, Unit * caster, SpellEntry const * triggeredSpell) const
|
||||
{
|
||||
for (uint8 i = 0 ; i < MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (SpellTargetType[triggeredSpell->EffectImplicitTargetA[i]] == TARGET_TYPE_UNIT_TARGET
|
||||
|| SpellTargetType[triggeredSpell->EffectImplicitTargetB[i]] == TARGET_TYPE_UNIT_TARGET
|
||||
|| SpellTargetType[triggeredSpell->EffectImplicitTargetA[i]] == TARGET_TYPE_CHANNEL
|
||||
|| SpellTargetType[triggeredSpell->EffectImplicitTargetB[i]] == TARGET_TYPE_CHANNEL
|
||||
|| SpellTargetType[triggeredSpell->EffectImplicitTargetA[i]] == TARGET_TYPE_DEST_TARGET
|
||||
|| SpellTargetType[triggeredSpell->EffectImplicitTargetB[i]] == TARGET_TYPE_DEST_TARGET)
|
||||
return caster;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
void AuraEffect::TriggerSpell(Unit * target, Unit * caster) const
|
||||
{
|
||||
if(!caster || !target)
|
||||
@@ -2246,8 +2231,8 @@ void AuraEffect::TriggerSpell(Unit * target, Unit * caster) const
|
||||
|
||||
if(triggeredSpellInfo)
|
||||
{
|
||||
Unit * triggerCaster = GetTriggerCaster(triggerTarget, caster, triggeredSpellInfo);
|
||||
triggerCaster->CastSpell(triggerTarget, triggeredSpellInfo, true, 0, this, GetCasterGUID());
|
||||
Unit * triggerCaster = GetTriggeredSpellCaster(triggeredSpellInfo, caster, triggerTarget);
|
||||
triggerCaster->CastSpell(triggerTarget, triggeredSpellInfo, true, 0, this);
|
||||
sLog.outDebug("AuraEffect::TriggerSpell: Spell %u Trigger %u",GetId(), triggeredSpellInfo->Id);
|
||||
}
|
||||
else if(target->GetTypeId()!=TYPEID_UNIT || !sScriptMgr.EffectDummyCreature(caster, GetId(), GetEffIndex(), (Creature*)triggerTarget))
|
||||
@@ -2265,7 +2250,7 @@ void AuraEffect::TriggerSpellWithValue(Unit * target, Unit * caster) const
|
||||
SpellEntry const *triggeredSpellInfo = sSpellStore.LookupEntry(triggerSpellId);
|
||||
if(triggeredSpellInfo)
|
||||
{
|
||||
Unit * triggerCaster = GetTriggerCaster(triggerTarget, caster, triggeredSpellInfo);
|
||||
Unit * triggerCaster = GetTriggeredSpellCaster(triggeredSpellInfo, caster, triggerTarget);
|
||||
|
||||
// generic casting code with custom spells and target/caster customs
|
||||
int32 basepoints0 = GetAmount();
|
||||
|
||||
@@ -72,7 +72,6 @@ class AuraEffect
|
||||
void PeriodicTick(Unit * target, Unit * caster) const;
|
||||
void PeriodicDummyTick(Unit * target, Unit * caster) const;
|
||||
Unit* GetTriggerTarget(Unit * target) const;
|
||||
Unit* GetTriggerCaster(Unit * target, Unit * caster, SpellEntry const * triggeredSpell) const;
|
||||
void TriggerSpell(Unit * target, Unit * caster) const;
|
||||
void TriggerSpellWithValue(Unit * target, Unit * caster) const;
|
||||
|
||||
|
||||
+26
-23
@@ -2203,7 +2203,9 @@ void Spell::EffectTriggerSpellWithValue(uint32 i)
|
||||
}
|
||||
|
||||
int32 bp = damage;
|
||||
m_caster->CastCustomSpell(unitTarget,triggered_spell_id,&bp,&bp,&bp,true,NULL,NULL,m_originalCasterGUID);
|
||||
Unit * caster = GetTriggeredSpellCaster(spellInfo, m_caster, unitTarget);
|
||||
|
||||
caster->CastCustomSpell(unitTarget,triggered_spell_id,&bp,&bp,&bp,true);
|
||||
}
|
||||
|
||||
void Spell::EffectTriggerRitualOfSummoning(uint32 i)
|
||||
@@ -2240,22 +2242,23 @@ void Spell::EffectForceCast(uint32 i)
|
||||
|
||||
if (damage)
|
||||
{
|
||||
if(m_spellInfo->EffectBasePoints[i] > 0)
|
||||
switch(m_spellInfo->Id)
|
||||
{
|
||||
switch(m_spellInfo->Id)
|
||||
{
|
||||
// 52463 also use custom damage and the summon veh spell use that damamge and cast mount aura?
|
||||
case 52588: unitTarget->RemoveAura(damage); break;
|
||||
}
|
||||
}
|
||||
else // this was for 52463, need further study
|
||||
{
|
||||
unitTarget->CastCustomSpell(unitTarget, spellInfo->Id, &damage, NULL, NULL, true, NULL, NULL, m_originalCasterGUID);
|
||||
return;
|
||||
case 52588: // Skeletal Gryphon Escape
|
||||
case 48598: // Ride Flamebringer Cue
|
||||
unitTarget->RemoveAura(damage);
|
||||
break;
|
||||
case 52463: // Hide In Mine Car
|
||||
case 52349: // Overtake
|
||||
unitTarget->CastCustomSpell(unitTarget, spellInfo->Id, &damage, NULL, NULL, true, NULL, NULL, m_originalCasterGUID);
|
||||
return;
|
||||
//case 72378: // Blood Nova
|
||||
//case 73058: // Blood Nova
|
||||
}
|
||||
}
|
||||
Unit * caster = GetTriggeredSpellCaster(spellInfo, m_caster, unitTarget);
|
||||
|
||||
unitTarget->CastSpell(unitTarget, spellInfo, true, NULL, NULL, m_originalCasterGUID);
|
||||
caster->CastSpell(unitTarget, spellInfo, true, NULL, NULL, m_originalCasterGUID);
|
||||
}
|
||||
|
||||
void Spell::EffectTriggerSpell(uint32 effIndex)
|
||||
@@ -2349,7 +2352,7 @@ void Spell::EffectTriggerSpell(uint32 effIndex)
|
||||
return;
|
||||
|
||||
for (int j=0; j < spell->StackAmount; ++j)
|
||||
m_caster->CastSpell(unitTarget, spell->Id, true, m_CastItem, NULL, m_originalCasterGUID);
|
||||
m_caster->CastSpell(unitTarget, spell->Id, true);
|
||||
return;
|
||||
}
|
||||
// Mercurial Shield - (need add max stack of 26464 Mercurial Shield)
|
||||
@@ -2361,13 +2364,13 @@ void Spell::EffectTriggerSpell(uint32 effIndex)
|
||||
return;
|
||||
|
||||
for (int j=0; j < spell->StackAmount; ++j)
|
||||
m_caster->CastSpell(unitTarget, spell->Id, true, m_CastItem, NULL, m_originalCasterGUID);
|
||||
m_caster->CastSpell(unitTarget, spell->Id, true);
|
||||
return;
|
||||
}
|
||||
// Righteous Defense
|
||||
case 31980:
|
||||
{
|
||||
m_caster->CastSpell(unitTarget, 31790, true, m_CastItem, NULL, m_originalCasterGUID);
|
||||
m_caster->CastSpell(unitTarget, 31790, true);
|
||||
return;
|
||||
}
|
||||
// Cloak of Shadows
|
||||
@@ -2419,9 +2422,9 @@ void Spell::EffectTriggerSpell(uint32 effIndex)
|
||||
|
||||
// Note: not exist spells with weapon req. and IsSpellHaveCasterSourceTargets == true
|
||||
// so this just for speedup places in else
|
||||
Unit *caster = IsSpellWithCasterSourceTargetsOnly(spellInfo) ? unitTarget : m_caster;
|
||||
Unit * caster = GetTriggeredSpellCaster(spellInfo, m_caster, unitTarget);
|
||||
|
||||
caster->CastSpell(unitTarget,spellInfo,true,NULL,NULL,m_originalCasterGUID);
|
||||
caster->CastSpell(unitTarget,spellInfo,true);
|
||||
}
|
||||
|
||||
void Spell::EffectTriggerMissileSpell(uint32 effect_idx)
|
||||
@@ -3392,10 +3395,10 @@ void Spell::EffectOpenLock(uint32 effIndex)
|
||||
//CanUseBattleGroundObject() already called in CheckCast()
|
||||
// in battleground check
|
||||
if(BattleGround *bg = player->GetBattleGround())
|
||||
{
|
||||
bg->EventPlayerClickedOnFlag(player, gameObjTarget);
|
||||
return;
|
||||
}
|
||||
{
|
||||
bg->EventPlayerClickedOnFlag(player, gameObjTarget);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (goInfo->type == GAMEOBJECT_TYPE_FLAGSTAND)
|
||||
{
|
||||
@@ -7367,7 +7370,7 @@ void Spell::EffectWMODamage(uint32 /*i*/)
|
||||
goft = sFactionTemplateStore.LookupEntry(gameObjTarget->GetUInt32Value(GAMEOBJECT_FACTION));
|
||||
// Do not allow to damage GO's of friendly factions (ie: Wintergrasp Walls)
|
||||
if (casterft && goft && !casterft->IsFriendlyTo(*goft))
|
||||
gameObjTarget->TakenDamage((uint32)damage, caster);
|
||||
gameObjTarget->TakenDamage((uint32)damage, caster);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -419,6 +419,21 @@ uint32 CalculatePowerCost(SpellEntry const * spellInfo, Unit const * caster, Spe
|
||||
return powerCost;
|
||||
}
|
||||
|
||||
Unit* GetTriggeredSpellCaster(SpellEntry const * spellInfo, Unit * caster, Unit * target)
|
||||
{
|
||||
for (uint8 i = 0 ; i < MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_UNIT_TARGET
|
||||
|| SpellTargetType[spellInfo->EffectImplicitTargetB[i]] == TARGET_TYPE_UNIT_TARGET
|
||||
|| SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_CHANNEL
|
||||
|| SpellTargetType[spellInfo->EffectImplicitTargetB[i]] == TARGET_TYPE_CHANNEL
|
||||
|| SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_DEST_TARGET
|
||||
|| SpellTargetType[spellInfo->EffectImplicitTargetB[i]] == TARGET_TYPE_DEST_TARGET)
|
||||
return caster;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
AuraState GetSpellAuraState(SpellEntry const * spellInfo)
|
||||
{
|
||||
// Seals
|
||||
|
||||
@@ -180,6 +180,7 @@ enum SpellLinkedType
|
||||
SPELL_LINK_REMOVE = 0,
|
||||
};
|
||||
|
||||
Unit * GetTriggeredSpellCaster(SpellEntry const * spellInfo, Unit * caster, Unit * target);
|
||||
SpellSpecific GetSpellSpecific(SpellEntry const * spellInfo);
|
||||
AuraState GetSpellAuraState(SpellEntry const * spellInfo);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user