Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ebb and flow boat summons teleport #3125

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading