From b974c7f3a7e01d57fbae185987494ec0c1e2d1c8 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 12 Apr 2021 14:43:08 -0400 Subject: [PATCH] Script/Spells: shaman spell fixes Port From (https://github.com/TrinityCore/TrinityCore/commit/b92e20f6c860bd1b5f3e7ce3f614dd48fc5b49c4) --- Source/Game/Entities/Item/ItemTemplate.cs | 2 + Source/Scripts/Spells/Shaman.cs | 114 +++++++++++++++++- .../2021_04_11_00_world_shaman_spells.sql | 11 ++ 3 files changed, 122 insertions(+), 5 deletions(-) create mode 100644 sql/updates/world/master/2021_04_11_00_world_shaman_spells.sql diff --git a/Source/Game/Entities/Item/ItemTemplate.cs b/Source/Game/Entities/Item/ItemTemplate.cs index 84bce862a..a77205778 100644 --- a/Source/Game/Entities/Item/ItemTemplate.cs +++ b/Source/Game/Entities/Item/ItemTemplate.cs @@ -321,6 +321,8 @@ namespace Game.Entities public bool IsConjuredConsumable() { return GetClass() == ItemClass.Consumable && GetFlags().HasAnyFlag(ItemFlags.Conjured); } public bool IsCraftingReagent() { return GetFlags2().HasAnyFlag(ItemFlags2.UsedInATradeskill); } + public bool IsWeapon() { return GetClass() == ItemClass.Weapon; } + public bool IsRangedWeapon() { return GetClass() == ItemClass.Weapon || GetSubClass() == (uint)ItemSubClassWeapon.Bow || diff --git a/Source/Scripts/Spells/Shaman.cs b/Source/Scripts/Spells/Shaman.cs index 1ecc05437..2d7c0279b 100644 --- a/Source/Scripts/Spells/Shaman.cs +++ b/Source/Scripts/Spells/Shaman.cs @@ -50,12 +50,15 @@ namespace Scripts.Spells.Shaman public const uint FlametongueWeaponAura = 319778; public const uint GatheringStorms = 198299; public const uint GatheringStormsBuff = 198300; + public const uint HealingRainVisual = 147490; + public const uint HealingRainHeal = 73921; public const uint ItemLightningShield = 23552; public const uint ItemLightningShieldDamage = 27635; public const uint ItemManaSurge = 23571; public const uint LavaBurst = 51505; public const uint LavaBurstBonusDamage = 71824; public const uint LavaSurge = 77762; + public const uint LiquidMagmaHit = 192231; public const uint PathOfFlamesSpread = 210621; public const uint PathOfFlamesTalent = 201909; public const uint PowerSurge = 40466; @@ -73,6 +76,11 @@ namespace Scripts.Spells.Shaman public const uint PetNetherwindsFatigued = 160455; } + struct CreatureIds + { + public const uint HealingRainInvisibleStalker = 73400; + } + [Script] // 108281 - Ancestral Guidance class spell_sha_ancestral_guidance : AuraScript { @@ -309,8 +317,7 @@ namespace Scripts.Spells.Shaman public override bool Load() { - Unit caster = GetCaster(); - return caster != null && caster.IsTypeId(TypeId.Player); + return GetCaster().IsTypeId(TypeId.Player); } void HandleEffectHitTarget(uint index) @@ -322,7 +329,7 @@ namespace Scripts.Spells.Shaman slot = EquipmentSlot.OffHand; Item targetItem = player.GetItemByPos(InventorySlots.Bag0, slot); - if (targetItem == null || !targetItem.GetTemplate().IsRangedWeapon()) + if (targetItem == null || !targetItem.GetTemplate().IsWeapon()) return; GetCaster().CastSpell(targetItem, SpellIds.FlametongueWeaponEnchant, true); @@ -335,7 +342,7 @@ namespace Scripts.Spells.Shaman } [Script] // 319778 - Flametongue - class spell_sha_flametongue_weapon_aura : AuraScript + class spell_sha_flametongue_weapon_AuraScript : AuraScript { public override bool Validate(SpellInfo spellInfo) { @@ -347,7 +354,7 @@ namespace Scripts.Spells.Shaman PreventDefaultAction(); Unit attacker = eventInfo.GetActor(); - int damage = (int)(attacker.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.12f / 2600 * attacker.GetBaseAttackTime(WeaponAttackType.BaseAttack)); + int damage = Math.Max(1, (int)(attacker.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.0264f)); attacker.CastCustomSpell(SpellIds.FlametongueAttack, SpellValueMod.BasePoint0, damage, eventInfo.GetActionTarget(), TriggerCastFlags.FullMask, null, aurEff); } @@ -357,6 +364,70 @@ namespace Scripts.Spells.Shaman } } + [Script] // 73920 - Healing Rain + class spell_sha_healing_rain : SpellScript + { + void InitializeVisualStalker() + { + Aura aura = GetHitAura(); + if (aura != null) + { + WorldLocation dest = GetExplTargetDest(); + if (dest != null) + { + int duration = GetSpellInfo().CalcDuration(GetOriginalCaster()); + TempSummon summon = GetCaster().GetMap().SummonCreature(CreatureIds.HealingRainInvisibleStalker, dest, null, (uint)duration, GetOriginalCaster()); + if (summon == null) + return; + + summon.CastSpell(summon, SpellIds.HealingRainVisual, true); + + var script = aura.GetScript("spell_sha_healing_rain"); + if (script != null) + script.SetVisualDummy(summon); + } + } + } + + public override void Register() + { + OnHit.Add(new HitHandler(InitializeVisualStalker)); + } + } + + [Script] // 73920 - Healing Rain (Aura) + class spell_sha_healing_rain_AuraScript : AuraScript + { + ObjectGuid _visualDummy; + float _x; + float _y; + float _z; + + public void SetVisualDummy(TempSummon summon) + { + _visualDummy = summon.GetGUID(); + summon.GetPosition(out _x, out _y, out _z); + } + + void HandleEffectPeriodic(AuraEffect aurEff) + { + GetTarget().CastSpell(_x, _y, _z, SpellIds.HealingRainHeal, true, null, aurEff); + } + + void HandleEffecRemoved(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Creature summon = ObjectAccessor.GetCreature(GetTarget(), _visualDummy); + if (summon != null) + summon.DespawnOrUnsummon(); + } + + public override void Register() + { + OnEffectRemove.Add(new EffectApplyHandler(HandleEffecRemoved, 1, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 1, AuraType.PeriodicDummy)); + } + } + [Script] // 52042 - Healing Stream Totem class spell_sha_healing_stream_totem_heal : SpellScript { @@ -638,6 +709,39 @@ namespace Scripts.Spells.Shaman } } + [Script] // 192223 - Liquid Magma Totem (erupting hit spell) + class spell_sha_liquid_magma_totem : SpellScript + { + bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.LiquidMagmaHit); + } + + void HandleEffectHitTarget(uint effIndex) + { + Unit hitUnit = GetHitUnit(); + if (hitUnit != null) + GetCaster().CastSpell(hitUnit, SpellIds.LiquidMagmaHit, true); + } + + void HandleTargetSelect(List targets) + { + // choose one random target from targets + if (targets.Count > 1) + { + WorldObject selected = targets.SelectRandom(); + targets.Clear(); + targets.Add(selected); + } + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(HandleTargetSelect, 0, Targets.UnitDestAreaEnemy)); + OnEffectHitTarget.Add(new EffectHandler(HandleEffectHitTarget, 0, SpellEffectName.Dummy)); + } + } + [Script] // 210621 - Path of Flames Spread class spell_sha_path_of_flames_spread : SpellScript { diff --git a/sql/updates/world/master/2021_04_11_00_world_shaman_spells.sql b/sql/updates/world/master/2021_04_11_00_world_shaman_spells.sql new file mode 100644 index 000000000..fdcf2fc85 --- /dev/null +++ b/sql/updates/world/master/2021_04_11_00_world_shaman_spells.sql @@ -0,0 +1,11 @@ +-- Update various shaman spells +UPDATE `creature_template` SET `spell1` = 192226 WHERE `entry` = 97369; -- Liquid Magma Totem +UPDATE `creature_template` SET `spell1` = 8145 WHERE `entry` = 5913; -- Tremor Totem +UPDATE `creature_template` SET `spell1` = 118905 WHERE `entry` = 61245; -- Capacitator + +DELETE FROM `spell_script_names` WHERE `ScriptName` IN ('spell_sha_healing_rain', 'spell_sha_liquid_magma_totem', 'spell_sha_flametongue_weapon', 'spell_sha_flametongue_weapon_aura'); +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(73920, 'spell_sha_healing_rain'), +(192223, 'spell_sha_liquid_magma_totem'), +(318038, 'spell_sha_flametongue_weapon'), +(319778, 'spell_sha_flametongue_weapon_aura');