From b81141a158b3616c07eabb840d82151befdca2ce Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Tue, 14 Mar 2017 18:33:33 -0400 Subject: [PATCH] More fixings and improvements. --- .../actors/chara/player/Player.cs | 2 +- FFXIVClassic Map Server/lua/LuaEngine.cs | 45 +++++++++++++------ data/scripts/commands/ActivateCommand.lua | 11 +++-- .../directors/Quest/QuestDirectorMan0l001.lua | 20 ++++++++- data/scripts/global.lua | 9 +++- 5 files changed, 64 insertions(+), 23 deletions(-) diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index e0796018..d48bb26a 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -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) diff --git a/FFXIVClassic Map Server/lua/LuaEngine.cs b/FFXIVClassic Map Server/lua/LuaEngine.cs index e03f9c49..846d3175 100644 --- a/FFXIVClassic Map Server/lua/LuaEngine.cs +++ b/FFXIVClassic Map Server/lua/LuaEngine.cs @@ -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 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; } } diff --git a/data/scripts/commands/ActivateCommand.lua b/data/scripts/commands/ActivateCommand.lua index 7c01a62f..dffa22d1 100644 --- a/data/scripts/commands/ActivateCommand.lua +++ b/data/scripts/commands/ActivateCommand.lua @@ -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 \ No newline at end of file diff --git a/data/scripts/directors/Quest/QuestDirectorMan0l001.lua b/data/scripts/directors/Quest/QuestDirectorMan0l001.lua index a9e0110b..86776c57 100644 --- a/data/scripts/directors/Quest/QuestDirectorMan0l001.lua +++ b/data/scripts/directors/Quest/QuestDirectorMan0l001.lua @@ -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); diff --git a/data/scripts/global.lua b/data/scripts/global.lua index bad49181..43cc44b5 100644 --- a/data/scripts/global.lua +++ b/data/scripts/global.lua @@ -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)