Permalink
Browse files

Earth Shield is no longer using Dummy Handler for handling its effect…

… and now it is being properly handled by SpellProc. As well now it triggers SpellId 379 to do an actual heal, charges are not being removed on positive spell cast and it doesn't trigger Ancestral Healing when it does a crit heal. Don't forget to apply the SQL update.
  • Loading branch information...
1 parent b48e593 commit ff7807127d6662c1170f1ff632cb21598f2c668d @neo-mat committed Feb 9, 2012
@@ -0,0 +1 @@
+INSERT INTO `spell_effects_override` (`spellId`, `ImplicitTargetA`) VALUES ('379', '21') -- Earth Shield Triggered Spell
@@ -52,14 +52,6 @@ void SpellProc::CastSpell(Unit* victim, SpellEntry* CastingSpell, int* dmg_overw
spell->forced_basepoints[2] = dmg_overwrite[2];
spell->ProcedOnSpell = CastingSpell;
- if(mSpell->Id == 974 || mSpell->Id == 32593 || mSpell->Id == 32594 || mSpell->Id == 49283 || mSpell->Id == 49284) // Earth Shield handler
- {
- spell->pSpellId = mSpell->Id;
- spell->SpellEffectDummy(0);
- delete spell;
- return;
- }
-
if(mOrigSpell != NULL)
spell->pSpellId = mOrigSpell->Id;
@@ -36,6 +36,31 @@ class FrostBrandAttackSpellProc : public SpellProc
}
};
+class EarthShieldSpellProc : public SpellProc
+{
+ SPELL_PROC_FACTORY_FUNCTION(EarthShieldSpellProc);
+
+ bool DoEffect(Unit* victim, SpellEntry* CastingSpell, uint32 flag, uint32 dmg, uint32 abs, int* dmg_overwrite, uint32 weapon_damage_type)
+ {
+ int32 value = mOrigSpell->EffectBasePoints[0];
+ dmg_overwrite[0] = value;
+
+ return false;
+ }
+
+ void CastSpell(Unit* victim, SpellEntry* CastingSpell, int* dmg_overwrite)
+ {
+ Unit* caster = TO_PLAYER(mTarget->GetMapMgr()->_GetObject(mCaster));
@jackpoz

jackpoz Feb 9, 2012

Don't cast an object to Player and then store in in a Unit reference. If you need a Unit* , use GetUnit(). If you need a Player* , use GetPlayer() .

@neo-mat

neo-mat Feb 9, 2012

Owner

Heh, was thinking about it earlier today while was in traffic, it was left there due to testing. And isn't _GetObject() returning GetPlayer anyway based on type of guid? Object* MapMgr::_GetObject returns me default: GetUnit(guid), Unit* MapMgr::GetUnit checks type of guid and returns me GetPlayer(Arcemu::Util::GUID_LOPART(guid)). But yeah, I don't need it to be stored in a Unit reference, just cudn't figure out at start who was an owner of the proc because spell proc was casted by target of the mother spell, so copypasted Empowered Renew proc handler and started to work from there.

Thanks for reminding, would have forgotten :>

@jackpoz

jackpoz Feb 9, 2012

it's usually better to use the lowest possible class so it will work with more casters. If that's not possible, than using the method that already returns the right reference type is better than TO<Type*>( GetObject() ) as it's type safe, while with GetObject() you have to check if it's of the Type you want before casting it.

Listen to some music when stuck in the traffic instead of thinking about ArcEmu ;)

@neo-mat

neo-mat Feb 9, 2012

Owner

Hah, I was listening to ThePianoGuys, but still had this in my mind no idea why :(

Well, sSpellFactoryMgr.NewSpell takes caster as an Object* so guess Object* caster = mTarget->GetMapMgr()->_GetObject(mCaster) will do the job.

+ if(caster == NULL)
+ return;
+
+ Spell* spell = sSpellFactoryMgr.NewSpell(caster, mSpell, true, NULL);
+ SpellCastTargets targets(mTarget->GetGUID());
+ spell->prepare(&targets);
+ }
+
+};
+
class FlametongueWeaponSpellProc : public SpellProc
{
SPELL_PROC_FACTORY_FUNCTION(FlametongueWeaponSpellProc);
@@ -110,4 +135,5 @@ void SpellProcMgr::SetupShamman()
AddByNameHash(SPELL_HASH_FROSTBRAND_ATTACK, &FrostBrandAttackSpellProc::Create);
AddById(10444, &FlametongueWeaponSpellProc::Create);
+ AddById(379, &EarthShieldSpellProc::Create);
}
@@ -1751,6 +1751,12 @@ uint32 Unit::HandleProc(uint32 flag, Unit* victim, SpellEntry* CastingSpell, boo
case 16177:
case 16236:
case 16237:
+ {
+ if(CastingSpell == NULL)
+ continue;
+ if(CastingSpell->NameHash == SPELL_HASH_EARTH_SHIELD) //Do not proc on Earth Shield crits
+ continue;
+ }
//Shaman - Earthliving Weapon
case 51940:
case 51989:
@@ -63,23 +63,6 @@ bool SkyShatterRegalia(uint32 i, Spell* s)
return true;
}
-bool EarthShield(uint32 i, Spell* s)
-{
- if(!s->pSpellId)
- return false;
-
- SpellEntry* spellInfo = dbcSpell.LookupEntryForced(s->pSpellId);
- if(!spellInfo)
- return false;
-
- uint32 heal32 = s->CalculateEffect(i, s->u_caster);
- s->SetUnitTarget(s->u_caster);
- if(heal32)
- s->Heal(heal32);
-
- return true;
-}
-
bool ManaTide(uint32 i, Spell* s)
{
Unit* unitTarget = s->GetUnitTarget();
@@ -93,15 +76,14 @@ bool ManaTide(uint32 i, Spell* s)
return true;
}
-bool EarthShieldDummyAura(uint32 i, Aura* a, bool apply)
+bool EarthShieldDummyAura(uint32 i, Aura* pAura, bool apply)
{
- Unit* m_target = a->GetTarget();
+ Unit* m_target = pAura->GetTarget();
if(apply)
- m_target->AddProcTriggerSpell(a->GetSpellProto(), a->m_casterGuid, NULL, NULL);
- //remove the proc trigger spell if there's only 1 aura left, so the one being removed right now
- else if(m_target->GetAuraStackCount(a->GetSpellId()) == 1)
- m_target->RemoveProcTriggerSpell(a->GetSpellId(), a->m_casterGuid);
+ m_target->AddProcTriggerSpell(379, pAura->GetSpellId(), pAura->m_casterGuid, pAura->GetSpellProto()->procChance, pAura->GetSpellProto()->procFlags & ~PROC_ON_SPELL_LAND_VICTIM, pAura->GetSpellProto()->procCharges, NULL, NULL);
+ else if(m_target->GetAuraStackCount(pAura->GetSpellId()) == 1)
+ m_target->RemoveProcTriggerSpell(379, pAura->m_casterGuid);
return true;
}
@@ -130,26 +112,15 @@ void SetupShamanSpells(ScriptMgr* mgr)
mgr->register_dummy_spell(38443, &SkyShatterRegalia);
- uint32 earthshieldids[] =
- {
- 974,
- 32593,
- 32594,
- 49283,
- 49284,
- 0
- };
- mgr->register_dummy_spell(earthshieldids, &EarthShield);
-
mgr->register_dummy_spell(39610, &ManaTide);
uint32 earthshielddummyauraids[] =
{
974,
32593,
32594,
- 49284,
49283,
+ 49284,
0
};
mgr->register_dummy_aura(earthshielddummyauraids, &EarthShieldDummyAura);

0 comments on commit ff78071

Please sign in to comment.