E
Evil Puncker
Guest
if monster drop any item of the table (I'd like to use item names, but ID is fine too), it will MULTIPLY it by the random amount between min and max count chance, lets say a chicken dropped 2 chicken feathers, when I open the corpse there will be the amount of [formula(2 MULTIPLIED BY random 2 to 50 from the table bonus)] (probability to drop from 4 to 100 chicken feathers)(0 if no chicken feather dropped), thanks in advanced! I even tried to make it with some other code but no success ![Stick Out Tongue :p :p](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
I'm using TFS 1.3 latest
I'm using TFS 1.3 latest
Lua:
-- pseudo table
local config = {
[1] = {itemname = "chicken feather", rate = {2, 50}},
[2] = {itemname = "soul orb", rate = {1, 5}}
}
local function scanContainer(cid, position)
local player = Player(cid)
if not player then
return
end
local corpse = Tile(position):getTopDownItem()
if not corpse or not corpse:isContainer() then
return
end
if corpse:getType():isCorpse() and corpse:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == cid then
for a = corpse:getSize() - 1, 0, -1 do
local containerItem = corpse:getItem(a)
if containerItem then
if player then
-- pseudo code start
if isItemStackable(containerItem:getId()) then
local targetName = config[ItemType(name):getId()]
local rate = math.random(table values between {x and y})
if not targetName then
return true
end
Container(corpse):addItem(ItemType("itemname"):getId()[], droppedItemCount * rate)
end
-- pseudo code end
end
end
end
end
end
function onKill(player, target)
if not target:isMonster() then
return true
end
addEvent(scanContainer, 10, player:getId(), target:getPosition())
return true
end
Last edited by a moderator: