ID:144417
 
Code:Saying spells
obj
spells
var/dmg
var/mob/trg
fire
Fireball
icon='spells.dmi'
icon_state="fireball"
Bump()
spawn()
zz
if(trg in oview(0))
trg.hp=80
else
sleep(1)
goto zz
Click()
if(!usr.target)return
if(usr.target in oview(8))
for(var/mob/M in oview(8))
if(M.owner==usr.key)
var/obj/spells/fire/Fireball/O=new(M.loc)
O.dmg=roll(5)
O.trg=usr.target
walk_towards(O,usr.target,1)
sleep(10)
del( O )


Problem description:I need it so that when someone uses the spell it shows up in text as "say" i tried manytimes to get it to work but nothing happened


side codeing.....


 usr.element=input("Choose your element","Choose Element")in list("Fire","Water","Wind","Earth","Darkness","Light")
if(usr.element=="Fire")
var/obj/spells/fire/Fireball/O=new(usr)
zz
var/A=input("Please name you Lvl 1 Fire spell","New Spell")as text
if(!A)goto zz
O.name="[O.name] ([A])"

Please don't copy code from the forum and expect us to help. Thanks.
if(trg in oview(0))

Read this then come back and tell me why the above is pretty redundant. :p


goto zz

Don't ever use goto in this situation. It's bad form and goto was designed for use back when your parents were born... it's old and gross.
//this is so much better than the way you were doing it
while(!trg in oview(0))
sleep(1)
trg.hp=80


And even that is broken, because oview(0) is never going to return a list of objects (you probably want view(0)?), and oview() (and view. and range, and orange) default to usr, and usr in Bump() is bad!

view(0,src) is more like what you need. Although to be honest, you're better off just comparing locations of the fireball and it's target- or better, comparing whatever it just bumped with and the target.

Bump(var/atom/victim)
if(trg == victim)
world << "[trg] just got burnt!]".
In response to Xx Dark Wizard xX
what are you talking about ???? :?
In response to Elation
Elation wrote:
Don't ever use goto in this situation. It's bad form and goto was designed for use back when your parents were born... it's old and gross.

The goto statement has its uses; this just isn't one of them, nor is he likely to ever encounter one. This situation clearly calls for while(). So you're right to say not to use goto in this situation, but it's not so much "old and gross" as ill-fitted to 99.9% of the situations you'll run across.

Lummox JR