So I've found some piece of code from Erikas Kontenis : http://otland.net/f82/special-bonus-loot-storage-155952/
That will let us add loot to body. Tested it work.
What I want is to add custom attributes to the items ( that include changing the base attack, base defence, base armor and description )
I tried by using this code
It's supposed to make rat drop an Ice Rapier that have between 10 and 20 base attack but with this code I don't receive any item... no error code at all.
That will let us add loot to body. Tested it work.
What I want is to add custom attributes to the items ( that include changing the base attack, base defence, base armor and description )
I tried by using this code
Code:
local monsters = {
["demon"] = {item = 2160, count = 2, chance = 70},
["rat"] = {item = 2396, count = 1, chance = 100}
}
function onKill(cid, target, lastHit)
local v = getMonsterInfo(getCreatureName(target)).lookCorpse
local chance = math.random(1, 100)
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
local newStats = (math.random(10, 20))
local item = doCreateItemEx(a.item)
doItemSetAttribute(item, 'attack', newStats)
doAddContainerItem(corpse, item)
end
addEvent(dropLoot, 0, getThingPos(target), v,cid)
end
end
end
return true
end
It's supposed to make rat drop an Ice Rapier that have between 10 and 20 base attack but with this code I don't receive any item... no error code at all.