ID:172273
 
in my code for the magic system when you click the fire button it works out that a mob in front of you and casts
the spell opon them but it stops dead.

please help the code is below


obj
fire_cast
icon = 'effects.dmi'
icon_state = "Fire_cast"
name = "fire"
screen_loc = "4,2"
Click()
if(usr.mp >= 5)
var/mob/M = locate(/mob) in get_step(src,src.dir)
if(M != null)
var/obj/O = new/obj/fire(M.loc)
usr.mp = usr.mp - 0
var/damage = (rand(1,7 + round(usr.level / 3,1))) - M.def
if(damage <= 0)
damage = 1
M.hp = M.hp - damage
s_damage(M, damage, "#FF0000")
usr << sound("sfx/Fire.wav",0)
M << sound("sfx/Fire.wav",0)
sleep(3)
del(O)
else
usr << "you need more mp!"


oh and yer he/she does have more than 5 mp at the start.
if(src.mp >= 5)
gives me error:src.mp:undefined var

this is on the first usr i have changed plz help

In response to Madpeter
have you defined mp as a mob variable?

mob
var
mp

(No copy and paste cause of spaces)also put ur other major stats there like hp
In response to Mooseboy
yes i do
mob/var/mp = 20

:) but that dont help me much, but still ty anyway.
Madpeter wrote:
in my code for the magic system when you click the fire button it works out that a mob in front of you and casts
the spell opon them but it stops dead.

How much of this gets executed, like does the fire object appear, does the s_damage appear of the mob, and does the sound play. Are there any run-time errors when executing this? Please provide any information on these points.
In response to Madpeter
Bump
In response to Lazyboy
there is no effects and no runtime errors.

[edit]
fixed it
var/mob/M = locate(/mob/) in get_step(usr,usr.dir)

forgot to add the last / after the locate mob bit :)
In response to Madpeter
src is the object, and it doesnt have mp, usr does. Otherwise I dont understand where that problem is because src.mp is not in the code above.