• 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 Diablo loot script help

newby

Active Member
Joined
Jun 11, 2016
Messages
183
Reaction score
43
Did I forgotten something?
I'm trying to use this script (from: https://otland.net/threads/mod-random-item-stats.130295/)

/mods/DiabloLoot.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Random Item Stats" enabled="1">
<config name="itemstats_conf"><![CDATA[
-- //
extra_loot_key = 123 --: optional storage for higher loot rate
vocation_base_attackspeed = getVocationInfo(1).attackSpeed --: used for attackSpeed stat
-- //

tiers, attr = {}, {}

tiers['rare'] = {
color = 66, -- color of 'RARE' text
extra = {0, 0},
attrNames = true, -- show attribute names instead of rare
chance = {
[1] = 10000,
[2] = 5000 -- chance for 2nd stat
}
}
tiers['epic'] = {
color = 35,
extra = {7, 20}, -- additional percent bonus
chance = {
[1] = 3333,
[2] = 25000
}
}
tiers['legendary'] = {
color = 149,
extra = {20, 35},
chance = {
[1] = 1000,
[2] = 100000 -- 2 bonuses always
}
}

MELEE = 0
DISTANCE = 1
ARMOR = 2
SHIELD = 3
WAND = 4
DURATION_RING = 5
CHARGES = 6

--! attributes
attr['quick'] = {
attr = 'attackSpeed',
name = 'Attack Speed',
percent = {6, 20},
types = {MELEE, DISTANCE, WAND}
}
attr['fortified'] = {
attr = 'extraDefense',
base = 'defense',
name = 'Defense',
percent = {7, 25},
types = {MELEE, SHIELD}
}
attr['deadly'] = {
attr = 'extraAttack',
base = 'attack',
name = 'Attack',
types = {MELEE},
percent = {7, 25}
}
attr['strong'] = {
attr = 'armor',
name = 'Armor',
percent = {7, 20},
types = {ARMOR}
}
attr['hawkeye\'s'] = {
attr = 'hitChance',
name = 'Hit Chance',
percent = {10, 25},
types = {DISTANCE}
}
--[[ // not available without source edit
attr['farsight'] = {
attr = 'shootRange',
name = 'Shoot Range',
percent = {17, 34},
types = {DISTANCE, WAND}
}
]]
attr['charged'] = {
attr = 'charges',
name = 'Charges',
percent = {30, 45},
types = {CHARGES}
}
attr['divine'] = {
attr = 'duration',
name = 'Duration',
percent = {35, 50},
types = {DURATION_RING}
}
--/ attributes

rate = getConfigInfo('rateLoot')

if( getConfigInfo('monsterLootMessage') ~= 0 )then
print('[Notice] Set monsterLootMessage = 0 to prevent duplicate loot messages')
end
]]></config>

