• 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 Way to make monster drop loot? TFS 0.1

8674011

New Member
Joined
Jun 21, 2010
Messages
160
Reaction score
3
Location
The House
In a creature script I want it to make a creature drop an extra loot.

Just the line, or method of getting the creature's body and adding the loot to it would suffice.
 
Code:
<loot>
        <item id="2148" countmax="40" chance="100000"/><!-- gold coin -->
        <item id="5883" chance="1000"/><!-- ape fur -->
        <item id="1987" chance="100000"><!-- bag -->
            <inside>
                <item id="2676" countmax="11" chance="5000"/><!-- banana -->
                <item id="2200" chance="2000"/><!-- protection amulet -->
                <item id="2209" chance="3857"/><!-- club ring -->
                <item id="2166" chance="1529"/><!-- power ring -->
                <item id="2463" chance="1667"/><!-- plate armor -->
                <item id="7618" chance="1467"/><!-- health potion -->
            </inside>
        </item>
    </loot>

This is from Kongra, you can change to whatever you want.

Just add <loot> and that is it.
 
I think he is talking about a thing like the color of magic world change, during a certin time some monsters drop a letter.
Would be a big waste of time to add & remove that when the event starts / ends. Have no ide if there is any, but would like to know aswell.

Maybe @Mark could tell us / if its on the todo list.
 
Code:
<loot>
        <item id="2148" countmax="40" chance="100000"/><!-- gold coin -->
        <item id="5883" chance="1000"/><!-- ape fur -->
        <item id="1987" chance="100000"><!-- bag -->
            <inside>
                <item id="2676" countmax="11" chance="5000"/><!-- banana -->
                <item id="2200" chance="2000"/><!-- protection amulet -->
                <item id="2209" chance="3857"/><!-- club ring -->
                <item id="2166" chance="1529"/><!-- power ring -->
                <item id="2463" chance="1667"/><!-- plate armor -->
                <item id="7618" chance="1467"/><!-- health potion -->
            </inside>
        </item>
    </loot>

This is from Kongra, you can change to whatever you want.

Just add <loot> and that is it.
I think he is talking about a thing like the color of magic world change, during a certin time some monsters drop a letter.
Would be a big waste of time to add & remove that when the event starts / ends. Have no ide if there is any, but would like to know aswell.

Maybe @Mark could tell us / if its on the todo list.

Thanks for trying guys, and I meant like if I were to kill a monster, is there a line of code that I could add another loot item, BESIDES the ones that they drop before.
 
Isent that what I said? :p
Except the certin time of a year, like a addMonsterDrop(item) function?
 
O, I got it! Something like doPlayerAddItem(cid,idnumber,1)

Post your script dear fellow member, that way we all help each other :)
 
Code:
local config = {
    ["dragon"] = {2160, 1},
    ["dragon lord"] = {2195, 1}
}

function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    local monster = Monster(cid)
    local target = config[monster:getName():lower()]
    if not target then
        return true
    end
  
    Container(corpse):addItem(target[1], target[2])
    return true
end

Don't forget to register the event.
 
Code:
local config = {
    ["dragon"] = {2160, 1},
    ["dragon lord"] = {2195, 1}
}

function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    local monster = Monster(cid)
    local target = config[monster:getName():lower()]
    if not target then
        return true
    end
 
    Container(corpse):addItem(target[1], target[2])
    return true
end

Don't forget to register the event.

what about adding a chance (from 0 to 100) to each creature? :D
 
what about adding a chance (from 0 to 100) to each creature? :D
Code:
local config = {
    ["dragon"] = {chance = 10, itemid = 2160, count = 1},
    ["dragon lord"] = {chance = 3, itemid = 2195, count = 1}
}

function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    local monster = Monster(cid)
    local targetName = config[monster:getName():lower()]
    if not targetName then
        return true
    end
   
    local rand = math.random(100)
    if rand <= targetName["chance"] then
        Container(corpse):addItem(targetName["itemid"], targetName["count"])
    end
end
 
Back
Top