Scripts/Spells: Migrate Some Scripted Spells to Scripts

Port From (https://github.com/TrinityCore/TrinityCore/commit/d72e809ecf9349d45127e743d23a8391bddabc41)
This commit is contained in:
hondacrx
2021-12-01 11:29:31 -05:00
parent c59535dc05
commit 0257f00aab
5 changed files with 174 additions and 156 deletions
-134
View File
@@ -2748,17 +2748,6 @@ namespace Game.Spells
return;
unitTarget.RemoveAurasDueToSpell((uint)effectInfo.CalcValue());
break;
// Bending Shinbone
case 8856:
{
if (itemTarget == null && !m_caster.IsTypeId(TypeId.Player))
return;
uint spell_id = RandomHelper.Rand32(20) != 0 ? 8854u : 8855u;
m_caster.CastSpell(m_caster, spell_id, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetOriginalCastId(m_castId));
return;
}
// Brittle Armor - need remove one 24575 Brittle Armor aura
case 24590:
unitTarget.RemoveAuraFromStack(24575);
@@ -2793,36 +2782,6 @@ namespace Game.Spells
m_caster.CastSpell(unitTarget, 22682, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetOriginalCastId(m_castId));
return;
}
// Mirren's Drinking Hat
case 29830:
{
uint item = 0;
switch (RandomHelper.IRand(1, 6))
{
case 1:
case 2:
case 3:
item = 23584;
break; // Loch Modan Lager
case 4:
case 5:
item = 23585;
break; // Stouthammer Lite
case 6:
item = 23586;
break; // Aerie Peak Pale Ale
}
if (item != 0)
DoCreateItem(item);
break;
}
case 20589: // Escape artist
case 30918: // Improved Sprint
{
// Removes snares and roots.
unitTarget.RemoveMovementImpairingAuras(true);
break;
}
// Mug Transformation
case 41931:
{
@@ -2867,70 +2826,6 @@ namespace Game.Spells
break;
}
// Goblin Weather Machine
case 46203:
{
if (unitTarget == null)
return;
uint spellId = 0;
switch (RandomHelper.IRand(1, 4))
{
case 0: spellId = 46740; break;
case 1: spellId = 46739; break;
case 2: spellId = 46738; break;
case 3: spellId = 46736; break;
}
unitTarget.CastSpell(unitTarget, spellId, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetOriginalCastId(m_castId));
break;
}
// 5, 000 Gold
case 46642:
{
if (unitTarget == null || !unitTarget.IsTypeId(TypeId.Player))
return;
unitTarget.ToPlayer().ModifyMoney(5000 * MoneyConstants.Gold);
break;
}
// Death Knight Initiate Visual
case 51519:
{
if (unitTarget == null || !unitTarget.IsTypeId(TypeId.Unit))
return;
uint iTmpSpellId;
switch (unitTarget.GetDisplayId())
{
case 25369: iTmpSpellId = 51552; break; // bloodelf female
case 25373: iTmpSpellId = 51551; break; // bloodelf male
case 25363: iTmpSpellId = 51542; break; // draenei female
case 25357: iTmpSpellId = 51541; break; // draenei male
case 25361: iTmpSpellId = 51537; break; // dwarf female
case 25356: iTmpSpellId = 51538; break; // dwarf male
case 25372: iTmpSpellId = 51550; break; // forsaken female
case 25367: iTmpSpellId = 51549; break; // forsaken male
case 25362: iTmpSpellId = 51540; break; // gnome female
case 25359: iTmpSpellId = 51539; break; // gnome male
case 25355: iTmpSpellId = 51534; break; // human female
case 25354: iTmpSpellId = 51520; break; // human male
case 25360: iTmpSpellId = 51536; break; // nightelf female
case 25358: iTmpSpellId = 51535; break; // nightelf male
case 25368: iTmpSpellId = 51544; break; // orc female
case 25364: iTmpSpellId = 51543; break; // orc male
case 25371: iTmpSpellId = 51548; break; // tauren female
case 25366: iTmpSpellId = 51547; break; // tauren male
case 25370: iTmpSpellId = 51545; break; // troll female
case 25365: iTmpSpellId = 51546; break; // troll male
default: return;
}
unitTarget.CastSpell(unitTarget, iTmpSpellId, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetOriginalCastId(m_castId));
Creature npc = unitTarget.ToCreature();
npc.LoadEquipment();
return;
}
// Emblazon Runeblade
case 51770:
{
@@ -3099,35 +2994,6 @@ namespace Game.Spells
return;
}
// Stoneclaw Totem
case 55328: // Rank 1
case 55329: // Rank 2
case 55330: // Rank 3
case 55332: // Rank 4
case 55333: // Rank 5
case 55335: // Rank 6
case 55278: // Rank 7
case 58589: // Rank 8
case 58590: // Rank 9
case 58591: // Rank 10
{
// Cast Absorb on totems
for (byte slot = (int)SummonSlot.Totem; slot < SharedConst.MaxTotemSlot; ++slot)
{
if (unitTarget.m_SummonSlot[slot].IsEmpty())
continue;
Creature totem = unitTarget.GetMap().GetCreature(unitTarget.m_SummonSlot[slot]);
if (totem != null && totem.IsTotem())
{
CastSpellExtraArgs args = new(TriggerCastFlags.FullMask);
args.SetOriginalCastId(m_castId);
args.AddSpellMod(SpellValueMod.BasePoint0, damage);
m_caster.CastSpell(totem, 55277, args);
}
}
break;
}
case 45668: // Ultra-Advanced Proto-Typical Shortening Blaster
{
if (unitTarget == null || !unitTarget.IsTypeId(TypeId.Unit))
+37
View File
@@ -553,6 +553,43 @@ namespace Scripts.Spells.DeathKnight
}
}
[Script] // 69961 - Glyph of Scourge Strike
class spell_dk_glyph_of_scourge_strike_script : SpellScript
{
void HandleScriptEffect(uint effIndex)
{
Unit caster = GetCaster();
Unit target = GetHitUnit();
var mPeriodic = target.GetAuraEffectsByType(AuraType.PeriodicDamage);
foreach (var aurEff in mPeriodic)
{
SpellInfo spellInfo = aurEff.GetSpellInfo();
// search our Blood Plague and Frost Fever on target
if (spellInfo.SpellFamilyName == SpellFamilyNames.Deathknight && spellInfo.SpellFamilyFlags[2].HasAnyFlag(0x2u) &&
aurEff.GetCasterGUID() == caster.GetGUID())
{
int countMin = aurEff.GetBase().GetMaxDuration();
int countMax = spellInfo.GetMaxDuration();
// this Glyph
countMax += 9000;
if (countMin < countMax)
{
aurEff.GetBase().SetDuration(aurEff.GetBase().GetDuration() + 3000);
aurEff.GetBase().SetMaxDuration(countMin + 3000);
}
}
}
}
public override void Register()
{
OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect));
}
}
[Script] // 206940 - Mark of Blood
class spell_dk_mark_of_blood : AuraScript
{
+31
View File
@@ -1681,6 +1681,23 @@ namespace Scripts.Spells.Generic
}
}
[Script] // 46642 - 5,000 Gold
class spell_gen_5000_gold : SpellScript
{
void HandleScript(uint effIndex)
{
Player target = GetHitPlayer();
if (target != null)
target.ModifyMoney(5000 * MoneyConstants.Gold);
}
public override void Register()
{
OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect));
}
}
[Script] // 131474 - Fishing
class spell_gen_fishing : SpellScript
{
@@ -2437,6 +2454,20 @@ namespace Scripts.Spells.Generic
}
}
[Script]
class spell_gen_remove_impairing_auras : SpellScript
{
void HandleScriptEffect(uint effIndex)
{
GetHitUnit().RemoveMovementImpairingAuras(true);
}
public override void Register()
{
OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect));
}
}
// 23493 - Restoration
[Script] // 24379 - Restoration
class spell_gen_restoration : AuraScript
+81 -21
View File
@@ -77,6 +77,12 @@ namespace Scripts.Spells.Items
public const uint SpeedOfTheVrykulHero = 71560; // +700 Haste
public const uint StrengthOfTheTaunkaHero = 71561; // +700 Strength
//GoblinWeatherMachine
public const uint PersonalizedWeather1 = 46740;
public const uint PersonalizedWeather2 = 46739;
public const uint PersonalizedWeather3 = 46738;
public const uint PersonalizedWeather4 = 46736;
//Defibrillate
public const uint GoblinJumperCablesFail = 8338;
public const uint GoblinJumperCablesXlFail = 23055;
@@ -444,6 +450,11 @@ namespace Scripts.Spells.Items
public const uint HeartCandy6 = 21823;
public const uint HeartCandy7 = 21822;
public const uint HeartCandy8 = 21820;
//MirrensDrinkingHat
public const uint LochModanLager = 23584;
public const uint StouthammerLite = 23585;
public const uint AeriePeakPaleAle = 23586;
}
struct QuestIds
@@ -646,7 +657,7 @@ namespace Scripts.Spells.Items
{
GetTarget().RemoveAurasDueToSpell(SpellIds.MoteOfAnger);
}
public override void Register()
{
OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy));
@@ -806,7 +817,7 @@ namespace Scripts.Spells.Items
DoCheckProc.Add(new CheckProcHandler(CheckProc));
}
}
[Script] // 71564 - Deadly Precision
class spell_item_deadly_precision : AuraScript
{
@@ -950,6 +961,24 @@ namespace Scripts.Spells.Items
}
}
[Script] // 46203 - Goblin Weather Machine
class spell_item_goblin_weather_machine : SpellScript
{
void HandleScript(uint effIndex)
{
Unit target = GetHitUnit();
uint spellId = RandomHelper.RAND(SpellIds.PersonalizedWeather1, SpellIds.PersonalizedWeather2, SpellIds.PersonalizedWeather3, SpellIds.PersonalizedWeather4);
target.CastSpell(target, spellId, new CastSpellExtraArgs(TriggerCastFlags.FullMask)
.SetOriginalCastId(GetSpell().m_castId));
}
public override void Register()
{
OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect));
}
}
// 8342 - Defibrillate (Goblin Jumper Cables) have 33% chance on success
// 22999 - Defibrillate (Goblin Jumper Cables XL) have 50% chance on success
// 54732 - Defibrillate (Gnomish Army Knife) have 67% chance on success
@@ -1106,7 +1135,7 @@ namespace Scripts.Spells.Items
OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 0, AuraType.PeriodicTriggerSpell));
}
}
[Script] // 7434 - Fate Rune of Unsurpassed Vigor
class spell_item_fate_rune_of_unsurpassed_vigor : AuraScript
{
@@ -1674,10 +1703,10 @@ namespace Scripts.Spells.Items
{
DoCheckAreaTarget.Add(new CheckAreaTargetHandler(CheckCaster));
AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real));
AfterEffectRemove .Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real));
AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real));
}
}
// http://www.wowhead.com/item=6657 Savory Deviate Delight
[Script] // 8213 Savory Deviate Delight
class spell_item_savory_deviate_delight : SpellScript
@@ -1841,7 +1870,7 @@ namespace Scripts.Spells.Items
{
GetTarget().RemoveAurasDueToSpell(SpellIds.ShadowmourneSoulFragment);
}
public override void Register()
{
DoCheckProc.Add(new CheckProcHandler(CheckProc));
@@ -3043,21 +3072,21 @@ namespace Scripts.Spells.Items
switch (aurEff.GetId())
{
case SpellIds.DeathChoiceNormalAura:
{
if (str > agi)
caster.CastSpell(caster, SpellIds.DeathChoiceNormalStrength, new CastSpellExtraArgs(aurEff));
else
caster.CastSpell(caster, SpellIds.DeathChoiceNormalAgility, new CastSpellExtraArgs(aurEff));
break;
}
{
if (str > agi)
caster.CastSpell(caster, SpellIds.DeathChoiceNormalStrength, new CastSpellExtraArgs(aurEff));
else
caster.CastSpell(caster, SpellIds.DeathChoiceNormalAgility, new CastSpellExtraArgs(aurEff));
break;
}
case SpellIds.DeathChoiceHeroicAura:
{
if (str > agi)
caster.CastSpell(caster, SpellIds.DeathChoiceHeroicStrength, new CastSpellExtraArgs(aurEff));
else
caster.CastSpell(caster, SpellIds.DeathChoiceHeroicAgility, new CastSpellExtraArgs(aurEff));
break;
}
{
if (str > agi)
caster.CastSpell(caster, SpellIds.DeathChoiceHeroicStrength, new CastSpellExtraArgs(aurEff));
else
caster.CastSpell(caster, SpellIds.DeathChoiceHeroicAgility, new CastSpellExtraArgs(aurEff));
break;
}
default:
break;
}
@@ -3111,7 +3140,7 @@ namespace Scripts.Spells.Items
{
GetTarget().RemoveAurasDueToSpell(_stackSpell);
}
public override void Register()
{
OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell));
@@ -3241,6 +3270,37 @@ namespace Scripts.Spells.Items
}
}
[Script] // 29830 - Mirren's Drinking Hat
class spell_item_mirrens_drinking_hat : SpellScript
{
void HandleScriptEffect(uint effIndex)
{
uint itemId = 0;
switch (RandomHelper.URand(1, 6))
{
case 1:
case 2:
case 3:
itemId = ItemIds.LochModanLager;
break;
case 4:
case 5:
itemId = ItemIds.StouthammerLite;
break;
case 6:
itemId = ItemIds.AeriePeakPaleAle;
break;
}
if (itemId != 0)
CreateItem(itemId, ItemContext.None);
}
public override void Register()
{
OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect));
}
}
[Script] // 13180 - Gnomish Mind Control Cap
class spell_item_mind_control_cap_SpellScript : SpellScript
{
+25 -1
View File
@@ -28,6 +28,10 @@ namespace Scripts.Spells.Quest
{
struct SpellIds
{
//BendingShinbone
public const uint BendingShinbone1 = 8854;
public const uint BendingShinbone2 = 8855;
//Thaumaturgychannel
public const uint ThaumaturgyChannel = 21029;
@@ -355,8 +359,28 @@ namespace Scripts.Spells.Quest
uint _despawnTime;
}
// 9712 - Thaumaturgy Channel
[Script]
class spell_q1846_bending_shinbone : SpellScript
{
void HandleScriptEffect(uint effIndex)
{
Item target = GetHitItem();
Unit caster = GetCaster();
if (!target && !caster.IsPlayer())
return;
uint spellId = RandomHelper.randChance(20) ? SpellIds.BendingShinbone1 : SpellIds.BendingShinbone2;
caster.CastSpell(caster, spellId, new CastSpellExtraArgs(TriggerCastFlags.FullMask)
.SetOriginalCastId(GetSpell().m_castId));
}
public override void Register()
{
OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect));
}
}
[Script] // 9712 - Thaumaturgy Channel
class spell_q2203_thaumaturgy_channel : AuraScript
{
public override bool Validate(SpellInfo spellInfo)