@@ -6,13 +6,11 @@ local ID = zones[xi.zone.MHAURA]
66--- @type TZone
77local zoneObject = {}
88
9- local piratesChance = 10 -- 10% chance to zone from mhaura/selbina into pirates encounter
10-
119zoneObject .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 )
2625end
2726
2827zoneObject .onInitialize = function (zone )
@@ -58,6 +57,10 @@ zoneObject.onConquestUpdate = function(zone, updatetype, influence, owner, ranki
5857end
5958
6059zoneObject .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
8785end
9189
9290zoneObject .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
109109end
0 commit comments