ID:263845
 
Code:
    proc/BlasT()
if (MP < 2+(blastlevel*2))
usr << "Not enough MP"
else
usr << "You shoot your Blast"
MP -= 3+(blastlevel*2)
var/obj/beam = new/obj/spells/firebolt
beam.dir = usr.dir
beam.loc = usr.loc
while(beam)
step(beam,beam.dir)
var/turf/T = beam.loc
if(T.density == 1)
del(beam)
break
for(var/mob/M as mob in T)
if(istype(M,/mob/enemies))
var/damage = round(((rand(1+(blastlevel*3),3+(blastlevel*3)))*((Intelligence/100)+1)),1)
M.HP -= damage
usr << "You Blasted the enemy for \blue[damage] damage"
del(beam)
DeadEnemy(M)
sleep(1)


Problem description:

ok this is my first time using the developer forums to ask for help on a code problem (dont like to admit when i cant do something) but the problem is this everything works with the projectile except when it hits the monster it dosent hit the monster it just keeps going like the monster has no density but it does and i dont even know if the damage would work because it dosent hit the monster help?
Maybe you should change projectile to density 1 too?Sorry if this is a bad advice >.<.
In response to IOwned
Yea, make the projectile density 1 and use the bump() proc to detect what its hitting.
In response to Evidence
LOL I didn't know I was right.I'm still a beginner coder .
You should not be using usr in procs. I assume this proc belongs to mob, so you should be using src instead of usr in every instance. Especially because you're already mixing src and usr.
In response to Garthor
    proc/BlasT()
if (MP < 2+(blastlevel*2))
usr << "Not enough MP"
else
usr << "You shoot your Blast"
var/damage = round(((rand(1+(blastlevel*3),3+(blastlevel*3)))*((Intelligence/100)+1)),1)
var/obj/beam = new/obj/spells/firebolt
beam.dir = usr.dir
beam.loc = usr.loc
beam.density = 1
while(beam)
step(beam,beam.dir)
var/turf/T = beam.loc
if(T.density == 1)
del(beam)
break
for(var/mob/M as mob in T)
if(M)
Bump(M)
Attack(M)
MP -= 3+(blastlevel*2)
M.HP -= damage
usr << "You Blasted the enemy for \blue[damage] damage"
del(beam)
break
DeadEnemy(M)
sleep(1)


ok so thats the new code but the problem is with the var/turf/T = beam.loc part of the code while the blast has a density theres nothing ever with in the same tile its in so can anyone help on fixing it?