damian00912
Member
- Joined
- Sep 11, 2009
- Messages
- 90
- Reaction score
- 6
Hallo! I have script for extra drop from every monsters, and it's item with id xxxx and have 5% chance to drop from every monsters, but players write me about it's not true, and that weak monsters have a greater drop of this item, and stronger monsters have less of these items, can someone experienced please comment?
Thanks you!
Lua:
math.randomseed(os.time())
local extra_loot = {
{items = {
{id = 40407, chance = 5000}
}}
}
local extra_loot_d = CreatureEvent("extra_loot_d")
function Container:addExtraLoot(c, t)
if t.hasName then
local cn = c:getName():lower()
local cm = t.hasName:lower()
if not cn:match(cm) then
return true
end
end
for i = 1, #t.items do
local count = 1
if t.items[i].count then
if t.items[i].countMax then
count = math.random(t.items[i].count, t.items[i].countMax)
else
count = t.items[i].count
end
else
if t.items[i].countMax then
count = math.random(1, t.items[i].countMax)
end
end
if math.random(0, 100000) <= t.items[i].chance then
self:addItem(t.items[i].id, count)
end
end
end
function extra_loot_d.onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
if not creature:isMonster() then
return true
end
if creature:getMaster() then
return true
end
if corpse then
local itemType = corpse:getType()
if itemType:isCorpse() and itemType:isContainer() then
for i = 1, #extra_loot do
corpse:addExtraLoot(creature, extra_loot[i])
end
end
return true
end
end
extra_loot_d:register()
Thanks you!