Skip to content

Commit

Permalink
add: Carpenters' Landing barge
Browse files Browse the repository at this point in the history
  • Loading branch information
ampitere committed May 18, 2024
1 parent 5b9fca5 commit 6379c9e
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 1 deletion.
177 changes: 177 additions & 0 deletions scripts/globals/barge.lua
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions scripts/zones/Carpenters_Landing/IDs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 <item>.
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...
Expand Down
30 changes: 29 additions & 1 deletion scripts/zones/Carpenters_Landing/Zone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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
Expand All @@ -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
9 changes: 9 additions & 0 deletions scripts/zones/Phanauet_Channel/Zone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
5 changes: 5 additions & 0 deletions sql/transport.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 6379c9e

Please sign in to comment.