Non-npc stuff is now also using script system. Wrote new scripts for all sidemenu commands.

This commit is contained in:
Filip Maj 2016-06-18 12:26:29 -04:00
parent 4e69022072
commit 51bbf4ae2e
4 changed files with 17 additions and 36 deletions

View File

@ -246,12 +246,8 @@ 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
if (ownerActor != null)
{
player.GetActor().currentEventOwner = eventStart.scriptOwnerActorID;
player.GetActor().currentEventName = eventStart.triggerName;

View File

@ -82,9 +82,6 @@ namespace FFXIVClassic_Map_Server.Actors
public uint currentEventOwner = 0;
public string currentEventName = "";
public uint currentCommand = 0;
public string currentCommandName = "";
public Coroutine currentEventRunning;
//Player Info
@ -1137,7 +1134,11 @@ namespace FFXIVClassic_Map_Server.Actors
currentEventRunning.Resume(objects.ToArray());
}
else
LuaEngine.DoActorOnEventStarted(this, owner, start);
{
currentEventRunning = LuaEngine.DoActorOnEventStarted(this, owner, start);
currentEventRunning.Resume(objects.ToArray());
}
}
public void UpdateEvent(EventUpdatePacket update)
@ -1181,16 +1182,7 @@ namespace FFXIVClassic_Map_Server.Actors
currentEventOwner = 0;
currentEventName = "";
}
public void EndCommand()
{
SubPacket p = EndEventPacket.BuildPacket(actorId, currentCommand, currentCommandName);
p.DebugPrintSubPacket();
QueuePacket(p);
currentCommand = 0;
currentCommandName = "";
currentEventRunning = null;
}
public void SendInstanceUpdate()

View File

@ -56,7 +56,7 @@ namespace FFXIVClassic_Map_Server.lua
return null;
}
public static void DoActorOnEventStarted(Player player, Actor target, EventStartPacket eventStart)
public static Coroutine DoActorOnEventStarted(Player player, Actor target, EventStartPacket eventStart)
{
string luaPath;
@ -76,24 +76,17 @@ namespace FFXIVClassic_Map_Server.lua
Script 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;
}
}

View File

@ -39,7 +39,7 @@ function init(npc)
return false, false, 0, 0;
end
function onEventStarted(player, npc)
function onEventStarted(player, npc, triggerName)
require("/unique/".. npc.zone.zoneName .."/PopulaceShopSalesman/" .. npc:GetUniqueId())