From b627ecf0feebb5e4f4bb3a4df71130dd59f84faf Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Thu, 25 Jul 2019 19:46:05 -0400 Subject: [PATCH] Finished filling out lua script for rentals/summons/new chocos. --- .../npc/populace/PopulaceChocoboLender.lua | 77 ++++++------ .../npc/populace/PopulaceChocoboLender.lua | 114 ------------------ 2 files changed, 40 insertions(+), 151 deletions(-) delete mode 100644 data/scripts/base/chara/npc/populace/PopulaceChocoboLender.lua diff --git a/Data/scripts/base/chara/npc/populace/PopulaceChocoboLender.lua b/Data/scripts/base/chara/npc/populace/PopulaceChocoboLender.lua index abb7b223..b1a19107 100644 --- a/Data/scripts/base/chara/npc/populace/PopulaceChocoboLender.lua +++ b/Data/scripts/base/chara/npc/populace/PopulaceChocoboLender.lua @@ -11,10 +11,20 @@ eventSetChocoboName(true) - Opens the set name dialog eventAfterChocoboName(player) - Called if player done naming chocobo, shows cutscene, returns state and waits to teleport outside city. eventCancelChocoboName(player) - Called if player cancels naming chocobo, returns state. eventTalkStepBreak(player) - Finishes talkTurn and says a goodbye + +Notes: + +* Rent price and time seems to be hardcoded into the client. Price is always 800gil and time is 10m. +* The func eventSetChocoboName *requires* the actor with id `1080101` to be present in the client instance or it will crash (thanks Jorge for finding that). +* Special spawn codes must be sent for getting your chocobo or renting for it to work properly. + --]] require ("global") +local rentalPrice = 800; +local rentalTime = 10; + local gcIssuances = { [1500006] = 2001004, [1500061] = 2001005, @@ -28,39 +38,32 @@ local startAppearances = { }; local cityExits = { - [1500006] = 15, - [1500061] = 14, - [1000840] = 16 + [1500006] = {133, -6.032, 46.356, 132.572, 3.034}, + [1500061] = {150, 333.271, 5.889, -943.275, 0.794}, + [1000840] = {170, -26.088, 181.846, -79.438, 2.579} }; function init(npc) return false, false, 0, 0; end -function onEventStarted(player, npc, triggerName) - - --callClientFunction(player, "eventTalkWelcome", player); - --callClientFunction(player, "eventAskMainMenu", player, 20, true, true, true, true, 4); - --callClientFunction(player, "eventTalkMyChocobo", player); - --callClientFunction(player, "eventSetChocoboName", false); - --callClientFunction(player, "eventAfterChocoboName", player); - +function onEventStarted(player, npc, triggerName) local curLevel = 20; -- TODO: pull from character local hasIssuance = player:GetItemPackage(INVENTORY_KEYITEMS):HasItem(gcIssuances[npc:GetActorClassId()]); local hasChocobo = player.hasChocobo; - if (player.isGM and hasChocobo == false) then -- Let GMs auto have the issuance for debugging + if (hasChocobo == false) then -- Let GMs auto have the issuance for debugging hasIssuance = true; end - local rentPrice = 800; - local hasFunds = (player:GetCurrentGil() >= rentPrice); + local hasFunds = (player:GetCurrentGil() >= rentalPrice); callClientFunction(player, "eventTalkWelcome", player); - local menuChoice = callClientFunction(player, "eventAskMainMenu", player, curLevel, hasFunds, hasIssuance, true, true, player.chocoboAppearance); + local menuChoice = callClientFunction(player, "eventAskMainMenu", player, curLevel, hasFunds, hasIssuance, hasChocobo, hasChocobo, 0); if (menuChoice == 1) then -- Issuance option + callClientFunction(player, "eventTalkMyChocobo", player); local nameResponse = callClientFunction(player, "eventSetChocoboName", true); @@ -70,31 +73,28 @@ function onEventStarted(player, npc, triggerName) player:EndEvent(); return; else - local appearance = startAppearances[npc:GetActorClassId()]; - player:IssueChocobo(appearance, nameResponse); - callClientFunction(player, "eventAfterChocoboName", player); - mountChocobo(player); - GetWorldManager():DoZoneChange(player, cityExits[npc:GetActorClassId()]); - player:SendGameMessage(player, GetWorldMaster(), 25248, 0x20, 2001007); - player:SendDataPacket("attention", GetWorldMaster(), "", 25248, 2001007); - + player:IssueChocobo(appearance, startAppearances[npc:GetActorClassId()]); + callClientFunction(player, "eventAfterChocoboName", player); + + --Add Chocobo License and remove issuance if (player:GetItemPackage(INVENTORY_KEYITEMS):HasItem(2001007) == false) then player:GetItemPackage(INVENTORY_KEYITEMS):AddItem(2001007); end - player:GetItemPackage(INVENTORY_KEYITEMS):RemoveItem(gcIssuances[npc:GetActorClassId()], 1); - player:EndEvent(); - return; + --Warp with the special chocobo warp mode. + mountChocobo(player); + GetWorldManager():DoZoneChange(player, cityExits[npc:GetActorClassId()][1], nil, 0, SPAWN_CHOCOBO_GET, cityExits[npc:GetActorClassId()][2], cityExits[npc:GetActorClassId()][3], cityExits[npc:GetActorClassId()][4], cityExits[npc:GetActorClassId()][5]); end elseif(menuChoice == 2) then -- Summon Bird mountChocobo(player); - GetWorldManager():DoZoneChange(player, cityExits[npc:GetActorClassId()]); + GetWorldManager():DoZoneChange(player, cityExits[npc:GetActorClassId()][1], nil, 0, SPAWN_NO_ANIM, cityExits[npc:GetActorClassId()][2], cityExits[npc:GetActorClassId()][3], cityExits[npc:GetActorClassId()][4], cityExits[npc:GetActorClassId()][5]); elseif(menuChoice == 3) then -- Change Barding callClientFunction(player, "eventTalkStepBreak", player); elseif(menuChoice == 5) then -- Rent Bird - issueRentalChocobo(player); + mountChocobo(player, true, 1); + GetWorldManager():DoZoneChange(player, cityExits[npc:GetActorClassId()][1], nil, 0, SPAWN_CHOCOBO_RENTAL, cityExits[npc:GetActorClassId()][2], cityExits[npc:GetActorClassId()][3], cityExits[npc:GetActorClassId()][4], cityExits[npc:GetActorClassId()][5]); else callClientFunction(player, "eventTalkStepBreak", player); end @@ -102,13 +102,16 @@ function onEventStarted(player, npc, triggerName) player:EndEvent(); end -function mountChocobo(player) - player:SendChocoboAppearance(); +function mountChocobo(player, isRental, rentalMinutes) + if (isRental) then + player:ChangeMusic(64); + player:StartChocoboRental(rentalMinutes); + else + player:ChangeMusic(83); + end + + player:SendMountAppearance(); player:SetMountState(1); - player:ChangeSpeed(0.0, 5.0, 10.0); - player:ChangeState(15); -end - -function issueRentalChocobo(player) - --TODO: Write issue rental chocobo code -end + player:ChangeSpeed(0.0, 5.0, 10.0, 10.0); + player:ChangeState(15); +end \ No newline at end of file diff --git a/data/scripts/base/chara/npc/populace/PopulaceChocoboLender.lua b/data/scripts/base/chara/npc/populace/PopulaceChocoboLender.lua deleted file mode 100644 index abb7b223..00000000 --- a/data/scripts/base/chara/npc/populace/PopulaceChocoboLender.lua +++ /dev/null @@ -1,114 +0,0 @@ ---[[ - -PopulaceChocoboLender Script - -Functions: - -eventTalkWelcome(player) - Start Text -eventAskMainMenu(player, curLevel, hasFundsForRent, isPresentChocoboIssuance, isSummonMyChocobo, isChangeBarding, currentChocoboWare) - Shows the main menu -eventTalkMyChocobo(player) - Starts the cutscene for getting a chocobo -eventSetChocoboName(true) - Opens the set name dialog -eventAfterChocoboName(player) - Called if player done naming chocobo, shows cutscene, returns state and waits to teleport outside city. -eventCancelChocoboName(player) - Called if player cancels naming chocobo, returns state. -eventTalkStepBreak(player) - Finishes talkTurn and says a goodbye ---]] - -require ("global") - -local gcIssuances = { - [1500006] = 2001004, - [1500061] = 2001005, - [1000840] = 2001006 -}; - -local startAppearances = { - [1500006] = CHOCOBO_LIMSA1, - [1500061] = CHOCOBO_GRIDANIA1, - [1000840] = CHOCOBO_ULDAH1 -}; - -local cityExits = { - [1500006] = 15, - [1500061] = 14, - [1000840] = 16 -}; - -function init(npc) - return false, false, 0, 0; -end - -function onEventStarted(player, npc, triggerName) - - --callClientFunction(player, "eventTalkWelcome", player); - --callClientFunction(player, "eventAskMainMenu", player, 20, true, true, true, true, 4); - --callClientFunction(player, "eventTalkMyChocobo", player); - --callClientFunction(player, "eventSetChocoboName", false); - --callClientFunction(player, "eventAfterChocoboName", player); - - local curLevel = 20; -- TODO: pull from character - local hasIssuance = player:GetItemPackage(INVENTORY_KEYITEMS):HasItem(gcIssuances[npc:GetActorClassId()]); - local hasChocobo = player.hasChocobo; - - if (player.isGM and hasChocobo == false) then -- Let GMs auto have the issuance for debugging - hasIssuance = true; - end - - local rentPrice = 800; - local hasFunds = (player:GetCurrentGil() >= rentPrice); - - callClientFunction(player, "eventTalkWelcome", player); - - local menuChoice = callClientFunction(player, "eventAskMainMenu", player, curLevel, hasFunds, hasIssuance, true, true, player.chocoboAppearance); - - if (menuChoice == 1) then -- Issuance option - callClientFunction(player, "eventTalkMyChocobo", player); - local nameResponse = callClientFunction(player, "eventSetChocoboName", true); - - if (nameResponse == "") then -- Cancel Chocobo naming - callClientFunction(player, "eventCancelChocoboName", player); - callClientFunction(player, "eventTalkStepBreak", player); - player:EndEvent(); - return; - else - local appearance = startAppearances[npc:GetActorClassId()]; - player:IssueChocobo(appearance, nameResponse); - callClientFunction(player, "eventAfterChocoboName", player); - mountChocobo(player); - GetWorldManager():DoZoneChange(player, cityExits[npc:GetActorClassId()]); - player:SendGameMessage(player, GetWorldMaster(), 25248, 0x20, 2001007); - player:SendDataPacket("attention", GetWorldMaster(), "", 25248, 2001007); - - if (player:GetItemPackage(INVENTORY_KEYITEMS):HasItem(2001007) == false) then - player:GetItemPackage(INVENTORY_KEYITEMS):AddItem(2001007); - end - - player:GetItemPackage(INVENTORY_KEYITEMS):RemoveItem(gcIssuances[npc:GetActorClassId()], 1); - - player:EndEvent(); - return; - end - - elseif(menuChoice == 2) then -- Summon Bird - mountChocobo(player); - GetWorldManager():DoZoneChange(player, cityExits[npc:GetActorClassId()]); - elseif(menuChoice == 3) then -- Change Barding - callClientFunction(player, "eventTalkStepBreak", player); - elseif(menuChoice == 5) then -- Rent Bird - issueRentalChocobo(player); - else - callClientFunction(player, "eventTalkStepBreak", player); - end - - player:EndEvent(); -end - -function mountChocobo(player) - player:SendChocoboAppearance(); - player:SetMountState(1); - player:ChangeSpeed(0.0, 5.0, 10.0); - player:ChangeState(15); -end - -function issueRentalChocobo(player) - --TODO: Write issue rental chocobo code -end