Skip to content

Commit 4655357

Browse files
authored
fix: ebb and flow boat summons teleport (#3125)
This fixes the ebb and flow boat teleport that was not teleporting player summons Fixes #2943
1 parent 93448b8 commit 4655357

File tree

2 files changed

+43
-27
lines changed

2 files changed

+43
-27
lines changed

data-otservbr-global/lib/quests/soul_war.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ function Player:getSoulWarZoneMonster()
14551455
return zoneMonsterName
14561456
end
14571457

1458-
function Player:isInBoatSpot()
1458+
function Creature:isInBoatSpot()
14591459
-- Get ebb and flow zone and check if player is in zone
14601460
local zone = SoulWarQuest.ebbAndFlow.getZone()
14611461
local tile = Tile(self:getPosition())
@@ -1464,11 +1464,11 @@ function Player:isInBoatSpot()
14641464
groundId = tile:getGround():getId()
14651465
end
14661466
if zone and zone:isInZone(self:getPosition()) and tile and groundId == SoulWarQuest.ebbAndFlow.boatId then
1467-
logger.trace("Player {} is in boat spot", self:getName())
1467+
logger.trace("Creature {} is in boat spot", self:getName())
14681468
return true
14691469
end
14701470

1471-
logger.trace("Player {} is not in boat spot", self:getName())
1471+
logger.trace("Creature {} is not in boat spot", self:getName())
14721472
return false
14731473
end
14741474

data-otservbr-global/scripts/quests/soul_war/globalevent-ebb_and_flow_change_maps.lua

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,25 @@ local function updateWaterPoolsSize()
1818
end
1919

2020
local function loadMapEmpty()
21-
if SoulWarQuest.ebbAndFlow.getZone():countPlayers() > 0 then
22-
local players = SoulWarQuest.ebbAndFlow.getZone():getPlayers()
23-
for _, player in ipairs(players) do
24-
if player:getPosition().z == 8 then
25-
if player:isInBoatSpot() then
26-
local teleportPosition = player:getPosition()
27-
teleportPosition.z = 9
28-
player:teleportTo(teleportPosition)
29-
logger.trace("Teleporting player to down.")
21+
local playersInZone = SoulWarQuest.ebbAndFlow.getZone():countPlayers()
22+
local monstersInZone = SoulWarQuest.ebbAndFlow.getZone():countMonsters()
23+
if playersInZone > 0 or monstersInZone > 0 then
24+
local creatures = SoulWarQuest.ebbAndFlow.getZone():getCreatures()
25+
for _, creature in ipairs(creatures) do
26+
local creatureMaster = creature:getMaster()
27+
local player = creature:getPlayer()
28+
if creature:isPlayer() or (creature:isMonster() and creatureMaster and creatureMaster:getPlayer()) then
29+
if creature:getPosition().z == 8 then
30+
if creature:isInBoatSpot() then
31+
local teleportPosition = creature:getPosition()
32+
teleportPosition.z = 9
33+
creature:teleportTo(teleportPosition)
34+
logger.trace("Teleporting player to down.")
35+
end
36+
if player then
37+
player:sendCreatureAppear()
38+
end
3039
end
31-
player:sendCreatureAppear()
3240
end
3341
end
3442
end
@@ -72,22 +80,30 @@ local function findNearestRoomPosition(playerPosition)
7280
end
7381

7482
local function loadMapInundate()
75-
if SoulWarQuest.ebbAndFlow.getZone():countPlayers() > 0 then
76-
local players = SoulWarQuest.ebbAndFlow.getZone():getPlayers()
77-
for _, player in ipairs(players) do
78-
local playerPosition = player:getPosition()
79-
if playerPosition.z == 9 then
80-
if player:isInBoatSpot() then
81-
local nearestCenterPosition = findNearestRoomPosition(playerPosition)
82-
player:teleportTo(nearestCenterPosition)
83-
logger.trace("Teleporting player to the near center position room and updating tile.")
84-
else
85-
player:teleportTo(SoulWarQuest.ebbAndFlow.waitPosition)
86-
logger.trace("Teleporting player to wait position and updating tile.")
83+
local playersInZone = SoulWarQuest.ebbAndFlow.getZone():countPlayers()
84+
local monstersInZone = SoulWarQuest.ebbAndFlow.getZone():countMonsters()
85+
if playersInZone > 0 or monstersInZone > 0 then
86+
local creatures = SoulWarQuest.ebbAndFlow.getZone():getCreatures()
87+
for _, creature in ipairs(creatures) do
88+
local creatureMaster = creature:getMaster()
89+
local player = creature:getPlayer()
90+
if creature:isPlayer() or (creature:isMonster() and creatureMaster and creatureMaster:getPlayer()) then
91+
local creaturePosition = creature:getPosition()
92+
if creaturePosition.z == 9 then
93+
if creature:isInBoatSpot() then
94+
local nearestCenterPosition = findNearestRoomPosition(creaturePosition)
95+
creature:teleportTo(nearestCenterPosition)
96+
logger.trace("Teleporting player to the near center position room and updating tile.")
97+
else
98+
creature:teleportTo(SoulWarQuest.ebbAndFlow.waitPosition)
99+
logger.trace("Teleporting player to wait position and updating tile.")
100+
end
101+
creaturePosition:sendMagicEffect(CONST_ME_TELEPORT)
102+
end
103+
if player then
104+
player:sendCreatureAppear()
87105
end
88-
playerPosition:sendMagicEffect(CONST_ME_TELEPORT)
89106
end
90-
player:sendCreatureAppear()
91107
end
92108
end
93109

0 commit comments

Comments
 (0)