Skip to content

Commit

Permalink
fix: ebb and flow boat summons teleport (#3125)
Browse files Browse the repository at this point in the history
This fixes the ebb and flow boat teleport that was not teleporting
player summons

Fixes #2943
  • Loading branch information
phacUFPE authored Nov 18, 2024
1 parent 93448b8 commit 4655357
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 27 deletions.
6 changes: 3 additions & 3 deletions data-otservbr-global/lib/quests/soul_war.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ function Player:getSoulWarZoneMonster()
return zoneMonsterName
end

function Player:isInBoatSpot()
function Creature:isInBoatSpot()
-- Get ebb and flow zone and check if player is in zone
local zone = SoulWarQuest.ebbAndFlow.getZone()
local tile = Tile(self:getPosition())
Expand All @@ -1464,11 +1464,11 @@ function Player:isInBoatSpot()
groundId = tile:getGround():getId()
end
if zone and zone:isInZone(self:getPosition()) and tile and groundId == SoulWarQuest.ebbAndFlow.boatId then
logger.trace("Player {} is in boat spot", self:getName())
logger.trace("Creature {} is in boat spot", self:getName())
return true
end

logger.trace("Player {} is not in boat spot", self:getName())
logger.trace("Creature {} is not in boat spot", self:getName())
return false
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,25 @@ local function updateWaterPoolsSize()
end

local function loadMapEmpty()
if SoulWarQuest.ebbAndFlow.getZone():countPlayers() > 0 then
local players = SoulWarQuest.ebbAndFlow.getZone():getPlayers()
for _, player in ipairs(players) do
if player:getPosition().z == 8 then
if player:isInBoatSpot() then
local teleportPosition = player:getPosition()
teleportPosition.z = 9
player:teleportTo(teleportPosition)
logger.trace("Teleporting player to down.")
local playersInZone = SoulWarQuest.ebbAndFlow.getZone():countPlayers()
local monstersInZone = SoulWarQuest.ebbAndFlow.getZone():countMonsters()
if playersInZone > 0 or monstersInZone > 0 then
local creatures = SoulWarQuest.ebbAndFlow.getZone():getCreatures()
for _, creature in ipairs(creatures) do
local creatureMaster = creature:getMaster()
local player = creature:getPlayer()
if creature:isPlayer() or (creature:isMonster() and creatureMaster and creatureMaster:getPlayer()) then
if creature:getPosition().z == 8 then
if creature:isInBoatSpot() then
local teleportPosition = creature:getPosition()
teleportPosition.z = 9
creature:teleportTo(teleportPosition)
logger.trace("Teleporting player to down.")
end
if player then
player:sendCreatureAppear()
end
end
player:sendCreatureAppear()
end
end
end
Expand Down Expand Up @@ -72,22 +80,30 @@ local function findNearestRoomPosition(playerPosition)
end

local function loadMapInundate()
if SoulWarQuest.ebbAndFlow.getZone():countPlayers() > 0 then
local players = SoulWarQuest.ebbAndFlow.getZone():getPlayers()
for _, player in ipairs(players) do
local playerPosition = player:getPosition()
if playerPosition.z == 9 then
if player:isInBoatSpot() then
local nearestCenterPosition = findNearestRoomPosition(playerPosition)
player:teleportTo(nearestCenterPosition)
logger.trace("Teleporting player to the near center position room and updating tile.")
else
player:teleportTo(SoulWarQuest.ebbAndFlow.waitPosition)
logger.trace("Teleporting player to wait position and updating tile.")
local playersInZone = SoulWarQuest.ebbAndFlow.getZone():countPlayers()
local monstersInZone = SoulWarQuest.ebbAndFlow.getZone():countMonsters()
if playersInZone > 0 or monstersInZone > 0 then
local creatures = SoulWarQuest.ebbAndFlow.getZone():getCreatures()
for _, creature in ipairs(creatures) do
local creatureMaster = creature:getMaster()
local player = creature:getPlayer()
if creature:isPlayer() or (creature:isMonster() and creatureMaster and creatureMaster:getPlayer()) then
local creaturePosition = creature:getPosition()
if creaturePosition.z == 9 then
if creature:isInBoatSpot() then
local nearestCenterPosition = findNearestRoomPosition(creaturePosition)
creature:teleportTo(nearestCenterPosition)
logger.trace("Teleporting player to the near center position room and updating tile.")
else
creature:teleportTo(SoulWarQuest.ebbAndFlow.waitPosition)
logger.trace("Teleporting player to wait position and updating tile.")
end
creaturePosition:sendMagicEffect(CONST_ME_TELEPORT)
end
if player then
player:sendCreatureAppear()
end
playerPosition:sendMagicEffect(CONST_ME_TELEPORT)
end
player:sendCreatureAppear()
end
end

Expand Down

0 comments on commit 4655357

Please sign in to comment.