diff --git a/FFXIVClassic Map Server/PacketProcessor.cs b/FFXIVClassic Map Server/PacketProcessor.cs index 11777b0c..5300ce79 100644 --- a/FFXIVClassic Map Server/PacketProcessor.cs +++ b/FFXIVClassic Map Server/PacketProcessor.cs @@ -247,11 +247,10 @@ namespace FFXIVClassic_Map_Server Actor ownerActor = Server.GetStaticActors(eventStart.scriptOwnerActorID); - if (ownerActor != null) - { - player.GetActor().currentEventOwner = eventStart.scriptOwnerActorID; - player.GetActor().currentEventName = eventStart.triggerName; - } + + player.GetActor().currentEventOwner = eventStart.scriptOwnerActorID; + player.GetActor().currentEventName = eventStart.triggerName; + if (ownerActor == null) { diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index 9df32c67..6d3454f2 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -1131,7 +1131,19 @@ namespace FFXIVClassic_Map_Server.Actors if (owner is Npc) { currentEventRunning = ((Npc)owner).GetEventStartCoroutine(this); - currentEventRunning.Resume(objects.ToArray()); + + if (currentEventRunning != null) + { + try + { + currentEventRunning.Resume(objects.ToArray()); + } + catch (ScriptRuntimeException e) + { + Program.Log.Error("[LUA] {0}", e.Message); + EndEvent(); + } + } } else { diff --git a/data/scripts/base/chara/npc/object/BookShelf.lua b/data/scripts/base/chara/npc/object/BookShelf.lua index 5d43890a..e5ef5b1d 100644 --- a/data/scripts/base/chara/npc/object/BookShelf.lua +++ b/data/scripts/base/chara/npc/object/BookShelf.lua @@ -1,11 +1,10 @@ +require ("global") + function init(npc) return false, false, 0, 0; end function onEventStarted(player, npc, triggerName) - player:RunEventFunction("bookTalk"); + player:callClientFunction(player, "bookTalk"); + player:EndEvent(); end - -function onEventUpdate(player, npc, step, menuOptionSelected) - player:EndEvent(); -end \ No newline at end of file diff --git a/data/scripts/base/chara/npc/object/ObjectBed.lua b/data/scripts/base/chara/npc/object/ObjectBed.lua index 17640c17..4b211b9c 100644 --- a/data/scripts/base/chara/npc/object/ObjectBed.lua +++ b/data/scripts/base/chara/npc/object/ObjectBed.lua @@ -1,25 +1,21 @@ +require ("global") function init(npc) return false, false, 0, 0; end function onEventStarted(player, npc, triggerName) - player:RunEventFunction("askLogout", player); -end -function onEventUpdate(player, npc, eventStep, menuOptionSelected) + choice = callClientFunction(player, "askLogout", player); - if (menuOptionSelected == 1) then - player:EndEvent(); - return; - elseif (menuOptionSelected == 2) then + if (choice == 2) then player:QuitGame(); - elseif (menuOptionSelected == 3) then + elseif (choice == 3) then player:Logout(); - elseif (menuOptionSelected == 4) then + elseif (choice == 4) then player:SendMessage(33, "", "Heck the bed"); - end + end player:EndEvent(); - + end \ No newline at end of file diff --git a/data/scripts/base/chara/npc/object/ObjectInnDoor.lua b/data/scripts/base/chara/npc/object/ObjectInnDoor.lua index c0c69269..24b7161b 100644 --- a/data/scripts/base/chara/npc/object/ObjectInnDoor.lua +++ b/data/scripts/base/chara/npc/object/ObjectInnDoor.lua @@ -1,3 +1,4 @@ +require ("global") function init(npc) return false, false, 0, 0; @@ -5,15 +6,11 @@ end function onEventStarted(player, npc, triggerName) defaultFst = GetStaticActor("DftFst"); - player:RunEventFunction("delegateEvent", player, defaultFst, "defaultTalkWithInn_ExitDoor", nil, nil, nil); -end - -function onEventUpdate(player, npc, resultId, isExitYes) - - if (isExitYes ~= nil and isExitYes == 1) then + choice = callClientFunction(player, "delegateEvent", player, defaultFst, "defaultTalkWithInn_ExitDoor", nil, nil, nil); + + if (choice == 1) then GetWorldManager():DoZoneChange(player, 1); - else - player:EndEvent(); end + player:EndEvent(); end \ No newline at end of file diff --git a/data/scripts/base/chara/npc/populace/PopulaceCutscenePlayer.lua b/data/scripts/base/chara/npc/populace/PopulaceCutscenePlayer.lua index 1e98e2c4..337e5710 100644 --- a/data/scripts/base/chara/npc/populace/PopulaceCutscenePlayer.lua +++ b/data/scripts/base/chara/npc/populace/PopulaceCutscenePlayer.lua @@ -1,9 +1,3 @@ function init(npc) return false, false, 0, 0; -end - -function onEventStarted(player, npc, triggerName) -end - -function onEventUpdate(player, npc) end \ No newline at end of file diff --git a/data/scripts/base/chara/npc/populace/PopulaceGuildlevePublisher.lua b/data/scripts/base/chara/npc/populace/PopulaceGuildlevePublisher.lua index 15bc895a..08bf5ca2 100644 --- a/data/scripts/base/chara/npc/populace/PopulaceGuildlevePublisher.lua +++ b/data/scripts/base/chara/npc/populace/PopulaceGuildlevePublisher.lua @@ -16,23 +16,80 @@ eventTalkChangeOne(skipQuestion) talkOfferMaxOver() askRetryRegionalleve(guildLeveId, leveAllowances); -Menu Ids: - --]] +require ("global") + function init(npc) return false, false, 0, 0; end function onEventStarted(player, npc) - player:RunEventFunction("eventTalkType", 0x30, true, 0x02CE, 0x356, 0x367, true, 0, nil, 0x29, 0,0,0); + + ::MENU_LOOP:: + menuChoice = callClientFunction(player, "eventTalkType", 0x30, true, 0x02CE, 0x356, 0x367, true, 0, nil, 0x29, 0,0,0); + --Battlecraft + if (menuChoice == 1) then + resultGLPack = callClientFunction(player, "eventTalkPack", 201, 207); + + if (resultGLPack == nil) then + goto MENU_LOOP; + else + + ::CARDS_LOOP:: + cards = {0x30C3, 0x30C4, 0x30C1, 0x30C5, 0x30C6, 0x30C7, 0x30C8, 0x30C9}; + + chosenGLCard = callClientFunction(player, "eventTalkCard", cards[1], cards[2], cards[3], cards[4], cards[5], cards[6], cards[7], cards[8]); + + if (chosenGLCard == -1) then + goto MENU_LOOP; + else + wasAccepted = callClientFunction(player, "eventTalkDetail", cards[chosenGLCard], 0, 0xF4242, 0xD, 0xF4242, 0, 0, true, 0); + + if (wasAccepted == true) then + + end + + goto CARDS_LOOP; + + end + end + + --FieldCraft Miner + elseif (menuChoice == 0x15) then + --FieldCraft Botanist + elseif (menuChoice == 0x16) then + --FieldCraft Fisher + elseif (menuChoice == 0x17) then + --FieldCraft Quit + elseif (menuChoice == 0x18) then + --Faction Broken Blade + elseif (menuChoice == 0x29) then + --Faction Shields + elseif (menuChoice == 0x2A) then + --Faction Horn and Hand + elseif (menuChoice == 0x2B) then + --Leve Evaluation + elseif (menuChoice == 5) then + --Tutorial + elseif (menuChoice == 6) then + --End of Info + elseif (menuChoice == 7) then + --Quit + elseif (menuChoice == 8) then + end + + -- + -- + -- + player:EndEvent(); end function onEventUpdate(player, npc, step, menuOptionSelected) --player:RunEventFunction("eventTalkType", 0x32, true, 0x02CE, 0x356, 0x367, false, 2, nil, 0x29, 0,0,0); player:RunEventFunction("eventTalkPack", 201, 207); --player:RunEventFunction("eventTalkCard", 0x30C3, 0x30C4, 0x30C1, 0x30C5, 0x30C6, 0x30C7, 0x30C8, 0x30C9); - --player:RunEventFunction("eventTalkDetail", 0x30C4, 2, 0xF4242, 0xD, 0xF4242, 0, 0xFF, true, 11); + -- --player:RunEventFunction("eventGLChangeDetail", 0xDEAD, 0x30C4, 0xFF, 0xF4242, 0xD, 0xF4242, 0, 2, true); - player:EndEvent(); + end \ No newline at end of file diff --git a/data/scripts/base/chara/npc/populace/PopulaceLinkshellManager.lua b/data/scripts/base/chara/npc/populace/PopulaceLinkshellManager.lua index ce2ac829..53157eb2 100644 --- a/data/scripts/base/chara/npc/populace/PopulaceLinkshellManager.lua +++ b/data/scripts/base/chara/npc/populace/PopulaceLinkshellManager.lua @@ -1,28 +1,56 @@ +--[[ + +PopulaceLinkshellManager Script + +Functions: + +eventTalkStep1(noLinkshellActive) - Says intro. If noLinkshellActive = true, say newbie stuff. +eventTalkStep2(noLinkshellActive) - Shows menu, if noLinkshellActive = true, only give ability to make linkshell. +eventTalkStepMakeupDone() - Confirm when creating LS +eventTalkStepModifyDone() - Confirm when modding LS +eventTalkStepBreakDone() - Confirm when deleting LS + +--]] + +require ("global") + function init(npc) return false, false, 0, 0; end -function onEventStarted(player, npc) - isNew = false; - player:RunEventFunction("eventTalkStep1", isNew); +function createLinkshell(name, crest) + end -function onEventUpdate(player, npc, step, menuOptionSelected, lsName, lsCrest) - - if (menuOptionSelected == nil) then - player:EndEvent(); - return; - end - - isNew = false; - if (menuOptionSelected == 1) then - player:RunEventFunction("eventTalkStep2", isNew); - elseif (menuOptionSelected == 10) then - player:EndEvent(); - return; - elseif (menuOptionSelected == 3) then - --createLinkshell - player:RunEventFunction("eventTalkStepMakeupDone", isNew); - end +function modifyLinkshell(name, crest) +end + +function disbandLinkshell(name, crest) + +end + +function onEventStarted(player, npc, triggerName) + + hasNoActiveLS = false; + + callClientFunction(player, "eventTalkStep1", hasNoActiveLS); + command, lsName, crestId = callClientFunction(player, "eventTalkStep2", hasNoActiveLS); + + --Create + if (result == 3) then + createLinkshell(lsName, crestId); + callClientFunction(player, "eventTalkStepMakeupDone"); + --Modify + elseif (result == 1) then + modifyLinkshell(lsName, crestId); + callClientFunction(player, "eventTalkStepModifyDone"); + --Disband + elseif (result == 5) then + disbandLinkshell(lsName, crestId); + callClientFunction(player, "eventTalkStepBreakDone"); + end + + player:endEvent(); + end \ No newline at end of file diff --git a/data/scripts/base/chara/npc/populace/PopulaceRetainerManager.lua b/data/scripts/base/chara/npc/populace/PopulaceRetainerManager.lua new file mode 100644 index 00000000..50c0b727 --- /dev/null +++ b/data/scripts/base/chara/npc/populace/PopulaceRetainerManager.lua @@ -0,0 +1,77 @@ +--[[ + +PopulaceRetainerManager Script + +Functions: + +eventTalkStep1(true) - Intro tutorial if no retainer +newEventTalkStep1(sayIntro) - Seems to be a post-Tanaka version of the intro???? +eventTalkStep2() - Choose retainer yourself (go to race select) or let npc do it +eventTaklSelectCutSeane(cutsceneName, actorClassId1, actorClassId2, actorClassId3, actorClassId4, actorClassId5) - Starts the advance cutscene to choose a retainer. 5 retainer actorClassId's are given. +eventTalkStep4(actorClassId) - Opens up the retainer naming dialog +eventTalkStepFinalAnswer(actorClassId) - Confirm Dialog +eventTalkStepError(errorCode) - Error dialog, 1: No Extra Retainers, 2: Server Busy. +eventTalkStepFinish() + +--]] + +require ("global") + +function init(npc) + return false, false, 0, 0; +end + +function onEventStarted(player, npc, triggerName) + + introChoice = callClientFunction(player, "newEventTalkStep1", false); + + if (introChoice == 1) then + + raceChoice = callClientFunction(player, "eventTalkStep2"); + + while (true) do + + if (retainerChoice == 0) then + raceChoice = callClientFunction(player, "eventTalkStep22"); + end + + if (raceChoice == 0) then + --Choose random actorId + elseif (raceChoice > 0) then + --Choose 5 random but correct actor ids + retainerChoice = callClientFunction(player, "eventTaklSelectCutSeane", "rtn0g010", 0x2DCB1A, 0x2DCB1A, 0x2DCB1A, 0x2DCB1A, 0x2DCB1A); + + if (retainerChoice == -1) then + player:EndEvent(); + return; + elseif (retainerChoice > 0) then + --Retainer chosen, choose name + retainerName = callClientFunction(player, "eventTalkStep4", 0x2DCB1A); + + if (retainerName ~= "") then + confirmChoice = callClientFunction(player, "eventTalkStepFinalAnswer", 0x2DCB1A); + + if (confirmChoice == 1) then + callClientFunction(player, "eventTalkStepFinish"); + player:EndEvent(); + return; + elseif (confirmChoice == 3) then + raceChoice = 0; + else + player:EndEvent(); + return; + end + + end + + end + else + break; + end + + end + + end + + player:EndEvent(); +end \ No newline at end of file diff --git a/data/scripts/base/chara/npc/populace/shop/PopulaceGuildShop.lua b/data/scripts/base/chara/npc/populace/shop/PopulaceGuildShop.lua index a3727d1f..72348129 100644 --- a/data/scripts/base/chara/npc/populace/shop/PopulaceGuildShop.lua +++ b/data/scripts/base/chara/npc/populace/shop/PopulaceGuildShop.lua @@ -1,3 +1,5 @@ +require ("global") + function init(npc) return false, false, 0, 0; end @@ -44,12 +46,10 @@ function onEventStarted(player, npc) saySheetId = 19; end - player:RunEventFunction("welcomeTalk", nil, saySheetId, player); - coroutine.yield(); + callClientFunction(player, "welcomeTalk", nil, saySheetId, player); while (true) do - player:RunEventFunction("selectMode", nil, npc:GetActorClassId(), false, 1000001); --Step 2, state your business - choice = coroutine.yield(); + choice = callClientFunction(player, "selectMode", nil, npc:GetActorClassId(), false, 1000001); --Step 2, state your business if (choice == 3) then @@ -60,17 +60,4 @@ function onEventStarted(player, npc) end -end - -function onEventUpdate(player, npc, step, menuOptionSelected) - - --player:RunEventFunction("cashbackTalkCommand", 22004, 22004, 22004, 22004, 22004, 22004, 22004, 22004, 22004, 22004, 22004); --Refund Abilities??? - --player:RunEventFunction("cashbackTalk", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); --Refund items??? - - if (menuOptionSelected == 4) then - player:EndEvent(); - else - player:RunEventFunction("selectMode", nil, npc:GetActorClassId(), false, 1000001); --Step 2, state your business - end - end \ No newline at end of file diff --git a/data/scripts/base/chara/npc/populace/shop/PopulaceShopSalesman.lua b/data/scripts/base/chara/npc/populace/shop/PopulaceShopSalesman.lua index 31ae2c80..362be4f3 100644 --- a/data/scripts/base/chara/npc/populace/shop/PopulaceShopSalesman.lua +++ b/data/scripts/base/chara/npc/populace/shop/PopulaceShopSalesman.lua @@ -29,11 +29,7 @@ finishTalkTurn() - Done at the end. --]] -function callClientFunction(player, functionName, ...) - player:RunEventFunction(functionName, ...); - result = coroutine.yield(); - return result; -end +require ("global") function init(npc) return false, false, 0, 0; diff --git a/data/scripts/commands/ActivateCommand.lua b/data/scripts/commands/ActivateCommand.lua index 2c9b022d..c15247e5 100644 --- a/data/scripts/commands/ActivateCommand.lua +++ b/data/scripts/commands/ActivateCommand.lua @@ -14,7 +14,7 @@ function onEventStarted(player, command, triggerName) player:ChangeState(0); end - player:EndCommand(); + player:endEvent(); --For Opening Tutorial if (player:HasQuest("Man0l0") or player:HasQuest("Man0g0") or player:HasQuest("Man0u0")) then diff --git a/data/scripts/commands/AttackWeaponSkill.lua b/data/scripts/commands/AttackWeaponSkill.lua index cafc3921..e3f3a3a4 100644 --- a/data/scripts/commands/AttackWeaponSkill.lua +++ b/data/scripts/commands/AttackWeaponSkill.lua @@ -16,7 +16,7 @@ function onEventStarted(player, actor, triggerName) player:SendGameMessage(worldMaster, 32503, 0x20); end - player:EndCommand(); + player:EndEvent(); end diff --git a/data/scripts/commands/BonusPointCommand.lua b/data/scripts/commands/BonusPointCommand.lua index dfda0c2f..d5f48b44 100644 --- a/data/scripts/commands/BonusPointCommand.lua +++ b/data/scripts/commands/BonusPointCommand.lua @@ -8,16 +8,16 @@ operateUI(pointsAvailable, pointsLimit, str, vit, dex, int, min, pie) --]] +require ("global") + function onEventStarted(player, actor, triggerName) --local points = player:GetAttributePoints(); --player:RunEventFunction("delegateCommand", actor, "operateUI", points.available, points.limit, points.inSTR, points.inVIT, points.inDEX, points.inINT, points.inMIN, points.inPIT); - player:RunEventFunction("delegateCommand", actor, "operateUI", 10, 10, 10, 10, 10, 10, 10, 10); -end - -function onEventUpdate(player, actor, step, arg1) - - --Submit + result = callClientFunction(player, "delegateCommand", actor, "operateUI", 100, 100, 10, 10, 10, 10, 10, 10); - player:EndCommand(); + --Do Save + if (result == true) then + end + player:endEvent(); end \ No newline at end of file diff --git a/data/scripts/commands/CheckCommand.lua b/data/scripts/commands/CheckCommand.lua index 9d1bbf52..5e78e279 100644 --- a/data/scripts/commands/CheckCommand.lua +++ b/data/scripts/commands/CheckCommand.lua @@ -14,6 +14,6 @@ function onEventStarted(player, commandactor, triggerName, arg1, arg2, arg3, arg player:examinePlayer(actor); end - player:EndCommand(); + player:EndEvent(); end diff --git a/data/scripts/commands/ChocoboRideCommand.lua b/data/scripts/commands/ChocoboRideCommand.lua index 37267720..9952417f 100644 --- a/data/scripts/commands/ChocoboRideCommand.lua +++ b/data/scripts/commands/ChocoboRideCommand.lua @@ -42,6 +42,6 @@ function onEventStarted(player, actor, triggerName, isGoobbue) player:ChangeState(0); end - player:EndCommand(); + player:EndEvent(); end \ No newline at end of file diff --git a/data/scripts/commands/DiceCommand.lua b/data/scripts/commands/DiceCommand.lua index 1b0ede05..9f9bd110 100644 --- a/data/scripts/commands/DiceCommand.lua +++ b/data/scripts/commands/DiceCommand.lua @@ -15,7 +15,7 @@ function onEventStarted(player, actor, triggerName, maxNumber) worldMaster = GetWorldMaster(); player:SendGameMessage(player, worldMaster, 25342, 0x20, result, maxNumber); - player:EndCommand(); + player:EndEvent(); end diff --git a/data/scripts/commands/EmoteSitCommand.lua b/data/scripts/commands/EmoteSitCommand.lua index 5694c9b5..5f58c4c0 100644 --- a/data/scripts/commands/EmoteSitCommand.lua +++ b/data/scripts/commands/EmoteSitCommand.lua @@ -16,7 +16,7 @@ function onEventStarted(player, actor, triggerName, emoteId) player:ChangeState(0); end - player:EndCommand(); + player:EndEvent(); end diff --git a/data/scripts/commands/EmoteStandardCommand.lua b/data/scripts/commands/EmoteStandardCommand.lua index 82d36f72..505102f9 100644 --- a/data/scripts/commands/EmoteStandardCommand.lua +++ b/data/scripts/commands/EmoteStandardCommand.lua @@ -15,7 +15,7 @@ function onEventStarted(player, actor, triggerName, emoteId) player:DoEmote(emoteId); end - player:EndCommand(); + player:EndEvent(); end diff --git a/data/scripts/commands/EquipCommand.lua b/data/scripts/commands/EquipCommand.lua index dc838845..8d741d32 100644 --- a/data/scripts/commands/EquipCommand.lua +++ b/data/scripts/commands/EquipCommand.lua @@ -69,7 +69,7 @@ function onEventStarted(player, actor, triggerName, invActionInfo, param1, param end end - player:EndCommand(); + player:EndEvent(); end function loadGearset(player, classId) diff --git a/data/scripts/commands/ItemWasteCommand.lua b/data/scripts/commands/ItemWasteCommand.lua index 073576c1..ceb6f493 100644 --- a/data/scripts/commands/ItemWasteCommand.lua +++ b/data/scripts/commands/ItemWasteCommand.lua @@ -11,5 +11,5 @@ The param "itemDBIds" has the vars: item1 and item2. function onEventStarted(player, actor, triggerName, invActionInfo, param1, param2, param3, param4, param5, param6, param7, param8, itemDBIds) player:GetInventory(0x00):RemoveItem(invActionInfo.slot); - player:EndCommand(); + player:EndEvent(); end diff --git a/data/scripts/commands/LogoutCommand.lua b/data/scripts/commands/LogoutCommand.lua index 037e70b9..7f56d757 100644 --- a/data/scripts/commands/LogoutCommand.lua +++ b/data/scripts/commands/LogoutCommand.lua @@ -8,46 +8,20 @@ eventConfirm() eventCountDown() eventLogoutFade() -Menu Ids: - -Menu: 0 -Countdown: 1 - --]] -function onEventStarted(player, command) - --player:SetCurrentMenuId(0); - --player:RunEventFunction("delegateCommand", command, "eventConfirm"); - player:Logout(); -end +require ("global") -function onEventUpdate(player, command, triggerName, step, arg1, arg2) +function onEventStarted(player, command, triggerName) - currentMenuId = player:GetCurrentMenuId(); + choice = callClientFunction(player, "delegateCommand", command, "eventConfirm"); - --Menu Dialog - if (currentMenuId == 0) then - if (arg1 == 1) then --Exit - player:QuitGame(); - player:EndCommand(); - elseif (arg1 == 2) then --Character Screen - player:Logout(); - player:EndCommand(); - --player:SetCurrentMenuId(1); - --player:RunEventFunction("delegateCommand", command, "eventCountDown"); - elseif (arg1 == 3) then --Cancel - player:EndCommand(); - end - --Countdown Dialog - elseif (currentMenuId == 1) then - - if (arg2 == 1) then --Logout Complete - player:Logout(); - player:EndCommand(); - elseif (arg2 == 2) then --Cancel Pressed - player:EndCommand(); - end - + if (choice == 1) then + player:QuitGame(); + elseif (choice == 2) then + player:Logout(); end -end \ No newline at end of file + player:EndEvent(); + +end diff --git a/data/scripts/commands/PartyInviteCommand.lua b/data/scripts/commands/PartyInviteCommand.lua index 74a74db9..59a8fc08 100644 --- a/data/scripts/commands/PartyInviteCommand.lua +++ b/data/scripts/commands/PartyInviteCommand.lua @@ -14,6 +14,6 @@ function onEventStarted(player, actor, triggerName, name, arg1, arg2, arg3, acto GetWorldManager():CreateInvitePartyGroup(player, actorId); end - player:EndCommand(); + player:EndEvent(); end \ No newline at end of file diff --git a/data/scripts/commands/TeleportCommand.lua b/data/scripts/commands/TeleportCommand.lua index 0a558cfb..eb08a965 100644 --- a/data/scripts/commands/TeleportCommand.lua +++ b/data/scripts/commands/TeleportCommand.lua @@ -8,22 +8,42 @@ eventRegion(numAnima) eventAetheryte(region, animaCost1, animaCost2, animaCost3, animaCost4, animaCost5, animaCost6) eventConfirm(isReturn, isInBattle, cityReturnNum, 138821, forceAskReturnOnly) -Menu Ids: - -Region Menu: 0 -Aetheryte Menu: 1 -Confirm Menu: 2 - --]] +require ("global") + +function doTeleport(region, aetheryte) +end + function onEventStarted(player, actor, triggerName, isTeleport) - if (isTeleport == 0) then - player:SetCurrentMenuId(0); - player:RunEventFunction("delegateCommand", actor, "eventRegion", 100); + if (isTeleport == 0) then + while (true) do + regionChoice = callClientFunction(player, "delegateCommand", actor, "eventRegion", 100); + + if (regionChoice == nil) then break end + + while (true) do + aetheryteChoice = callClientFunction(player, "delegateCommand", actor, "eventAetheryte", regionChoice, 2, 2, 2, 4, 4, 4); + + if (aetheryteChoice == nil) then break end + + confirmChoice = callClientFunction(player, "delegateCommand", actor, "eventConfirm", false, false, 1, 138824, false); + + if (confirmChoice == 1) then + doTeleport(regionChoice, aetheryteChoice); + end + + player:endEvent(); + return; + + end + + end else - player:SetCurrentMenuId(2); - player:RunEventFunction("delegateCommand", actor, "eventConfirm", true, false, 1, 0x138824, false); - end + callClientFunction(player, "delegateCommand", actor, "eventConfirm", true, false, 1, 0x138824, false); + end + + player:endEvent(); end function onEventUpdate(player, actor, step, arg1) @@ -48,4 +68,4 @@ function onEventUpdate(player, actor, step, arg1) player:EndCommand(); end -end \ No newline at end of file +end diff --git a/data/scripts/global.lua b/data/scripts/global.lua index 5b7d0984..b51a6403 100644 --- a/data/scripts/global.lua +++ b/data/scripts/global.lua @@ -12,4 +12,12 @@ ACTORSTATE_ACTIVE = 2; ACTORSTATE_DEAD2 = 3; ACTORSTATE_SITTING_ONOBJ = 11; ACTORSTATE_SITTING_ONFLOOR = 13; -ACTORSTATE_MOUNTED = 15; \ No newline at end of file +ACTORSTATE_MOUNTED = 15; + +--UTILS + +function callClientFunction(player, functionName, ...) + player:RunEventFunction(functionName, ...); + result = coroutine.yield(); + return result; +end \ No newline at end of file diff --git a/data/scripts/unique/fst0Town01/PopulaceStandard/vkorolon.lua b/data/scripts/unique/fst0Town01/PopulaceStandard/vkorolon.lua index 22cc60c7..e71825bd 100644 --- a/data/scripts/unique/fst0Town01/PopulaceStandard/vkorolon.lua +++ b/data/scripts/unique/fst0Town01/PopulaceStandard/vkorolon.lua @@ -1,13 +1,13 @@ +require ("global") + function onEventStarted(player, npc) defaultFst = GetStaticActor("DftFst"); - player:RunEventFunction("delegateEvent", player, defaultFst, "defaultTalkWithInn_Desk", nil, nil, nil); + choice = callClientFunction(player, "delegateEvent", player, defaultFst, "defaultTalkWithInn_Desk", nil, nil, nil); -end - -function onEventUpdate(player, npc, blah, menuSelect) - - if (menuSelect == 1) then + if (choice == 1) then GetWorldManager():DoZoneChange(player, 13); + elseif (choice == 2) then + --Do Set Homepoint end player:EndEvent(); diff --git a/data/scripts/unique/sea0Town01/PopulaceStandard/mytesyn.lua b/data/scripts/unique/sea0Town01/PopulaceStandard/mytesyn.lua index 2d15ca2b..5c468992 100644 --- a/data/scripts/unique/sea0Town01/PopulaceStandard/mytesyn.lua +++ b/data/scripts/unique/sea0Town01/PopulaceStandard/mytesyn.lua @@ -1,15 +1,14 @@ +require ("global") + function onEventStarted(player, npc) defaultSea = GetStaticActor("DftSea"); - player:RunEventFunction("delegateEvent", player, defaultSea, "defaultTalkWithInn_Desk", nil, nil, nil); + choice = callClientFunction(player, "delegateEvent", player, defaultSea, "defaultTalkWithInn_Desk", nil, nil, nil); -end - -function onEventUpdate(player, npc, blah, menuSelect) - - if (menuSelect == 1) then - GetWorldManager():DoZoneChange(player, 12); + if (choice == 1) then + GetWorldManager():DoZoneChange(player, 13); + elseif (choice == 2) then + --Do Set Homepoint end - player:EndEvent(); - + player:EndEvent(); end \ No newline at end of file diff --git a/data/scripts/unique/wil0Town01/PopulaceStandard/momodi.lua b/data/scripts/unique/wil0Town01/PopulaceStandard/momodi.lua index 5033af94..8183e89f 100644 --- a/data/scripts/unique/wil0Town01/PopulaceStandard/momodi.lua +++ b/data/scripts/unique/wil0Town01/PopulaceStandard/momodi.lua @@ -1,10 +1,16 @@ +require("global") + function onEventStarted(player, npc) defaultWil = GetStaticActor("DftWil"); - player:RunEventFunction("delegateEvent", player, defaultWil, "defaultTalkWithMomodi_001", nil, nil, nil); + tutorialU1 = GetStaticActor("Trl0u1"); + --callClientFunction(player, "delegateEvent", player, defaultWil, "defaultTalkWithMomodi_001", nil, nil, nil); + callClientFunction(player, "switchEvent", defaultWil, tutorialU1, nil, nil, 1, 1, 0x3F1); + player:endEvent(); + end function onEventUpdate(player, npc, blah, menuSelect) - player:EndEvent(); + end \ No newline at end of file