More work on scripts

This commit is contained in:
hondacrx
2023-10-20 07:29:05 -04:00
parent c56e1752f5
commit 1c6563718e
16 changed files with 3224 additions and 607 deletions
+124 -123
View File
@@ -1,4 +1,4 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using Framework.Constants;
@@ -8,194 +8,182 @@ using Game.Spells;
using System;
using System.Collections.Generic;
namespace Scripts.Events.Midsummer
namespace Scripts.Events
{
struct SpellIds
{
//Brazierhit
public const uint TorchTossingTraining = 45716;
public const uint TorchTossingPractice = 46630;
public const uint TorchTossingTrainingSuccessAlliance = 45719;
public const uint TorchTossingTrainingSuccessHorde = 46651;
public const uint TargetIndicatorCosmetic = 46901;
public const uint TargetIndicator = 45723;
public const uint BraziersHit = 45724;
//RibbonPoleData
public const uint HasFullMidsummerSet = 58933;
public const uint BurningHotPoleDance = 58934;
public const uint RibbonPolePeriodicVisual = 45406;
public const uint RibbonDance = 29175;
public const uint TestRibbonPole1 = 29705;
public const uint TestRibbonPole2 = 29726;
public const uint TestRibbonPole3 = 29727;
//Jugglingtorch
public const uint JuggleTorchSlow = 45792;
public const uint JuggleTorchMedium = 45806;
public const uint JuggleTorchFast = 45816;
public const uint JuggleTorchSelf = 45638;
public const uint JuggleTorchShadowSlow = 46120;
public const uint JuggleTorchShadowMedium = 46118;
public const uint JuggleTorchShadowFast = 46117;
public const uint JuggleTorchShadowSelf = 46121;
public const uint GiveTorch = 45280;
//Flingtorch
public const uint FlingTorchTriggered = 45669;
public const uint FlingTorchShadow = 46105;
public const uint JuggleTorchMissed = 45676;
public const uint TorchesCaught = 45693;
public const uint TorchCatchingSuccessAlliance = 46081;
public const uint TorchCatchingSuccessHorde = 46654;
public const uint TorchCatchingRemoveTorches = 46084;
}
struct QuestIds
{
//JugglingTorch
public const uint TorchCatchingA = 11657;
public const uint TorchCatchingH = 11923;
public const uint MoreTorchCatchingA = 11924;
public const uint MoreTorchCatchingH = 11925;
}
[Script] // 45724 - Braziers Hit!
class spell_midsummer_braziers_hit : AuraScript
{
const uint SpellTorchTossingTraining = 45716;
const uint SpellTorchTossingPractice = 46630;
const uint SpellTorchTossingTrainingSuccessAlliance = 45719;
const uint SpellTorchTossingTrainingSuccessHorde = 46651;
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(SpellIds.TorchTossingTraining, SpellIds.TorchTossingPractice);
return ValidateSpellInfo(SpellTorchTossingTraining, SpellTorchTossingPractice, SpellTorchTossingTrainingSuccessAlliance, SpellTorchTossingTrainingSuccessHorde);
}
void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode)
{
Player player = GetTarget().ToPlayer();
if (!player)
if (player == null)
return;
if ((player.HasAura(SpellIds.TorchTossingTraining) && GetStackAmount() == 8) || (player.HasAura(SpellIds.TorchTossingPractice) && GetStackAmount() == 20))
if ((player.HasAura(SpellTorchTossingTraining) && GetStackAmount() == 8) || (player.HasAura(SpellTorchTossingPractice) && GetStackAmount() == 20))
{
if (player.GetTeam() == Team.Alliance)
player.CastSpell(player, SpellIds.TorchTossingTrainingSuccessAlliance, true);
player.CastSpell(player, SpellTorchTossingTrainingSuccessAlliance, true);
else if (player.GetTeam() == Team.Horde)
player.CastSpell(player, SpellIds.TorchTossingTrainingSuccessHorde, true);
player.CastSpell(player, SpellTorchTossingTrainingSuccessHorde, true);
Remove();
}
}
public override void Register()
{
AfterEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Reapply));
AfterEffectApply.Add(new(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Reapply));
}
}
[Script] // 45907 - Torch Target Picker
class spell_midsummer_torch_target_picker : SpellScript
{
const uint SpellTargetIndicatorCosmetic = 46901;
const uint SpellTargetIndicator = 45723;
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(SpellIds.TargetIndicatorCosmetic, SpellIds.TargetIndicator);
return ValidateSpellInfo(SpellTargetIndicatorCosmetic, SpellTargetIndicator);
}
void HandleScript(uint effIndex)
{
Unit target = GetHitUnit();
target.CastSpell(target, SpellIds.TargetIndicatorCosmetic, true);
target.CastSpell(target, SpellIds.TargetIndicator, true);
target.CastSpell(target, SpellTargetIndicatorCosmetic, true);
target.CastSpell(target, SpellTargetIndicator, true);
}
public override void Register()
{
OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy));
OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.Dummy));
}
}
[Script] // 46054 - Torch Toss (land)
class spell_midsummer_torch_toss_land : SpellScript
{
const uint SpellBraziersHit = 45724;
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(SpellIds.BraziersHit);
return ValidateSpellInfo(SpellBraziersHit);
}
void HandleScript(uint effIndex)
{
GetHitUnit().CastSpell(GetCaster(), SpellIds.BraziersHit, true);
GetHitUnit().CastSpell(GetCaster(), SpellBraziersHit, true);
}
public override void Register()
{
OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect));
OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect));
}
}
[Script] // 29705, 29726, 29727 - Test Ribbon Pole Channel
class spell_midsummer_test_ribbon_pole_channel : AuraScript
{
const uint SpellHasFullMidsummerSet = 58933;
const uint SpellBurningHotPoleDance = 58934;
const uint SpellRibbonPolePeriodicVisual = 45406;
const uint SpellRibbonDance = 29175;
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(SpellIds.RibbonPolePeriodicVisual, SpellIds.BurningHotPoleDance, SpellIds.HasFullMidsummerSet, SpellIds.RibbonDance);
return ValidateSpellInfo(SpellRibbonPolePeriodicVisual, SpellBurningHotPoleDance, SpellHasFullMidsummerSet, SpellRibbonDance);
}
void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode)
{
GetTarget().RemoveAurasDueToSpell(SpellIds.RibbonPolePeriodicVisual);
GetTarget().RemoveAurasDueToSpell(SpellRibbonPolePeriodicVisual);
}
void PeriodicTick(AuraEffect aurEff)
{
Unit target = GetTarget();
target.CastSpell(target, SpellIds.RibbonPolePeriodicVisual, true);
target.CastSpell(target, SpellRibbonPolePeriodicVisual, true);
Aura aur = target.GetAura(SpellIds.RibbonDance);
Aura aur = target.GetAura(SpellRibbonDance);
if (aur != null)
{
aur.SetMaxDuration(Math.Min(3600000, aur.GetMaxDuration() + 180000));
aur.RefreshDuration();
if (aur.GetMaxDuration() == 3600000 && target.HasAura(SpellIds.HasFullMidsummerSet))
target.CastSpell(target, SpellIds.BurningHotPoleDance, true);
if (aur.GetMaxDuration() == 3600000 && target.HasAura(SpellHasFullMidsummerSet))
target.CastSpell(target, SpellBurningHotPoleDance, true);
}
else
target.CastSpell(target, SpellIds.RibbonDance, true);
target.CastSpell(target, SpellRibbonDance, true);
}
public override void Register()
{
AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 1, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real));
OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 1, AuraType.PeriodicTriggerSpell));
AfterEffectRemove.Add(new(HandleRemove, 1, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real));
OnEffectPeriodic.Add(new(PeriodicTick, 1, AuraType.PeriodicTriggerSpell));
}
}
[Script] // 45406 - Holiday - Midsummer, Ribbon Pole Periodic Visual
class spell_midsummer_ribbon_pole_periodic_visual : AuraScript
{
const uint SpellTestRibbonPole1 = 29705;
const uint SpellTestRibbonPole2 = 29726;
const uint SpellTestRibbonPole3 = 29727;
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(SpellIds.TestRibbonPole1, SpellIds.TestRibbonPole2, SpellIds.TestRibbonPole3);
return ValidateSpellInfo(SpellTestRibbonPole1, SpellTestRibbonPole2, SpellTestRibbonPole3);
}
void PeriodicTick(AuraEffect aurEff)
{
Unit target = GetTarget();
if (!target.HasAura(SpellIds.TestRibbonPole1) && !target.HasAura(SpellIds.TestRibbonPole2) && !target.HasAura(SpellIds.TestRibbonPole3))
if (!target.HasAura(SpellTestRibbonPole1) && !target.HasAura(SpellTestRibbonPole2) && !target.HasAura(SpellTestRibbonPole3))
Remove();
}
public override void Register()
{
OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 0, AuraType.PeriodicDummy));
OnEffectPeriodic.Add(new(PeriodicTick, 0, AuraType.PeriodicDummy));
}
}
struct JugglingTorch
{
public const uint SpellJuggleTorchSlow = 45792;
public const uint SpellJuggleTorchMedium = 45806;
public const uint SpellJuggleTorchFast = 45816;
public const uint SpellJuggleTorchSelf = 45638;
public const uint SpellJuggleTorchShadowSlow = 46120;
public const uint SpellJuggleTorchShadowMedium = 46118;
public const uint SpellJuggleTorchShadowFast = 46117;
public const uint SpellJuggleTorchShadowSelf = 46121;
public const uint SpellGiveTorch = 45280;
public const uint QuestTorchCatchingA = 11657;
public const uint QuestTorchCatchingH = 11923;
public const uint QuestMoreTorchCatchingA = 11924;
public const uint QuestMoreTorchCatchingH = 11925;
}
[Script] // 45819 - Throw Torch
class spell_midsummer_juggle_torch : SpellScript
{
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(SpellIds.JuggleTorchSlow, SpellIds.JuggleTorchMedium, SpellIds.JuggleTorchFast, SpellIds.JuggleTorchSelf,
SpellIds.JuggleTorchShadowSlow, SpellIds.JuggleTorchShadowMedium, SpellIds.JuggleTorchShadowFast, SpellIds.JuggleTorchShadowSelf);
return ValidateSpellInfo(JugglingTorch.SpellJuggleTorchSlow, JugglingTorch.SpellJuggleTorchMedium, JugglingTorch.SpellJuggleTorchFast, JugglingTorch.SpellJuggleTorchSelf,
JugglingTorch.SpellJuggleTorchShadowSlow, JugglingTorch.SpellJuggleTorchShadowMedium, JugglingTorch.SpellJuggleTorchShadowFast, JugglingTorch.SpellJuggleTorchShadowSelf);
}
void HandleDummy(uint effIndex)
@@ -206,38 +194,38 @@ namespace Scripts.Events.Midsummer
Position spellDest = GetExplTargetDest();
float distance = GetCaster().GetExactDist2d(spellDest.GetPositionX(), spellDest.GetPositionY());
uint torchSpellID = 0;
uint torchShadowSpellID = 0;
uint torchSpellID;
uint torchShadowSpellID;
if (distance <= 1.5f)
{
torchSpellID = SpellIds.JuggleTorchSelf;
torchShadowSpellID = SpellIds.JuggleTorchShadowSelf;
torchSpellID = JugglingTorch.SpellJuggleTorchSelf;
torchShadowSpellID = JugglingTorch.SpellJuggleTorchShadowSelf;
spellDest = GetCaster().GetPosition();
}
else if (distance <= 10.0f)
{
torchSpellID = SpellIds.JuggleTorchSlow;
torchShadowSpellID = SpellIds.JuggleTorchShadowSlow;
torchSpellID = JugglingTorch.SpellJuggleTorchSlow;
torchShadowSpellID = JugglingTorch.SpellJuggleTorchShadowSlow;
}
else if (distance <= 20.0f)
{
torchSpellID = SpellIds.JuggleTorchMedium;
torchShadowSpellID = SpellIds.JuggleTorchShadowMedium;
torchSpellID = JugglingTorch.SpellJuggleTorchMedium;
torchShadowSpellID = JugglingTorch.SpellJuggleTorchShadowMedium;
}
else
{
torchSpellID = SpellIds.JuggleTorchFast;
torchShadowSpellID = SpellIds.JuggleTorchShadowFast;
torchSpellID = JugglingTorch.SpellJuggleTorchFast;
torchShadowSpellID = JugglingTorch.SpellJuggleTorchShadowFast;
}
GetCaster().CastSpell(spellDest, torchSpellID, new CastSpellExtraArgs(false));
GetCaster().CastSpell(spellDest, torchShadowSpellID, new CastSpellExtraArgs(false));
GetCaster().CastSpell(spellDest, torchSpellID);
GetCaster().CastSpell(spellDest, torchShadowSpellID);
}
public override void Register()
{
OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy));
OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy));
}
}
@@ -246,43 +234,56 @@ namespace Scripts.Events.Midsummer
{
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(SpellIds.GiveTorch);
return ValidateSpellInfo(JugglingTorch.SpellGiveTorch);
}
void HandleDummy(uint effIndex)
{
Player player = GetHitPlayer();
if (!player)
if (player == null)
return;
if (player.GetQuestStatus(QuestIds.TorchCatchingA) == QuestStatus.Rewarded || player.GetQuestStatus(QuestIds.TorchCatchingH) == QuestStatus.Rewarded)
player.CastSpell(player, SpellIds.GiveTorch);
if (player.GetQuestStatus(JugglingTorch.QuestTorchCatchingA) == QuestStatus.Rewarded || player.GetQuestStatus(JugglingTorch.QuestTorchCatchingH) == QuestStatus.Rewarded)
player.CastSpell(player, JugglingTorch.SpellGiveTorch);
}
public override void Register()
{
OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy));
OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy));
}
}
struct FlingTorch
{
public const uint SpellFlingTorchTriggered = 45669;
public const uint SpellFlingTorchShadow = 46105;
public const uint SpellJuggleTorchMissed = 45676;
public const uint SpellTorchesCaught = 45693;
public const uint SpellTorchCatchingSuccessAlliance = 46081;
public const uint SpellTorchCatchingSuccessHorde = 46654;
public const uint SpellTorchCatchingRemoveTorches = 46084;
}
[Script] // 46747 - Fling torch
class spell_midsummer_fling_torch : SpellScript
{
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(SpellIds.FlingTorchTriggered, SpellIds.FlingTorchShadow);
return ValidateSpellInfo(FlingTorch.SpellFlingTorchTriggered, FlingTorch.SpellFlingTorchShadow);
}
void HandleDummy(uint effIndex)
{
Position dest = GetCaster().GetFirstCollisionPosition(30.0f, (float)RandomHelper.NextDouble() * (2 * MathF.PI));
GetCaster().CastSpell(dest, SpellIds.FlingTorchTriggered, new CastSpellExtraArgs(true));
GetCaster().CastSpell(dest, SpellIds.FlingTorchShadow, new CastSpellExtraArgs(false));
Position dest = GetCaster().GetFirstCollisionPosition(30.0f, (float)RandomHelper.NextDouble() * (float)(2 * MathF.PI));
GetCaster().CastSpell(dest, FlingTorch.SpellFlingTorchTriggered, true);
GetCaster().CastSpell(dest, FlingTorch.SpellFlingTorchShadow);
}
public override void Register()
{
OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy));
OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy));
}
}
@@ -291,26 +292,26 @@ namespace Scripts.Events.Midsummer
{
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(SpellIds.JuggleTorchMissed);
return ValidateSpellInfo(FlingTorch.SpellJuggleTorchMissed);
}
void HandleTriggerMissile(uint effIndex)
{
Position pos = GetHitDest();
if (pos != null)
{
{
if (GetCaster().GetExactDist2d(pos) > 3.0f)
{
PreventHitEffect(effIndex);
GetCaster().CastSpell(GetExplTargetDest(), SpellIds.JuggleTorchMissed, new CastSpellExtraArgs(false));
GetCaster().RemoveAura(SpellIds.TorchesCaught);
GetCaster().CastSpell(GetExplTargetDest(), FlingTorch.SpellJuggleTorchMissed);
GetCaster().RemoveAura(FlingTorch.SpellTorchesCaught);
}
}
}
public override void Register()
{
OnEffectHit.Add(new EffectHandler(HandleTriggerMissile, 0, SpellEffectName.TriggerMissile));
OnEffectHit.Add(new(HandleTriggerMissile, 0, SpellEffectName.TriggerMissile));
}
}
@@ -319,13 +320,13 @@ namespace Scripts.Events.Midsummer
{
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(SpellIds.FlingTorchTriggered, SpellIds.TorchCatchingSuccessAlliance, SpellIds.TorchCatchingSuccessHorde, SpellIds.TorchCatchingRemoveTorches, SpellIds.FlingTorchShadow);
return ValidateSpellInfo(FlingTorch.SpellFlingTorchTriggered, FlingTorch.SpellTorchCatchingSuccessAlliance, FlingTorch.SpellTorchCatchingSuccessHorde, FlingTorch.SpellTorchCatchingRemoveTorches, FlingTorch.SpellFlingTorchShadow);
}
void HandleScriptEffect(uint effIndex)
{
Player player = GetHitPlayer();
if (!player)
if (player == null)
return;
if (GetExplTargetDest() == null)
@@ -337,33 +338,33 @@ namespace Scripts.Events.Midsummer
byte requiredCatches = 0;
// Number of required catches depends on quest - 4 for the normal quest, 10 for the daily version
if (player.GetQuestStatus(QuestIds.TorchCatchingA) == QuestStatus.Incomplete || player.GetQuestStatus(QuestIds.TorchCatchingH) == QuestStatus.Incomplete)
if (player.GetQuestStatus(JugglingTorch.QuestTorchCatchingA) == QuestStatus.Incomplete || player.GetQuestStatus(JugglingTorch.QuestTorchCatchingH) == QuestStatus.Incomplete)
requiredCatches = 3;
else if (player.GetQuestStatus(QuestIds.MoreTorchCatchingA) == QuestStatus.Incomplete || player.GetQuestStatus(QuestIds.MoreTorchCatchingH) == QuestStatus.Incomplete)
else if (player.GetQuestStatus(JugglingTorch.QuestMoreTorchCatchingA) == QuestStatus.Incomplete || player.GetQuestStatus(JugglingTorch.QuestMoreTorchCatchingH) == QuestStatus.Incomplete)
requiredCatches = 9;
// Used quest item without being on quest - do nothing
if (requiredCatches == 0)
return;
if (player.GetAuraCount(SpellIds.TorchesCaught) >= requiredCatches)
if (player.GetAuraCount(FlingTorch.SpellTorchesCaught) >= requiredCatches)
{
player.CastSpell(player, (player.GetTeam() == Team.Alliance) ? SpellIds.TorchCatchingSuccessAlliance : SpellIds.TorchCatchingSuccessHorde);
player.CastSpell(player, SpellIds.TorchCatchingRemoveTorches);
player.RemoveAura(SpellIds.TorchesCaught);
player.CastSpell(player, (player.GetTeam() == Team.Alliance) ? FlingTorch.SpellTorchCatchingSuccessAlliance : FlingTorch.SpellTorchCatchingSuccessHorde);
player.CastSpell(player, FlingTorch.SpellTorchCatchingRemoveTorches);
player.RemoveAura(FlingTorch.SpellTorchesCaught);
}
else
{
Position dest = player.GetFirstCollisionPosition(15.0f, (float)RandomHelper.NextDouble() * (2 * MathF.PI));
player.CastSpell(player, SpellIds.TorchesCaught);
player.CastSpell(dest, SpellIds.FlingTorchTriggered, new CastSpellExtraArgs(true));
player.CastSpell(dest, SpellIds.FlingTorchShadow, new CastSpellExtraArgs(false));
Position dest = player.GetFirstCollisionPosition(15.0f, (float)RandomHelper.NextDouble() * (float)(2 * MathF.PI));
player.CastSpell(player, FlingTorch.SpellTorchesCaught);
player.CastSpell(dest, FlingTorch.SpellFlingTorchTriggered, true);
player.CastSpell(dest, FlingTorch.SpellFlingTorchShadow);
}
}
public override void Register()
{
OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect));
OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ScriptEffect));
}
}
@@ -378,8 +379,8 @@ namespace Scripts.Events.Midsummer
public override void Register()
{
OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaEntry));
OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 2, Targets.UnitDestAreaEntry));
OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaEntry));
OnObjectAreaTargetSelect.Add(new(FilterTargets, 2, Targets.UnitDestAreaEntry));
}
}
}
}