<event type="kill" name="itemstats" event="script"><![CDATA[
domodlib('itemstats_conf')

function round(n, s)
return tonumber(('%.' .. (s or 0) .. 'f'):format(n))
end

function getContentDescription(uid, sep)
local ret, i, containers = '', 0, {}
while( i < getContainerSize(uid) )do
local v, s = getContainerItem(uid, i), ''
local k = getItemInfo(v.itemid)
k.name = getItemAttribute(v.uid, 'name') or k.name
if( k.name ~= '' )then
if( v.type > 1 and k.stackable and k.showCount )then
s = v.type .. ' ' .. k.plural
else
local article = getItemAttribute(v.uid, 'article') or k.article
s = (article == '' and '' or article .. ' ') .. k.name
end
ret = ret .. (i == 0 and not sep and '' or ', ') .. s
if( isContainer(v.uid) and getContainerSize(v.uid) ~= 0 )then
table.insert(containers, v.uid)
end
else
ret = ret .. (i == 0 and not sep and '' or ', ') .. 'an item of type ' .. v.itemid .. ', please report it to gamemaster'
end
i = i + 1
end
for i = 1, #containers do
ret = ret .. getContentDescription(containers, true)
end
return ret
end

local function send(cid, corpse, monster)
if( isPlayer(cid) )then
local ret = corpse and isContainer(corpse) and getContentDescription(corpse)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'))
local party = getPlayerParty(cid)
if( party )then
for _, pid in ipairs(getPartyMembers(party)) do
doPlayerSendChannelMessage(pid, '', 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'), TALKTYPE_CHANNEL_W, CHANNEL_PARTY)
end
end
end
end

local function createLoot(i, ext)
local item = type(i.id) == 'table' and i.id[math.random(#i.id)] or i.id
local random = math.ceil(math.random(100000) / ext)
local tmpItem, f

if( random < i.chance )then
if i.subType == -1 then
f = getItemInfo(item)
end
tmpItem = doCreateItemEx(item,
i.subType ~= -1 and i.subType or
f.stackable and random % i.count + 1 or
f.charges ~= 0 and f.charges or
1
)
end

if( not tmpItem )then
return
end

if( i.actionId ~= -1 )then
doItemSetAttribute(tmpItem, 'aid', i.actionId)
end

if( i.uniqueId ~= -1 )then
doItemSetAttribute(tmpItem, 'uid', i.uniqueId)
end

if( i.text ~= '' )then
doItemSetAttribute(tmpItem, 'text', i.text)
end

local ret, done

for k, v in pairs(tiers) do
local cur, used = {}, {}
for i = 1, #v.chance do
if( math.random(100000) <= v.chance )then
if( f )then
f = getItemInfo(item)
end
if( not f.stackable )then
for m, n in pairs(attr) do
if( not table.find(used, m) and
(
( table.find(n.types, MELEE) and table.find({WEAPON_SWORD, WEAPON_CLUB, WEAPON_AXE}, f.weaponType) ) or
( table.find(n.types, DISTANCE) and f.weaponType == WEAPON_DIST and f.ammoType ~= 0 ) or
( table.find(n.types, ARMOR) and f.armor ~= 0 and f.wieldPosition ~= CONST_SLOT_NECKLACE ) or
( table.find(n.types, SHIELD) and f.defense ~= 0 and f.weaponType == WEAPON_SHIELD ) or
( table.find(n.types, WAND) and f.weaponType == WEAPON_WAND ) or
( table.find(n.types, DURATION_RING) and f.wieldPosition == CONST_SLOT_RING and f.transformEquipTo ~= 0 ) or
( table.find(n.types, CHARGES) and table.find({CONST_SLOT_RING, CONST_SLOT_NECKLACE}, f.wieldPosition) and f.charges ~= 0 )
) )then
table.insert(cur, m)
end
end

if( #cur ~= 0 )then
local n = cur[math.random(#cur)]
table.insert(used, n)

n = attr[n]
local percent, new, tmp = math.random(n.percent[1] + (v.extra[1] or 0), n.percent[2] + (v.extra[2] or 0))
-- hacks
if( n.attr == 'duration' )then
tmp = getItemInfo(f.transformEquipTo)
if tmp.transformDeEquipTo ~= item then
break
end
new = round( tmp.decayTime * (1 + percent / 100) * 1000 )
elseif( n.attr == 'attackSpeed' )then
new = round( vocation_base_attackspeed / (1 + percent / 100) )
elseif( n.attr == 'hitChance' ) then
new = round(
f.hitChance == -1 and
percent
or
f.hitChance * (1 + percent / 100)
)
else
new = round(
n.base and
f[n['attr']] + f[n['base']] * (percent / 100)
or
f[n['attr']] * (1 + percent / 100)
)

if( new == f[n[n.base and 'base' or 'attr']] )then -- no improvement
break
end
end

doItemSetAttribute(tmpItem, n.attr:lower(), new)

local name = getItemAttribute(tmpItem, 'name')
if( v.attrNames or not name )then
local name = (v.attrNames and used[#used] or k) .. ' ' .. (name or f.name)
doItemSetAttribute(tmpItem, 'name', name)

if( f.article ~= '' )then
local article = getArticle(name)
if( article ~= f.article )then
doItemSetAttribute(tmpItem, 'article', article)
end
end
end

local desc = getItemAttribute(tmpItem, 'description') or f.description
doItemSetAttribute(tmpItem, 'description', '[' .. n.name .. ': +' .. percent .. '%]' .. (desc == '' and '' or '\n' .. desc))

ret = k
end
cur = {}
if( #v.chance == i )then
done = true
end
end
else
done = i ~= 1
break
end
end
if( done )then
break
end
end

return tmpItem, ret
end

local function createChildLoot(parent, i, ext, pos)
if( not i or #i == 0 )then
return true
end

local size, cap = 0, getContainerCap(parent)
for k = 1, #i do
if( size == cap )then
break
end
local tmp, ret = createLoot(i[k], ext)
if( tmp )then
if( isContainer(tmp) )then
if( createChildLoot(tmp, i[k].child, ext, pos) )then
doAddContainerItemEx(parent, tmp)
size = size + 1
else
doRemoveItem(tmp)
end
else
if( ret )then
doSendMagicEffect(pos, CONST_ME_MAGIC_GREEN)
doSendAnimatedText(pos, ret:upper(), tiers[ret].color)
end
doAddContainerItemEx(parent, tmp)
size = size + 1
end
end
end

return size > 0
end

local function dropLoot(pos, v, ext, master, cid, target)
local corpse
if( not master or master == target )then -- 0.3/4
corpse = getTileItemById(pos, v.lookCorpse).uid
if( isContainer(corpse) )then
for i = 1, getContainerSize(corpse) do
doRemoveItem(getContainerItem(corpse, 0).uid)
end
local size, cap = 0, getContainerCap(corpse)
for i = 1, #v.loot do
if( size == cap )then
break
end
local tmp, ret = createLoot(v.loot, ext)
if( tmp )then
if( isContainer(tmp) )then
if( createChildLoot(tmp, v.loot.child, ext, pos) )then
doAddContainerItemEx(corpse, tmp)
size = size + 1
else
doRemoveItem(tmp)
end
else
if( ret )then
doSendMagicEffect(pos, CONST_ME_MAGIC_GREEN)
doSendAnimatedText(pos, ret:upper(), tiers[ret].color)
end
doAddContainerItemEx(corpse, tmp)
size = size + 1
end
end
end
end
end
send(cid, corpse, v.description)
end

function onKill(cid, target, damage, flags)
if( (damage == true or bit.band(flags, 1) == 1) and isMonster(target) )then -- 0.3/4
local v = getMonsterInfo(getCreatureName(target))
if( v and v.lookCorpse ~= 0 )then
local s = getCreatureStorage(cid, extra_loot_key)
addEvent(dropLoot, 0, getThingPos(target), v, s == -1 and rate or s, getCreatureMaster(target), cid, target)
end
end
return true
end
]]></event>

<event type="login" name="itemstats_login" event="buffer"><![CDATA[
registerCreatureEvent(cid, 'itemstats')
]]></event>

</mod>

But every monster i kill don't drop any loot, and flood it on console:
Code:
[14:50:46.495] [Error - CreatureScript Interface]
[14:50:46.495] In a timer event called from:
[14:50:46.495] domodlib('itemstats_conf')

[14:50:46.495] function round(n, s)
[14:50:46.495] return tonumber(('%.' .. (s or 0) .. 'f'):format(n))
[14:50:46.495] end

[14:50:46.495] function getContentDescription(uid, sep)
[14:50:46.495] local ret, i, containers = '', 0, {}
[14:50:46.495] while( i < getContainerSize(uid) )do
[14:50:46.495] local v, s = getContainerItem(uid, i), ''
[14:50:46.495] local k = getItemInfo(v.itemid)
[14:50:46.495] k.name = getItemAttribute(v.uid, 'name') or k.name
[14:50:46.495] if( k.name ~= '' )then
[14:50:46.495] if( v.type > 1 and k.stackable and k.showCount )then
[14:50:46.495] s = v.type .. ' ' .. k.plural
[14:50:46.495] else
[14:50:46.495] local article = getItemAttribute(v.uid, 'article') or k.article
[14:50:46.495] s = (article == '' and '' or article .. ' ') .. k.name
[14:50:46.496] end
[14:50:46.496] ret = ret .. (i == 0 and not sep and '' or ', ') .. s
[14:50:46.496] if( isContainer(v.uid) and getContainerSize(v.uid) ~= 0 )then
[14:50:46.496] table.insert(containers, v.uid)
[14:50:46.496] end
[14:50:46.496] else
[14:50:46.496] ret = ret .. (i == 0 and not sep and '' or ', ') .. 'an item of type ' .. v.itemid .. ', please report it to gamemaster'
[14:50:46.496] end
[14:50:46.496] i = i + 1
[14:50:46.496] end
[14:50:46.496] for i = 1, #containers do
[14:50:46.496] ret = ret .. getContentDescription(containers, true)
[14:50:46.496] end
[14:50:46.496] return ret
[14:50:46.496] end

[14:50:46.496] local function send(cid, corpse, monster)
[14:50:46.496] if( isPlayer(cid) )then
[14:50:46.496] local ret = corpse and isContainer(corpse) and getContentDescription(corpse)
[14:50:46.496] doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'))
[14:50:46.496] local party = getPlayerParty(cid)
[14:50:46.496] if( party )then
[14:50:46.496] for _, pid in ipairs(getPartyMembers(party)) do
[14:50:46.496] doPlayerSendChannelMessage(pid, '', 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'), TALKTYPE_CHANNEL_W, CHANNEL_PARTY)
[14:50:46.496] end
[14:50:46.496] end
[14:50:46.496] end
[14:50:46.496] end

[14:50:46.496] local function createLoot(i, ext)
[14:50:46.496] local item = type(i.id) == 'table' and i.id[math.random(#i.id)] or i.id
[14:50:46.496] local random = math.ceil(math.random(100000) / ext)
[14:50:46.496] local tmpItem, f

[14:50:46.496] if( random < i.chance )then
[14:50:46.496] if i.subType == -1 then
[14:50:46.496] f = getItemInfo(item)
[14:50:46.496] end
[14:50:46.496] tmpItem = doCreateItemEx(item,
[14:50:46.496] i.subType ~= -1 and i.subType or
[14:50:46.496] f.stackable and random % i.count + 1 or
[14:50:46.496] f.charges ~= 0 and f.charges or
[14:50:46.496] 1
[14:50:46.496] )
[14:50:46.496] end

[14:50:46.496] if( not tmpItem )then
[14:50:46.496] return
[14:50:46.496] end

[14:50:46.496] if( i.actionId ~= -1 )then
[14:50:46.496] doItemSetAttribute(tmpItem, 'aid', i.actionId)
[14:50:46.496] end

[14:50:46.496] if( i.uniqueId ~= -1 )then
[14:50:46.496] doItemSetAttribute(tmpItem, 'uid', i.uniqueId)
[14:50:46.496] end

[14:50:46.496] if( i.text ~= '' )then
[14:50:46.496] doItemSetAttribute(tmpItem, 'text', i.text)
[14:50:46.496] end

[14:50:46.497] local ret, done

[14:50:46.497] for k, v in pairs(tiers) do
[14:50:46.497] local cur, used = {}, {}
[14:50:46.497] for i = 1, #v.chance do
[14:50:46.497] if( math.random(100000) <= v.chance )then
[14:50:46.497] if( f )then
[14:50:46.497] f = getItemInfo(item)
[14:50:46.497] end
[14:50:46.497] if( not f.stackable )then
[14:50:46.497] for m, n in pairs(attr) do
[14:50:46.497] if( not table.find(used, m) and
[14:50:46.497] (
[14:50:46.497] ( table.find(n.types, MELEE) and table.find({WEAPON_SWORD, WEAPON_CLUB, WEAPON_AXE}, f.weaponType) ) or
[14:50:46.497] ( table.find(n.types, DISTANCE) and f.weaponType == WEAPON_DIST and f.ammoType ~= 0 ) or
[14:50:46.497] ( table.find(n.types, ARMOR) and f.armor ~= 0 and f.wieldPosition ~= CONST_SLOT_NECKLACE ) or
[14:50:46.497] ( table.find(n.types, SHIELD) and f.defense ~= 0 and f.weaponType == WEAPON_SHIELD ) or
[14:50:46.497] ( table.find(n.types, WAND) and f.weaponType == WEAPON_WAND ) or
[14:50:46.497] ( table.find(n.types, DURATION_RING) and f.wieldPosition == CONST_SLOT_RING and f.transformEquipTo ~= 0 ) or
[14:50:46.497] ( table.find(n.types, CHARGES) and table.find({CONST_SLOT_RING, CONST_SLOT_NECKLACE}, f.wieldPosition) and f.charges ~= 0 )
[14:50:46.497] ) )then
[14:50:46.497] table.insert(cur, m)
[14:50:46.497] end
[14:50:46.497] end

[14:50:46.497] if( #cur ~= 0 )then
[14:50:46.497] local n = cur[math.random(#cur)]
[14:50:46.497] table.insert(used, n)

[14:50:46.497] n = attr[n]
[14:50:46.497] local percent, new, tmp = math.random(n.percent[1] + (v.extra[1] or 0), n.percent[2] + (v.extra[2] or 0))
[14:50:46.497] -- hacks
[14:50:46.497] if( n.attr == 'duration' )then
[14:50:46.497] tmp = getItemInfo(f.transformEquipTo)
[14:50:46.497] if tmp.transformDeEquipTo ~= item then
[14:50:46.498] break
[14:50:46.498] end
[14:50:46.498] new = round( tmp.decayTime * (1 + percent / 100) * 1000 )
[14:50:46.498] elseif( n.attr == 'attackSpeed' )then
[14:50:46.498] new = round( vocation_base_attackspeed / (1 + percent / 100) )
[14:50:46.498] elseif( n.attr == 'hitChance' ) then
[14:50:46.498] new = round(
[14:50:46.498] f.hitChance == -1 and
[14:50:46.498] percent
[14:50:46.498] or
[14:50:46.498] f.hitChance * (1 + percent / 100)
[14:50:46.498] )
[14:50:46.498] else
[14:50:46.498] new = round(
[14:50:46.498] n.base and
[14:50:46.498] f[n['attr']] + f[n['base']] * (percent / 100)
[14:50:46.498] or
[14:50:46.498] f[n['attr']] * (1 + percent / 100)
[14:50:46.498] )

[14:50:46.498] if( new == f[n[n.base and 'base' or 'attr']] )then -- no improvement
[14:50:46.498] break
[14:50:46.498] end
[14:50:46.498] end

[14:50:46.498] doItemSetAttribute(tmpItem, n.attr:lower(), new)

[14:50:46.498] local name = getItemAttribute(tmpItem, 'name')
[14:50:46.498] if( v.attrNames or not name )then
[14:50:46.498] local name = (v.attrNames and used[#used] or k) .. ' ' .. (name or f.name)
[14:50:46.498] doItemSetAttribute(tmpItem, 'name', name)

[14:50:46.498] if( f.article ~= '' )then
[14:50:46.498] local article = getArticle(name)
[14:50:46.498] if( article ~= f.article )then
[14:50:46.498] doItemSetAttribute(tmpItem, 'article', article)
[14:50:46.498] end
[14:50:46.498] end
[14:50:46.498] end

[14:50:46.499] local desc = getItemAttribute(tmpItem, 'description') or f.description
[14:50:46.499] doItemSetAttribute(tmpItem, 'description', '[' .. n.name .. ': +' .. percent .. '%]' .. (desc == '' and '' or '\n' .. desc))

[14:50:46.499] ret = k
[14:50:46.499] end
[14:50:46.499] cur = {}
[14:50:46.499] if( #v.chance == i )then
[14:50:46.499] done = true
[14:50:46.499] end
[14:50:46.499] end
[14:50:46.499] else
[14:50:46.499] done = i ~= 1
[14:50:46.499] break
[14:50:46.499] end
[14:50:46.499] end
[14:50:46.499] if( done )then
[14:50:46.499] break
[14:50:46.499] end
[14:50:46.499] end

[14:50:46.499] return tmpItem, ret
[14:50:46.499] end

[14:50:46.499] local function createChildLoot(parent, i, ext, pos)
[14:50:46.499] if( not i or #i == 0 )then
[14:50:46.499] return true
[14:50:46.499] end

[14:50:46.499] local size, cap = 0, getContainerCap(parent)
[14:50:46.499] for k = 1, #i do
[14:50:46.499] if( size == cap )then
[14:50:46.499] break
[14:50:46.499] end
[14:50:46.499] local tmp, ret = createLoot(i[k], ext)
[14:50:46.499] if( tmp )then
[14:50:46.499] if( isContainer(tmp) )then
[14:50:46.499] if( createChildLoot(tmp, i[k].child, ext, pos) )then
[14:50:46.499] doAddContainerItemEx(parent, tmp)
[14:50:46.499] size = size + 1
[14:50:46.499] else
[14:50:46.499] doRemoveItem(tmp)
[14:50:46.499] end
[14:50:46.499] else
[14:50:46.499] if( ret )then
[14:50:46.499] doSendMagicEffect(pos, CONST_ME_MAGIC_GREEN)
[14:50:46.499] doSendAnimatedText(pos, ret:upper(), tiers[ret].color)
[14:50:46.500] end
[14:50:46.500] doAddContainerItemEx(parent, tmp)
[14:50:46.500] size = size + 1
[14:50:46.500] end
[14:50:46.500] end
[14:50:46.500] end

[14:50:46.500] return size > 0
[14:50:46.500] end

[14:50:46.500] local function dropLoot(pos, v, ext, master, cid, target)
[14:50:46.500] local corpse
[14:50:46.500] if( not master or master == target )then -- 0.3/4
[14:50:46.500] corpse = getTileItemById(pos, v.lookCorpse).uid
[14:50:46.500] if( isContainer(corpse) )then
[14:50:46.500] for i = 1, getContainerSize(corpse) do
[14:50:46.500] doRemoveItem(getContainerItem(corpse, 0).uid)
[14:50:46.500] end
[14:50:46.500] local size, cap = 0, getContainerCap(corpse)
[14:50:46.500] for i = 1, #v.loot do
[14:50:46.500] if( size == cap )then
[14:50:46.500] break
[14:50:46.500] end
[14:50:46.500] local tmp, ret = createLoot(v.loot, ext)
[14:50:46.500] if( tmp )then
[14:50:46.500] if( isContainer(tmp) )then
[14:50:46.500] if( createChildLoot(tmp, v.loot.child, ext, pos) )then
[14:50:46.500] doAddContainerItemEx(corpse, tmp)
[14:50:46.500] size = size + 1
[14:50:46.500] else
[14:50:46.500] doRemoveItem(tmp)
[14:50:46.500] end
[14:50:46.500] else
[14:50:46.500] if( ret )then
[14:50:46.500] doSendMagicEffect(pos, CONST_ME_MAGIC_GREEN)
[14:50:46.500] doSendAnimatedText(pos, ret:upper(), tiers[ret].color)
[14:50:46.500] end
[14:50:46.500] doAddContainerItemEx(corpse, tmp)
[14:50:46.500] size = size + 1
[14:50:46.500] end
[14:50:46.500] end
[14:50:46.500] end
[14:50:46.500] end
[14:50:46.500] end
[14:50:46.500] send(cid, corpse, v.description)
[14:50:46.500] end

[14:50:46.500] function onKill(cid, target, damage, flags)
[14:50:46.500] if( (damage == true or bit.band(flags, 1) == 1) and isMonster(target) )then -- 0.3/4
[14:50:46.500] local v = getMonsterInfo(getCreatureName(target))
[14:50:46.500] if( v and v.lookCorpse ~= 0 )then
[14:50:46.500] local s = getCreatureStorage(cid, extra_loot_key)
[14:50:46.500] addEvent(dropLoot, 0, getThingPos(target), v, s == -1 and rate or s, getCreatureMaster(target), cid, target)
[14:50:46.500] end
[14:50:46.500] end
[14:50:46.501] return true
[14:50:46.501] end
[14:50:46.501] :onKill
[14:50:46.501] Description:
[14:50:46.501] [string "LuaInterface::loadBuffer"]:53: attempt to compare number with nil
[14:50:46.501] stack traceback:
[14:50:46.501]    [string "LuaInterface::loadBuffer"]:53: in function 'createLoot'
[14:50:46.501]    [string "LuaInterface::loadBuffer"]:225: in function <[string "LuaInterface::loadBuffer"]:212>

I'm using 0.4
 
Are you using 0.4?
I tried to use this script too, but not work, tried to make changes like this:
Code:
<event type="login" name="itemstats_login" event="script"><![CDATA[
   function onLogin(cid)
       registerCreatureEvent(cid, 'randomstats_loot')
       return true
   end
]]>
</event>

But still not working...

Maybe @Extrodus can help us, he using this script in a 0.4 server
 
Are you using 0.4?
I tried to use this script too, but not work, tried to make changes like this:
Code:
<event type="login" name="itemstats_login" event="script"><![CDATA[
   function onLogin(cid)
       registerCreatureEvent(cid, 'randomstats_loot')
       return true
   end
]]>
</event>

But still not working...

Maybe @Extrodus can help us, he using this script in a 0.4 server

Yes, i'm using 0.4

Did you set the monsterLootMessage to 0 in config.lua?

Code:
    -- Loot
   -- monsterLootMessage 0 to disable, 1 - only party, 2 - only player, 3 - party or player (like Tibia's)
   checkCorpseOwner = false
   monsterLootMessage = 0
   monsterLootMessageType = 25

Sure! It's just change it and use the mod, right?
Could you post yours?
 
Hey sorry for the delay, this is my version - doesnt have the same attribute settings but you would be changing those anyway.
http://pastebin.com/BvnDST54

@gmstrikker - Dont rename that registerevent function, it should stay as itemstats

Srry, my dumb...

I was testing your script to see how its work...
And lol, it's really funny more OTs should have it, to players looking for it, it's make a new value in items

Did you know why bows, wands and rods never drop enchanted?
I mean, i make a monster with this drops:
Code:
       <item id="2182" chance="100000000"/>                   <!-- rod -->
       <item id="2190" chance="100000000"/>                   <!-- wand -->
       <item id="2456" chance="100000000"/>                   <!-- bow -->

I hunt it 3 hours and don't drop nothing enchated (wand,rod, bow)
Yes, script working because have others 2 loots
Code:
       <item id="2380" chance="50000"/>               <!-- hand axe -->
       <item id="2512" chance="60000"/>               <!-- wooden shield -->
And it drop enchanted a lot times

Yes, i use attack formula base to wands,rods and bows
Code:
10:59 You see a bow (Range:6, Atk +1).
It weighs 31.00 oz.

10:59 You see a wand of vortex (Atk:1).
It can only be wielded properly by sorcerers.
It weighs 19.00 oz.
Surges of energy rush through the tip of this wand.

10:59 You see a snakebite rod (Atk:1).
It can only be wielded properly by druids.
It weighs 19.00 oz.
It seems to twitch and quiver as if trying to escape your grip.

Thats how i change the script:
http://hastebin.com/orurowavej.lua
 
Pretty sure on cross bows gain the hitchance, not 100% sure.

I've setted loot rates to 100, using:
Code:
       <item name="longsword" chance="10000" />
       <item name="wand of vortex" chance="10000" />
       <item name="snakebite rod" chance="10000" />
       <item name="crossbow" chance="10000" />
       <item name="bow" chance="10000" />

But only longsword comes enchanted...
Wands,Rods,Bows, Crossbow don't get nothing enchanted...

If i implement it should fuck mages,paladins because its only helps knights


It shouldnt work? I've edited that parts:
Code:
--! attributes
attr['quick'] = {
    attr = 'attackSpeed',
    name = 'Attack Speed',
    percent = {10, 50},
    types = {MELEE, DISTANCE, WAND}
}
attr['fortified'] = {
    attr = 'extraDefense',
    base = 'defense',
    name = 'Defense',
    percent = {10, 50},
    types = {MELEE, SHIELD}
}
attr['deadly'] = {
    attr = 'extraAttack',
    base = 'attack',
    name = 'Attack',
    types = {MELEE, DISTANCE, WAND},
    percent = {10, 50}
}
attr['strong'] = {
    attr = 'armor',
    name = 'Armor',
    percent = {10, 50},
    types = {ARMOR}
}
attr['hawkeye\'s'] = {
    attr = 'hitChance',
    name = 'Hit Chance',
    percent = {10, 50},
    types = {DISTANCE}
}
--[[ // not available without source edit
attr['farsight'] = {
    attr = 'shootRange',
    name = 'Shoot Range',
    percent = {10, 20},
    types = {DISTANCE, WAND}
}
]]
attr['charged'] = {
    attr = 'charges',
    name = 'Charges',
    percent = {40, 80},
    types = {CHARGES}
}
attr['divine'] = {
    attr = 'duration',
    name = 'Duration',
    percent = {40, 80},
    types = {DURATION_RING}
}
--/ attributes

full code:
http://hastebin.com/orurowavej.lua
 
Interesting, well wands do not get enchanted unless you add source edit for shootRange; but crossbow should get hitchance; that does not require source edit.

Ill check my server later to see if I can get a crossbow to enchant
 
Interesting, well wands do not get enchanted unless you add source edit for shootRange; but crossbow should get hitchance; that does not require source edit.

Ill check my server later to see if I can get a crossbow to enchant

But i dont want change that range attack thing
Code:
attr['quick'] = {
   attr = 'attackSpeed',
    name = 'Attack Speed',
    percent = {10, 50},
    types = {MELEE, DISTANCE, WAND}
}

It shoudnt add attack on wands, rods, bows, crossbows?

And it:
Code:
attr['hawkeye\'s'] = {
   attr = 'hitChance',
    name = 'Hit Chance',
    percent = {10, 50},
    types = {DISTANCE}
}

On bows and crossbows?
 
You cant add extra attack to a wand since thats managed in a line of code in weapons.xml.
As for attack speed, you would think that might work, cant promise anything until I get to checking it.
 

Similar threads

Replies
16
Views
476
Back
Top