mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
Merge branch 'master' of https://bitbucket.org/Ioncannon/ffxiv-classic-server into lua_commands
# Conflicts: # FFXIVClassic Map Server/dataobjects/ConnectedPlayer.cs # FFXIVClassic Map Server/lua/LuaEngine.cs # data/scripts/global.lua
This commit is contained in:
@@ -248,16 +248,11 @@ namespace FFXIVClassic_Map_Server
|
||||
*/
|
||||
|
||||
Actor ownerActor = Server.GetStaticActors(eventStart.scriptOwnerActorID);
|
||||
if (ownerActor != null && ownerActor is Command)
|
||||
{
|
||||
player.GetActor().currentCommand = eventStart.scriptOwnerActorID;
|
||||
player.GetActor().currentCommandName = eventStart.triggerName;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.GetActor().currentEventOwner = eventStart.scriptOwnerActorID;
|
||||
player.GetActor().currentEventName = eventStart.triggerName;
|
||||
}
|
||||
|
||||
|
||||
player.GetActor().currentEventOwner = eventStart.scriptOwnerActorID;
|
||||
player.GetActor().currentEventName = eventStart.triggerName;
|
||||
|
||||
|
||||
if (ownerActor == null)
|
||||
{
|
||||
@@ -275,8 +270,8 @@ namespace FFXIVClassic_Map_Server
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LuaEngine.DoActorOnEventStarted(player.GetActor(), ownerActor, eventStart);
|
||||
|
||||
player.GetActor().StartEvent(ownerActor, eventStart);
|
||||
|
||||
Program.Log.Debug("\n===Event START===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nEvent Starter: {4}\nParams: {5}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.val1, eventStart.val2, eventStart.triggerName, LuaUtils.DumpParams(eventStart.luaParams));
|
||||
break;
|
||||
@@ -288,7 +283,7 @@ namespace FFXIVClassic_Map_Server
|
||||
subpacket.DebugPrintSubPacket();
|
||||
EventUpdatePacket eventUpdate = new EventUpdatePacket(subpacket.data);
|
||||
Program.Log.Debug("\n===Event UPDATE===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nStep: 0x{4:X}\nParams: {5}", eventUpdate.actorID, eventUpdate.scriptOwnerActorID, eventUpdate.val1, eventUpdate.val2, eventUpdate.step, LuaUtils.DumpParams(eventUpdate.luaParams));
|
||||
|
||||
/*
|
||||
//Is it a static actor? If not look in the player's instance
|
||||
Actor updateOwnerActor = Server.GetStaticActors(player.GetActor().currentEventOwner);
|
||||
if (updateOwnerActor == null)
|
||||
@@ -301,8 +296,10 @@ namespace FFXIVClassic_Map_Server
|
||||
if (updateOwnerActor == null)
|
||||
break;
|
||||
}
|
||||
*/
|
||||
player.GetActor().UpdateEvent(eventUpdate);
|
||||
|
||||
LuaEngine.DoActorOnEventUpdated(player.GetActor(), updateOwnerActor, eventUpdate);
|
||||
//LuaEngine.DoActorOnEventUpdated(player.GetActor(), updateOwnerActor, eventUpdate);
|
||||
|
||||
break;
|
||||
case 0x012F:
|
||||
|
@@ -36,7 +36,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
protected Dictionary<uint, Actor> mActorList = new Dictionary<uint, Actor>();
|
||||
protected List<Actor>[,] mActorBlock;
|
||||
|
||||
Script areaScript;
|
||||
LuaScript areaScript;
|
||||
|
||||
public Area(uint id, string zoneName, ushort regionId, string className, ushort bgmDay, ushort bgmNight, ushort bgmBattle, bool isIsolated, bool isInn, bool canRideChocobo, bool canStealth, bool isInstanceRaid)
|
||||
: base(id)
|
||||
|
@@ -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;
|
||||
@@ -296,7 +301,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
|
||||
public List<LuaParam> DoActorInit(Player player)
|
||||
{
|
||||
Script parent = null, child = null;
|
||||
LuaScript parent = null, child = null;
|
||||
|
||||
if (File.Exists("./scripts/base/" + classPath + ".lua"))
|
||||
parent = LuaEngine.LoadScript("./scripts/base/" + classPath + ".lua");
|
||||
@@ -322,45 +327,37 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
return lparams;
|
||||
}
|
||||
|
||||
public void DoEventStart(Player player, EventStartPacket eventStart)
|
||||
public Coroutine GetEventStartCoroutine(Player player)
|
||||
{
|
||||
Script parent = null, child = null;
|
||||
LuaScript parent = null, child = null;
|
||||
|
||||
if (File.Exists("./scripts/base/" + classPath + ".lua"))
|
||||
parent = LuaEngine.LoadScript("./scripts/base/" + classPath + ".lua");
|
||||
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)
|
||||
{
|
||||
Script parent = null, child = null;
|
||||
LuaScript parent = null, child = null;
|
||||
|
||||
if (File.Exists("./scripts/base/" + classPath + ".lua"))
|
||||
parent = LuaEngine.LoadScript("./scripts/base/" + classPath + ".lua");
|
||||
@@ -394,7 +391,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
|
||||
internal void DoOnActorSpawn(Player player)
|
||||
{
|
||||
Script parent = null, child = null;
|
||||
LuaScript parent = null, child = null;
|
||||
|
||||
if (File.Exists("./scripts/base/" + classPath + ".lua"))
|
||||
parent = LuaEngine.LoadScript("./scripts/base/" + classPath + ".lua");
|
||||
|
@@ -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
|
||||
{
|
||||
@@ -80,10 +82,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
public uint currentEventOwner = 0;
|
||||
public string currentEventName = "";
|
||||
|
||||
public uint currentCommand = 0;
|
||||
public string currentCommandName = "";
|
||||
|
||||
public uint eventMenuId = 0;
|
||||
public Coroutine currentEventRunning;
|
||||
|
||||
//Player Info
|
||||
public uint[] timers = new uint[20];
|
||||
@@ -1133,6 +1132,81 @@ 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);
|
||||
|
||||
if (currentEventRunning != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
currentEventRunning.Resume(objects.ToArray());
|
||||
}
|
||||
catch (ScriptRuntimeException e)
|
||||
{
|
||||
Program.Log.Error("[LUA] {0}", e.Message);
|
||||
EndEvent();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EndEvent();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currentEventRunning = LuaEngine.DoActorOnEventStarted(this, owner, start);
|
||||
|
||||
if (currentEventRunning != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
currentEventRunning.Resume(objects.ToArray());
|
||||
}
|
||||
catch (ScriptRuntimeException e)
|
||||
{
|
||||
Program.Log.Error("[LUA] {0}", e.Message);
|
||||
EndEvent();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EndEvent();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void UpdateEvent(EventUpdatePacket update)
|
||||
{
|
||||
if (currentEventRunning == null)
|
||||
return;
|
||||
|
||||
if (currentEventRunning.State == CoroutineState.Suspended)
|
||||
{
|
||||
try
|
||||
{
|
||||
currentEventRunning.Resume(LuaUtils.CreateLuaParamObjectList(update.luaParams));
|
||||
}
|
||||
catch (ScriptRuntimeException e)
|
||||
{
|
||||
Program.Log.Error("[LUA] {0}", e.Message);
|
||||
EndEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void KickEvent(Actor actor, string conditionName, params object[] parameters)
|
||||
{
|
||||
if (actor == null)
|
||||
@@ -1165,29 +1239,9 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
|
||||
currentEventOwner = 0;
|
||||
currentEventName = "";
|
||||
eventMenuId = 0;
|
||||
currentEventRunning = null;
|
||||
}
|
||||
|
||||
public void EndCommand()
|
||||
{
|
||||
SubPacket p = EndEventPacket.BuildPacket(actorId, currentCommand, currentCommandName);
|
||||
p.DebugPrintSubPacket();
|
||||
QueuePacket(p);
|
||||
|
||||
currentCommand = 0;
|
||||
currentCommandName = "";
|
||||
}
|
||||
|
||||
public void SetCurrentMenuId(uint id)
|
||||
{
|
||||
eventMenuId = id;
|
||||
}
|
||||
|
||||
public uint GetCurrentMenuId()
|
||||
{
|
||||
return eventMenuId;
|
||||
}
|
||||
|
||||
|
||||
public void SendInstanceUpdate()
|
||||
{
|
||||
|
||||
|
@@ -47,7 +47,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsClientConnectionsReady()
|
||||
{
|
||||
return (zoneConnection != null && chatConnection != null);
|
||||
@@ -57,7 +57,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
||||
{
|
||||
zoneConnection.Disconnect();
|
||||
chatConnection.Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsDisconnected()
|
||||
{
|
||||
@@ -110,11 +110,11 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
||||
playerActor.moveState = moveState;
|
||||
|
||||
GetActor().zone.UpdateActorPosition(GetActor());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void UpdateInstance(List<Actor> list)
|
||||
{
|
||||
{
|
||||
List<BasePacket> basePackets = new List<BasePacket>();
|
||||
List<SubPacket> RemoveActorSubpackets = new List<SubPacket>();
|
||||
List<SubPacket> posUpdateSubpackets = new List<SubPacket>();
|
||||
@@ -125,7 +125,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
||||
if (!list.Contains(actorInstanceList[i]))
|
||||
{
|
||||
GetActor().QueuePacket(RemoveActorPacket.BuildPacket(playerActor.actorId, actorInstanceList[i].actorId));
|
||||
actorInstanceList.RemoveAt(i);
|
||||
actorInstanceList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
||||
{
|
||||
GetActor().QueuePacket(actor.GetSpawnPackets(playerActor.actorId, 1));
|
||||
GetActor().QueuePacket(actor.GetInitPackets(playerActor.actorId));
|
||||
GetActor().QueuePacket(actor.GetSetEventStatusPackets(playerActor.actorId));
|
||||
GetActor().QueuePacket(actor.GetSetEventStatusPackets(playerActor.actorId));
|
||||
actorInstanceList.Add(actor);
|
||||
|
||||
if (actor is Npc)
|
||||
|
@@ -57,14 +57,8 @@ namespace FFXIVClassic_Map_Server.lua
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void DoActorOnEventStarted(Player player, Actor target, EventStartPacket eventStart)
|
||||
{
|
||||
if (target is Npc)
|
||||
{
|
||||
((Npc)target).DoEventStart(player, eventStart);
|
||||
return;
|
||||
}
|
||||
|
||||
public static Coroutine DoActorOnEventStarted(Player player, Actor target, EventStartPacket eventStart)
|
||||
{
|
||||
string luaPath;
|
||||
|
||||
if (target is Command)
|
||||
@@ -83,24 +77,17 @@ namespace FFXIVClassic_Map_Server.lua
|
||||
LuaScript script = LoadScript(luaPath);
|
||||
|
||||
if (script == null)
|
||||
return;
|
||||
return null;
|
||||
|
||||
//Have to Do this to combine LuaParams
|
||||
List<Object> objects = new List<Object>();
|
||||
objects.Add(player);
|
||||
objects.Add(target);
|
||||
objects.Add(eventStart.triggerName);
|
||||
|
||||
if (eventStart.luaParams != null)
|
||||
objects.AddRange(LuaUtils.CreateLuaParamObjectList(eventStart.luaParams));
|
||||
|
||||
//Run Script
|
||||
if (!script.Globals.Get("onEventStarted").IsNil())
|
||||
script.Call(script.Globals["onEventStarted"], objects.ToArray());
|
||||
return script.CreateCoroutine(script.Globals["onEventStarted"]).Coroutine;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
SendError(player, String.Format("ERROR: Could not find script for actor {0}.", target.GetName()));
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user