diff --git a/scripts/globals/barge.lua b/scripts/globals/barge.lua new file mode 100644 index 00000000000..39f723bdc61 --- /dev/null +++ b/scripts/globals/barge.lua @@ -0,0 +1,177 @@ +----------------------------------- +-- Carptenters' Landing Barge +-- https://www.bg-wiki.com/ffxi/Phanauet_Channel +----------------------------------- +xi = xi or {} +xi.barge = xi.barge or {} + +local actions = +{ + ARRIVE = 0, + DEPART = 1, +} + +-- Barge destinations +local destinations = +{ + NORTH_LANDING = 0, + CENTRAL_LANDING = 1, + SOUTH_LANDING = 2, +} + +-- Locations for timekeeper NPCs +xi.barge.location = +{ + NORTH_LANDING = 0, + CENTRAL_LANDING = 1, + SOUTH_LANDING = 2, + PHANAUET_CHANNEL = 3, +} + +local bargeSchedule = +{ + [xi.barge.location.NORTH_LANDING] = + { + { time = 960, action = actions.ARRIVE, route = destinations.CENTRAL_LANDING }, -- 16:00 + { time = 1045, action = actions.DEPART, route = destinations.CENTRAL_LANDING }, -- 17:25 + }, + [xi.barge.location.CENTRAL_LANDING] = + { + { time = 275, action = actions.ARRIVE, route = destinations.SOUTH_LANDING }, -- 04:35 + { time = 310, action = actions.DEPART, route = destinations.SOUTH_LANDING }, -- 05:10 + { time = 1155, action = actions.ARRIVE, route = destinations.SOUTH_LANDING }, -- 19:15 + { time = 1190, action = actions.DEPART, route = destinations.SOUTH_LANDING }, -- 19:50 + }, + [xi.barge.location.SOUTH_LANDING] = + { + { time = 50, action = actions.DEPART, route = destinations.CENTRAL_LANDING }, -- 00:50 + { time = 575, action = actions.ARRIVE, route = destinations.NORTH_LANDING }, -- 09:35 + { time = 660, action = actions.DPEART, route = destinations.NORTH_LANDING }, -- 10:10 + { time = 1415, action = actions.ARRIVE, route = destinations.CENTRAL_LANDING }, -- 23:35 + }, + [xi.barge.location.PHANAUET_CHANNEL] = + { + { time = 275, action = actions.ARRIVE, route = destinations.SOUTH_LANDING }, -- 04:35 + { time = 575, action = actions.ARRIVE, route = destinations.NORTH_LANDING }, -- 09:35 + { time = 960, action = actions.ARRIVE, route = destinations.CENTRAL_LANDING }, -- 16:00 + { time = 1155, action = actions.ARRIVE, route = destinations.SOUTH_LANDING }, -- 19:15 + { time = 1415, action = actions.ARRIVE, route = destinations.CENTRAL_LANDING }, -- 23:35 + }, +} + +xi.barge.timekeeperOnTrigger = function(player, location, eventId) + local schedule = bargeSchedule[location] + + if schedule then + local currentTime = VanadielHour() * 60 + VanadielMinute() + local nextEvent = nil + + for i = 1, #schedule do + if schedule[i].time > currentTime then + nextEvent = schedule[i] + break + end + end + + local gameMins = nextEvent.time - currentTime + local earthSecs = gameMins * 60 / 25 -- one earth second is 25 game seconds + + if location == xi.barge.location.PHANAUET_CHANNEL then + local earthMins = math.ceil(earthSecs / 60) + local gameHours = math.floor(gameMins / 60) + player:startEvent(eventId, earthMins, gameHours, nextEvent.route) + else + player:startEvent(eventId, earthSecs, nextEvent.action, 0, nextEvent.route) + end + else + printf('[warning] bad location %i in xi.barge.timekeeperOnTrigger', location) + end +end + +xi.barge.aboard = function(player, triggerArea, isAboard) + player:setCharVar('[barge]aboard', isAboard and triggerArea or 0) +end + +xi.barge.onZoneIn = function(player) + local zoneId = player:getZoneID() + + -- Zoning into Phanauet Channel. Set [barge]arrivalEventId based on schedule. + if zoneId == xi.zone.PHANAUET_CHANNEL then + local schedule = bargeSchedule[xi.barge.location.PHANAUET_CHANNEL] + local currentTime = VanadielHour() * 60 + VanadielMinute() + local nextEvent = nil + + for i = 1, #schedule do + if schedule[i].time > currentTime then + nextEvent = schedule[i] + break + end + end + + if nextEvent == nil then -- schedule is on the next day + nextEvent = schedule[1] + end + + if nextEvent.route == destinations.NORTH_LANDING then + player:setCharVar('[barge]arrivalEventId', 11) + elseif nextEvent.route == destinations.CENTRAL_LANDING then + player:setCharVar('[barge]arrivalEventId', 10) + elseif nextEvent.route == destinations.SOUTH_LANDING then + player:setCharVar('[barge]arrivalEventId', 38) + end + + -- Zoning into Carpteners' Landing. Play the eventId stored in [barge]arrivalEventId. + elseif zoneId == xi.zone.CARPENTERS_LANDING then + local eventId = player:getCharVar('[barge]arrivalEventId') + player:setCharVar('[barge]arrivalEventId', 0) + + if eventId > 0 then + return eventId + else + player:setPos(-136.983, -1.969, 60.653, 95, 2) + return -1 + end + end +end + +xi.barge.onTransportEvent = function(player, transport) + local ID = zones[player:getZoneID()] + local aboard = player:getCharVar('[barge]aboard') + local departEvent = -1 + local kickEvent = -1 + + -- South Landing + if aboard == 1 then + departEvent = 14 + kickEvent = 33 + -- Central Landing + elseif aboard == 2 then + departEvent = 40 + kickEvent = 42 + -- North Landing + elseif aboard == 3 then + departEvent = 16 + kickEvent = 34 + end + + if aboard > 0 then + if player:hasKeyItem(xi.ki.BARGE_TICKET) then + player:delKeyItem(xi.ki.BARGE_TICKET) + player:startEvent(departEvent) + elseif player:hasKeyItem(xi.ki.BARGE_MULTI_TICKET) then + local uses = player:getCharVar('Barge_Ticket') + + if uses == 1 then + player:messageSpecial(ID.text.BARGE_TICKET_USED, 0, xi.ki.BARGE_MULTI_TICKET) + player:delKeyItem(xi.ki.BARGE_MULTI_TICKET) + else + player:messageSpecial(ID.text.BARGE_TICKET_REMAINING, 0, xi.ki.BARGE_MULTI_TICKET, uses - 1) + end + + player:setCharVar('Barge_Ticket', uses - 1) + player:startEvent(departEvent) + else + player:startEvent(kickEvent) + end + end +end diff --git a/scripts/zones/Carpenters_Landing/IDs.lua b/scripts/zones/Carpenters_Landing/IDs.lua index c0a077fb88b..1323ab907d1 100644 --- a/scripts/zones/Carpenters_Landing/IDs.lua +++ b/scripts/zones/Carpenters_Landing/IDs.lua @@ -28,6 +28,8 @@ zones[xi.zone.CARPENTERS_LANDING] = FISHING_MESSAGE_OFFSET = 7285, -- You can't fish here. LOGGING_IS_POSSIBLE_HERE = 7402, -- Logging is possible here if you have . BEUGUNGEL_SHOP_DIALOG = 7434, -- Hello, [sir/ma'am]! I'm selling goods direct from the Carpenters' Guild. + BARGE_TICKET_REMAINING = 7453, -- You use your %. (# trip[/s] remaining) + BARGE_TICKET_USED = 7454, -- You use up your %. CRYPTONBERRY_EXECUTOR_DIE = 7486, -- ...Cleave our foesss with barren hate. CRYPTONBERRY_ASSASSIN_2HR = 7487, -- ..Take up thy lanternsss. The truth we shall illuminate. CRYPTONBERRY_EXECUTOR_2HR = 7488, -- Through this we ssseek our just reward... diff --git a/scripts/zones/Carpenters_Landing/Zone.lua b/scripts/zones/Carpenters_Landing/Zone.lua index a9b447e7231..f88f15a294c 100644 --- a/scripts/zones/Carpenters_Landing/Zone.lua +++ b/scripts/zones/Carpenters_Landing/Zone.lua @@ -11,6 +11,10 @@ zoneObject.onChocoboDig = function(player, precheck) end zoneObject.onInitialize = function(zone) + zone:registerTriggerArea(1, 233, -10, -546, 260, 10, -509) -- Barge while docked at South landing + zone:registerTriggerArea(2, -151, -10, 63, -100, 10, 80) -- Barge while docked at Central landing + zone:registerTriggerArea(3, -326, -10, 534, -264, 10, 521) -- Barge while docked at North landing + UpdateNMSpawnPoint(ID.mob.TEMPEST_TIGON) GetMobByID(ID.mob.TEMPEST_TIGON):setRespawnTime(math.random(900, 10800)) @@ -26,7 +30,11 @@ zoneObject.onZoneIn = function(player, prevZone) player:getYPos() == 0 and player:getZPos() == 0 then - player:setPos(6.509, -9.163, -819.333, 239) + if prevZone == xi.zone.PHANAUET_CHANNEL then + cs = xi.barge.onZoneIn(player) + else + player:setPos(6.509, -9.163, -819.333, 239) + end end return cs @@ -45,12 +53,32 @@ zoneObject.onGameHour = function(zone) end zoneObject.onTriggerAreaEnter = function(player, triggerArea) + print('triger') + xi.barge.aboard(player, triggerArea:GetTriggerAreaID(), true) +end + +zoneObject.onTriggerAreaLeave = function(player, triggerArea) + xi.barge.aboard(player, triggerArea:GetTriggerAreaID(), false) +end + +zoneObject.onTransportEvent = function(player, transport) + print('transportevent') + xi.barge.onTransportEvent(player, transport) end zoneObject.onEventUpdate = function(player, csid, option, npc) end zoneObject.onEventFinish = function(player, csid, option, npc) + if csid == 11 then -- North Landing arriving + player:startEvent(13) + elseif csid == 10 then -- Central Landing arriving + player:startEvent(39) + elseif csid == 38 then -- South Landing arriving + player:startEvent(12) + elseif csid == 14 or csid == 16 or csid == 40 then -- Barge departing + player:setPos(0, 0, 0, 0, xi.zone.PHANAUET_CHANNEL) + end end return zoneObject diff --git a/scripts/zones/Phanauet_Channel/Zone.lua b/scripts/zones/Phanauet_Channel/Zone.lua index e6802e84890..0bc0f24be0e 100644 --- a/scripts/zones/Phanauet_Channel/Zone.lua +++ b/scripts/zones/Phanauet_Channel/Zone.lua @@ -9,6 +9,8 @@ end zoneObject.onZoneIn = function(player, prevZone) local cs = -1 + xi.barge.onZoneIn(player) + if player:getXPos() == 0 and player:getYPos() == 0 and @@ -21,6 +23,10 @@ zoneObject.onZoneIn = function(player, prevZone) return cs end +zoneObject.onTransportEvent = function(player, transport) + player:startEvent(100) +end + zoneObject.onConquestUpdate = function(zone, updatetype, influence, owner, ranking, isConquestAlliance) xi.conq.onConquestUpdate(zone, updatetype, influence, owner, ranking, isConquestAlliance) end @@ -32,6 +38,9 @@ zoneObject.onEventUpdate = function(player, csid, option, npc) end zoneObject.onEventFinish = function(player, csid, option, npc) + if csid == 100 then + player:setPos(0, 0, 0, 0, xi.zone.CARPENTERS_LANDING) + end end return zoneObject diff --git a/sql/transport.sql b/sql/transport.sql index f654e0ccd38..3e0516645a3 100644 --- a/sql/transport.sql +++ b/sql/transport.sql @@ -54,3 +54,8 @@ INSERT INTO `transport` VALUES (16,'Manaclip_Bibiki-Purgonorgo',16793984,1679398 INSERT INTO `transport` VALUES (17,'Manaclip_Purgonorgo-Bibiki',16793984,16793986,-392.000,0.000,-364.000,128,0,20,21,500,720,20,40,20,3); INSERT INTO `transport` VALUES (18,'Selbina-Mhaura_Boat_Pirates',17793088,17793087,9.294,0.000,-69.775,0,485,18,19,382,480,18,80,17,227); INSERT INTO `transport` VALUES (19,'Mhaura-Selbina_Boat_Pirates',17797182,17797181,-0.516,0.026,-8.409,0,493,18,19,382,480,18,80,17,228); +INSERT INTO `transport` VALUES (20,'Carpenters_Landing-South-Arriving_Barge',16785748,16785756,246.38,0.0,-529.79,64,0,23,0,50,280,35,0,0,1); +INSERT INTO `transport` VALUES (21,'Carpenters_Landing-South-Departing_Barge',16785748,16785756,246.38,0.0,-529.79,192,0,18,19,90,280,15,80,15,1); +INSERT INTO `transport` VALUES (22,'Carpenters_Landing-Central_Barge',16785748,16785757,-125.04,0.000,72.79,160,0,20,21,50,280,15,0,0,1); +INSERT INTO `transport` VALUES (23,'Carpenters_Landing-North-Arriving_Barge',16785748,16785758,-291.675,0.000,-516.18,32,0,22,0,50,280,35,0,0,1); +INSERT INTO `transport` VALUES (24,'Carpenters_Landing-North-Departing_Barge',16785748,16785758,-291.675,0.000,-516.18,160,0,24,25,90,280,15,120,15,1);