diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 8015555f8..1e2d83ec8 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -572,7 +572,7 @@ Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoi Unit* Aura::GetCaster() const { - if(m_caster_guid==m_target->GetGUID()) + if(m_caster_guid == m_target->GetGUID()) return m_target; //return ObjectAccessor::GetUnit(*m_target,m_caster_guid); @@ -1450,10 +1450,10 @@ void Aura::HandleAddTargetTrigger(bool apply, bool /*Real*/) void Aura::TriggerSpell() { - Unit* caster = GetCaster(); + const uint64& casterGUID = GetCasterGUID(); Unit* target = GetTriggerTarget(); - if(!caster || !target) + if(!casterGUID || !target) return; // generic casting code with custom spells and target/caster customs @@ -1479,9 +1479,9 @@ void Aura::TriggerSpell() case 17949: case 27252: { - if (caster->GetTypeId()!=TYPEID_PLAYER) + if (target->GetTypeId() != TYPEID_PLAYER) return; - Item* item = ((Player*)caster)->GetWeaponForAttack(BASE_ATTACK); + Item* item = ((Player*)target)->GetWeaponForAttack(BASE_ATTACK); if (!item) return; uint32 enchant_id = 0; @@ -1496,10 +1496,10 @@ void Aura::TriggerSpell() return; } // remove old enchanting before applying new - ((Player*)caster)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,false); + ((Player*)target)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,false); item->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, m_modifier.periodictime+1000, 0); // add new enchanting - ((Player*)caster)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,true); + ((Player*)target)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,true); return; } // // Periodic Mana Burn @@ -1542,14 +1542,13 @@ void Aura::TriggerSpell() // Restoration case 23493: { - int32 heal = caster->GetMaxHealth() / 10; - caster->DealHeal(caster, heal, auraSpellInfo); + int32 heal = target->GetMaxHealth() / 10; + target->DealHeal(target, heal, auraSpellInfo); - int32 mana = caster->GetMaxPower(POWER_MANA); - if (mana) + if (int32 mana = target->GetMaxPower(POWER_MANA)) { mana /= 10; - caster->EnergizeBySpell(caster, 23493, mana, POWER_MANA); + target->EnergizeBySpell(target, 23493, mana, POWER_MANA); } return; } @@ -1579,7 +1578,7 @@ void Aura::TriggerSpell() case 25371: { int32 bpDamage = target->GetMaxHealth()*10/100; - caster->CastCustomSpell(target, 25373, &bpDamage, NULL, NULL, true, NULL, this); + target->CastCustomSpell(target, 25373, &bpDamage, NULL, NULL, true, NULL, this, casterGUID); return; } // // Pain Spike @@ -1606,7 +1605,7 @@ void Aura::TriggerSpell() case 27808: { int32 bpDamage = target->GetMaxHealth()*26/100; - caster->CastCustomSpell(target, 29879, &bpDamage, NULL, NULL, true, NULL, this); + target->CastCustomSpell(target, 29879, &bpDamage, NULL, NULL, true, NULL, this, casterGUID); return; } // // Detonate Mana @@ -1657,10 +1656,13 @@ void Aura::TriggerSpell() // Extract Gas case 30427: { + Unit* caster = GetCaster(); + if (!caster) + return; // move loot to player inventory and despawn target if(caster->GetTypeId() ==TYPEID_PLAYER && - target->GetTypeId() == TYPEID_UNIT && - ((Creature*)target)->GetCreatureInfo()->type == CREATURE_TYPE_GAS_CLOUD) + target->GetTypeId() == TYPEID_UNIT && + ((Creature*)target)->GetCreatureInfo()->type == CREATURE_TYPE_GAS_CLOUD) { Player* player = (Player*)caster; Creature* creature = (Creature*)target; @@ -1700,7 +1702,7 @@ void Aura::TriggerSpell() case 31373: { // Summon Elemental after create item - caster->SummonCreature(17870, 0, 0, 0, caster->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0); + target->SummonCreature(17870, 0, 0, 0, target->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0); return; } // // Bloodmyst Tesla @@ -1722,9 +1724,9 @@ void Aura::TriggerSpell() { // cast 24 spells 34269-34289, 34314-34316 for(uint32 spell_id = 34269; spell_id != 34290; ++spell_id) - caster->CastSpell(m_target, spell_id, true); + target->CastSpell(target, spell_id, true, NULL, this, casterGUID); for(uint32 spell_id = 34314; spell_id != 34317; ++spell_id) - caster->CastSpell(m_target, spell_id, true); + target->CastSpell(target, spell_id, true, NULL, this, casterGUID); return; } // // Gravity Lapse @@ -1815,7 +1817,10 @@ void Aura::TriggerSpell() if(m_target->GetTypeId() != TYPEID_UNIT) return; - caster->CastSpell(caster, 38495, true); + if (Unit* caster = GetCaster()) + caster->CastSpell(caster, 38495, true, NULL, this); + else + return; Creature* creatureTarget = (Creature*)m_target; @@ -2073,7 +2078,7 @@ void Aura::TriggerSpell() bool all = true; for(int i = 0; i < MAX_TOTEM; ++i) { - if(!caster->m_TotemSlot[i]) + if(!target->m_TotemSlot[i]) { all = false; break; @@ -2081,9 +2086,9 @@ void Aura::TriggerSpell() } if(all) - caster->CastSpell(caster, 38437, true); + target->CastSpell(target, 38437, true, NULL, this); else - caster->RemoveAurasDueToSpell(38437); + target->RemoveAurasDueToSpell(38437); return; } default: @@ -2113,14 +2118,14 @@ void Aura::TriggerSpell() // 2) maybe aura must be replace by new with accumulative stat mods instead stacking // prevent cast by triggered auras - if(m_caster_guid == m_target->GetGUID()) + if(casterGUID == target->GetGUID()) return; // stop triggering after each affected stats lost > 90 int32 intelectLoss = 0; int32 spiritLoss = 0; - Unit::AuraList const& mModStat = m_target->GetAurasByType(SPELL_AURA_MOD_STAT); + Unit::AuraList const& mModStat = target->GetAurasByType(SPELL_AURA_MOD_STAT); for(Unit::AuraList::const_iterator i = mModStat.begin(); i != mModStat.end(); ++i) { if ((*i)->GetId() == 1010) @@ -2137,47 +2142,52 @@ void Aura::TriggerSpell() if(intelectLoss <= -90 && spiritLoss <= -90) return; - caster = target; break; } // Mana Tide case 16191: { - caster->CastCustomSpell(target, trigger_spell_id, &m_modifier.m_amount, NULL, NULL, true, NULL, this); + target->CastCustomSpell(target, trigger_spell_id, &m_modifier.m_amount, NULL, NULL, true, NULL, this); return; } // Ground Slam case 33525: - target->CastSpell(target, trigger_spell_id, true); + target->CastSpell(target, trigger_spell_id, true, NULL, this, casterGUID); return; // Beacon of Light case 53563: // original caster must be target (beacon) - m_target->CastSpell(m_target,trigger_spell_id,true,NULL,this,m_target->GetGUID()); + target->CastSpell(target, trigger_spell_id, true, NULL, this, target->GetGUID()); return; } } // All ok cast by default case if(triggeredSpellInfo) - caster->CastSpell(target, triggeredSpellInfo, true, 0, this); - else if(target->GetTypeId()!=TYPEID_UNIT || !Script->EffectDummyCreature(caster, GetId(), GetEffIndex(), (Creature*)target)) - sLog.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex()); + target->CastSpell(target, triggeredSpellInfo, true, NULL, this, casterGUID); + else + { + if (Unit* caster = GetCaster()) + { + if(target->GetTypeId() != TYPEID_UNIT || !Script->EffectDummyCreature(caster, GetId(), GetEffIndex(), (Creature*)target)) + sLog.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex()); + } + } } void Aura::TriggerSpellWithValue() { - Unit* caster = GetCaster(); + const uint64& casterGUID = GetCasterGUID(); Unit* target = GetTriggerTarget(); - if(!caster || !target) + if(!casterGUID || !target) return; // generic casting code with custom spells and target/caster customs uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex]; int32 basepoints0 = this->GetModifier()->m_amount; - caster->CastCustomSpell(target, trigger_spell_id, &basepoints0, NULL, NULL, true, NULL, this); + target->CastCustomSpell(target, trigger_spell_id, &basepoints0, NULL, NULL, true, NULL, this, casterGUID); } /*********************************************************/ diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4413e6f5f..224e103f3 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 "8685" + #define REVISION_NR "8686" #endif // __REVISION_NR_H__