Scripts/Misc: Migrate world event scripts to separate files 2

Port From (https://github.com/TrinityCore/TrinityCore/commit/4281049e0c0d38a968d1d37bdd3ec04e35b81850)
This commit is contained in:
hondacrx
2022-07-04 15:13:42 -04:00
parent 9fc2cd8b26
commit 4ae61d8811
6 changed files with 130 additions and 454 deletions
+47 -20
View File
@@ -37,6 +37,14 @@ namespace Scripts.Events.Brewfest
public const uint RamFatigue = 43052;
public const uint ExhaustedRam = 43332;
public const uint RelayRaceTurnIn = 44501;
//Brewfestmounttransformation
public const uint MountRam100 = 43900;
public const uint MountRam60 = 43899;
public const uint MountKodo100 = 49379;
public const uint MountKodo60 = 49378;
public const uint BrewfestMountTransform = 49357;
public const uint BrewfestMountTransformReverse = 52845;
}
struct QuestIds
@@ -348,27 +356,46 @@ namespace Scripts.Events.Brewfest
}
}
[Script]
class spell_item_brewfest_mount_transformation : SpellScript
{
public override bool Validate(SpellInfo spell)
{
return ValidateSpellInfo(SpellIds.MountRam100, SpellIds.MountRam60, SpellIds.MountKodo100, SpellIds.MountKodo60);
}
void HandleDummy(uint effIndex)
{
Player caster = GetCaster().ToPlayer();
if (caster.HasAuraType(AuraType.Mounted))
{
caster.RemoveAurasByType(AuraType.Mounted);
uint spell_id;
switch (GetSpellInfo().Id)
{
case SpellIds.BrewfestMountTransform:
if (caster.GetSpeedRate(UnitMoveType.Run) >= 2.0f)
spell_id = caster.GetTeam() == Team.Alliance ? SpellIds.MountRam100 : SpellIds.MountKodo100;
else
spell_id = caster.GetTeam() == Team.Alliance ? SpellIds.MountRam60 : SpellIds.MountKodo60;
break;
case SpellIds.BrewfestMountTransformReverse:
if (caster.GetSpeedRate(UnitMoveType.Run) >= 2.0f)
spell_id = caster.GetTeam() == Team.Horde ? SpellIds.MountRam100 : SpellIds.MountKodo100;
else
spell_id = caster.GetTeam() == Team.Horde ? SpellIds.MountRam60 : SpellIds.MountKodo60;
break;
default:
return;
}
caster.CastSpell(caster, spell_id, true);
}
}
public override void Register()
{
OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy));
}
}
}
+38
View File
@@ -33,6 +33,16 @@ namespace Scripts.Events.LoveIsInTheAir
//public const uint MealParticle = 45114; // Holiday - Valentine - Romantic Picnic Meal Particle - Unused
public const uint DrinkVisual = 45121; // Holiday - Valentine - Romantic Picnic Drink Visual
public const uint RomanticPicnicAchiev = 45123; // Romantic Picnic Periodic = 5000
//CreateHeartCandy
public const uint CreateHeartCandy1 = 26668;
public const uint CreateHeartCandy2 = 26670;
public const uint CreateHeartCandy3 = 26671;
public const uint CreateHeartCandy4 = 26672;
public const uint CreateHeartCandy5 = 26673;
public const uint CreateHeartCandy6 = 26674;
public const uint CreateHeartCandy7 = 26675;
public const uint CreateHeartCandy8 = 26676;
}
[Script] // 45102 Romantic Picnic
@@ -94,4 +104,32 @@ namespace Scripts.Events.LoveIsInTheAir
OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.PeriodicDummy));
}
}
[Script] // 26678 - Create Heart Candy
class spell_item_create_heart_candy : SpellScript
{
uint[] CreateHeartCandySpells =
{
SpellIds.CreateHeartCandy1, SpellIds.CreateHeartCandy2, SpellIds.CreateHeartCandy3, SpellIds.CreateHeartCandy4,
SpellIds.CreateHeartCandy5, SpellIds.CreateHeartCandy6, SpellIds.CreateHeartCandy7, SpellIds.CreateHeartCandy8
};
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(CreateHeartCandySpells);
}
void HandleScript(uint effIndex)
{
PreventHitDefaultEffect(effIndex);
Player target = GetHitPlayer();
if (target != null)
target.CastSpell(target, CreateHeartCandySpells.SelectRandom(), true);
}
public override void Register()
{
OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect));
}
}
}
+45 -27
View File
@@ -34,6 +34,13 @@ namespace Scripts.Events.WinterVeil
public const uint Px238WinterWondervoltTransform2 = 26272;
public const uint Px238WinterWondervoltTransform3 = 26273;
public const uint Px238WinterWondervoltTransform4 = 26274;
//Reindeertransformation
public const uint FlyingReindeer310 = 44827;
public const uint FlyingReindeer280 = 44825;
public const uint FlyingReindeer60 = 44824;
public const uint Reindeer100 = 25859;
public const uint Reindeer60 = 25858;
}
[Script] // 26218 - Mistletoe
@@ -98,35 +105,46 @@ namespace Scripts.Events.WinterVeil
}
}
[Script]
class spell_item_reindeer_transformation : SpellScript
{
public override bool Validate(SpellInfo spell)
{
return ValidateSpellInfo(SpellIds.FlyingReindeer310, SpellIds.FlyingReindeer280, SpellIds.FlyingReindeer60, SpellIds.Reindeer100, SpellIds.Reindeer60);
}
void HandleDummy(uint effIndex)
{
Unit caster = GetCaster();
if (caster.HasAuraType(AuraType.Mounted))
{
float flyspeed = caster.GetSpeedRate(UnitMoveType.Flight);
float speed = caster.GetSpeedRate(UnitMoveType.Run);
caster.RemoveAurasByType(AuraType.Mounted);
//5 different spells used depending on mounted speed and if mount can fly or not
if (flyspeed >= 4.1f)
// Flying Reindeer
caster.CastSpell(caster, SpellIds.FlyingReindeer310, true); //310% flying Reindeer
else if (flyspeed >= 3.8f)
// Flying Reindeer
caster.CastSpell(caster, SpellIds.FlyingReindeer280, true); //280% flying Reindeer
else if (flyspeed >= 1.6f)
// Flying Reindeer
caster.CastSpell(caster, SpellIds.FlyingReindeer60, true); //60% flying Reindeer
else if (speed >= 2.0f)
// Reindeer
caster.CastSpell(caster, SpellIds.Reindeer100, true); //100% ground Reindeer
else
// Reindeer
caster.CastSpell(caster, SpellIds.Reindeer60, true); //60% ground Reindeer
}
}
public override void Register()
{
OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy));
}
}
}