• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[Mod] Random Item Stats

how to modify the chances? type:
rare: 1%
epic: 5%
legendary: 10%
 
a bit late, but here's how:
Lua:
tiers['rare'] = {
	color = 66, -- color of 'RARE' text
	extra = {0, 0},
	attrNames = true, -- show attribute names instead of rare
	chance = {
		[1] = 10000, -- 10%
		[2] = 5000 -- 5% chance for 2nd stat
	}
}
tiers['epic'] = {
	color = 35,
	extra = {7, 20}, -- additional percent bonus
	chance = {
		[1] = 5000, -- 5%
		[2] = 25000 -- 25% for second bonus
	}
}
tiers['legendary'] = {
	color = 149,
	extra = {20, 35},
	chance = {
		[1] = 1000, -- 1%
		[2] = 100000 -- 2 bonuses always
	}
}
 
Can you make an item that is used over items that have the same chances to make it rare, epic or legendary, if don't then the item will be deleted (broken).
 
Cyko:

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
}
}

That part, the bold one means the chance that the item appears?
 
Ive tried to get this working on 8.6 rev3884; but it doesnt seem to be working properly.. any luck with anyone else?
 
My version of script:
PHP:
18:55 Loot of Demonplague Consumer: 2 Demon dusts, 9 Mind orbs, primitive steel helmet (Armor: 2), broken golden armor (Armor: 7), primitive plate legs (Armor: 1), damaged giant sword (Min Damage: 166, Max Damage: 203), Violet gem, 7 Talons, damaged demon shield (Defense: 32), Fire mushroom, 3 Health potions, broken blue robe (Armor: 4), broken demon helmet (Armor: 3)
PHP:
18:55 Loot of Demonplague Consumer: 2 Demon dusts, 11 Mind orbs, primitive fire sword (Min Damage: 14, Max Damage: 19), Red gem, Violet gem, Life crystal, 4 Fire mushrooms, low quality demonrage sword (Min Damage: 108, Max Damage: 137), 3 Health potions, 25 Black pearls, broken thunder hammer (Min Damage: 61, Max Damage: 70), damaged molten plate (Armor: 13)
PHP:
18:56 Loot of Demonplague Consumer: 3 Demon dusts, 3 Mind orbs, primitive steel helmet (Armor: 1), broken plate legs (Armor: 3), damaged giant sword (Min Damage: 185, Max Damage: 227), damaged fire sword (Min Damage: 56, Max Damage: 76), Red gem, primitive thunder hammer (Min Damage: 46, Max Damage: 53), low quality warrior helmet (Armor: 5), good quality demon armor of leather (Armor: 20)

^^
 
17:10 Loot of a valkyrie: nothing

It drops items, but it doesnt show it in the loot message. Nor does is it changing the items to the rare or epic, etc. Any help.. this is 3884, 0.4; it should work according to you.
 
hello Cyko,
i have small problem with ur script,
http://otland.net/f163/mod-random-item-stats-130295/
Its working and its fine, but i have also Upgrading system (Wklej.to - po prostu wklej to! - paste: YX0Iu).
And when i have np "Epic Katana" and wanna upg it, then word "Epic" dissapear. Stay just "Katana +1"
Like: before
Code:
You see an epic triple-blade scythe (Atk:60 +26, Def:40 +1).
After:
Code:
You see an triple-blade scythe +1 (Atk:62, Def:41 +2).
As you see effects dissapears too :S (but attack speed dont)
I think u know what i mean.


Can u somehow solve my problem?
If u dont wanna or dont have time i understand it :3

Thanks,
Erexo
 
Last edited:
try to use this same functions i've used
mock upgrade system

if not setItemName then
function setItemName(uid,name)
return doItemSetAttribute(uid,'article',name)
end
doItemSetAttribute(itemEx.uid,'article', getItemArticleById(itemEx.itemid)..' +'..(level+1)..slot)


15:02 You see a deadly quick ice rapier (Atk:22 +10 physical + 18 ice, Def:1) that has 1 charge left.
It weighs 15.00 oz.
[Attack: +24%]
[Attack Speed: +18%]

15:02 Trying refine with 100% of sucess!
15:02 Your item has been upgrated to +1.

15:02 You see an +1 deadly quick ice rapier (Atk:24 +10 physical + 18 ice, Def:3) that has 1 charge left.
It weighs 15.00 oz.
[Attack: +24%]
[Attack Speed: +18%]

hey, sure :) this is mock upgrade system.
add this in actions.xml
<action itemid="8310" event="script" value="tools/upgrade.lua"/>
<action itemid="8300" event="script" value="tools/upgrade.lua"/>
item 8300 is 100% suscess

create a lua file called upgrade.lua in actions/tools folder and paste this:
--- Perfect refine system by Mock the bear (MTB).
--- Email: [email protected]
-- &a = weapon attack
-- &d = weapon defense
-- &s = shield defense
-- &p = armor defense
-- # = nivel do item
-- @ = max level
local gain = {
gainArmor='&p+2',loseArmor='&p-2',
gainShield='&s+2',loseShield='&s-2',
gainAttack='&a+2',loseAttack='&a-2',
gainDefense='&d+2',loseDefense='&d-2',
chance='(100/math.sqrt((((@/4)+(#*2))/@)*#))',
maxlvl = 11,
blocked_ids = {}
}
local it = {
--[itemid] = [percent]
[8310] = 0, -- 0% additional
[8300] = 100, -- 50%
}
if not setItemName then
function setItemName(uid,name)
return doItemSetAttribute(uid,'article',name)
end
function setItemArmor(uid,name)
return doItemSetAttribute(uid,'armor',name)
end
function setItemDefense(uid,name)
return doItemSetAttribute(uid,'defense',name)
end
function setItemAttack(uid,name)
return doItemSetAttribute(uid,'attack',name)
end
function getItemAttack(uid)
return getItemAttribute(uid,'attack')
end
function getItemDefense(uid)
return getItemAttribute(uid,'defense')
end
function getItemArmor(uid)
if type(uid) == 'number' then
return getItemAttribute(uid,'armor')
else
return getItemInfo(uid.itemid).armor
end
end
end

local function isArmor(uid) -- Function by Mock the bear.
if (getItemInfo(uid.itemid).armor ~= 0) and (getItemWeaponType(uid.uid) == 0) then
return true
end
return false
end
local function isWeapon(uid) -- Function by Mock the bear.
uid = uid or 0
local f = getItemWeaponType(uid)
if f == 1 or f == 2 or f == 3 then
return true
end
return false
end
local function isShield(uid) -- Function by Mock the bear.
uid = uid or 0
if getItemWeaponType(uid) == 5 then
return true
end
return false
end
local function isBow(uid) -- Function by Mock the bear.
uid = uid or 0
if getItemWeaponType(uid) == 4 then
return true
end
return false
end
local function getWeaponLevel(uid) -- Function by Mock the bear.
uid = uid or 0
local name = getItemArticle(uid.uid) or getItemInfo(uid.itemid).name or ''
local lvl = string.match(name,'%s%+(%d+)%s*')
return tonumber(lvl) or 0
end
local function doTransform(s,i) -- Function by Mock the bear.
local c = string.gsub(s,'@',gain.maxlvl)
local c = string.gsub(c,'&a',(getItemAttack(i.uid) ~= 0 and getItemAttack(i.uid) or getItemInfo(i.itemid).attack))
local c = string.gsub(c,'&d',(getItemDefense(i.uid) ~= 0 and getItemDefense(i.uid) or getItemInfo(i.itemid).defense))
local c = string.gsub(c,'&s',(getItemDefense(i.uid) ~= 0 and getItemDefense(i.uid) or getItemInfo(i.itemid).defense))
local c = string.gsub(c,'&p',(getItemArmor(i.uid) ~= 0 and getItemArmor(i.uid) or getItemInfo(i.itemid).armor))
local c = string.gsub(c,'#',getWeaponLevel(i))
local q = assert(loadstring('return '..c))
return math.floor(assert(q()))
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.uid == 0 or item.itemid == 0 then return false end
toPosition.stackpos = 255
if isInArray(gain.blocked_ids, itemEx.itemid)
or (not getItemWeaponType(itemEx.uid) or getItemWeaponType(itemEx.uid) > 5)
or (getItemWeaponType(itemEx.uid) == 0 and not isArmor(itemEx))
or itemEx.itemid == 0 or itemEx.type > 1 or isItemStackable(itemEx.uid) then
doPlayerSendTextMessage(cid, 19,"You cant refine this item.")
return TRUE
end
if isCreature(itemEx.uid) == TRUE then
return FALSE
end
local level = getWeaponLevel(itemEx)
local chance = doTransform(gain.chance,itemEx)
if level == gain.maxlvl then
doSendMagicEffect(toPosition, 2)
return doPlayerSendTextMessage(cid, 19,"Your item is on max level, you can't upgrade it.")
end
doPlayerSendTextMessage(cid, 19,"Trying refine with "..(chance+it[item.itemid] > 100 and 100 or chance+it[item.itemid]).."% of sucess!")
if chance+it[item.itemid] >= math.random(0,100) then
local nm = getItemName(itemEx.uid)
local slot = nm:match('(%[.+%])') or '' ---If you server use slot system dont change it ^^
slot = slot~='' and ' '..slot or slot
doItemSetAttribute(itemEx.uid,'article', getItemArticleById(itemEx.itemid)..' +'..(level+1)..slot)
addEvent(doPlayerSendTextMessage,500,cid, 19,"Your item has been upgrated to +"..(level+1)..slot..".")
doSendMagicEffect(toPosition, 12)
if isArmor(itemEx) then
local get = doTransform(gain.gainArmor,itemEx)
setItemArmor(itemEx.uid,get)
elseif isBow(itemEx.uid) then
setItemAttack(itemEx.uid, doTransform(gain.gainAttack,itemEx))
elseif isWeapon(itemEx.uid) then
setItemAttack(itemEx.uid, doTransform(gain.gainAttack,itemEx))
setItemDefense(itemEx.uid, doTransform(gain.gainDefense,itemEx))
elseif isShield(itemEx.uid) then
setItemDefense(itemEx.uid, doTransform(gain.gainShield,itemEx))
end
else
if level == 0 then
addEvent(doPlayerSendTextMessage,500,cid, 19,"No effect.")
doSendMagicEffect(toPosition, 2)
elseif level > 0 then
local nm = getItemName(itemEx.uid)
local slot = nm:match('(%[.+%])') or '' ---If you server use slot system dont change it ^^
slot = slot~='' and ' '..slot or slot
if level == 1 then
doItemSetAttribute(itemEx.uid,'article', getItemArticleById(itemEx.itemid)..slot)
addEvent(doPlayerSendTextMessage,500,cid, 19,"Your item back to normal.")
else
doItemSetAttribute(itemEx.uid,'article', getItemArticleById(itemEx.itemid)..' +'..(level-1)..slot)
addEvent(doPlayerSendTextMessage,500,cid, 19,"Your item back to +"..(level-1)..slot..".")
end
if isArmor(itemEx) then
setItemArmor(itemEx.uid,doTransform(gain.loseArmor ,itemEx))
elseif isWeapon(itemEx.uid) then
setItemAttack(itemEx.uid, doTransform(gain.loseAttack,itemEx))
setItemDefense(itemEx.uid, doTransform(gain.loseDefense,itemEx))
elseif isBow(itemEx.uid) then
setItemAttack(itemEx.uid, doTransform(gain.loseAttack,itemEx))
elseif isShield(itemEx.uid) then
setItemDefense(itemEx.uid, doTransform(gain.loseShield,itemEx))
end
end
doSendMagicEffect(toPosition, 9)
end
doRemoveItem(item.uid,1)
return true
end
 
Last edited:
sry for double post, but its possible to boost items just in the weapons.xml? because anyone need a boosted mace, rapier and others

or create something function that check "banned id" and u put noob itens id :p
 
Thx for help me televolt, but that still not what i need ;S
i have other upg system, and that isnt working what i want (i have 3 items to upg, one can upg to lv3, second to lv 6, and third to lvl 11). When i try do that with mock system, isnt working :S
So i need changes for my script :(
Wklej.to - po prostu wklej to! - paste: YX0Iu

Someone can help?
 
Thx for help me televolt, but that still not what i need ;S
i have other upg system, and that isnt working what i want (i have 3 items to upg, one can upg to lv3, second to lv 6, and third to lvl 11). When i try do that with mock system, isnt working :S
So i need changes for my script :(
Wklej.to - po prostu wklej to! - paste: YX0Iu

Someone can help?


ahhh okay, i will do something and post here :D
 
Has anyone got this working on rev 4267 for client 8.7?
 
allways only show

22:47 Loot of a dragon: nothing

and have loot in dragon.
script dont work in 0.4_DEV with normal libs
 
it really dont make sense..
why dont work with me ?

I use r3777

I probably have problem in

Code:
isContainer

I try test


Code:
213:      corpse = getTileItemById(pos, v.lookCorpse).uid
215:      if( isContainer(corpse) )then
216:			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Debug Part 1'))

it dont return noting ingame


I really test all functions.

My problem is isContainer


anyone can send me this function corretly ?
 
Last edited:
you can try add

Code:
if( (damage == true or bit.band(flags, 1) == 1) and isMonster(target) and getPlayerGroupId(cid) > 4 )then -- 0.3/4


I dont make this flood. have deleted messagens here
 
Last edited:
tested in my server (tfs 0.3.6) with a character with attackspeed 500ms then equip a legendary sword with attackspeed +38% and the attack speed is now like 1200ms more or less

isn't supposed that should be faster?
 
This script is very nice, thank you!

On a side note, Im looking to customize it. I have added a movespeed attribute in the appropriate areas:
Lua:
	vocation_base_basespeed = getVocationInfo(1).baseSpeed

attr['speedy'] = {
	attr = 'moveSpeed',
	name = 'Speed',
	percent = {5, 5},
	types = {MELEE, DISTANCE, WAND, SHIELD, ARMOR, WAND, DURATION_RING, CHARGES}
}

						elseif( n.attr == 'moveSpeed' )then
							new = round( vocation_base_basespeed + (10 * percent ))
But I am confused as to where the script applies this new value to the field I want it in. I am basically copying how attackspeed is changed through the vocations.xml, and want to do something similar with both movespeed and elemental resists. I will continue playing with it, but if somebody can point out the obvious I would appreciate it greatly.
 
Back
Top