• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Boss Room [1.4.2]

OTcreator

Active Member
Joined
Feb 14, 2022
Messages
379
Solutions
1
Reaction score
39
Hello!
I need this script for TFS 1.4.2. [MOVEMENTS]

Lua:
local teleports = {
    [1054] = {boss = "Necropharus", task = "Necromancers", telePos = {x = 270, y = 374, z = 11}, spawnPos = {x = 270, y = 371, z = 11}, from = {x = 267, y = 367, z = 11}, to = {x = 272, y = 374, z = 11}},
    [1009] = {boss = "The Horned Fox", task = "Minotaurs", telePos = {x = 1880, y = 1266, z = 9}, spawnPos = {x = 1884, y = 1265, z = 9}, from = {x = 1882, y = 1261, z = 9}, to = {x = 1886, y = 1266, z = 9}},
    [1053] = {boss = "Ron The Ripper", task = "Pirates", telePos = {x = 343, y = 864, z = 6}, spawnPos = {x = 344, y = 858, z = 6}, from = {x = 341, y = 860, z = 6}, to = {x = 347, y = 864, z = 6}},
    [1022] = {boss = "Demodras", task = "Dragon Lords", telePos = {x = 1876, y = 1271, z = 8}, spawnPos = {x = 1878, y = 1267, z = 8}, from = {x = 1878, y = 1265, z = 8}, to = {x = 1881, y = 1269, z = 8}},
    [1029] = {boss = "Tiquandas Revenge", task = "Carniphila", telePos = {x = 1417, y = 814, z = 7}, spawnPos = {x = 1415, y = 807, z = 7}, from = {x = 1412, y = 805, z = 7}, to = {x = 1420, y = 811, z = 7}},
}

local function getCreaturesInArena(fromPos, toPos, getMonsters)
    local creaturesInArena = {}
    for x = fromPos.x, toPos.x do
        for y = fromPos.y, toPos.y do
            for z = fromPos.z, toPos.z do
                local creature = getTopCreature({x = x, y = y, z = z}).uid
                if creature and (getMonsters and isMonster(creature) or not getMonsters and isPlayer(creature)) then
                    table.insert(creaturesInArena, creature)
                end
            end
        end
    end
    return creaturesInArena
end

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)

    local arena = teleports[item.uid]
    local boss = arena.boss
    local task = arena.task
    
    if not isPlayer(cid) then
        return true
    end


    if (#getCreaturesInArena(arena.from, arena.to, false) > 0) then
        doTeleportThing(cid, fromPosition, true)
        doPlayerSendCancel(cid, "Wait. Someone else is in the room.")
        return true
    end


    if not (getPlayerStorageValue(cid, (item.uid)) == 1) then
           doCreatureSay(cid, "You already killed ".. boss .." or you do not have a completed ".. task .." task.", TALKTYPE_ORANGE_1)
        doTeleportThing(cid, fromPosition, false)
        return true
    end


    if (#getCreaturesInArena(arena.from, arena.to, true) > 0) then
        for _, anyMonsterOnArena in ipairs(getCreaturesInArena(arena.from, arena.to, true)) do
            doRemoveCreature(anyMonsterOnArena)
        end
    end
    
    doTeleportThing(cid, arena.telePos)
    doSendMagicEffect(arena.telePos, CONST_ME_TELEPORT)
    doSummonCreature(boss, arena.spawnPos)
    doSendMagicEffect(arena.spawnPos, CONST_ME_TELEPORT)
    return true
end
 
not tested
Lua:
local teleports = {
    [1054] = {boss = "Necropharus", task = "Necromancers", telePos = {x = 270, y = 374, z = 11}, spawnPos = {x = 270, y = 371, z = 11}, from = {x = 267, y = 367, z = 11}, to = {x = 272, y = 374, z = 11}},
    [1009] = {boss = "The Horned Fox", task = "Minotaurs", telePos = {x = 1880, y = 1266, z = 9}, spawnPos = {x = 1884, y = 1265, z = 9}, from = {x = 1882, y = 1261, z = 9}, to = {x = 1886, y = 1266, z = 9}},
    [1053] = {boss = "Ron The Ripper", task = "Pirates", telePos = {x = 343, y = 864, z = 6}, spawnPos = {x = 344, y = 858, z = 6}, from = {x = 341, y = 860, z = 6}, to = {x = 347, y = 864, z = 6}},
    [1022] = {boss = "Demodras", task = "Dragon Lords", telePos = {x = 1876, y = 1271, z = 8}, spawnPos = {x = 1878, y = 1267, z = 8}, from = {x = 1878, y = 1265, z = 8}, to = {x = 1881, y = 1269, z = 8}},
    [1029] = {boss = "Tiquandas Revenge", task = "Carniphila", telePos = {x = 1417, y = 814, z = 7}, spawnPos = {x = 1415, y = 807, z = 7}, from = {x = 1412, y = 805, z = 7}, to = {x = 1420, y = 811, z = 7}},
}

function getCreaturesInArena(fromPos, toPos, getMonsters)
    local creaturesInArena = {}
    for x = fromPos.x, toPos.x do
        for y = fromPos.y, toPos.y do
            for z = fromPos.z, toPos.z do
                local tile = Tile(Position(x, y, z))
                if tile then
                    local creature = tile:getTopCreature()
                    if creature and (getMonsters and creature:isMonster() or not getMonsters and creature:isPlayer()) then
                        table.insert(creaturesInArena, creature)
                    end
                end
            end
        end
    end
    return creaturesInArena
end

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    local arena = teleports[item.uid]
    local boss = arena.boss
    local task = arena.task
    
    local player = Player(cid)
    
    if not player then
        return true
    end

    if (#getCreaturesInArena(arena.from, arena.to, false) > 0) then
        player:teleportTo(fromPosition, false)
        player:say("Wait. Someone else is in the room.", TALKTYPE_ORANGE_1)
        return true
    end

    if not (player:getStorageValue(arena.boss) == 1) then
        player:say("You already killed " .. boss .. " or you do not have a completed " .. task .. " task.", TALKTYPE_ORANGE_1)
        player:teleportTo(fromPosition, false)
        return true
    end

    if (#getCreaturesInArena(arena.from, arena.to, true) > 0) then
        for _, anyCreatureOnArena in ipairs(getCreaturesInArena(arena.from, arena.to, true)) do
            anyCreatureOnArena:remove()
        end
    end
    
    player:teleportTo(arena.telePos, false)
    arena.telePos:sendMagicEffect(CONST_ME_TELEPORT)
    Game.createMonster(boss, arena.spawnPos, true, true)
    arena.spawnPos:sendMagicEffect(CONST_ME_TELEPORT)
    return true
end
 
Back
Top