• 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

i've managed to configure this to fit my needs so Great thanks to your contribution ♥.
any chance i can get the old code before this changed:
"• Removed level requirements to open chest"

i want to do:
Common Cursed Chest [Lv.25+]
Rare Cursed Chest [Lv.50+]
Epic Cursed Chest [ Lv.80+]
Legendary Cursed Chest [ Lv.120+]

so players wont open Legendary that spawn in low level camp and might get low level unnecessary deaths.


Edit:
i guess i need to stick something like this
Lua:
   local playerLevel = player:getLevel()
   local minLevel = cursedChest[cursedChest].minLevel
   if cursedChest[cursedChest].minLevel >= playerLevel then
       player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to be level "..minLevel.." to open this Cursed Chest.")
       return true
   end
on the function OnUse ?
 
Last edited:
ive manage to configure this to fit my needs, any chance i can get the old code before this changed:
"•Removed level requirements to open chest"
Not really, I mean, that came with a big update so most code changed. Older versions would be harder to compare.
 
ohh i see, so as the one who made the code and understand much more than me. how hard will it be to add this option again?

i mean, is it gonna be simple addition of "If else" or a total rewirte of the entire "onUse" function?
 
ohh i see, so as the one who made the code and understand much more than me. how hard will it be to add this option again?

i mean, is it gonna be simple addition of "If else" or a total rewirte of the entire "onUse" function?
Level should be different for each tier or entire chest?
 
Level should be different for each tier or entire chest?

to open Common Cursed Chest you should be [Lv.25+].
to open Rare Cursed Chest you should be [Lv.50+].
to open Epic Cursed Chest you should be [ Lv.80+].
to open Legendary Cursed Chest you should be [ Lv.120+].

so i think add some kind of line
Lua:
   local playerLevel = player:getLevel()
   local minLevel = cursedChest[cursedChest].minLevel
   if cursedChest[cursedChest].minLevel >= playerLevel then
       player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to be level "..minLevel.." to open this Cursed Chest.")
       return true
   end
in the onUse and add extra "minLevel = x" line here

Lua:
CURSED_CHESTS_TIERS = {
    {
        tier = CURSED_CHESTS_TIER_COMMON,
        minLevel = 25,
        chance = 70,
        text = "Common Cursed Chest [Lv.25+]",
        item = 1740,
        monstersPerWave = 1
    },
    {
        tier = CURSED_CHESTS_TIER_RARE,
        minLevel = 50,
        chance = 50,
        text = "Rare Cursed Chest [Lv.50+]",
        item = 1750,
        monstersPerWave = 1
    },
    {
        tier = CURSED_CHESTS_TIER_EPIC,
        minLevel = 80,
        chance = 30,
        text = "Epic Cursed Chest [party of Lv.80+]",
        item = 1746,
        monstersPerWave = 1
    },
    {
        tier = CURSED_CHESTS_TIER_LEGENDARY,
        minLevel = 120,
        chance = 10,
        text = "Legendary Cursed Chest [party of Lv.120+]",
        item = 12664,
        monstersPerWave = 1
    }
}


that way we can control what chest can be open based on level and players won't lose their stuff just because they underestimate the chests. (little more user friendly :D)
 
Last edited:
to open Common Cursed Chest you should be [Lv.25+].
to open Rare Cursed Chest you should be [Lv.50+].
to open Epic Cursed Chest you should be [ Lv.80+].
to open Legendary Cursed Chest you should be [ Lv.120+].

so i think add some kind of line
Lua:
   local playerLevel = player:getLevel()
   local minLevel = cursedChest[cursedChest].minLevel
   if cursedChest[cursedChest].minLevel >= playerLevel then
       player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to be level "..minLevel.." to open this Cursed Chest.")
       return true
   end
in the onUse and add extra "minLevel = x" line here

Lua:
CURSED_CHESTS_TIERS = {
    {
        tier = CURSED_CHESTS_TIER_COMMON,
        minLevel = 25,
        chance = 70,
        text = "Common Cursed Chest [Lv.25+]",
        item = 1740,
        monstersPerWave = 1
    },
    {
        tier = CURSED_CHESTS_TIER_RARE,
        minLevel = 50,
        chance = 50,
        text = "Rare Cursed Chest [Lv.50+]",
        item = 1750,
        monstersPerWave = 1
    },
    {
        tier = CURSED_CHESTS_TIER_EPIC,
        minLevel = 80,
        chance = 30,
        text = "Epic Cursed Chest [party of Lv.80+]",
        item = 1746,
        monstersPerWave = 1
    },
    {
        tier = CURSED_CHESTS_TIER_LEGENDARY,
        minLevel = 120,
        chance = 10,
        text = "Legendary Cursed Chest [party of Lv.120+]",
        item = 12664,
        monstersPerWave = 1
    }
}


that way we can control what chest can be open based on level and players won't lose their stuff just because they underestimate the chests. (little more user friendly :D)
So you need me to make this or...? I'm confused now.
 
Replace actions script.


thank you so much ♥
i just finish do a test, seems to work perfectly!.. thanks again!

btw, to those who might want to use the tables for monster waves and loot i did for mine.

heres the script, no boss fight, only 4 waves and the loot is listed and named just in case you want to mix it up a bit

Lua:
CURSED_CHESTS_TIERS = {
    {
        tier = CURSED_CHESTS_TIER_COMMON,
        chance = 70,
        text = "Common Cursed Chest [Lv.25+]",
        item = 1740,
        monstersPerWave = 1,
        reqLevel = 25
    },
    {
        tier = CURSED_CHESTS_TIER_RARE,
        chance = 50,
        text = "Rare Cursed Chest [Lv.50+]",
        item = 1750,
        monstersPerWave = 1,
        reqLevel = 50
    },
    {
        tier = CURSED_CHESTS_TIER_EPIC,
        chance = 30,
        text = "Epic Cursed Chest [Lv.80+]",
        item = 1746,
        monstersPerWave = 1,
        reqLevel = 80
    },
    {
        tier = CURSED_CHESTS_TIER_LEGENDARY,
        chance = 10,
        text = "Legendary Cursed Chest [Lv.120+]",
        item = 12664,
        monstersPerWave = 1,
        reqLevel = 120
    }
}

