mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-07-25 03:48:23 +02:00
New style of scripting for better complex menus.
This commit is contained in:
parent
cdf4b3a2f2
commit
4e69022072
8 changed files with 170 additions and 58 deletions
|
@ -181,6 +181,11 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
return BasePacket.CreatePacket(propPacketUtil.Done(), true, false);
|
||||
}
|
||||
|
||||
public string GetUniqueId()
|
||||
{
|
||||
return uniqueIdentifier;
|
||||
}
|
||||
|
||||
public uint GetActorClassId()
|
||||
{
|
||||
return actorClassId;
|
||||
|
@ -322,7 +327,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
return lparams;
|
||||
}
|
||||
|
||||
public void DoEventStart(Player player, EventStartPacket eventStart)
|
||||
public Coroutine GetEventStartCoroutine(Player player)
|
||||
{
|
||||
Script parent = null, child = null;
|
||||
|
||||
|
@ -331,31 +336,23 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
if (File.Exists(String.Format("./scripts/unique/{0}/{1}/{2}.lua", zone.zoneName, className, uniqueIdentifier)))
|
||||
child = LuaEngine.LoadScript(String.Format("./scripts/unique/{0}/{1}/{2}.lua", zone.zoneName, className, uniqueIdentifier));
|
||||
|
||||
if (parent == null)
|
||||
if (parent == null && child == null)
|
||||
{
|
||||
LuaEngine.SendError(player, String.Format("ERROR: Could not find script for actor {0}.", GetName()));
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
//Have to do this to combine LuaParams
|
||||
List<Object> objects = new List<Object>();
|
||||
objects.Add(player);
|
||||
objects.Add(this);
|
||||
objects.Add(eventStart.triggerName);
|
||||
|
||||
if (eventStart.luaParams != null)
|
||||
objects.AddRange(LuaUtils.CreateLuaParamObjectList(eventStart.luaParams));
|
||||
|
||||
//Run Script
|
||||
DynValue result;
|
||||
Coroutine coroutine;
|
||||
|
||||
if (child != null && !child.Globals.Get("onEventStarted").IsNil())
|
||||
result = child.Call(child.Globals["onEventStarted"], objects.ToArray());
|
||||
coroutine = child.CreateCoroutine(child.Globals["onEventStarted"]).Coroutine;
|
||||
else if (!parent.Globals.Get("onEventStarted").IsNil())
|
||||
result = parent.Call(parent.Globals["onEventStarted"], objects.ToArray());
|
||||
coroutine = parent.CreateCoroutine(parent.Globals["onEventStarted"]).Coroutine;
|
||||
else
|
||||
return;
|
||||
return null;
|
||||
|
||||
return coroutine;
|
||||
}
|
||||
|
||||
public void DoEventUpdate(Player player, EventUpdatePacket eventUpdate)
|
||||
|
|
|
@ -15,6 +15,8 @@ using FFXIVClassic_Map_Server.packets.send.player;
|
|||
using FFXIVClassic_Map_Server.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MoonSharp.Interpreter;
|
||||
using FFXIVClassic_Map_Server.packets.receive.events;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.Actors
|
||||
{
|
||||
|
@ -82,8 +84,8 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
|
||||
public uint currentCommand = 0;
|
||||
public string currentCommandName = "";
|
||||
|
||||
public uint eventMenuId = 0;
|
||||
|
||||
public Coroutine currentEventRunning;
|
||||
|
||||
//Player Info
|
||||
public uint[] timers = new uint[20];
|
||||
|
@ -1118,6 +1120,35 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
QueuePacket(spacket);
|
||||
}
|
||||
|
||||
public void StartEvent(Actor owner, EventStartPacket start)
|
||||
{
|
||||
//Have to do this to combine LuaParams
|
||||
List<Object> objects = new List<Object>();
|
||||
objects.Add(this);
|
||||
objects.Add(owner);
|
||||
objects.Add(start.triggerName);
|
||||
|
||||
if (start.luaParams != null)
|
||||
objects.AddRange(LuaUtils.CreateLuaParamObjectList(start.luaParams));
|
||||
|
||||
if (owner is Npc)
|
||||
{
|
||||
currentEventRunning = ((Npc)owner).GetEventStartCoroutine(this);
|
||||
currentEventRunning.Resume(objects.ToArray());
|
||||
}
|
||||
else
|
||||
LuaEngine.DoActorOnEventStarted(this, owner, start);
|
||||
}
|
||||
|
||||
public void UpdateEvent(EventUpdatePacket update)
|
||||
{
|
||||
if (currentEventRunning == null)
|
||||
return;
|
||||
|
||||
if (currentEventRunning.State == CoroutineState.Suspended)
|
||||
currentEventRunning.Resume(LuaUtils.CreateLuaParamObjectList(update.luaParams));
|
||||
}
|
||||
|
||||
public void KickEvent(Actor actor, string conditionName, params object[] parameters)
|
||||
{
|
||||
if (actor == null)
|
||||
|
@ -1150,7 +1181,6 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
|
||||
currentEventOwner = 0;
|
||||
currentEventName = "";
|
||||
eventMenuId = 0;
|
||||
}
|
||||
|
||||
public void EndCommand()
|
||||
|
@ -1163,16 +1193,6 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
currentCommandName = "";
|
||||
}
|
||||
|
||||
public void SetCurrentMenuId(uint id)
|
||||
{
|
||||
eventMenuId = id;
|
||||
}
|
||||
|
||||
public uint GetCurrentMenuId()
|
||||
{
|
||||
return eventMenuId;
|
||||
}
|
||||
|
||||
public void SendInstanceUpdate()
|
||||
{
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue