Skip to content

Commit dbea5f5

Browse files
authored
Merge pull request LandSandBoat#8467 from Xaver-DaRed/clup
[Chore] Selbina and Mhaura zone script cleanup
2 parents b04070a + b28f535 commit dbea5f5

2 files changed

Lines changed: 40 additions & 40 deletions

File tree

scripts/zones/Mhaura/Zone.lua

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ local ID = zones[xi.zone.MHAURA]
66
---@type TZone
77
local zoneObject = {}
88

9-
local piratesChance = 10 -- 10% chance to zone from mhaura/selbina into pirates encounter
10-
119
zoneObject.onGameHour = function(zone)
1210
local laughingBison = GetNPCByID(ID.npc.LAUGHING_BISON)
1311
if laughingBison then
1412
-- Script for Laughing Bison sign flip animations
15-
local timer = 1152 - ((GetSystemTime() - 1009810802)%1152)
13+
local timer = 1152 - (GetSystemTime() - 1009810802) % 1152
1614

1715
-- Next ferry is Al Zhabi for higher values.
1816
if timer >= 576 then
@@ -22,7 +20,8 @@ zoneObject.onGameHour = function(zone)
2220
end
2321
end
2422

25-
zone:setLocalVar('piratesVoyageRng', math.random(1, 100))
23+
local destinationId = math.random(1, 100) <= 10 and xi.zone.SHIP_BOUND_FOR_SELBINA_PIRATES or xi.zone.SHIP_BOUND_FOR_SELBINA
24+
zone:setLocalVar('[Pirate]Zone', destinationId)
2625
end
2726

2827
zoneObject.onInitialize = function(zone)
@@ -58,6 +57,10 @@ zoneObject.onConquestUpdate = function(zone, updatetype, influence, owner, ranki
5857
end
5958

6059
zoneObject.onTransportEvent = function(player, prevZoneId, transportId)
60+
if player:isInEvent() then
61+
return
62+
end
63+
6164
if
6265
prevZoneId == xi.zone.OPEN_SEA_ROUTE_TO_AL_ZAHBI or
6366
prevZoneId == xi.zone.OPEN_SEA_ROUTE_TO_MHAURA
@@ -69,19 +72,14 @@ zoneObject.onTransportEvent = function(player, prevZoneId, transportId)
6972
then
7073
player:startEvent(200)
7174
else
72-
-- TODO find rejection event, as this method doesn't cleanly boot from the boat and if you were inside the ship, the game client keeps it rendered
73-
player:setPos(8.200, -1.363, 3.445, 192)
75+
player:startEvent(204)
7476
player:messageSpecial(ID.text.DO_NOT_POSSESS, xi.ki.BOARDING_PERMIT)
7577
end
7678
else
77-
-- TODO don't double fire transport events (a ship "arrives" from normal and pirates zones at the same time and triggers a transport event)
78-
if not player:isInEvent() then
79-
if player:hasKeyItem(xi.ki.FERRY_TICKET) then
80-
player:startEvent(200)
81-
else
82-
-- TODO find rejection event, as this method doesn't cleanly boot from the boat and if you were inside the ship, the game client keeps it rendered
83-
player:setPos(8.200, -1.363, 3.445, 192)
84-
end
79+
if player:hasKeyItem(xi.ki.FERRY_TICKET) then
80+
player:startEvent(200)
81+
else
82+
player:startEvent(204)
8583
end
8684
end
8785
end
@@ -91,19 +89,21 @@ end
9189

9290
zoneObject.onEventFinish = function(player, csid, option, npc)
9391
if csid == 200 then
94-
local DepartureTime = VanadielHour()
95-
96-
if DepartureTime % 8 == 0 then
97-
local currZone = player:getZone()
98-
if currZone and currZone:getLocalVar('piratesVoyageRng') <= piratesChance then
99-
player:setPos(0, 0, 0, 0, xi.zone.SHIP_BOUND_FOR_SELBINA_PIRATES)
100-
else
101-
player:setPos(0, 0, 0, 0, xi.zone.SHIP_BOUND_FOR_SELBINA)
102-
end
103-
elseif DepartureTime % 8 == 4 then
92+
local departureTime = VanadielHour() % 8
93+
local zone = player:getZone()
94+
local destinationId = zone and zone:getLocalVar('[Pirate]Zone') or xi.zone.SHIP_BOUND_FOR_SELBINA
95+
96+
-- To Selbina.
97+
if departureTime == 0 then
98+
player:setPos(0, 0, 0, 0, destinationId)
99+
100+
-- To Al Zahbi
101+
elseif departureTime == 4 then
104102
player:setPos(0, 0, 0, 0, xi.zone.OPEN_SEA_ROUTE_TO_AL_ZAHBI)
103+
104+
-- Something went wrong, dump them on the dock for safety.
105105
else
106-
player:setPos(8, -1, 5, 62, 249) -- Something went wrong, dump them on the dock for safety.
106+
player:setPos(8, -1, 5, 62, xi.zone.MHAURA)
107107
end
108108
end
109109
end

scripts/zones/Selbina/Zone.lua

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ local ID = zones[xi.zone.SELBINA]
66
---@type TZone
77
local zoneObject = {}
88

9-
local piratesChance = 10 -- 10% chance to zone from mhaura/selbina into pirates encounter
10-
119
zoneObject.onInitialize = function(zone)
1210
xi.server.setExplorerMoogles(ID.npc.EXPLORER_MOOGLE)
1311
InitializeFishingContestSystem()
1412
end
1513

1614
zoneObject.onGameHour = function(zone)
17-
zone:setLocalVar('piratesVoyageRng', math.random(1, 100))
15+
local destinationId = math.random(1, 100) <= 10 and xi.zone.SHIP_BOUND_FOR_MHAURA_PIRATES or xi.zone.SHIP_BOUND_FOR_MHAURA
16+
zone:setLocalVar('[Pirate]Zone', destinationId)
1817
end
1918

2019
zoneObject.onZoneTick = function(zone)
@@ -60,26 +59,27 @@ end
6059
zoneObject.onTransportEvent = function(player, prevZoneId, transportId)
6160
-- TODO don't double fire transport events (a ship "arrives" from normal and pirates zones at the same time and triggers a transport event)
6261
if not player:isInEvent() then
63-
if player:hasKeyItem(xi.ki.FERRY_TICKET) then
64-
player:startEvent(200)
65-
else
66-
-- TODO find rejection event, as this method doesn't cleanly boot from the boat and if you were inside the ship, the game client keeps it rendered
67-
player:setPos(32.500, -2.500, -45.500, 192)
68-
end
62+
return
63+
end
64+
65+
if player:hasKeyItem(xi.ki.FERRY_TICKET) then
66+
player:startEvent(200)
67+
else
68+
player:startEvent(204)
6969
end
7070
end
7171

7272
zoneObject.onEventUpdate = function(player, csid, option, npc)
7373
end
7474

7575
zoneObject.onEventFinish = function(player, csid, option, npc)
76+
-- Transport event.
7677
if csid == 200 then
77-
local currZone = player:getZone()
78-
if currZone and currZone:getLocalVar('piratesVoyageRng') <= piratesChance then
79-
player:setPos(0, 0, 0, 0, xi.zone.SHIP_BOUND_FOR_MHAURA_PIRATES)
80-
else
81-
player:setPos(0, 0, 0, 0, xi.zone.SHIP_BOUND_FOR_MHAURA)
82-
end
78+
local zone = player:getZone()
79+
local destinationId = zone and zone:getLocalVar('[Pirate]Zone') or xi.zone.SHIP_BOUND_FOR_MHAURA
80+
player:setPos(0, 0, 0, 0, destinationId)
81+
82+
-- Quest logic. TODO: Convert quest to interaction.
8383
elseif
8484
csid == 1101 and
8585
npcUtil.completeQuest(player, xi.questLog.OUTLANDS, xi.quest.id.outlands.I_LL_TAKE_THE_BIG_BOX, { item = 14226, fameArea = xi.fameArea.NORG, var = { 'Enagakure_Killed', 'illTakeTheBigBoxCS' } })

0 commit comments

Comments
 (0)