CURSED_CHESTS_CONFIG = {
    [1] = {
            message = "Prepare to defend against 4 waves of monsters.",
            rewards = {
                [CURSED_CHESTS_TIER_COMMON] = {
                    { -- Platinum Coins
                        chance = 100,
                        item = 2152,
                        random = true,
                        amount = 60
                    },
                    { -- Bonelord Helmet
                        chance = 5,
                        item = 3972,
                        random = true,
                        amount = 1
                    },
                    { -- crown Helmet
                        chance = 5,
                        item = 2491,
                        random = true,
                        amount = 1
                    },
                    { -- Patched boots
                        chance = 3,
                        item = 2641,
                        random = true,
                        amount = 1
                    },
                    { -- Noble Axe
                        chance = 3,
                        item = 7456,
                        random = true,
                        amount = 1
                    },
                    { -- Djinn Blade
                        chance = 3,
                        item = 2451,
                        random = true,
                        amount = 1
                    },
                    { -- Shadow Sceptre
                        chance = 3,
                        item = 7451,
                        random = true,
                        amount = 1
                    },
                    { -- Hailstorm Rod
                        chance = 3,
                        item = 2183,
                        random = true,
                        amount = 1
                    },
                    { -- Wand of Inferno
                        chance = 3,
                        item = 2187,
                        random = true,
                        amount = 1
                    },
                    { -- Health potions
                        chance = 30,
                        item = 7618,
                        random = true,
                        amount = 100
                    },
                    { -- Mana potions
                        chance = 30,
                        item = 7620,
                        random = true,
                        amount = 100
                    },
                    { -- Crystal Coins
                        chance = 10,
                        item = 2160,
                        random = true,
                        amount = 3
                    }
                },
                [CURSED_CHESTS_TIER_RARE] = {
                    { -- Platinum Coins
                        chance = 100,
                        item = 2152,
                        random = true,
                        amount = 80
                    },
                    { -- Crystal Coins
                        chance = 10,
                        item = 2160,
                        random = true,
                        amount = 7
                    },
                    { -- Strong Health potions
                        chance = 30,
                        item = 7588,
                        random = true,
                        amount = 100
                    },
                    { -- Strong Mana potions
                        chance = 30,
                        item = 7589,
                        random = true,
                        amount = 100
                    },
                    { -- Guardian Axe
                        chance = 3,
                        item = 15454,
                        random = true,
                        amount = 1
                    },
                    { -- Pair of Iron Fists
                        chance = 3,
                        item = 20108,
                        random = true,
                        amount = 1
                    },
                    { -- Ornate Crossbow
                        chance = 3,
                        item = 15644,
                        random = true,
                        amount = 1
                    },
                    { -- Royal Helmet
                        chance = 7,
                        item = 2498,
                        random = true,
                        amount = 1
                    },
                    { -- Underworld Rod
                        chance = 3,
                        item = 8910,
                        random = true,
                        amount = 1
                    },
                    { -- Wand of Voodoo
                        chance = 3,
                        item = 8922,
                        random = true,
                        amount = 1
                    },
                    { -- Thaian Sword
                        chance = 3,
                        item = 7391,
                        random = true,
                        amount = 1
                    },
                    { -- Boots of Haste
                        chance = 5,
                        item = 2195,
                        amount = 1
                    }
                },
                [CURSED_CHESTS_TIER_EPIC] = {
                    { -- Platinum Coins
                        chance = 100,
                        item = 2152,
                        random = true,
                        amount = 100
                    },
                    { -- Crystal Coins
                        chance = 20,
                        random = true,
                        item = 2160,
                        amount = 15
                    },
                    { -- Great Mana Potion
                        chance = 30,
                        random = true,
                        item = 7590,
                        amount = 100
                    },
                    { -- Great Health Potion
                        chance = 30,
                        random = true,
                        item = 7591,
                        amount = 100
                    },
                    { -- Glooth Axe
                        chance = 3,
                        random = true,
                        item = 23551,
                        amount = 1
                    },
                    { -- Glooth Blade
                        chance = 3,
                        random = true,
                        item = 23550,
                        amount = 1
                    },
                    { -- Glooth Club
                        chance = 3,
                        random = true,
                        item = 23549,
                        amount = 1
                    },
                    { -- Arbalest
                        chance = 3,
                        random = true,
                        item = 5803,
                        amount = 1
                    },                 
                    { -- Pirate Boots
                        chance = 3,
                        random = true,
                        item = 5462,
                        amount = 1
                    },                 
                    { -- Helmet of the Ancients
                        chance = 3,
                        random = true,
                        item = 2342,
                        amount = 1
                    },                 
                    { -- Wand of Defiance
                        chance = 3,
                        random = true,
                        item = 18390,
                        amount = 1
                    },             
                    { -- Muck Rod
                        chance = 3,
                        random = true,
                        item = 18411,
                        amount = 1
                    } 
                },
                [CURSED_CHESTS_TIER_LEGENDARY] = {
                    { -- Platinum Coins
                        chance = 100,
                        item = 2152,
                        random = true,
                        amount = 300
                    },
                    { -- Ultimate Health Potion
                        chance = 100,
                        item = 8473,
                        random = true,
                        amount = 300
                    },         
                    { -- Great spirit potion
                        chance = 100,
                        item = 8472,
                        random = true,
                        amount = 300
                    },
                    { -- Demonwing Axe
                        chance = 3,
                        item = 8926,
                        random = true,
                        amount = 3
                    },         
                    { -- Hammer of Prophecy
                        chance = 3,
                        item = 7450,
                        random = true,
                        amount = 3
                    },             
                    { -- Warlord Sword
                        chance = 3,
                        item = 2408,
                        random = true,
                        amount = 3
                    },
                    { -- Boots of Haste
                        chance = 3,
                        item = 2195,
                        amount = 3
                    },             
                    { -- Umbral Crossbow
                        chance = 3,
                        item = 22420,
                        random = true,
                        amount = 3
                    },
                    { -- Amulet of Loss
                        chance = 7,
                        item = 2173,
                        random = true,
                        amount = 10
                    },
                    { -- Sudden Death Rune
                        chance = 10,
                        item = 2268,
                        random = true,
                        amount = 300
                    },
                    { -- Crystal Coins
                        chance = 70,
                        item = 2160,
                        random = true,
                        amount = 60
                    }
                }
            },
            waves = {
                [CURSED_CHESTS_TIER_COMMON] = {
                    { -- Wave 1
                        "Goblin",
                        "Snake",
                        "Troll",
                        "Wasp",
                        "Poison Spider"
                    },
                    { -- Wave 2
                        "Amazon",
                        "Nomad",
                        "Valkyrie",
                        "Bandit",
                        "Assassin",
                        "Wild Warrior"
                    },
                    { -- Wave 3
                        "Dwarf Guard",
                        "Minotaur Guard",
                        "Scarab",
                        "Slime",
                        "Tarantula"
                    },
                    { -- Wave 4
                        "Stone Golem",
                        "Cyclops Drone",
                        "Cyclops",
                        "Cyclops Smith",
                        "Frost Giant"
                    }
                },
                [CURSED_CHESTS_TIER_RARE] = {
                    { -- Wave 1
                        "Orc Berserker",
                        "Orc Marauder",
                        "Dragon Hatchling",
                        "Wilting Leaf Golem",
                        "Haunted Treeling"
                    },
                    { -- Wave 2
                        "Vampire",
                        "Zombie",
                        "Water Elemental",
                        "Mutated Rat",
                        "Necromancer"
                    },
                    { -- Wave 3
                        "Ice Witch",
                        "Grave Guard",
                        "Wyvern",
                        "Frost Dragon Hatchling",
                        "Lich"
                    },
                    { -- Wave 4
                        "Yeti",
                        "Dragon",
                        "Earth Elemental",
                        "Elder Bonelord",
                        "Energy Elemental"
                    }
                },
                [CURSED_CHESTS_TIER_EPIC] = {
                    { -- Wave 1
                        "Ancient Scarab",
                        "orc Warlord",
                        "Mutated Bat",
                        "Undead Gladiator",
                        "Banshee"
                    },
                    { -- Wave 2
                        "Mutated Tiger",
                        "Vampire Bride",
                        "Giant Spider",
                        "Nightstalker",
                        "Bonebeast"
                    },
                    { -- Wave 3
                        "Vampire Viscount",
                        "Braindeath",
                        "Crystal Spider",
                        "Brimstone Bug",
                        "Bog Raider"
                    },
                    { -- Wave 4
                        "Lizard Legionnaire",
                        "Frost Dragon",
                        "Wyrm",
                        "Hydra",
                        "Crawler"
                    }
                },
                [CURSED_CHESTS_TIER_LEGENDARY] = {
                    { -- Wave 1
                        "Fire Devil",
                        "Gozzler",
                        "Nightstalker"
                    },
                    { -- Wave 2
                        "Fire Devil",
                        "Gozzler",
                        "Nightstalker",
                        "Diabolic Imp"
                    },
                    { -- Wave 3
                        "Fire Devil",
                        "Gozzler",
                        "Nightstalker",
                        "Diabolic Imp",
                        "Nightmare"
                    },
                    { -- Wave 4
                        "Fire Devil",
                        "Nightstalker",
                        "Diabolic Imp",
                        "Nightmare",
                        "Frazzlemaw"
                    }
                }
            },
        }
}

