• 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!

TFS 1.X+ Boss

alcapone

Member
Joined
Jan 13, 2021
Messages
89
Reaction score
10
Lua:
if not warzoneConfig then
    warzoneConfig = {
        [45700] = {
            center = Position(33110, 31965, 10),
            maxRangeX = 12, minRangeX = 26, minRangeY = 15, maxRangeY = 17,
            bossResp = Position(33102, 31956, 10),
            boss = "Deathstrike",
            teleportTo = Position(33096, 31955, 10),
            locked = false,
            storage = Storage.BigfootBurden.BossWarzone1,
            interval = 20 * 60 * 60,-- 20 hours
            exit = Position(33001, 31900, 9)
        },
        [45701] = {
            center = Position(33117, 31956, 11),
            maxRangeX = 14, minRangeX = 14, minRangeY = 14, maxRangeY = 14,
            bossResp = Position(33116, 31956, 11),
            boss = "Gnomevil",
            teleportTo = Position(33106, 31955, 11),
            locked = false,
            storage = Storage.BigfootBurden.BossWarzone2,
            interval = 20 * 60 * 60,-- 20 hours
            exit = Position(33001, 31900, 9),
            wall = 18459 --Id of current crystais in warzone 2 (open killing parasite)
        },
        [45702] = {
            center = Position(33090, 31910, 12),
            maxRangeX = 12, minRangeX = 12, minRangeY = 12, maxRangeY = 12,
            bossResp = Position(33088, 31910, 12),
            boss = "Abyssador",
            teleportTo = Position(33083, 31904, 12), --Place where the player will be teleported inside the room
            locked = false,
            storage = Storage.BigfootBurden.BossWarzone3,
            interval = 20 * 60 * 60,-- 20 hours
            exit = Position(33001, 31900, 9)
        }
    }

    warzoneConfig.spawnBoss = function (name, pos)
        local boss = Game.createMonster(name, pos, false, true)
        if boss then
            local c = warzoneConfig.findByName(name)
            c.locked = true
            boss:registerEvent('BossWarzoneDeath')
        end
    end
    warzoneConfig.findByName = function(name, last)
        local i, v = next(warzoneConfig, last)
        if type(v) == 'table' and v.boss == name then
            return v
        elseif not i then
            return nil
        end
        return warzoneConfig.findByName(name, i)
    end

    warzoneConfig.resetRoom = function(roomwarzone, msg, releaseRoom)
        if releaseRoom then
            roomwarzone.locked = false
        end

        local spectators = Game.getSpectators(roomwarzone.center, false, false,
        roomwarzone.minRangeX, roomwarzone.maxRangeX, roomwarzone.minRangeY, roomwarzone.maxRangeY)
        for i = 1, #spectators do
            if spectators[i]:isPlayer() then
                spectators[i]:teleportTo(roomwarzone.exit)
                spectators[i]:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg)
            else
                spectators[i]:remove()
            end
        end
    end
end

I have a problem in the script when many players come in, several bosses are summoned
 

Fermantor

Active Member
Joined
Dec 16, 2009
Messages
209
Solutions
4
Reaction score
33
Location
Germany
This is neither a move script, nor an action script, so those functions are getting triggered somewhere else. Send the other script (probably movement on the teleporter) as well.
 
OP
OP
A

alcapone

Member
Joined
Jan 13, 2021
Messages
89
Reaction score
10
This is neither a move script, nor an action script, so those functions are getting triggered somewhere else. Send the other script (probably movement on the teleporter) as well.
Lua:
local function filter(list, f, i)
    if i < #list then
        if f(list[i]) then
            return list[i], filter(list, f, i + 1)
        else
            return filter(list, f, i + 1)
        end
    elseif list[i] and f(list[i]) then
        return list[i]
    end
end

local function spawnBoss(inf)
    local boss = Game.createMonster(inf.boss, inf.bossResp)
    boss:registerEvent('BossWarzoneDeath')
end

local warzoneBoss = MoveEvent()

function warzoneBoss.onStepIn(creature, item, pos, fromPosition)
    if not creature:isPlayer() then
        creature:teleportTo(fromPosition)
        return false
    end

    local warzone = warzoneConfig[item:getActionId()]
    if not warzone then
        return false
    end

    if creature:getStorageValue(warzone.storage) > os.time() then
        creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have already cleared this warzone in the last 20 hours.")
        creature:teleportTo(fromPosition)
        return false
    end

    if warzone.locked then
        creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Please, wait until the room is cleared. \z
        This happens 30 minutes after the last team entered.")
        creature:teleportTo(fromPosition)
        return true
    end

    creature:teleportTo(warzone.teleportTo)
    creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have half an hour to heroically defeat the \z
    " .. warzone.boss .. ". Otherwise you'll be teleported out by the gnomish emergency device." )
    return true
end

warzoneBoss:type("stepin")
warzoneBoss:aid(45700, 45701, 45702)
warzoneBoss:register()



Lua:
local versperothPosition = Position(33075, 31878, 12)

local function removeMinion(mid)
    local monster = Monster(mid)
    if monster then
        monster:getPosition():sendMagicEffect(CONST_ME_POFF)
        monster:remove()
    end
end

local function executeVersperothBattle(mid)
    if Game.getStorageValue(GlobalStorage.BigfootBurden.Versperoth.Battle) ~= 1 then
        return false
    end

    if mid then
        local monster = Monster(mid)
        if not monster then
            return false
        else
        end

        Game.setStorageValue(GlobalStorage.BigfootBurden.Versperoth.Health, monster:getHealth())
        monster:remove()
        local blood = Tile(versperothPosition):getItemById(2019)
        if blood then
            blood:remove()
        end

        local hole = Tile(versperothPosition):getItemById(18462)
        if not hole then
            Game.createItem(18462, 1, versperothPosition)
        end
        versperothPosition:sendMagicEffect(CONST_ME_POFF)

        local position, minionMonster
        for i = 1, 10 do
            position = Position(math.random(33070, 33081), math.random(31874, 31883), 12)
            minionMonster = Game.createMonster('Minion of Versperoth', position)
            position:sendMagicEffect(CONST_ME_TELEPORT)
            if minionMonster then
                addEvent(removeMinion, 20 * 1000, minionMonster.uid)
            end
        end
        addEvent(executeVersperothBattle, 10 * 1000)
        return
    end

    local monster = Game.createMonster('Versperoth', versperothPosition, false, true)
    if monster then
        local holee = Tile(versperothPosition):getItemById(18462)
        if holee then
            holee:remove()
        end
        versperothPosition:sendMagicEffect(CONST_ME_GROUNDSHAKER)
        monster:setHealth(Game.getStorageValue(GlobalStorage.BigfootBurden.Versperoth.Health))
        addEvent(executeVersperothBattle, 20 * 1000, monster.uid)
    end
end

local versperothSpawn = MoveEvent()

function versperothSpawn.onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    if Game.getStorageValue(GlobalStorage.BigfootBurden.Versperoth.Battle) >= 1 then
        player:say("Versperoth has already been defeated in the last 30 minutes.", TALKTYPE_MONSTER_SAY)
        return true
    end
    player:teleportTo(Position(33072, 31877, 12))
    Game.setStorageValue(GlobalStorage.BigfootBurden.Versperoth.Battle, 1)
    Game.setStorageValue(GlobalStorage.BigfootBurden.Versperoth.Health, 100000)
    executeVersperothBattle()
    item:remove()
    return true
end

versperothSpawn:type("stepin")
versperothSpawn:id(18463)
versperothSpawn:register()
 

Fermantor

Active Member
Joined
Dec 16, 2009
Messages
209
Solutions
4
Reaction score
33
Location
Germany
Lua:
local function spawnBoss(inf)
    local boss = Game.createMonster(inf.boss, inf.bossResp)
    boss:registerEvent('BossWarzoneDeath')
end
I am confused. There is this line, that spawns the boss, but it is nowhere executed.
 
Last edited:
OP
OP
A

alcapone

Member
Joined
Jan 13, 2021
Messages
89
Reaction score
10
as I understand it pulls the information from the first script but nowhere does it check if the monster already exists before creating
 

Fermantor

Active Member
Joined
Dec 16, 2009
Messages
209
Solutions
4
Reaction score
33
Location
Germany
Well, the first script is kinda just a lib for all warzones but doesn't execute anything on its own. If you are using notepad++ you can press CTRL+Shift+F to open the search in files window. You then search for "spawnBoss" and pick the /data folder of your server and check, where this is executed
 
OP
OP
A

alcapone

Member
Joined
Jan 13, 2021
Messages
89
Reaction score
10
Well, the first script is kinda just a lib for all warzones but doesn't execute anything on its own. If you are using notepad++ you can press CTRL+Shift+F to open the search in files window. You then search for "spawnBoss" and pick the /data folder of your server and check, where this is executed
Lua:
local posdotp = Position(33104, 31908, 10)

local creatures = {
    "humongous fungus",
    "hideous fungus"
}

local function removeTp()
    local t = Tile(posdotp):getItemById(1387)
    if t then
        t:remove()
        Game.createItem(17999,1,posdotp)-- Stone pos
        posdotp:sendMagicEffect(CONST_ME_POFF)
    end
end

local function magicEffectWz(pos, cons)
    pos:sendMagicEffect(cons)
end

local function createTp()
    local cristal = Tile(posdotp):getItemById(17999)
    if cristal then
        cristal:remove()
        local tp = Game.createItem(1387, 1, posdotp)
        if tp then
            tp:setActionId(45700)
        end
    end
    return true
end

local bigfootWarzoneCrystal = Action()
function bigfootWarzoneCrystal.onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    local config = warzoneConfig.findByName("Deathstrike")
    if Game.getStorageValue(96974) < 1 then
        Game.setStorageValue(96974, 1)
        for i = 1, 10 do
          for k = 1, 6 do
            pos = Position(math.random(33094, 33101), math.random(31900, 31916), 10)
                addEvent(Game.createMonster, i * 20 * 1000, creatures[math.random(1,2)], pos)
                addEvent(magicEffectWz, i * 20 * 1000, pos, CONST_ME_TELEPORT)
            end
        end

        player:say("The crystals are charging!", TALKTYPE_MONSTER_SAY, false, player, toPosition)
        addEvent(createTp, 200000) -- 3.33 min
        addEvent(removeTp, 260000) -- 4.33 min
        addEvent(warzoneConfig.spawnBoss, 280000, config.boss, config.bossResp) -- 5 min
        addEvent(warzoneConfig.resetRoom, 30 * 60 * 1000, config, "You were teleported out by the gnomish emergency device.", true)
        addEvent(Game.setStorageValue, 30 * 60 * 1000, 96974, 0)
    else
        doPlayerSendCancel(player, "Wait 30 minutes to start again.")
    end
    return true
end

bigfootWarzoneCrystal:uid(3143)
bigfootWarzoneCrystal:register()





Lua:
--[[
Created by gagoosh [gudan garam on otland]
for otx server malucoo
]]

local positionsWall = {
    {x = 33098, y = 31979, z = 11},
    {x = 33098, y = 31978, z = 11},
    {x = 33098, y = 31977, z = 11},
    {x = 33098, y = 31976, z = 11}
}

local function recreateCrystals(c)
    for i = 1, #positionsWall do
        local crystal = Tile(positionsWall[i]):getItemById(c.wall) or nil
        if not item then
            Game.createItem(c.wall, 1, positionsWall[i])
        end
    end

    local spectators = Game.getSpectators(Position(33099, 31977, 11), false, false, 1, 1, 1, 2)
    for i = 1, #spectators do
        if spectators[i]:isPlayer() then
            local specPos = spectators[i]:getPosition()
            spectators[i]:teleportTo(Position(specPos.x - 2, specPos.y, specPos.z))
        else
            spectators[i]:getPosition():sendMagicEffect(CONST_ME_POFF)
            spectators[i]:remove()
        end
    end
end

local parasiteWarzone = CreatureEvent("ParasiteWarzone")
function parasiteWarzone.onKill(player, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return false
    end

    local targetName = targetMonster:getName():lower()
    if targetName ~= 'parasite' then
        return false
    end

    local master = targetMonster:getMaster()
    if not master or master:isPlayer() then
        return false
    end

    local pos = targetMonster:getPosition()
    if pos.x ~= 33097 or pos.y > 31979 or pos.y < 31976 or pos.z ~= 11 then
        return false
    end

    local config = warzoneConfig.findByName('Gnomevil')
    if config.locked then
        targetMonster:say("It seems that someone has already destroyed the walls in the last 30 minutes.", TALKTYPE_MONSTER_SAY)
        return false
    end

    if config.wall < 18461 and config.wall >= 18459 then
        for i = 1, #positionsWall do
            local crystal = Tile(positionsWall[i]):getItemById(config.wall)
            if crystal then
                Tile(positionsWall[i]):getItemById(config.wall):remove()
                Game.createItem(config.wall+1, 1, positionsWall[i])
            end
        end
        config.wall = config.wall + 1
    elseif config.wall == 18461 then
        for i = 1, #positionsWall do
            local crystal = Tile(positionsWall[i]):getItemById(config.wall)
            if crystal then
                Tile(positionsWall[i]):getItemById(config.wall):remove()
            end
        end
        config.wall = 18459
        addEvent(recreateCrystals, 1 * 60 * 1000, config)
        addEvent(warzoneConfig.spawnBoss, 1 * 60 * 1000, config.boss, config.bossResp)
        addEvent(warzoneConfig.resetRoom, 30 * 60 * 1000, config, "You were teleported out by the gnomish emergency device.", true)
    end
    return true
end

parasiteWarzone:register()
 

Fermantor

Active Member
Joined
Dec 16, 2009
Messages
209
Solutions
4
Reaction score
33
Location
Germany
From that scripts it seems that neither deathstrike, nor gnomevil can spawn more than once. So are all bosses spawning multiple times, or only abyssador?
 
OP
OP
A

alcapone

Member
Joined
Jan 13, 2021
Messages
89
Reaction score
10
is there a way to check if the addEvent that creates the boss is active? to check if the addEvent is active it will not be executed again
 

Fermantor

Active Member
Joined
Dec 16, 2009
Messages
209
Solutions
4
Reaction score
33
Location
Germany
is there a way to check if the addEvent that creates the boss is active? to check if the addEvent is active it will not be executed again
Yeah, that's what you wanna do. BEFORE the addEvent is started -> check if globalStorageValue ~= 1 (not equal 1) -> then start Event and set globalStorageValue to 1
But for that you need to know, where the boss spawning event is called.
 
Top