From a67b6a1da5da4169e3d19db49b82519edd41eb62 Mon Sep 17 00:00:00 2001 From: Laise Date: Fri, 1 Oct 2010 13:16:48 +0200 Subject: [PATCH] [10570] Store spell entry of triggering spell on triggered, original patch provided by insider42 --- src/game/Spell.cpp | 3 ++- src/game/Spell.h | 3 ++- src/game/Unit.cpp | 51 ++++++++++++++++++++++++++-------------- src/game/Unit.h | 12 +++++----- src/shared/revision_nr.h | 2 +- 5 files changed, 44 insertions(+), 27 deletions(-) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 39f0d1565..3e32f62a2 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -319,7 +319,7 @@ void SpellCastTargets::write( ByteBuffer& data ) const data << m_strTarget; } -Spell::Spell( Unit* caster, SpellEntry const *info, bool triggered, ObjectGuid originalCasterGUID, Spell** triggeringContainer ) +Spell::Spell( Unit* caster, SpellEntry const *info, bool triggered, ObjectGuid originalCasterGUID, Spell** triggeringContainer, SpellEntry const* triggeredBy ) { MANGOS_ASSERT( caster != NULL && info != NULL ); MANGOS_ASSERT( info == sSpellStore.LookupEntry( info->Id ) && "`info` must be pointer to sSpellStore element"); @@ -334,6 +334,7 @@ Spell::Spell( Unit* caster, SpellEntry const *info, bool triggered, ObjectGuid o else m_spellInfo = info; + m_triggeredBySpellInfo = triggeredBy; m_caster = caster; m_selfContainer = NULL; m_triggeringContainer = triggeringContainer; diff --git a/src/game/Spell.h b/src/game/Spell.h index 481b1426a..a1a4e3128 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -342,7 +342,7 @@ class Spell void EffectSpecCount(SpellEffectIndex eff_idx); void EffectActivateSpec(SpellEffectIndex eff_idx); - Spell( Unit* caster, SpellEntry const *info, bool triggered, ObjectGuid originalCasterGUID = ObjectGuid(), Spell** triggeringContainer = NULL ); + Spell( Unit* caster, SpellEntry const *info, bool triggered, ObjectGuid originalCasterGUID = ObjectGuid(), Spell** triggeringContainer = NULL, SpellEntry const* triggeredBy = NULL); ~Spell(); void prepare(SpellCastTargets const* targets, Aura* triggeredByAura = NULL); @@ -422,6 +422,7 @@ class Spell //void HandleAddAura(Unit* Target); SpellEntry const* m_spellInfo; + SpellEntry const* m_triggeredBySpellInfo; int32 m_currentBasePoints[MAX_EFFECT_INDEX]; // cache SpellEntry::CalculateSimpleValue and use for set custom base points Item* m_CastItem; uint8 m_cast_count; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 3448163f1..a2b378383 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1080,7 +1080,7 @@ void Unit::CastStop(uint32 except_spellid) InterruptSpell(CurrentSpellTypes(i),false); } -void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster) +void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); @@ -1093,10 +1093,10 @@ void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castIte return; } - CastSpell(Victim, spellInfo, triggered, castItem, triggeredByAura, originalCaster); + CastSpell(Victim, spellInfo, triggered, castItem, triggeredByAura, originalCaster, triggeredBy); } -void Unit::CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster) +void Unit::CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) { if(!spellInfo) { @@ -1110,10 +1110,15 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered, if (castItem) DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id); - if(originalCaster.IsEmpty() && triggeredByAura) - originalCaster = triggeredByAura->GetCasterGUID(); + if (triggeredByAura) + { + if(originalCaster.IsEmpty()) + originalCaster = triggeredByAura->GetCasterGUID(); - Spell *spell = new Spell(this, spellInfo, triggered, originalCaster); + triggeredBy = triggeredByAura->GetSpellProto(); + } + + Spell *spell = new Spell(this, spellInfo, triggered, originalCaster, NULL, triggeredBy); SpellCastTargets targets; targets.setUnitTarget( Victim ); @@ -1121,7 +1126,7 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered, spell->prepare(&targets, triggeredByAura); } -void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster) +void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); @@ -1134,10 +1139,10 @@ void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 return; } - CastCustomSpell(Victim, spellInfo, bp0, bp1, bp2, triggered, castItem, triggeredByAura, originalCaster); + CastCustomSpell(Victim, spellInfo, bp0, bp1, bp2, triggered, castItem, triggeredByAura, originalCaster, triggeredBy); } -void Unit::CastCustomSpell(Unit* Victim, SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster) +void Unit::CastCustomSpell(Unit* Victim, SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) { if(!spellInfo) { @@ -1151,10 +1156,15 @@ void Unit::CastCustomSpell(Unit* Victim, SpellEntry const *spellInfo, int32 cons if (castItem) DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id); - if(originalCaster.IsEmpty() && triggeredByAura) - originalCaster = triggeredByAura->GetCasterGUID(); + if (triggeredByAura) + { + if(originalCaster.IsEmpty()) + originalCaster = triggeredByAura->GetCasterGUID(); - Spell *spell = new Spell(this, spellInfo, triggered, originalCaster); + triggeredBy = triggeredByAura->GetSpellProto(); + } + + Spell *spell = new Spell(this, spellInfo, triggered, originalCaster, NULL, triggeredBy); if(bp0) spell->m_currentBasePoints[EFFECT_INDEX_0] = *bp0; @@ -1172,7 +1182,7 @@ void Unit::CastCustomSpell(Unit* Victim, SpellEntry const *spellInfo, int32 cons } // used for scripting -void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster) +void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); @@ -1185,11 +1195,11 @@ void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, return; } - CastSpell(x, y, z, spellInfo, triggered, castItem, triggeredByAura, originalCaster); + CastSpell(x, y, z, spellInfo, triggered, castItem, triggeredByAura, originalCaster, triggeredBy); } // used for scripting -void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster) +void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) { if(!spellInfo) { @@ -1203,10 +1213,15 @@ void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, boo if (castItem) DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id); - if(originalCaster.IsEmpty() && triggeredByAura) - originalCaster = triggeredByAura->GetCasterGUID(); + if (triggeredByAura) + { + if(originalCaster.IsEmpty()) + originalCaster = triggeredByAura->GetCasterGUID(); - Spell *spell = new Spell(this, spellInfo, triggered, originalCaster); + triggeredBy = triggeredByAura->GetSpellProto(); + } + + Spell *spell = new Spell(this, spellInfo, triggered, originalCaster, NULL, triggeredBy); SpellCastTargets targets; targets.setDestination(x, y, z); diff --git a/src/game/Unit.h b/src/game/Unit.h index 5efc78313..38434b986 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1428,12 +1428,12 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype); void EnergizeBySpell(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype); uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage); - void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid()); - void CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid()); - void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid()); - void CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid()); - void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid()); - void CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid()); + void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + void CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + void CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + void CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); bool IsDamageToThreatSpell(SpellEntry const * spellInfo) const; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index b5d2f135e..f2958ce5c 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10569" + #define REVISION_NR "10570" #endif // __REVISION_NR_H__