PS: LEGENDARY Tables not finish yet.
 
not giving the final reward

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/cursed_chests.lua:onDeath
data/actions/scripts/cursed_chest.lua:413: attempt to call method 'getEmptySlots' (a nil value)
stack traceback:
    [C]: in function 'getEmptySlots'
    data/actions/scripts/cursed_chest.lua:413: in function 'FinishCursedChestEvent'
    data/actions/scripts/cursed_chest.lua:491: in function <data/actions/scripts/cursed_chest.lua:479>
    (...tail calls...)
 
Can something be added for only the first player who "opened" can take the loot at the end. and if the player dies reset the chest?

@oen432
 
Can something be added for only the first player who "opened" can take the loot at the end. and if the player dies reset the chest?

@oen432
  • If player is not in a party and activates the chest, only he is able to open that chest
  • If player is in a party and activates the chest, only he and party members are able to open that chest
 
in test today, players not in party are able to open chest
 
not giving the final reward

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/cursed_chests.lua:onDeath
data/actions/scripts/cursed_chest.lua:413: attempt to call method 'getEmptySlots' (a nil value)
stack traceback:
    [C]: in function 'getEmptySlots'
    data/actions/scripts/cursed_chest.lua:413: in function 'FinishCursedChestEvent'
    data/actions/scripts/cursed_chest.lua:491: in function <data/actions/scripts/cursed_chest.lua:479>
    (...tail calls...)
