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

Action [TFS 1.X] Cursed Chests

Code:
    <globalevent name="CursedChestSpawner" interval="43200000‬" script="cursed_chest_spawner.lua"/>
I don't want another chest to spawn after the finished one does anybody know how because I couldn't catch why it do this in the script
--edit
i did it by that way is it safe?
Code:
CURSED_CHESTS_AID = 4283

CURSED_CHESTS_SPAWNS = {
    [1] = {
        pos = Position(980, 1080, 7),
        size = 10,
        chests = {1}
    },
    [2] = {
        pos = Position(1060, 1085, 7),
        size = 10,
        chests = {1}
    },
    [3] = {
        pos = Position(1090, 1050, 7),
        size = 10,
        chests = {1}
    }
}

function _onThink(cid, interval, lastExecution)
    for spawnId, data in ipairs(CURSED_CHESTS_SPAWNS) do
        if not data.spawned then
            local from = Position(data.pos.x - data.size, data.pos.y - data.size, data.pos.z)
            local to = Position(data.pos.x + data.size, data.pos.y + data.size, data.pos.z)
            local chestId = math.random(1, #data.chests)
            local spawnPos = Position(math.random(from.x, to.x), math.random(from.y, to.y), data.pos.z)
            local tile = Tile(spawnPos)
            local spawnTest = 0

            while spawnTest < 100 do
                if isBadTile(tile) then
                    spawnPos = Position(math.random(from.x, to.x), math.random(from.y, to.y), data.pos.z)
                    tile = Tile(spawnPos)
                    spawnTest = spawnTest + 1
                else
                    break
                end
            end

            if spawnTest < 100 then
                local rarity = nil
                for i = #CURSED_CHESTS_TIERS, 1, -1 do
                    rarity = CURSED_CHESTS_TIERS[i]
                    if math.random(1, 100) <= rarity.chance then
                        break
                    end
                end
                if rarity ~= nil then
                    local chest = Game.createItem(rarity.item, 1, spawnPos)
                    chest:setActionId(CURSED_CHESTS_AID)
                    spawnPos:sendMagicEffect(CONST_ME_GROUNDSHAKER)
                    local chestData = {}
                    chestData.pos = spawnPos
                    chestData.spawnId = spawnId
                    chestData.wave = 0
                    chestData.monsters = {}
                    chestData.active = 0
                    chestData.finished = false
                    chestData.container = chest
                    chestData.chest = CURSED_CHESTS_CONFIG[chestId]
                    chestData.rarity = rarity
                    CURSED_CHESTS_DATA[#CURSED_CHESTS_DATA + 1] = chestData
                    data.spawned = true
                end
            end

        end
    end
    return true
end

function onThink(cid, interval, lastExecution)
    addEvent(_onThink, 43200000)
   return true
end
 
Last edited by a moderator:
@oen432 Is it possible to change this script so it only summon monsters and the chest disappear direclty after spawning the monsters without any reward on the chest?
 
I tested it for a while and:

bug:
if there is alot of firefields around - some monsters are not spawning. Problably becouse on spawnpos is firefield and in every pos around. After that script instead of spawning 20 mobs, spawns only 19 or less and there is no way to advance forward in waves. You have to add a function what checks for firefields etc or check how many script has spawned mobs in total without any errors.

Also there is no way to edit boss for each chest rarity. You may change the code to make last wave be always a boss fight, unless something other is in cfg.

It would be good if chest are able to spawn randomly around the map. Deeper map - higher rarity. And more chests at once. Example one chest spawns every 5 minutes, for up to 30 chests in total. When 30th spawned players needs to destroy one chest to make script spawn 31th etc.
In the past I made a script what spawns herbs for alchemists around the map. Script was checking if lava is near, if yes - script was spawning fire blossoms etc. I can give you that code, so you will be able to upgrade your cursed chests.


#edit
are chests immune to disintegrate rune? my rune's script is bugged, someone have to check it
 
Last edited:
Nice script! But best of all is that sweet ass widescreen supported client you got there.
 
any way to prevent the monsters to push the chest?
once monster push it, its bug it and stop all waves and wont be able to be lootable
 
How do I change the position of the message: "Epic Cursed Chest?"

I changed the sprite from the chest and it is no longer centralized.

1586376954171.png
 
What if ill add more waves and last one will be with boss monsters? but how to make that last wave will spawn just one monster, or how to make different monsters for each box, thats issue i cant manage to fix
 
What if ill add more waves and last one will be with boss monsters? but how to make that last wave will spawn just one monster, or how to make different monsters for each box, thats issue i cant manage to fix
Huh? Just check examples in data\actions\scripts\custom\cursed_chest.lua. Last wave is boss, only 1.
 
i think he means how do you change the monsters that spawn with each rarity, so for example rare boxes have X monsters, epic have X, each with different bosses.
 
i think he means how do you change the monsters that spawn with each rarity, so for example rare boxes have X monsters, epic have X, each with different bosses.
Well, you can't do that.
 
how to make the reward chest like? for each player who participates receive a share of the reward? without having that party
 
No innovative minimum. I loved the idea. In my case, my server does not have data / events (TFS 1.2). What can I do to use it?
 
Back
Top