More fixings and improvements.

This commit is contained in:
Filip Maj 2017-03-14 18:33:33 -04:00
parent 718bc28c57
commit b81141a158
5 changed files with 64 additions and 23 deletions

View File

@ -1231,7 +1231,7 @@ namespace FFXIVClassic_Map_Server.Actors
public void UpdateEvent(EventUpdatePacket update)
{
LuaEngine.GetInstance().OnEventUpdate(this);
LuaEngine.GetInstance().OnEventUpdate(this, update.luaParams);
}
public void KickEvent(Actor actor, string conditionName, params object[] parameters)

View File

@ -85,7 +85,7 @@ namespace FFXIVClassic_Map_Server.lua
{
mSleepingOnTime.Remove(key);
DynValue value = key.Resume();
ResolveResume(key, value);
ResolveResume(null, key, value);
}
}
@ -102,16 +102,18 @@ namespace FFXIVClassic_Map_Server.lua
foreach (Coroutine key in mToAwake)
{
DynValue value = key.Resume();
ResolveResume(key, value);
ResolveResume(null, key, value);
}
}
public void OnEventUpdate(Player player)
public void OnEventUpdate(Player player, List<LuaParam> args)
{
if (mSleepingOnPlayerEvent.ContainsKey(player.actorId))
{
mSleepingOnPlayerEvent[player.actorId].Resume();
mSleepingOnPlayerEvent.Remove(player.actorId);
Coroutine coroutine = mSleepingOnPlayerEvent[player.actorId];
mSleepingOnPlayerEvent.Remove(player.actorId);
DynValue value = coroutine.Resume(LuaUtils.CreateLuaParamObjectList(args));
ResolveResume(null, coroutine, value);
}
else
player.EndEvent();
@ -203,6 +205,7 @@ namespace FFXIVClassic_Map_Server.lua
if (parent == null && child == null)
{
LuaEngine.SendError(player, String.Format("ERROR: Could not find script for actor {0}.", target.GetName()));
return;
}
//Run Script
@ -215,8 +218,8 @@ namespace FFXIVClassic_Map_Server.lua
if (coroutine != null)
{
DynValue value = coroutine.Resume();
ResolveResume(coroutine, value);
DynValue value = coroutine.Resume(player, target, args);
ResolveResume(player, coroutine, value);
}
}
@ -253,7 +256,10 @@ namespace FFXIVClassic_Map_Server.lua
{
//Need a seperate case for NPCs cause that child/parent thing.
if (target is Npc)
{
CallLuaFunctionNpc(player, (Npc)target, funcName, args);
return;
}
string luaPath = GetScriptPath(target);
LuaScript script = LoadScript(luaPath);
@ -262,7 +268,8 @@ namespace FFXIVClassic_Map_Server.lua
if (!script.Globals.Get(funcName).IsNil())
{
Coroutine coroutine = script.CreateCoroutine(script.Globals[funcName]).Coroutine;
coroutine.Resume(player, target, args);
DynValue value = coroutine.Resume(player, target, args);
ResolveResume(player, coroutine, value);
}
else
{
@ -277,15 +284,27 @@ namespace FFXIVClassic_Map_Server.lua
public void EventStarted(Player player, Actor target, EventStartPacket eventStart)
{
CallLuaFunction(player, target, "onEventStarted");
if (mSleepingOnPlayerEvent.ContainsKey(player.actorId))
{
Coroutine coroutine = mSleepingOnPlayerEvent[player.actorId];
mSleepingOnPlayerEvent.Remove(player.actorId);
DynValue value = coroutine.Resume();
ResolveResume(null, coroutine, value);
}
else
CallLuaFunction(player, target, "onEventStarted", eventStart.triggerName);
}
private DynValue ResolveResume(Coroutine coroutine, DynValue value)
private DynValue ResolveResume(Player player, Coroutine coroutine, DynValue value)
{
if (value == null || value.IsVoid())
return value;
if (value.Tuple != null && value.Tuple.Length >= 1 && value.Tuple[0].String != null)
if (value.String != null && value.String.Equals("_WAIT_EVENT"))
{
GetInstance().AddWaitEventCoroutine(player, coroutine);
}
else if (value.Tuple != null && value.Tuple.Length >= 1 && value.Tuple[0].String != null)
{
switch (value.Tuple[0].String)
{
@ -296,7 +315,7 @@ namespace FFXIVClassic_Map_Server.lua
GetInstance().AddWaitSignalCoroutine(coroutine, (string)value.Tuple[1].String);
break;
case "_WAIT_EVENT":
GetInstance().AddWaitEventCoroutine(new Player(null, 0), coroutine);
GetInstance().AddWaitEventCoroutine((Player)value.Tuple[1].UserData.Object, coroutine);
break;
default:
return value;
@ -437,7 +456,7 @@ namespace FFXIVClassic_Map_Server.lua
Coroutine coroutine = script.CreateCoroutine(script.Globals["onTrigger"]).Coroutine;
DynValue value = coroutine.Resume(player, LuaParam.ToArray());
GetInstance().ResolveResume(coroutine, value);
GetInstance().ResolveResume(player, coroutine, value);
return;
}
}

View File

@ -1,3 +1,5 @@
require ("global")
--[[
ActivateCommand Script
@ -10,15 +12,12 @@ function onEventStarted(player, command, triggerName)
if (player:GetState() == 0) then
player:ChangeState(2);
sendSignal("playerActive");
elseif (player:GetState() == 2) then
player:ChangeState(0);
sendSignal("playerPassive");
end
player:endEvent();
--For Opening Tutorial
--if (player:HasQuest("Man0l0") or player:HasQuest("Man0g0") or player:HasQuest("Man0u0")) then
--player:GetDirector("Quest/QuestDirectorMan0l001"):OnCommandEvent(player, command);
--end
end

View File

@ -19,10 +19,28 @@ end
function onEventStarted(player, actor, triggerName)
man0l0Quest = player:GetQuest("Man0l0");
callClientFunction(player, "delegateEvent", player, man0l0Quest, "processTtrBtl001", nil, nil, nil);
player:EndEvent();
waitForSignal("playerActive");
kickEventContinue(player, actor, "noticeEvent", "noticeEvent");
callClientFunction(player, "delegateEvent", player, man0l0Quest, "processTtrBtl002", nil, nil, nil);
callClientFunction(player, "delegateEvent", player, man0l0Quest, "processEvent000_2", nil, nil, nil);
player:EndEvent();
wait(4);
player:SendRequestedInfo(5); --Close TutorialWidget
player:SendRequestedInfo(2, nil, nil, 9055, 9055, 9055); --Open TutorialSuccessWidget for attacking enemy
wait(4);
player:SendRequestedInfo(4, nil, nil, nil, 12); --Open TP TutorialWidget
wait(4); --Should be wait for TP signal
player:SendRequestedInfo(5); --Close TutorialWidget
player:SendRequestedInfo(4, nil, nil, nil, 13); --Open WS TutorialWidget
wait(4); --Should be wait for weaponskillUsed signal
player:SendRequestedInfo(5); --Close TutorialWidget
player:SendRequestedInfo(2, nil, nil, 9065, 9065, 9065); --Open TutorialSuccessWidget for weapon skill
wait(4); --Should be wait for mobkill
callClientFunction(player, "delegateEvent", player, man0l0Quest, "processEvent000_2", nil, nil, nil);
player:ChangeMusic(7);
callClientFunction(player, "delegateEvent", player, man0l0Quest, "processEvent000_3", nil, nil, nil);

View File

@ -53,14 +53,19 @@ INVENTORY_EQUIPMENT_OTHERPLAYER = 0x00F9; --Max 0x23
--UTILS
function kickEventContinue(player, actor, trigger, ...)
player:kickEvent(actor, trigger, ...);
return coroutine.yield("_WAIT_EVENT", player);
end
function callClientFunction(player, functionName, ...)
player:RunEventFunction(functionName, ...);
result = coroutine.yield("_WAIT_EVENT");
result = coroutine.yield("_WAIT_EVENT", player);
return result;
end
function wait(seconds)
return coroutine.yield(_WAIT_TIME, seconds);
return coroutine.yield("_WAIT_TIME", seconds);
end
function waitForSignal(signal)