Core/Auras: periodics refactor part 5: ported periodic trigger spell auras to scripts
Port From (https://github.com/TrinityCore/TrinityCore/commit/44c8ccadd701c1a4bc0ce08ee53a7a7ba55289d4)
This commit is contained in:
@@ -4790,277 +4790,9 @@ namespace Game.Spells
|
||||
|
||||
void HandlePeriodicTriggerSpellAuraTick(Unit target, Unit caster)
|
||||
{
|
||||
// generic casting code with custom spells and target/caster customs
|
||||
uint triggerSpellId = GetSpellEffectInfo().TriggerSpell;
|
||||
|
||||
SpellInfo triggeredSpellInfo = Global.SpellMgr.GetSpellInfo(triggerSpellId, GetBase().GetCastDifficulty());
|
||||
SpellInfo auraSpellInfo = GetSpellInfo();
|
||||
uint auraId = auraSpellInfo.Id;
|
||||
|
||||
// specific code for cases with no trigger spell provided in field
|
||||
if (triggeredSpellInfo == null)
|
||||
{
|
||||
switch (auraSpellInfo.SpellFamilyName)
|
||||
{
|
||||
case SpellFamilyNames.Generic:
|
||||
{
|
||||
switch (auraId)
|
||||
{
|
||||
// Brood Affliction: Bronze
|
||||
case 23170:
|
||||
triggerSpellId = 23171;
|
||||
break;
|
||||
// Restoration
|
||||
case 24379:
|
||||
case 23493:
|
||||
{
|
||||
if (caster != null)
|
||||
{
|
||||
uint heal = (uint)caster.CountPctFromMaxHealth(10);
|
||||
HealInfo healInfo = new HealInfo(caster, target, heal, auraSpellInfo, auraSpellInfo.GetSchoolMask());
|
||||
caster.HealBySpell(healInfo);
|
||||
|
||||
// @todo: should proc other auras?
|
||||
int mana = caster.GetMaxPower(PowerType.Mana);
|
||||
if (mana != 0)
|
||||
{
|
||||
mana /= 10;
|
||||
caster.EnergizeBySpell(caster, 23493, mana, PowerType.Mana);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Nitrous Boost
|
||||
case 27746:
|
||||
if (caster != null && target.GetPower(PowerType.Mana) >= 10)
|
||||
{
|
||||
target.ModifyPower(PowerType.Mana, -10);
|
||||
target.SendEnergizeSpellLog(caster, 27746, 10, 0, PowerType.Mana);
|
||||
}
|
||||
else
|
||||
target.RemoveAurasDueToSpell(27746);
|
||||
return;
|
||||
// Frost Blast
|
||||
case 27808:
|
||||
if (caster != null)
|
||||
caster.CastCustomSpell(29879, SpellValueMod.BasePoint0, (int)target.CountPctFromMaxHealth(21), target, true, null, this);
|
||||
return;
|
||||
// Inoculate Nestlewood Owlkin
|
||||
case 29528:
|
||||
if (!target.IsTypeId(TypeId.Unit)) // prevent error reports in case ignored player target
|
||||
return;
|
||||
break;
|
||||
// Feed Captured Animal
|
||||
case 29917:
|
||||
triggerSpellId = 29916;
|
||||
break;
|
||||
// Extract Gas
|
||||
case 30427:
|
||||
{
|
||||
// move loot to player inventory and despawn target
|
||||
if (caster != null && caster.IsTypeId(TypeId.Player) &&
|
||||
target.IsTypeId(TypeId.Unit) &&
|
||||
target.ToCreature().GetCreatureTemplate().CreatureType == CreatureType.GasCloud)
|
||||
{
|
||||
Player player = caster.ToPlayer();
|
||||
Creature creature = target.ToCreature();
|
||||
// missing lootid has been reported on startup - just return
|
||||
if (creature.GetCreatureTemplate().SkinLootId == 0)
|
||||
return;
|
||||
|
||||
player.AutoStoreLoot(creature.GetCreatureTemplate().SkinLootId, LootStorage.Skinning, ItemContext.None, true);
|
||||
|
||||
creature.DespawnOrUnsummon();
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Quake
|
||||
case 30576:
|
||||
triggerSpellId = 30571;
|
||||
break;
|
||||
// Doom
|
||||
// @todo effect trigger spell may be independant on spell targets, and executed in spell finish phase
|
||||
// so instakill will be naturally done before trigger spell
|
||||
case 31347:
|
||||
{
|
||||
target.CastSpell(target, 31350, true, null, this);
|
||||
target.KillSelf();
|
||||
return;
|
||||
}
|
||||
// Spellcloth
|
||||
case 31373:
|
||||
{
|
||||
// Summon Elemental after create item
|
||||
target.SummonCreature(17870, 0, 0, 0, target.GetOrientation(), TempSummonType.DeadDespawn, 0);
|
||||
return;
|
||||
}
|
||||
// Flame Quills
|
||||
case 34229:
|
||||
{
|
||||
// cast 24 spells 34269-34289, 34314-34316
|
||||
for (uint spell_id = 34269; spell_id != 34290; ++spell_id)
|
||||
target.CastSpell(target, spell_id, true, null, this);
|
||||
for (uint spell_id = 34314; spell_id != 34317; ++spell_id)
|
||||
target.CastSpell(target, spell_id, true, null, this);
|
||||
return;
|
||||
}
|
||||
// Remote Toy
|
||||
case 37027:
|
||||
triggerSpellId = 37029;
|
||||
break;
|
||||
// Eye of Grillok
|
||||
case 38495:
|
||||
triggerSpellId = 38530;
|
||||
break;
|
||||
// Absorb Eye of Grillok (Zezzak's Shard)
|
||||
case 38554:
|
||||
{
|
||||
if (caster == null || !target.IsTypeId(TypeId.Unit))
|
||||
return;
|
||||
|
||||
caster.CastSpell(caster, 38495, true, null, this);
|
||||
|
||||
Creature creatureTarget = target.ToCreature();
|
||||
|
||||
creatureTarget.DespawnOrUnsummon();
|
||||
return;
|
||||
}
|
||||
// Tear of Azzinoth Summon Channel - it's not really supposed to do anything, and this only prevents the console spam
|
||||
case 39857:
|
||||
triggerSpellId = 39856;
|
||||
break;
|
||||
// Personalized Weather
|
||||
case 46736:
|
||||
triggerSpellId = 46737;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SpellFamilyNames.Shaman:
|
||||
{
|
||||
switch (auraId)
|
||||
{
|
||||
// Lightning Shield (The Earthshatterer set trigger after cast Lighting Shield)
|
||||
case 28820:
|
||||
{
|
||||
// Need remove self if Lightning Shield not active
|
||||
if (target.GetAuraEffect(AuraType.ProcTriggerSpell, SpellFamilyNames.Shaman, new FlagArray128(0x400, 0, 0)) == null)
|
||||
target.RemoveAurasDueToSpell(28820);
|
||||
return;
|
||||
}
|
||||
// Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus)
|
||||
case 38443:
|
||||
{
|
||||
bool all = true;
|
||||
for (int i = (int)SummonSlot.Totem; i < SharedConst.MaxSummonSlot; ++i)
|
||||
{
|
||||
if (target.m_SummonSlot[i].IsEmpty())
|
||||
{
|
||||
all = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (all)
|
||||
target.CastSpell(target, 38437, true, null, this);
|
||||
else
|
||||
target.RemoveAurasDueToSpell(38437);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Spell exist but require custom code
|
||||
switch (auraId)
|
||||
{
|
||||
// Pursuing Spikes (Anub'arak)
|
||||
case 65920:
|
||||
case 65922:
|
||||
case 65923:
|
||||
{
|
||||
Unit permafrostCaster = null;
|
||||
Aura permafrostAura = target.GetAura(66193);
|
||||
if (permafrostAura == null)
|
||||
permafrostAura = target.GetAura(67855);
|
||||
if (permafrostAura == null)
|
||||
permafrostAura = target.GetAura(67856);
|
||||
if (permafrostAura == null)
|
||||
permafrostAura = target.GetAura(67857);
|
||||
|
||||
if (permafrostAura != null)
|
||||
permafrostCaster = permafrostAura.GetCaster();
|
||||
|
||||
if (permafrostCaster != null)
|
||||
{
|
||||
Creature permafrostCasterCreature = permafrostCaster.ToCreature();
|
||||
if (permafrostCasterCreature != null)
|
||||
permafrostCasterCreature.DespawnOrUnsummon(3000);
|
||||
|
||||
target.CastSpell(target, 66181, false);
|
||||
target.RemoveAllAuras();
|
||||
Creature targetCreature = target.ToCreature();
|
||||
if (targetCreature != null)
|
||||
targetCreature.DisappearAndDie();
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Mana Tide
|
||||
case 16191:
|
||||
target.CastCustomSpell(target, triggerSpellId, m_amount, 0, 0, true, null, this);
|
||||
return;
|
||||
// Negative Energy Periodic
|
||||
case 46284:
|
||||
target.CastCustomSpell(triggerSpellId, SpellValueMod.MaxTargets, (int)(_ticksDone / 10 + 1), null, true, null, this);
|
||||
return;
|
||||
// Poison (Grobbulus)
|
||||
case 28158:
|
||||
case 54362:
|
||||
// Slime Pool (Dreadscale & Acidmaw)
|
||||
case 66882:
|
||||
target.CastCustomSpell(triggerSpellId, SpellValueMod.RadiusMod, (int)(((_ticksDone / 60.0f) * 0.9f + 0.1f) * 10000.0f * 2.0f / 3.0f), null, true, null, this);
|
||||
return;
|
||||
// Slime Spray - temporary here until preventing default effect works again
|
||||
// added on 9.10.2010
|
||||
case 69508:
|
||||
{
|
||||
if (caster != null)
|
||||
caster.CastSpell(target, triggerSpellId, true, null, null, caster.GetGUID());
|
||||
return;
|
||||
}
|
||||
case 24745: // Summon Templar, Trigger
|
||||
case 24747: // Summon Templar Fire, Trigger
|
||||
case 24757: // Summon Templar Air, Trigger
|
||||
case 24759: // Summon Templar Earth, Trigger
|
||||
case 24761: // Summon Templar Water, Trigger
|
||||
case 24762: // Summon Duke, Trigger
|
||||
case 24766: // Summon Duke Fire, Trigger
|
||||
case 24769: // Summon Duke Air, Trigger
|
||||
case 24771: // Summon Duke Earth, Trigger
|
||||
case 24773: // Summon Duke Water, Trigger
|
||||
case 24785: // Summon Royal, Trigger
|
||||
case 24787: // Summon Royal Fire, Trigger
|
||||
case 24791: // Summon Royal Air, Trigger
|
||||
case 24792: // Summon Royal Earth, Trigger
|
||||
case 24793: // Summon Royal Water, Trigger
|
||||
{
|
||||
// All this spells trigger a spell that requires reagents; if the
|
||||
// triggered spell is cast as "triggered", reagents are not consumed
|
||||
if (caster != null)
|
||||
caster.CastSpell(target, triggerSpellId, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reget trigger spell proto
|
||||
triggeredSpellInfo = Global.SpellMgr.GetSpellInfo(triggerSpellId, GetBase().GetCastDifficulty());
|
||||
|
||||
if (triggeredSpellInfo != null)
|
||||
{
|
||||
Unit triggerCaster = triggeredSpellInfo.NeedsToBeTriggeredByCaster(m_spellInfo) ? caster : target;
|
||||
|
||||
@@ -2984,6 +2984,25 @@ namespace Game.Entities
|
||||
case 43327:
|
||||
spellInfo.GetEffect(1).ApplyAuraPeriod = 1 * Time.InMilliseconds;
|
||||
break;
|
||||
// specific code for cases with no trigger spell provided in field
|
||||
case 23170: // Brood Affliction: Bronze
|
||||
spellInfo.GetEffect(0).TriggerSpell = 23171;
|
||||
break;
|
||||
case 29917: // Feed Captured Animal
|
||||
spellInfo.GetEffect(0).TriggerSpell = 29916;
|
||||
break;
|
||||
case 37027: // Remote Toy
|
||||
spellInfo.GetEffect(0).TriggerSpell = 37029;
|
||||
break;
|
||||
case 38495: // Eye of Grillok
|
||||
spellInfo.GetEffect(0).TriggerSpell = 38530;
|
||||
break;
|
||||
case 39857: // Tear of Azzinoth Summon Channel - it's not really supposed to do anything, and this only prevents the console spam
|
||||
spellInfo.GetEffect(0).TriggerSpell = 39856;
|
||||
break;
|
||||
case 46736:// Personalized Weather
|
||||
spellInfo.GetEffect(1).TriggerSpell = 46737;
|
||||
break;
|
||||
case 63026: // Summon Aspirant Test NPC (HACK: Target shouldn't be changed)
|
||||
case 63137: // Summon Valiant Test (HACK: Target shouldn't be changed; summon position should be untied from spell destination)
|
||||
spellInfo.GetEffect(0).TargetA = new SpellImplicitTargetInfo(Targets.DestDb);
|
||||
|
||||
Reference in New Issue
Block a user