ID:879324
 
(See the best response by Boubi.)
So I'm trying to give random stats to an item when it drops, but when I try to code it into the base item, I get errors when adding it anywhere within this code:
        Sword
icon='sword.dmi'
icon_state="sword"
str=40
firerate=3.5
layer=MOB_LAYER-1
Click()
if(usr.incar==0)
if(src in usr)
if(usr.weapon==null)
if (usr.meleeweapon<10) usr<<"You arn't skilled enough in Melee Weapons. (Level 10 Required)"
else
src.suffix="Equipped"
usr.overlays+='sword.dmi'
usr.icon_state="weapon2"
view()<<sound('sword_on.wav',0,0,0)
usr.weapon=src
usr<<"<font color=gray>You wield the <font color=gray>Sword<font color=gray> like a Jedi!"
layer=MOB_LAYER+10
return
if(usr.weapon==src)
src.suffix=null
usr.icon_state=""
usr.overlays-='sword.dmi'
view()<<sound('sword_off.wav',0,0,0)
usr.weapon=null
usr<<"<font color=gray>You unwield the <font color=gray>Sword<font color=gray> in style."
layer=MOB_LAYER-1
return

So, im thinking it needs to be added when the item is spawned. My code for that looks something like this:
new/obj/pickup/Sword(M.loc)
view()<<"<B><font color=white>A </font><font color=grey>Sword</font> <font color=white>bounces to the ground!</font></b>"


This is also the code for equipping the item:

        Sword
icon='sword.dmi'
icon_state="sword"
str=40
firerate=3.5
layer=MOB_LAYER-1
Click()
if(usr.incar==0)
if(src in usr)
if(usr.weapon==null)
if (usr.meleeweapon<10) usr<<"You arn't skilled enough in Melee Weapons. (Level 10 Required)"
else
src.suffix="Equipped"
usr.overlays+='sword.dmi'
usr.icon_state="weapon2"
view()<<sound('sword_on.wav',0,0,0)
usr.weapon=src
usr<<"<font color=gray>You wield the <font color=gray>Sword<font color=gray> like a Master!"
layer=MOB_LAYER+10
return
if(usr.weapon==src)
src.suffix=null
usr.icon_state=""
usr.overlays-='sword.dmi'
view()<<sound('sword_off.wav',0,0,0)
usr.weapon=null
usr<<"<font color=gray>You unwield the <font color=gray>Sword<font color=gray> in style."
layer=MOB_LAYER-1
return




Best response
To give the sword random stats you could modify New() for the sword and set its random stats there. When picking up sword, you'd need to save a reference to the sword or its stats in some sort of list for whoever picked it up.
    Sword
var
item_Level
range_min
range_max
icon = '.dmi'
icon_state = ""
layer = MOB_LAYER

New()
if(item_Level >= 10)
str = rand(range_min, range_max)
def = rand(range_min, range_max)
dex = rand(range_min, range_max)
Just to show you.

A few things you need to be aware of:
1: Always create a new obj/sword, and it will need a detail number(could be anything. It needs to identify obj/sword)
2: would need a variable to identify who the owner is.

basicly what boubi said :)