Scripts/Creature: Replace trigger_periodic with unique scripts
Port From (https://github.com/TrinityCore/TrinityCore/commit/7698203122a0f5e2e0e138b6dcaa93d383dce31a)
This commit is contained in:
@@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2012-2020 CypherCore <http://github.com/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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -229,14 +229,9 @@ namespace Scripts.World.NpcSpecial
|
|||||||
public const uint StuffingServer = 61795;
|
public const uint StuffingServer = 61795;
|
||||||
public const uint TurkeyServer = 61796;
|
public const uint TurkeyServer = 61796;
|
||||||
public const uint SweetPotatoesServer = 61797;
|
public const uint SweetPotatoesServer = 61797;
|
||||||
public static Dictionary<uint, uint> ChairSpells = new()
|
|
||||||
{
|
//VoidZone
|
||||||
{ CreatureIds.TheCranberryChair, CranberryServer },
|
public const uint Consumption = 28874;
|
||||||
{ CreatureIds.ThePieChair, PieServer },
|
|
||||||
{ CreatureIds.TheStuffingChair, StuffingServer },
|
|
||||||
{ CreatureIds.TheTurkeyChair, TurkeyServer },
|
|
||||||
{ CreatureIds.TheSweetPotatoChair, SweetPotatoesServer },
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct QuestConst
|
struct QuestConst
|
||||||
@@ -2081,9 +2076,18 @@ namespace Scripts.World.NpcSpecial
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Script]
|
[Script]
|
||||||
class npc_bountiful_tableAI : PassiveAI
|
class npc_bountiful_table : PassiveAI
|
||||||
{
|
{
|
||||||
public npc_bountiful_tableAI(Creature creature) : base(creature) { }
|
Dictionary<uint, uint> 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)
|
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.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();
|
Creature creature = who.ToCreature();
|
||||||
if (creature)
|
if (creature)
|
||||||
creature.SetDisplayFromModel(0);
|
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
|
class CastFoodSpell : BasicEvent
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user