Cleaned up the new scripting code. Added a helper function to do the yielding automatically. Modified all the scripts to use the new system and added a few new ones.

This commit is contained in:
Filip Maj 2016-06-19 18:52:34 -04:00
parent 51bbf4ae2e
commit 8743042950
28 changed files with 316 additions and 167 deletions

View File

@ -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;
}
if (ownerActor == null)
{

View File

@ -1131,8 +1131,20 @@ namespace FFXIVClassic_Map_Server.Actors
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
{
currentEventRunning = LuaEngine.DoActorOnEventStarted(this, owner, start);

View File

@ -1,11 +1,10 @@
require ("global")
function init(npc)
return false, false, 0, 0;
end
function onEventStarted(player, npc, triggerName)
player:RunEventFunction("bookTalk");
end
function onEventUpdate(player, npc, step, menuOptionSelected)
player:callClientFunction(player, "bookTalk");
player:EndEvent();
end

View File

@ -1,22 +1,18 @@
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

View File

@ -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
choice = callClientFunction(player, "delegateEvent", player, defaultFst, "defaultTalkWithInn_ExitDoor", nil, nil, nil);
function onEventUpdate(player, npc, resultId, isExitYes)
if (isExitYes ~= nil and isExitYes == 1) then
if (choice == 1) then
GetWorldManager():DoZoneChange(player, 1);
else
player:EndEvent();
end
player:EndEvent();
end

View File

@ -1,9 +1,3 @@
function init(npc)
return false, false, 0, 0;
end
function onEventStarted(player, npc, triggerName)
end
function onEventUpdate(player, npc)
end

View File

@ -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

View File

@ -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);
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 createLinkshell(name, crest)
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

View File

@ -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

View File

@ -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
@ -61,16 +61,3 @@ 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

View File

@ -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;

View File

@ -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

View File

@ -16,7 +16,7 @@ function onEventStarted(player, actor, triggerName)
player:SendGameMessage(worldMaster, 32503, 0x20);
end
player:EndCommand();
player:EndEvent();
end

View File

@ -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
player:EndCommand();
result = callClientFunction(player, "delegateCommand", actor, "operateUI", 100, 100, 10, 10, 10, 10, 10, 10);
--Do Save
if (result == true) then
end
player:endEvent();
end

View File

@ -14,6 +14,6 @@ function onEventStarted(player, commandactor, triggerName, arg1, arg2, arg3, arg
player:examinePlayer(actor);
end
player:EndCommand();
player:EndEvent();
end

View File

@ -42,6 +42,6 @@ function onEventStarted(player, actor, triggerName, isGoobbue)
player:ChangeState(0);
end
player:EndCommand();
player:EndEvent();
end

View File

@ -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

View File

@ -16,7 +16,7 @@ function onEventStarted(player, actor, triggerName, emoteId)
player:ChangeState(0);
end
player:EndCommand();
player:EndEvent();
end

View File

@ -15,7 +15,7 @@ function onEventStarted(player, actor, triggerName, emoteId)
player:DoEmote(emoteId);
end
player:EndCommand();
player:EndEvent();
end

View File

@ -69,7 +69,7 @@ function onEventStarted(player, actor, triggerName, invActionInfo, param1, param
end
end
player:EndCommand();
player:EndEvent();
end
function loadGearset(player, classId)

View File

@ -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

View File

@ -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
if (choice == 1) then
player:QuitGame();
player:EndCommand();
elseif (arg1 == 2) then --Character Screen
elseif (choice == 2) then
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
end
player:EndEvent();
end

View File

@ -14,6 +14,6 @@ function onEventStarted(player, actor, triggerName, name, arg1, arg2, arg3, acto
GetWorldManager():CreateInvitePartyGroup(player, actorId);
end
player:EndCommand();
player:EndEvent();
end

View File

@ -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);
else
player:SetCurrentMenuId(2);
player:RunEventFunction("delegateCommand", actor, "eventConfirm", true, false, 1, 0x138824, false);
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
callClientFunction(player, "delegateCommand", actor, "eventConfirm", true, false, 1, 0x138824, false);
end
player:endEvent();
end
function onEventUpdate(player, actor, step, arg1)

View File

@ -13,3 +13,11 @@ ACTORSTATE_DEAD2 = 3;
ACTORSTATE_SITTING_ONOBJ = 11;
ACTORSTATE_SITTING_ONFLOOR = 13;
ACTORSTATE_MOUNTED = 15;
--UTILS
function callClientFunction(player, functionName, ...)
player:RunEventFunction(functionName, ...);
result = coroutine.yield();
return result;
end

View File

@ -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();

View File

@ -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();
end

View File

@ -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