mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-24 21:57:45 +00:00
Reversed all my lua fuckery.
This commit is contained in:
parent
13727caf14
commit
bbd4fcef3b
4 changed files with 49 additions and 116 deletions
|
@ -110,7 +110,6 @@
|
||||||
<Compile Include="actors\quest\Quest.cs" />
|
<Compile Include="actors\quest\Quest.cs" />
|
||||||
<Compile Include="actors\StaticActors.cs" />
|
<Compile Include="actors\StaticActors.cs" />
|
||||||
<Compile Include="actors\world\WorldMaster.cs" />
|
<Compile Include="actors\world\WorldMaster.cs" />
|
||||||
<Compile Include="dataobjects\GameEvent.cs" />
|
|
||||||
<Compile Include="dataobjects\GuildleveData.cs" />
|
<Compile Include="dataobjects\GuildleveData.cs" />
|
||||||
<Compile Include="dataobjects\TradeTransaction.cs" />
|
<Compile Include="dataobjects\TradeTransaction.cs" />
|
||||||
<Compile Include="dataobjects\ZoneConnection.cs" />
|
<Compile Include="dataobjects\ZoneConnection.cs" />
|
||||||
|
|
|
@ -88,7 +88,10 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
74000, 78000, 81000, 85000, 89000, 92000, 96000, 100000, 100000, 110000}; //Level <= 50
|
74000, 78000, 81000, 85000, 89000, 92000, 96000, 100000, 100000, 110000}; //Level <= 50
|
||||||
|
|
||||||
//Event Related
|
//Event Related
|
||||||
private Stack<GameEvent> runningEvents = new Stack<GameEvent>();
|
public uint currentEventOwner = 0;
|
||||||
|
public string currentEventName = "";
|
||||||
|
|
||||||
|
public Coroutine currentEventRunning;
|
||||||
|
|
||||||
//Player Info
|
//Player Info
|
||||||
public uint destinationZone;
|
public uint destinationZone;
|
||||||
|
@ -1675,24 +1678,19 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
|
|
||||||
public void StartEvent(Actor owner, EventStartPacket start)
|
public void StartEvent(Actor owner, EventStartPacket start)
|
||||||
{
|
{
|
||||||
GameEvent startedEvent = new GameEvent(start.triggerName, this, owner);
|
LuaEngine.GetInstance().EventStarted(this, owner, start);
|
||||||
runningEvents.Push(startedEvent);
|
|
||||||
LuaEngine.GetInstance().EventStarted(startedEvent, start);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateEvent(EventUpdatePacket update)
|
public void UpdateEvent(EventUpdatePacket update)
|
||||||
{
|
{
|
||||||
GameEvent updateEvent = runningEvents.Peek();
|
LuaEngine.GetInstance().OnEventUpdate(this, update.luaParams);
|
||||||
LuaEngine.GetInstance().OnEventUpdate(updateEvent, update.luaParams);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void KickEvent(Actor actor, string conditionName, params object[] parameters)
|
public void KickEvent(Actor actor, string conditionName, params object[] parameters)
|
||||||
{
|
{
|
||||||
if (actor == null)
|
if (actor == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
runningEvents.Pop();
|
|
||||||
|
|
||||||
List<LuaParam> lParams = LuaUtils.CreateLuaParamList(parameters);
|
List<LuaParam> lParams = LuaUtils.CreateLuaParamList(parameters);
|
||||||
SubPacket spacket = KickEventPacket.BuildPacket(actorId, actor.actorId, 0x75dc1705, conditionName, lParams);
|
SubPacket spacket = KickEventPacket.BuildPacket(actorId, actor.actorId, 0x75dc1705, conditionName, lParams);
|
||||||
spacket.DebugPrintSubPacket();
|
spacket.DebugPrintSubPacket();
|
||||||
|
@ -1704,8 +1702,6 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
if (actor == null)
|
if (actor == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
runningEvents.Pop();
|
|
||||||
|
|
||||||
List<LuaParam> lParams = LuaUtils.CreateLuaParamList(parameters);
|
List<LuaParam> lParams = LuaUtils.CreateLuaParamList(parameters);
|
||||||
SubPacket spacket = KickEventPacket.BuildPacket(actorId, actor.actorId, unknown, conditionName, lParams);
|
SubPacket spacket = KickEventPacket.BuildPacket(actorId, actor.actorId, unknown, conditionName, lParams);
|
||||||
spacket.DebugPrintSubPacket();
|
spacket.DebugPrintSubPacket();
|
||||||
|
@ -1715,22 +1711,25 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
public void SetEventStatus(Actor actor, string conditionName, bool enabled, byte unknown)
|
public void SetEventStatus(Actor actor, string conditionName, bool enabled, byte unknown)
|
||||||
{
|
{
|
||||||
QueuePacket(packets.send.actor.events.SetEventStatus.BuildPacket(actor.actorId, enabled, unknown, conditionName));
|
QueuePacket(packets.send.actor.events.SetEventStatus.BuildPacket(actor.actorId, enabled, unknown, conditionName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RunEventFunction(string functionName, params object[] parameters)
|
public void RunEventFunction(string functionName, params object[] parameters)
|
||||||
{
|
{
|
||||||
List<LuaParam> lParams = LuaUtils.CreateLuaParamList(parameters);
|
List<LuaParam> lParams = LuaUtils.CreateLuaParamList(parameters);
|
||||||
SubPacket spacket = RunEventFunctionPacket.BuildPacket(actorId, runningEvents.Peek().GetOwnerActorId(), runningEvents.Peek().GetEventName(), functionName, lParams);
|
SubPacket spacket = RunEventFunctionPacket.BuildPacket(actorId, currentEventOwner, currentEventName, functionName, lParams);
|
||||||
spacket.DebugPrintSubPacket();
|
spacket.DebugPrintSubPacket();
|
||||||
QueuePacket(spacket);
|
QueuePacket(spacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EndEvent()
|
public void EndEvent()
|
||||||
{
|
{
|
||||||
GameEvent endingEvent = runningEvents.Pop();
|
SubPacket p = EndEventPacket.BuildPacket(actorId, currentEventOwner, currentEventName);
|
||||||
SubPacket p = EndEventPacket.BuildPacket(actorId, endingEvent.GetOwnerActorId(), endingEvent.GetEventName());
|
|
||||||
p.DebugPrintSubPacket();
|
p.DebugPrintSubPacket();
|
||||||
QueuePacket(p);
|
QueuePacket(p);
|
||||||
|
|
||||||
|
currentEventOwner = 0;
|
||||||
|
currentEventName = "";
|
||||||
|
currentEventRunning = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendInstanceUpdate()
|
public void SendInstanceUpdate()
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
using FFXIVClassic_Map_Server.Actors;
|
|
||||||
using MoonSharp.Interpreter;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FFXIVClassic_Map_Server.dataobjects
|
|
||||||
{
|
|
||||||
class GameEvent
|
|
||||||
{
|
|
||||||
private string eventName;
|
|
||||||
private uint ownerActorId;
|
|
||||||
private Player playerActor;
|
|
||||||
private Actor ownerActor;
|
|
||||||
private Coroutine coroutine;
|
|
||||||
private uint hashCode;
|
|
||||||
|
|
||||||
public GameEvent(String eventName, Player player, Actor owner)
|
|
||||||
{
|
|
||||||
this.eventName = eventName;
|
|
||||||
this.playerActor = player;
|
|
||||||
this.ownerActor = owner;
|
|
||||||
this.ownerActorId = owner.actorId;
|
|
||||||
hashCode = (uint)new Tuple<uint, uint, string>(player.actorId, owner.actorId, eventName).GetHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetEventName()
|
|
||||||
{
|
|
||||||
return eventName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint GetOwnerActorId()
|
|
||||||
{
|
|
||||||
return ownerActorId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Player GetPlayerActor()
|
|
||||||
{
|
|
||||||
return playerActor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Actor GetOwnerActor()
|
|
||||||
{
|
|
||||||
return ownerActor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Coroutine GetCoroutine()
|
|
||||||
{
|
|
||||||
return coroutine;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetCoroutine(Coroutine coroutine)
|
|
||||||
{
|
|
||||||
this.coroutine = coroutine;
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint GetUniqueEventId()
|
|
||||||
{
|
|
||||||
return hashCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -36,6 +36,7 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
|
|
||||||
private Timer luaTimer;
|
private Timer luaTimer;
|
||||||
|
|
||||||
|
|
||||||
private LuaEngine()
|
private LuaEngine()
|
||||||
{
|
{
|
||||||
UserData.RegistrationPolicy = InteropRegistrationPolicy.Automatic;
|
UserData.RegistrationPolicy = InteropRegistrationPolicy.Automatic;
|
||||||
|
@ -101,31 +102,31 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Coroutine key in mToAwake)
|
foreach (Coroutine key in mToAwake)
|
||||||
{
|
{
|
||||||
DynValue value = key.Resume();
|
DynValue value = key.Resume();
|
||||||
ResolveResume(null, key, value);
|
ResolveResume(null, key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnEventUpdate(GameEvent gEvent, List<LuaParam> args)
|
public void OnEventUpdate(Player player, List<LuaParam> args)
|
||||||
{
|
{
|
||||||
if (mSleepingOnPlayerEvent.ContainsKey(gEvent.GetUniqueEventId()))
|
if (mSleepingOnPlayerEvent.ContainsKey(player.actorId))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Coroutine coroutine = mSleepingOnPlayerEvent[gEvent.GetUniqueEventId()];
|
Coroutine coroutine = mSleepingOnPlayerEvent[player.actorId];
|
||||||
mSleepingOnPlayerEvent.Remove(gEvent.GetUniqueEventId());
|
mSleepingOnPlayerEvent.Remove(player.actorId);
|
||||||
DynValue value = coroutine.Resume(LuaUtils.CreateLuaParamObjectList(args));
|
DynValue value = coroutine.Resume(LuaUtils.CreateLuaParamObjectList(args));
|
||||||
ResolveResume(gEvent.GetPlayerActor(), coroutine, value);
|
ResolveResume(player, coroutine, value);
|
||||||
}
|
}
|
||||||
catch (ScriptRuntimeException e)
|
catch (ScriptRuntimeException e)
|
||||||
{
|
{
|
||||||
LuaEngine.SendError(gEvent.GetPlayerActor(), String.Format("OnEventUpdated: {0}", e.DecoratedMessage));
|
LuaEngine.SendError(player, String.Format("OnEventUpdated: {0}", e.DecoratedMessage));
|
||||||
gEvent.GetPlayerActor().EndEvent();
|
player.EndEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gEvent.GetPlayerActor().EndEvent();
|
player.EndEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetScriptPath(Actor target)
|
private static string GetScriptPath(Actor target)
|
||||||
|
@ -214,7 +215,7 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
|
|
||||||
private void CallLuaFunctionNpc(Player player, Npc target, string funcName, bool optional, params object[] args)
|
private void CallLuaFunctionNpc(Player player, Npc target, string funcName, bool optional, params object[] args)
|
||||||
{
|
{
|
||||||
object[] args2 = new object[args.Length + (player == null ? 1:2)];
|
object[] args2 = new object[args.Length + (player == null ? 1 : 2)];
|
||||||
Array.Copy(args, 0, args2, (player == null ? 1 : 2), args.Length);
|
Array.Copy(args, 0, args2, (player == null ? 1 : 2), args.Length);
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
|
@ -265,7 +266,7 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
catch (ScriptRuntimeException e)
|
catch (ScriptRuntimeException e)
|
||||||
{
|
{
|
||||||
SendError(player, e.DecoratedMessage);
|
SendError(player, e.DecoratedMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,9 +291,9 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
if (script != null)
|
if (script != null)
|
||||||
{
|
{
|
||||||
if (!script.Globals.Get(funcName).IsNil())
|
if (!script.Globals.Get(funcName).IsNil())
|
||||||
{
|
{
|
||||||
//Run Script
|
//Run Script
|
||||||
DynValue result = script.Call(script.Globals[funcName], args2);
|
DynValue result = script.Call(script.Globals[funcName], args2);
|
||||||
List<LuaParam> lparams = LuaUtils.CreateLuaParamList(result);
|
List<LuaParam> lparams = LuaUtils.CreateLuaParamList(result);
|
||||||
return lparams;
|
return lparams;
|
||||||
}
|
}
|
||||||
|
@ -322,7 +323,7 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
DynValue result = script.Call(script.Globals[funcName], args);
|
DynValue result = script.Call(script.Globals[funcName], args);
|
||||||
List<LuaParam> lparams = LuaUtils.CreateLuaParamList(result);
|
List<LuaParam> lparams = LuaUtils.CreateLuaParamList(result);
|
||||||
return lparams;
|
return lparams;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -361,36 +362,36 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
{
|
{
|
||||||
if (!(target is Area) && !optional)
|
if (!(target is Area) && !optional)
|
||||||
SendError(player, String.Format("Could not find script for actor {0}.", target.GetName()));
|
SendError(player, String.Format("Could not find script for actor {0}.", target.GetName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EventStarted(GameEvent gEvent, EventStartPacket eventStart)
|
public void EventStarted(Player player, Actor target, EventStartPacket eventStart)
|
||||||
{
|
{
|
||||||
List<LuaParam> lparams = eventStart.luaParams;
|
List<LuaParam> lparams = eventStart.luaParams;
|
||||||
lparams.Insert(0, new LuaParam(2, eventStart.triggerName));
|
lparams.Insert(0, new LuaParam(2, eventStart.triggerName));
|
||||||
|
if (mSleepingOnPlayerEvent.ContainsKey(player.actorId))
|
||||||
if (mSleepingOnPlayerEvent.ContainsKey(gEvent.GetUniqueEventId()))
|
|
||||||
{
|
{
|
||||||
Coroutine coroutine = mSleepingOnPlayerEvent[gEvent.GetUniqueEventId()];
|
Coroutine coroutine = mSleepingOnPlayerEvent[player.actorId];
|
||||||
mSleepingOnPlayerEvent.Remove(gEvent.GetUniqueEventId());
|
mSleepingOnPlayerEvent.Remove(player.actorId);
|
||||||
|
|
||||||
try{
|
try
|
||||||
|
{
|
||||||
DynValue value = coroutine.Resume();
|
DynValue value = coroutine.Resume();
|
||||||
ResolveResume(null, coroutine, value);
|
ResolveResume(null, coroutine, value);
|
||||||
}
|
}
|
||||||
catch (ScriptRuntimeException e)
|
catch (ScriptRuntimeException e)
|
||||||
{
|
{
|
||||||
LuaEngine.SendError(gEvent.GetPlayerActor(), String.Format("OnEventStarted: {0}", e.DecoratedMessage));
|
LuaEngine.SendError(player, String.Format("OnEventStarted: {0}", e.DecoratedMessage));
|
||||||
gEvent.GetPlayerActor().EndEvent();
|
player.EndEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (gEvent.GetOwnerActor() is Director)
|
if (target is Director)
|
||||||
((Director)gEvent.GetOwnerActor()).OnEventStart(gEvent.GetPlayerActor(), LuaUtils.CreateLuaParamObjectList(lparams));
|
((Director)target).OnEventStart(player, LuaUtils.CreateLuaParamObjectList(lparams));
|
||||||
else
|
else
|
||||||
CallLuaFunction(gEvent.GetPlayerActor(), gEvent.GetOwnerActor(), "onEventStarted", false, LuaUtils.CreateLuaParamObjectList(lparams));
|
CallLuaFunction(player, target, "onEventStarted", false, LuaUtils.CreateLuaParamObjectList(lparams));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DynValue ResolveResume(Player player, Coroutine coroutine, DynValue value)
|
public DynValue ResolveResume(Player player, Coroutine coroutine, DynValue value)
|
||||||
|
@ -399,8 +400,8 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
if (player != null && value.String != null && value.String.Equals("_WAIT_EVENT"))
|
if (player != null && value.String != null && value.String.Equals("_WAIT_EVENT"))
|
||||||
{
|
{
|
||||||
GetInstance().AddWaitEventCoroutine(player, coroutine);
|
GetInstance().AddWaitEventCoroutine(player, coroutine);
|
||||||
}
|
}
|
||||||
else if (value.Tuple != null && value.Tuple.Length >= 1 && value.Tuple[0].String != null)
|
else if (value.Tuple != null && value.Tuple.Length >= 1 && value.Tuple[0].String != null)
|
||||||
{
|
{
|
||||||
|
@ -428,7 +429,7 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
{
|
{
|
||||||
bool playerNull = player == null;
|
bool playerNull = player == null;
|
||||||
if (playerNull && param.Length >= 3)
|
if (playerNull && param.Length >= 3)
|
||||||
player = Server.GetWorldManager().GetPCInWorld(param[1] + " " + param[2]);
|
player = Server.GetWorldManager().GetPCInWorld(param[1] + " " + param[2]);
|
||||||
|
|
||||||
// load from scripts/commands/gm/ directory
|
// load from scripts/commands/gm/ directory
|
||||||
var path = String.Format("./scripts/commands/gm/{0}.lua", cmd.ToLower());
|
var path = String.Format("./scripts/commands/gm/{0}.lua", cmd.ToLower());
|
||||||
|
@ -611,9 +612,8 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
return;
|
return;
|
||||||
List<SubPacket> SendError = new List<SubPacket>();
|
List<SubPacket> SendError = new List<SubPacket>();
|
||||||
player.SendMessage(SendMessagePacket.MESSAGE_TYPE_SYSTEM_ERROR, "", message);
|
player.SendMessage(SendMessagePacket.MESSAGE_TYPE_SYSTEM_ERROR, "", message);
|
||||||
player.EndEvent();
|
player.QueuePacket(EndEventPacket.BuildPacket(player.actorId, player.currentEventOwner, player.currentEventName));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue