CreatureEvent [TFS 1.1] Random Item Stats

7804364

Member
Joined
Mar 6, 2010
Messages
472
Best answers
0
Reaction score
6
im having a huge error how is it working for you?
 

Jeffro

Alpha
Joined
Jan 17, 2015
Messages
235
Best answers
0
Reaction score
256
Location
New York
@7804364
Update to the latest TFS 1.1 and it will function correctly.

@zbizu
Thanks for you help again. I updated to the latest TFS 1.1 and worked 100%, right away! Good job!
 

7804364

Member
Joined
Mar 6, 2010
Messages
472
Best answers
0
Reaction score
6
well i have 10.41 fresh install, tfs 1.1 no errors but when i kill something i get this error

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/randomstats.lua:onKill
luaAddEvent(). Argument #3 is unsafe
stack traceback:
        [C]: in function 'addEvent'
        data/creaturescripts/scripts/randomstats.lua:257: in function <data/creaturescripts/scripts/randomstats.lua:255>
Litterly just compiled tfs 1.1 added nothing and i get this error...
 

Ninja

Global Moderator
Staff member
Global Moderator
Joined
Apr 6, 2010
Messages
5,937
Best answers
30
Reaction score
1,422
Location
Sweden
well i have 10.41 fresh install, tfs 1.1 no errors but when i kill something i get this error

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/randomstats.lua:onKill
luaAddEvent(). Argument #3 is unsafe
stack traceback:
        [C]: in function 'addEvent'
        data/creaturescripts/scripts/randomstats.lua:257: in function <data/creaturescripts/scripts/randomstats.lua:255>
Litterly just compiled tfs 1.1 added nothing and i get this error...
Passing userdata objects to addEvent is unsafe and might crash the server.

Change
Code:
addEvent(find_loot_Container, 2, player, target:getPosition())
to
Code:
addEvent(find_loot_Container, 2, player.uid, target:getPosition())
Change
Code:
function find_loot_Container(player, pos)
to
Code:
function find_loot_Container(cid, pos)
    local player = Player(cid)
    if not player then
        return
    end
 
Last edited:

7804364

Member
Joined
Mar 6, 2010
Messages
472
Best answers
0
Reaction score
6
Passing userdata objects to addEvent is unsafe and might crash the server.

Change
Code:
addEvent(find_loot_Container, 2, player, target:getPosition())
to
Code:
addEvent(find_loot_Container, 2, player.uid, target:getPosition())
Change
Code:
function find_loot_Container(player, pos)
to
Code:
function find_loot_Container(cid, pos)
    local player = Player(cid)
    if not player then
        return
    end
ok i did this, and i set the chance to 100% and i get no upgraded items, and no errors in console
 

7804364

Member
Joined
Mar 6, 2010
Messages
472
Best answers
0
Reaction score
6
Actually disregard that, it works now, only issue i see here is it NEVER upgrades weapons, only shields/necklaces
 

Moj mistrz

Monster Creator
Joined
Feb 1, 2008
Messages
926
Best answers
8
Reaction score
274
Location
Poland
Actually disregard that, it works now, only issue i see here is it NEVER upgrades weapons, only shields/necklaces
I can confirm that. It happened also to me that only shields and necklaces were with custom stats.
 
OP
zbizu

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
2,572
Best answers
2
Reaction score
1,473
Location
Poland
try increasing chances

@Eldin
I'm working on making slot system, randomstats and jewel upgrade one complex stat system
 
OP
zbizu

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
2,572
Best answers
2
Reaction score
1,473
Location
Poland
first post updated
should work now

edit: updated again
fixed "argument is unsafe"

now find_loot_Container(pos) doesn't need a player parameter anymore
 
Last edited:

Moj mistrz

Monster Creator
Joined
Feb 1, 2008
Messages
926
Best answers
8
Reaction score
274
Location
Poland
first post updated
should work now

edit: updated again
fixed "argument is unsafe"

now find_loot_Container(pos) doesn't need a player parameter anymore
Attack attribute now works, but still duration is not working for rings etc.

PS. is there any way to add speed boost to bohs for example? like ITEM_ATTRIBUTE_SPEED - does it exist anyways?
 
OP
zbizu

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
2,572
Best answers
2
Reaction score
1,473
Location
Poland
@Moj mistrz
It doesn't, unless you do source edits.


edit:
first post updated again

fixes:
- extradefense and other weapon attributes won't be assigned if base stat is 0
- stats for amulets and rings are assigned correctly now
 
Last edited:

Moj mistrz

Monster Creator
Joined
Feb 1, 2008
Messages
926
Best answers
8
Reaction score
274
Location
Poland
@Moj mistrz
It doesn't, unless you do source edits.


edit:
first post updated again

fixes:
- extradefense and other weapon attributes won't be assigned if base stat is 0
- stats for amulets and rings are assigned correctly now
Works great now with amulets and rings, it still adds extradefense to weapons which dont have this, but I've changed it by myself doing
this
Code:
if it_id:getExtraDefense()  then
to this
Code:
if it_id:getExtraDefense() > 0 or it_id:getExtraDefense() < 0

Still have two questions.
1. Is it possible to add some armor to items which dont have armor?(ex. bohs).
2. Is it possible to change accuracy/extradef when it's on minus like in the devileye or demonbone?
Original
Code:
19:46 You see the devileye (Range:6, Atk+20, Hit%-20).
It can only be wielded properly by paladins of level 100 or higher.
It weighs 55.00 oz.
Boosted
Code:
19:45 You see [accurate][sharpened] the devileye (Range:6, Atk+25, Hit%-24).
It can only be wielded properly by paladins of level 100 or higher.
It weighs 55.00 oz.
[atk: +25%]
[accuracy: +22%]
As you can see, it went from Hit%-20 to Hit%-24.
Would be good if it was Hit%-16.
 
Last edited:
OP
zbizu

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
2,572
Best answers
2
Reaction score
1,473
Location
Poland
it still adds extradefense to weapons
fixed

1. Is it possible to add some armor to items which dont have armor?(ex. bohs).
it's possible, here is an example:
Code:
local i = player:addItem("boots of haste")
i:setAttribute(ITEM_ATTRIBUTE_ARMOR, 4)
However, this script uses % of values so 0 + 0 * x% is still 0

2. Is it possible to change accuracy/extradef when it's on minus like in the devileye?
replace:
Code:
it_u:setAttribute(stats_used[stat][1], basestat + (basestat * v / 100))
to:
Code:
it_u:setAttribute(stats_used[stat][1], basestat + math.abs(basestat * v / 100))
I did it in first post also.

20:05 You see epic the devileye (Range:6, Atk+23, Hit%-12).
It can only be wielded properly by paladins of level 100 or higher.
It weighs 55.00 oz.
[accuracy: +38%]
[atk: +16%]
 
Last edited:
Top