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
+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)