-- =============================================================================
-- KONFIGURACJA GLOBALNA
-- =============================================================================
local storageResets = 525000
local tplist = {
["demeter 1"] = {pos = Position(3167, 2180, 7), level = 5000, reborn = 0, aid = 39400},
["demeter 2"] = {pos = Position(270, 440, 7), level = 120, reborn = 1, aid = 39400},
["demeter 3"] = {pos = Position(270, 440, 7), level = 120, reborn = 1, aid = 39400},
["rotworms"] = {pos = Position(216, 341, 8), level = 8, reborn = 0, aid = 39401},
["dl poi"] = {pos = Position(100, 200, 7), level = 50, reborn = 0, aid = 39402},
["dl fenrock"] = {pos = Position(150, 250, 7), level = 60, reborn = 0, aid = 39402},
["dl high"] = {pos = Position(180, 220, 8), level = 100, reborn = 3, aid = 39402},
["goroma"] = {pos = Position(555, 666, 15), level = 150, reborn = 2, aid = 39403}
}
-- =============================================================================
-- 1. RUCH: Informacja po wejściu na płytkę
-- =============================================================================
local tpMovement = MoveEvent()
function tpMovement.onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then return true end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Napisz na czacie nazwę expowiska, aby się teleportować. Dostępne opcje:")
for command, info in pairs(tplist) do
if info.aid == item.actionid then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "-> !tp " .. command .. " (Lvl: " .. info.level .. ", Reb: " .. info.reborn .. ")")
end
end
return true
end
-- Rejestracja Action ID z listy
local registeredAids = {}
for _, info in pairs(tplist) do
if not registeredAids[info.aid] then
tpMovement:aid(info.aid)
registeredAids[info.aid] = true
end
end
tpMovement:register()
-- =============================================================================
-- 2. TALKACTION: Obsługa komendy !tp
-- =============================================================================
local tpTalk = TalkAction("!tp")
function tpTalk.onSay(player, words, param, type)
local target = tplist[param:lower()]
if not target then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "Nie znaleziono takiego expowiska. Wpisz np. !tp demeter 1")
return false
end
-- Pobieramy pozycję, na której stoi gracz
local playerPos = player:getPosition()
local tile = Tile(playerPos)
if not tile then
return false
end
-- SPRAWDZENIE: Szukamy pod nogami gracza jakiegokolwiek przedmiotu, który ma odpowiednie Action ID
local hasCorrectAid = false
local items = tile:getItems()
if items then
for _, item in ipairs(items) do
if item:getActionId() == target.aid then
hasCorrectAid = true
break
end
end
end
-- Dodatkowe sprawdzenie dla samego podłoża (Ground Tile)
local ground = tile:getGround()
if ground and ground:getActionId() == target.aid then
hasCorrectAid = true
end
-- Jeśli gracz nie stoi na właściwym skrypcie/teleporcie, przerywamy
if not hasCorrectAid then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "Musisz stać na odpowiedniej płytce teleportu, aby użyć tej komendy!")
return false
end
-- Sprawdzenie wymagań (Reborn / Level)
local playerReborns = math.max(0, player:getStorageValue(storageResets))
if playerReborns < target.reborn then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Potrzebujesz minimum " .. target.reborn .. " Rebornów.")
return false
elseif player:getLevel() < target.level then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Potrzebujesz minimum " .. target.level .. " poziomu.")
return false
end
-- Teleportacja
playerPos:sendMagicEffect(CONST_ME_POFF)
player:teleportTo(target.pos)
target.pos:sendMagicEffect(CONST_ME_TELEPORT)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Przeniesiono na expowisko: " .. param .. "!")
return false
end
tpTalk:separator(" ")
tpTalk:register()