*(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:
QAston
2010-02-20 23:57:54 +01:00
parent 2e3f89b61f
commit 6323d7dc33
5 changed files with 45 additions and 42 deletions
+3 -18
View File
@@ -1971,21 +1971,6 @@ Unit* AuraEffect::GetTriggerTarget(Unit * target) const
return target; 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 void AuraEffect::TriggerSpell(Unit * target, Unit * caster) const
{ {
if(!caster || !target) if(!caster || !target)
@@ -2246,8 +2231,8 @@ void AuraEffect::TriggerSpell(Unit * target, Unit * caster) const
if(triggeredSpellInfo) if(triggeredSpellInfo)
{ {
Unit * triggerCaster = GetTriggerCaster(triggerTarget, caster, triggeredSpellInfo); Unit * triggerCaster = GetTriggeredSpellCaster(triggeredSpellInfo, caster, triggerTarget);
triggerCaster->CastSpell(triggerTarget, triggeredSpellInfo, true, 0, this, GetCasterGUID()); triggerCaster->CastSpell(triggerTarget, triggeredSpellInfo, true, 0, this);
sLog.outDebug("AuraEffect::TriggerSpell: Spell %u Trigger %u",GetId(), triggeredSpellInfo->Id); sLog.outDebug("AuraEffect::TriggerSpell: Spell %u Trigger %u",GetId(), triggeredSpellInfo->Id);
} }
else if(target->GetTypeId()!=TYPEID_UNIT || !sScriptMgr.EffectDummyCreature(caster, GetId(), GetEffIndex(), (Creature*)triggerTarget)) 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); SpellEntry const *triggeredSpellInfo = sSpellStore.LookupEntry(triggerSpellId);
if(triggeredSpellInfo) if(triggeredSpellInfo)
{ {
Unit * triggerCaster = GetTriggerCaster(triggerTarget, caster, triggeredSpellInfo); Unit * triggerCaster = GetTriggeredSpellCaster(triggeredSpellInfo, caster, triggerTarget);
// generic casting code with custom spells and target/caster customs // generic casting code with custom spells and target/caster customs
int32 basepoints0 = GetAmount(); int32 basepoints0 = GetAmount();
-1
View File
@@ -72,7 +72,6 @@ class AuraEffect
void PeriodicTick(Unit * target, Unit * caster) const; void PeriodicTick(Unit * target, Unit * caster) const;
void PeriodicDummyTick(Unit * target, Unit * caster) const; void PeriodicDummyTick(Unit * target, Unit * caster) const;
Unit* GetTriggerTarget(Unit * target) const; Unit* GetTriggerTarget(Unit * target) const;
Unit* GetTriggerCaster(Unit * target, Unit * caster, SpellEntry const * triggeredSpell) const;
void TriggerSpell(Unit * target, Unit * caster) const; void TriggerSpell(Unit * target, Unit * caster) const;
void TriggerSpellWithValue(Unit * target, Unit * caster) const; void TriggerSpellWithValue(Unit * target, Unit * caster) const;
+26 -23
View File
@@ -2203,7 +2203,9 @@ void Spell::EffectTriggerSpellWithValue(uint32 i)
} }
int32 bp = damage; 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) void Spell::EffectTriggerRitualOfSummoning(uint32 i)
@@ -2240,22 +2242,23 @@ void Spell::EffectForceCast(uint32 i)
if (damage) if (damage)
{ {
if(m_spellInfo->EffectBasePoints[i] > 0) switch(m_spellInfo->Id)
{ {
switch(m_spellInfo->Id) case 52588: // Skeletal Gryphon Escape
{ case 48598: // Ride Flamebringer Cue
// 52463 also use custom damage and the summon veh spell use that damamge and cast mount aura? unitTarget->RemoveAura(damage);
case 52588: unitTarget->RemoveAura(damage); break; break;
} case 52463: // Hide In Mine Car
} case 52349: // Overtake
else // this was for 52463, need further study unitTarget->CastCustomSpell(unitTarget, spellInfo->Id, &damage, NULL, NULL, true, NULL, NULL, m_originalCasterGUID);
{ return;
unitTarget->CastCustomSpell(unitTarget, spellInfo->Id, &damage, NULL, NULL, true, NULL, NULL, m_originalCasterGUID); //case 72378: // Blood Nova
return; //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) void Spell::EffectTriggerSpell(uint32 effIndex)
@@ -2349,7 +2352,7 @@ void Spell::EffectTriggerSpell(uint32 effIndex)
return; return;
for (int j=0; j < spell->StackAmount; ++j) 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; return;
} }
// Mercurial Shield - (need add max stack of 26464 Mercurial Shield) // Mercurial Shield - (need add max stack of 26464 Mercurial Shield)
@@ -2361,13 +2364,13 @@ void Spell::EffectTriggerSpell(uint32 effIndex)
return; return;
for (int j=0; j < spell->StackAmount; ++j) 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; return;
} }
// Righteous Defense // Righteous Defense
case 31980: case 31980:
{ {
m_caster->CastSpell(unitTarget, 31790, true, m_CastItem, NULL, m_originalCasterGUID); m_caster->CastSpell(unitTarget, 31790, true);
return; return;
} }
// Cloak of Shadows // Cloak of Shadows
@@ -2419,9 +2422,9 @@ void Spell::EffectTriggerSpell(uint32 effIndex)
// Note: not exist spells with weapon req. and IsSpellHaveCasterSourceTargets == true // Note: not exist spells with weapon req. and IsSpellHaveCasterSourceTargets == true
// so this just for speedup places in else // 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) void Spell::EffectTriggerMissileSpell(uint32 effect_idx)
@@ -3392,10 +3395,10 @@ void Spell::EffectOpenLock(uint32 effIndex)
//CanUseBattleGroundObject() already called in CheckCast() //CanUseBattleGroundObject() already called in CheckCast()
// in battleground check // in battleground check
if(BattleGround *bg = player->GetBattleGround()) if(BattleGround *bg = player->GetBattleGround())
{ {
bg->EventPlayerClickedOnFlag(player, gameObjTarget); bg->EventPlayerClickedOnFlag(player, gameObjTarget);
return; return;
} }
} }
else if (goInfo->type == GAMEOBJECT_TYPE_FLAGSTAND) else if (goInfo->type == GAMEOBJECT_TYPE_FLAGSTAND)
{ {
@@ -7367,7 +7370,7 @@ void Spell::EffectWMODamage(uint32 /*i*/)
goft = sFactionTemplateStore.LookupEntry(gameObjTarget->GetUInt32Value(GAMEOBJECT_FACTION)); goft = sFactionTemplateStore.LookupEntry(gameObjTarget->GetUInt32Value(GAMEOBJECT_FACTION));
// Do not allow to damage GO's of friendly factions (ie: Wintergrasp Walls) // Do not allow to damage GO's of friendly factions (ie: Wintergrasp Walls)
if (casterft && goft && !casterft->IsFriendlyTo(*goft)) if (casterft && goft && !casterft->IsFriendlyTo(*goft))
gameObjTarget->TakenDamage((uint32)damage, caster); gameObjTarget->TakenDamage((uint32)damage, caster);
} }
} }
+15
View File
@@ -419,6 +419,21 @@ uint32 CalculatePowerCost(SpellEntry const * spellInfo, Unit const * caster, Spe
return powerCost; 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) AuraState GetSpellAuraState(SpellEntry const * spellInfo)
{ {
// Seals // Seals
+1
View File
@@ -180,6 +180,7 @@ enum SpellLinkedType
SPELL_LINK_REMOVE = 0, SPELL_LINK_REMOVE = 0,
}; };
Unit * GetTriggeredSpellCaster(SpellEntry const * spellInfo, Unit * caster, Unit * target);
SpellSpecific GetSpellSpecific(SpellEntry const * spellInfo); SpellSpecific GetSpellSpecific(SpellEntry const * spellInfo);
AuraState GetSpellAuraState(SpellEntry const * spellInfo); AuraState GetSpellAuraState(SpellEntry const * spellInfo);