-- ===================================================== -- BOAT NAVIGATION SYSTEM -- AID 40000 = Embark (dock tile -> water) -- AID 40001 = Disembark (water tile -> dock) -- ===================================================== -- Helper: apply boat outfit and store original local function applyBoatOutfit(player, item, position, fromPosition) local playerOutfit = player:getOutfit() -- Store current outfit player:setStorageValue(709919, playerOutfit.lookType) player:setStorageValue(709920, playerOutfit.lookAddons) player:setStorageValue(709921, playerOutfit.lookWings or 0) player:setStorageValue(709922, playerOutfit.lookAura or 0) player:setStorageValue(709923, playerOutfit.lookShader or 0) -- Check equipped ship using the custom inventory storage system -- _SYSTEM.INVENTARIO[07] = RING slot, UID_01 = storage 1061 local shipId = player:getStorageValue(_SYSTEM.INVENTARIO[07].UID_01) local boatLookType = 0 if shipId == 42430 then boatLookType = 9017 elseif shipId == 42431 then boatLookType = 9018 elseif shipId == 42432 then boatLookType = 9019 elseif shipId == 42433 then boatLookType = 9541 elseif shipId == 42434 then boatLookType = 9542 elseif shipId == 42435 then boatLookType = 9543 elseif shipId == 42436 then boatLookType = 9544 end if boatLookType > 0 then playerOutfit.lookType = boatLookType playerOutfit.lookAddons = 0 playerOutfit.lookWings = 0 playerOutfit.lookAura = 0 playerOutfit.lookShader = 0 player:setOutfit(playerOutfit) return true end return false end -- Helper: restore original outfit local function restoreOutfit(player) local storedLookType = player:getStorageValue(709919) local storedLookAddons = player:getStorageValue(709920) local storedLookWings = player:getStorageValue(709921) local storedLookAura = player:getStorageValue(709922) local storedLookShader = player:getStorageValue(709923) if storedLookType > 0 then local playerOutfit = player:getOutfit() playerOutfit.lookType = storedLookType playerOutfit.lookAddons = storedLookAddons playerOutfit.lookWings = storedLookWings playerOutfit.lookAura = storedLookAura playerOutfit.lookShader = storedLookShader player:setOutfit(playerOutfit) end end -- ===================================================== -- TELEPORT EVENT (AID 40000 = embark / AID 40001 = disembark) -- ===================================================== local boatTeleport = MoveEvent() function boatTeleport.onStepIn(creature, item, position, fromPosition) local player = creature:getPlayer() if not player then return true end local actionId = item:getActionId() -- Prevent trigger if player was already on a tile with the same AID -- (avoids loop when teleporting onto another AID tile) local fromTile = Tile(fromPosition) if fromTile then local items = fromTile:getItems() if items then for _, i in ipairs(items) do if i:getActionId() == actionId then return true end end end end -- Calculate movement direction (1 step = 1 tile difference) local diffX = position.x - fromPosition.x local diffY = position.y - fromPosition.y if diffX == 0 and diffY == 0 then return true end -- Project destination 4 tiles ahead in walking direction local targetPos = Position( position.x + (diffX * 4), position.y + (diffY * 4), position.z ) if actionId == 40000 then -- EMBARK: verify boat equipped, apply outfit, teleport to water (Z+1) if not applyBoatOutfit(player, item, position, fromPosition) then player:teleportTo(fromPosition, true) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) player:say("You need to equip a boat in your ring slot to sail.", TALKTYPE_MONSTER_SAY) return false end targetPos.z = position.z + 1 player:teleportTo(targetPos) targetPos:sendMagicEffect(CONST_ME_TELEPORT) elseif actionId == 40001 then -- DISEMBARK: restore outfit and teleport to dock (Z-1) restoreOutfit(player) targetPos.z = position.z - 1 player:teleportTo(targetPos) targetPos:sendMagicEffect(CONST_ME_TELEPORT) end return true end boatTeleport:aid(40000, 40001) boatTeleport:register()