bump
 
was doing a test i removed the chest and ...
Code:
[New Thread 0x7ffff3ee3700 (LWP 31599)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff4ee5700 (LWP 31596)]
0x0000000000525c65 in LuaScriptInterface::luaItemGetPosition (L=0x9f3e70)
    at /home/servidor/tfs/src/luascript.cpp:6236
6236            pushPosition(L, item->getPosition());
Saving server...
[QUOTE] Saved house items in: 0.378 s[/QUOTE]
#0  0x0000000000525c65 in LuaScriptInterface::luaItemGetPosition (L=0x9f3e70)
    at /home/servidor/tfs/src/luascript.cpp:6236
        item = <optimized out>
#1  0x00007ffff7672c3d in ?? () from /usr/lib/x86_64-linux-gnu/liblua5.2.so.0
No symbol table info available.
#2  0x00007ffff767e59d in ?? () from /usr/lib/x86_64-linux-gnu/liblua5.2.so.0
No symbol table info available.
#3  0x00007ffff7672fa8 in ?? () from /usr/lib/x86_64-linux-gnu/liblua5.2.so.0
No symbol table info available.
#4  0x00007ffff76725bf in ?? () from /usr/lib/x86_64-linux-gnu/liblua5.2.so.0
No symbol table info available.
#5  0x00007ffff7673201 in ?? () from /usr/lib/x86_64-linux-gnu/liblua5.2.so.0
No symbol table info available.
#6  0x00007ffff766f186 in lua_pcallk ()
   from /usr/lib/x86_64-linux-gnu/liblua5.2.so.0
No symbol table info available.
#7  0x000000000051738c in LuaScriptInterface::protectedCall (L=0x9f3e70,
    nargs=nargs@entry=1, nresults=nresults@entry=1)
    at /home/servidor/tfs/src/luascript.cpp:287
        error_index = 5
        ret = <optimized out>
#8  0x00000000005aa42b in LuaScriptInterface::callFunction (
    this=this@entry=0x8ecdc0 <g_luaEnvironment>, params=1)
    at /home/servidor/tfs/src/luascript.cpp:511
        result = false
        size = 6
#9  0x00000000005aba34 in LuaEnvironment::executeTimerEvent (
    this=0x8ecdc0 <g_luaEnvironment>, eventIndex=568752)
    at /home/servidor/tfs/src/luascript.cpp:13851
        it = <optimized out>
        timerEventDesc = {scriptId = 1017, function = 456,
          parameters = std::list = {[0] = 1147}, eventId = 136627863}
#10 0x000000000063ebd7 in operator() (this=0x7ffe93be3150)
    at /usr/include/c++/4.9/functional:2439
No locals.
#11 operator() (this=0x7ffe93be3140) at /home/servidor/tfs/src/tasks.h:40
No locals.
#12 Dispatcher::threadMain (this=0x8edf00 <g_dispatcher>)
    at /home/servidor/tfs/src/tasks.cpp:60
        task = 0x7ffe93be3140
        taskLockUnique = {_M_device = 0x8edf18 <g_dispatcher+24>,
          _M_owns = false}
#13 0x00007ffff6921990 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#14 0x00007ffff6b7e064 in start_thread (arg=0x7ffff4ee5700)
    at pthread_create.c:309
        __res = <optimized out>
        pd = 0x7ffff4ee5700
        now = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140737302648576,
                6014126824752513590, 1, 140737354125408, 140737488347056,
                140737302648576, -6014115680901299658, -6014111912636218826},
              mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0},
            data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        [B]PRETTY_FUNCTION[/B] = "start_thread"
#15 0x00007ffff609162d in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
No locals.
 
Back
Top