From 5e2cc3795cadeb7def7b5b4956ae1757a0ad1706 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sat, 2 Jul 2022 21:13:39 -0400 Subject: [PATCH] Scripts/Creature: Replace trigger_periodic with unique scripts Port From (https://github.com/TrinityCore/TrinityCore/commit/7698203122a0f5e2e0e138b6dcaa93d383dce31a) --- Source/Scripts/World/MobGenericCreature.cs | 48 --------------------- Source/Scripts/World/NpcSpecial.cs | 50 +++++++++++++++++----- 2 files changed, 39 insertions(+), 59 deletions(-) delete mode 100644 Source/Scripts/World/MobGenericCreature.cs diff --git a/Source/Scripts/World/MobGenericCreature.cs b/Source/Scripts/World/MobGenericCreature.cs deleted file mode 100644 index a7bf973b9..000000000 --- a/Source/Scripts/World/MobGenericCreature.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2012-2020 CypherCore - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -using Framework.Constants; -using Game.AI; -using Game.Entities; -using Game.Scripting; -using Game.Spells; -using System; - -namespace Scripts.World -{ - [Script] - class trigger_periodic : NullCreatureAI - { - public trigger_periodic(Creature creature) : base(creature) - { - var interval = me.GetBaseAttackTime(WeaponAttackType.BaseAttack); - var spell = me.m_spells[0] != 0 ? Global.SpellMgr.GetSpellInfo(me.m_spells[0], me.GetMap().GetDifficultyID()) : null; - - _scheduler.Schedule(TimeSpan.FromMilliseconds(interval), task => - { - if (spell != null) - me.CastSpell(me, spell.Id, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetCastDifficulty(spell.Difficulty)); - task.Repeat(TimeSpan.FromMilliseconds(interval)); - }); - } - - public override void UpdateAI(uint diff) - { - _scheduler.Update(); - } - } -} \ No newline at end of file diff --git a/Source/Scripts/World/NpcSpecial.cs b/Source/Scripts/World/NpcSpecial.cs index cc3275c4f..991f10eae 100644 --- a/Source/Scripts/World/NpcSpecial.cs +++ b/Source/Scripts/World/NpcSpecial.cs @@ -229,14 +229,9 @@ namespace Scripts.World.NpcSpecial public const uint StuffingServer = 61795; public const uint TurkeyServer = 61796; public const uint SweetPotatoesServer = 61797; - public static Dictionary ChairSpells = new() - { - { CreatureIds.TheCranberryChair, CranberryServer }, - { CreatureIds.ThePieChair, PieServer }, - { CreatureIds.TheStuffingChair, StuffingServer }, - { CreatureIds.TheTurkeyChair, TurkeyServer }, - { CreatureIds.TheSweetPotatoChair, SweetPotatoesServer }, - }; + + //VoidZone + public const uint Consumption = 28874; } struct QuestConst @@ -2081,9 +2076,18 @@ namespace Scripts.World.NpcSpecial } [Script] - class npc_bountiful_tableAI : PassiveAI + class npc_bountiful_table : PassiveAI { - public npc_bountiful_tableAI(Creature creature) : base(creature) { } + Dictionary ChairSpells = new() + { + { CreatureIds.TheCranberryChair, SpellIds.CranberryServer }, + { CreatureIds.ThePieChair, SpellIds.PieServer }, + { CreatureIds.TheStuffingChair, SpellIds.StuffingServer }, + { CreatureIds.TheTurkeyChair, SpellIds.TurkeyServer }, + { CreatureIds.TheSweetPotatoChair, SpellIds.SweetPotatoesServer }, + }; + + public npc_bountiful_table(Creature creature) : base(creature) { } public override void PassengerBoarded(Unit who, sbyte seatId, bool apply) { @@ -2135,12 +2139,36 @@ namespace Scripts.World.NpcSpecial }; who.GetMotionMaster().LaunchMoveSpline(initializer, EventId.VehicleBoard, MovementGeneratorPriority.Highest); - who.m_Events.AddEvent(new CastFoodSpell(who, SpellIds.ChairSpells[who.GetEntry()]), who.m_Events.CalculateTime(TimeSpan.FromSeconds(1))); + who.m_Events.AddEvent(new CastFoodSpell(who, ChairSpells[who.GetEntry()]), who.m_Events.CalculateTime(TimeSpan.FromSeconds(1))); Creature creature = who.ToCreature(); if (creature) creature.SetDisplayFromModel(0); } } + + [Script] + class npc_gen_void_zone : ScriptedAI + { + public npc_gen_void_zone(Creature creature) : base(creature) { } + + public override void InitializeAI() + { + me.SetReactState(ReactStates.Passive); + } + + public override void JustAppeared() + { + _scheduler.Schedule(TimeSpan.FromSeconds(2), task => + { + DoCastSelf(SpellIds.Consumption); + }); + } + + public override void UpdateAI(uint diff) + { + _scheduler.Update(diff); + } + } class CastFoodSpell : BasicEvent {