ID:140956
 
Code:
obj/spell
density = 1
var
delay = 2
length=20
dmg=0
splash
mob/owner

New(_loc,mob/_owner)
if(_owner)
src.dir = _owner.dir
if(!src.loc) src.loc = get_step(_owner,_owner.dir)
src.owner = _owner
Move()
src.length--
if(!src.length) del src
return ..()
Bump(mob/O)
if(ismob(O))
var/damage = src.dmg
view(src) << "[src.owner] attacks [O] for [damage] damage!!"
O.hp -= damage
O.deathcheck()
del src
viewers(O) << "[src.owner] has hit [O:name] with \his [src]!"
else if(isobj(O))
if(hard == 0)
del O

del src
Fireball
icon = 'fireball.dmi'
delay = 2
length = 10
dmg = 2 + usr.fire




mob
var
haton = 0
weaponon = 0
cheston = 0
legson = 0
capeon = 0
defense = 0
mana = 100
maxmana = 100
list/spells=list()
hp = 100
maxhp = 100
fire = 0
Bookread = 0
water = 0
cooldown = 0


Problem description:

im trying to make so different spells' damage increase when you increase certain magic skill, spell's damage also increase(that means fire skill increase fire spells' damage, water skill increase water spells damage... fire skill is called fire), so im trying to make spell dmg equal to it's min damage + it's owner's skill, but i get undefined var error. also if some will say no ... in ..., then say what i should use
    Fireball
icon = 'fireball.dmi'
delay = 2
length = 10
dmg = 2 /*+ usr.fire*/ // wtf <.<

There is no usr at compile time, so that's just silly, you need to use a constant var. Add the owner's "fire" var to the Fireball's dmg when the obj is created:
    New(_loc,mob/_owner)
if(_owner)
src.dir = _owner.dir
if(!src.loc) src.loc = get_step(_owner,_owner.dir)
src.owner = _owner
src.dmg += _owner.fire
In response to Ruben7 (#1)
well, now every spell will use fire skill(if fire skill is 10, then fireball will do 10 damage, fire blast will do 10 damage, water attacks will do 10 damage), but im trying to do different spells do different damage, not just use spell with your favorite icon
In response to Martys1103 (#2)
Fireball
icon = 'fireball.dmi'
delay = 2
length = 10
dmg = 2
New(_loc,mob/_owner)
..()
if(_owner)
src.dmg += _owner.fire

Override New() for each spell and add the right var or whatever.
In response to Ruben7 (#3)
oh really, i can rewrite it and add element var(if(element==1(fire)) src.dmg+=_owner.fire). thanks for help