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

Solved Is this possible?

Hatsune Miku

Intermediate OT User
Joined
Jan 22, 2009
Messages
370
Reaction score
139
I am making a very hard boss.. There is a team required to kill it because it will heal 10% of its health every second. So I was planning to make it drop something on a 100% rate.. but only 1 item.

So if a team of 1 knight 2 healers. 2 mages and 2 archers go to kill the boss.. It will drop 1 or 2 items.. Not more. Not less, and the item will be selected out of a table I crate.. For example.. Magic Sword/SCA/Thunder Hammer/Arbalest or a wand.


TL;DR

Is it possbile to make monsters drop items at 100% rate but a maximum of 1? I got a boss that drops a range of weapons and I only want it to drop 1 at a time.
 
You can try this creaturescript.

Code:
local monsters = {
    ["boss one"] = {item = 9933, count = 1, chance = 10}
}

function onKill(cid, target, lastHit)
    local storage = 7474
    local v = getMonsterInfo(getCreatureName(target)).lookCorpse
    local chance = math.random(100)
    local sayLoot = 1

    if getCreatureStorage(cid, storage) == 1 then
        for k, a in pairs(monsters) do
            if (isMonster(target) and ((string.lower(getCreatureName(target))) == k)) then
                if a.chance >= chance then
                    local function dropLoot(pos, v, cid)
                        local corpse = getTileItemById(pos, v).uid
                        doAddContainerItem(corpse, a.item, math.random(1, a.count))
                        doCreatureSetStorage(cid, storage, (getCreatureStorage(cid, storage) + 1))
                        if sayLoot == 1 then
                            doCreatureSay(cid, "You have found " .. getItemInfo(a.item).name .. " in the creature's body.", TALKTYPE_MONSTER)
                        end
                    end           
                    addEvent(dropLoot, 0, getThingPos(target), v,cid)
                end
            end
        end
    end
    return true
end

It will take some editing though.
I do not take credit for this script. I did not make it and I'm blanking on who made it.
Red
 
Not sure how that works... Sorry for being a total noob :p I'm asuming the ["boss one"] should be my boss name so ["Lucifer"] But I can only add 1 loot to that it seems... My boss drops like 5 weapons....

Idk how I should edit that script tbh.. infact I don't even know what I should add it as in Creaturescripts.xml xD

Quick Edit: I'm using TFS 0.3.6
http://otland.net/threads/8-60-the-forgotten-server-0-3-6-crying-damson-v8.147913/
 
creaturescripts.xml:
Code:
    <event type="death" name="BossLoot" event="script" value="bossloot.lua"/>

The sum of all chances should be 1000 or atleast close to it or it might not be working as intended.
msg is send to all players who attacked the creature. |MONSTERNAME| is replaced with creature's name by the script.

creaturescripts/scripts/bossLoot.lua:

Code:
local config = {
    ["Chicken"] = {
        loot = {
            {id = 5803, count = 1, chance = 600},
            {id = 2421, count = 1, chance = 200},
            {id = 2431, count = 1, chance = 200}, 
        },
        msg = "It seems like |MONSTERNAME| dropped a rarity."
    }
}

function onDeath(cid, corpse, deathList)
    for name, c in pairs(config) do
        if getCreatureName(cid):lower() == name:lower() then
            local r, tmpChance = math.random(1000), 0
          
            for i = 1, #c.loot do
                local nextChance = tmpChance + c.loot[i].chance
                if r > tmpChance and r <= nextChance then
                    doAddContainerItem(corpse.uid, c.loot[i].id, c.loot[i].count)
                    break
                end
                tmpChance = nextChance
            end
              
            local msg = c.msg:gsub("|MONSTERNAME|", getCreatureName(cid))
            for _, pid in pairs(deathList) do
                if isPlayer(pid) then
                    doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, msg)
                end
            end
            return true
        end
    end
    print(string.format("[%s] is register for Boss Loot system, but has no config data.", getCreatureName(cid)))
    return true
end

In your monster file add:
Code:
    <script>
        <event name="BossLoot"/>
    </script>
after:
Code:
    </loot>
 
work like a charm :D thanks xD

Also can you make it so it broadcasts the killer names?
Example:
Code:
Summ and Derp killed Chicken
xD
 
Last edited:
Try
Code:
local config = {
    ["Chicken"] = {
        loot = {
            {id = 5803, count = 1, chance = 600},
            {id = 2421, count = 1, chance = 200},
            {id = 2431, count = 1, chance = 200}, 
        },
        msg = "It seems like |MONSTERNAME| dropped a rarity."
    }
}

function onDeath(cid, corpse, deathList)
    for name, c in pairs(config) do
        if getCreatureName(cid):lower() == name:lower() then
            local r, tmpChance = math.random(1000), 0
         
            for i = 1, #c.loot do
                local nextChance = tmpChance + c.loot[i].chance
                if r > tmpChance and r <= nextChance then
                    doAddContainerItem(corpse.uid, c.loot[i].id, c.loot[i].count)
                    break
                end
                tmpChance = nextChance
            end
             
            local players = {}
            local msg = c.msg:gsub("|MONSTERNAME|", getCreatureName(cid))
            for _, pid in pairs(deathList) do
                if isPlayer(pid) then
                    doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, msg)
                    table.insert(players, getCreatureName(pid))
                end
            end
           
            doBroadcastMessage(table.concat(players, ", "):reverse():gsub(",", "dna ", 1):reverse())
            return true
        end
    end
    print(string.format("[%s] is register for Boss Loot system, but has no config data.", getCreatureName(cid)))
    return true
end
 
Back
Top Bottom