• 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 Corpse = chest with uid

erikbs

Member
Joined
Jul 15, 2010
Messages
40
Reaction score
8
Hi there fellow Otlanders. :)

I have an idea for my server but Iam not sure how to go about this.
The idea is that a group of players can kill a boss together, the boss either drops a chest with uid, or the corpse of the boss is a chest with uid.
Then the chest has to have a storage so each player can only loot the chest once, and a timer for when that storage is removed so that a player group can hunt that boss again when it spawns again.

Can someone help me with this?
Is it possible to add a uid to the chest within the item.lua script for example?


Hope for a positive response <3

Erik
 
Solution
Imo, best idea is to make it a revscript, so you can have all the scripts in one file.

In your monster xml. register a script like below (The usual place for these are below the flags, but it doesn't matter where its placed as long as its a child of monster):
XML:
<script>
    <event name="ChestBossDeath"/>
</script>

Then you can create a file called chestBoss.lua, in data/scripts/
and inside it would look something like this (untested):

Lua:
local chestBossAID = 4598
local chestBossStorage = 3482
local chestBossMinutes = 120

local creatureevent = CreatureEvent("ChestBossDeath")
function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    corpse:setActionId(chestBossAID)...
Kinda cool idea
TFS version?
Yes I thought so too :D hehe

TFS: 1.4.2

Client: 10.98
Post automatically merged:

Here is a couple of screenshots of a test Boss which turns into a chest when killed.
The idea as mentioned above is that EVERY player can loot that chest once before the chest disappears. (now the chest is added as the monsters corpse with a decay to "0").

When the Boss spawns again (lets say in 2 hours) the storage from the chest will be reset (timer) so that the same players can loot the chest with the same storage again and again and again but only once pr chest. :)
 

Attachments

Last edited:
Yes I thought so too :D hehe

TFS: 1.4.2

Client: 10.98
Post automatically merged:

Here is a couple of screenshots of a test Boss which turns into a chest when killed.
The idea as mentioned above is that EVERY player can loot that chest once before the chest disappears. (now the chest is added as the monsters corpse with a decay to "0").

When the Boss spawns again (lets say in 2 hours) the storage from the chest will be reset (timer) so that the same players can loot the chest with the same storage again and again and again but only once pr chest. :)
What game is this? It's different from Tibia, and it looks great. Congratulations on your project!
 
Yes I thought so too :D hehe

TFS: 1.4.2

Client: 10.98
Post automatically merged:

Here is a couple of screenshots of a test Boss which turns into a chest when killed.
The idea as mentioned above is that EVERY player can loot that chest once before the chest disappears. (now the chest is added as the monsters corpse with a decay to "0").

When the Boss spawns again (lets say in 2 hours) the storage from the chest will be reset (timer) so that the same players can loot the chest with the same storage again and again and again but only once pr chest. :)
Just use the onDeath event, the second parameter that is passed is the corpse, so you can just call corpse:setUniqueId(uid) on it.

As for the rest of the mechanics, you can then just call an onUse event on the chest(with the uid), and dish out loot that way, and just store the lastTime in a player storage.
 
What game is this? It's different from Tibia, and it looks great. Congratulations on your project!
Thanks man :) yeah I wanted to make all my own graphic, but easy and limited enough so that I can see progress everything iam able to sit down and do a little work :)
Post automatically merged:

Just use the onDeath event, the second parameter that is passed is the corpse, so you can just call corpse:setUniqueId(uid) on it.

As for the rest of the mechanics, you can then just call an onUse event on the chest(with the uid), and dish out loot that way, and just store the lastTime in a player storage.
I have to learn how to do this :)

The "chest part" I already have, like the ramdon loot when opening the chest.

Need to do some research.
Feel free to help if you got the time and motivation 🤣🍻
 

Attachments

Imo, best idea is to make it a revscript, so you can have all the scripts in one file.

In your monster xml. register a script like below (The usual place for these are below the flags, but it doesn't matter where its placed as long as its a child of monster):
XML:
<script>
    <event name="ChestBossDeath"/>
</script>

Then you can create a file called chestBoss.lua, in data/scripts/
and inside it would look something like this (untested):

Lua:
local chestBossAID = 4598
local chestBossStorage = 3482
local chestBossMinutes = 120

local creatureevent = CreatureEvent("ChestBossDeath")
function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    corpse:setActionId(chestBossAID)
    return true
end
creatureevent:register()

local action = Action()
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)

    local timeNow = os.time()
    local chestBossTimestamp = player:getStorageValue(chestBossStorage)
    if timeNow < chestBossTimestamp then
        player:sendTextMessage(
            MESSAGE_EVENT_ADVANCE,
            string.format(
                "You need to wait %d minutes before you can loot this chest again.",
                math.ceil((chestBossTimestamp - timeNow) / 60)
            )
        )
    end
 
    player:setStorageValue(chestBossStorage, timeNow + chestBossMinutes * 60)

    --put your loot code here
 
    return true
end
action:aid(chestBossAID)
action:register()
 
Solution
Back
Top