ID:142878
 
Code:
obj
C4
icon = 'explosive.dmi'
icon_state = "c4"
density=1
Bump(A)
if(ismob(A))
var/mob/M = A
var/damage = round(src.tai*20)
M.hp -= damage
view(M) << "[M] was hit by Haretsu Horimono Nendo for [damage] damage!"
src.Frozen = 1
for (var/turf/X in view(5))//If it is withing 3 tiles of the "Explosion"...
X.overlays+='explosion.dmi'//Overlay the Explosion icon
spawn(5)//Wait a little bit
X.overlays+='dirt.dmi'
sleep(30)
X.overlays.Cut()//Delete the explosion, not all things last forever :)
M.Killer = Gowner
M.Death(usr)
sleep(5)
del(src)
if(istype(A,/turf/))
var/turf/T = A
if(T.density)
del(src)
if(istype(A,/obj/))
del(src)


Problem description:It just doens't create the Explosion Effect... making those overlays on the turfs (X) working... Please help me...

There's a small array of problems here.

Least critically:

There is no reason to include if() branches for /obj and /turf in this specific example, simply because nothing is done within them. Delete the last two if() statements and back-tab the del(src) at the end of the ismob() block.

Secondly, I'm not entirely sure if you're aware that delays within spawn() and sleep() are in ticks and not seconds. There are ten ticks in a second, so your spawn(5) statement means the explosion will remain for one half of a second, and not five seconds.

Immediately pertinent to the problem:

view() has two arguments in the order distance,center. Center defaults to usr, which is nonexistant in this case; view() returns nothing because there is no usr in this case.

spawn() is a tabbed construct like if(); your use of spawn() does nothing because there is no code tabbed after it. Your use of sleep(), however, is correct.

After taking these into consideration, you seem competent enough to solve the problems that remain.
In response to Mobius Evalon
Heya... thanks for that, I'll try to do it once i get home... And I know about the thicks... When i put spawn (5) it means that it will have a small fire announcing the explosion, then the explosion will come ;)

Thanks Anyway...


Cybork
In response to Mobius Evalon
Doesn't work after all...
I made some changes in the code:

obj
C4
icon = 'explosive.dmi'
icon_state = "c4"
density=1
Bump(A)
if(ismob(A))
var/mob/M = A
var/damage = round(src.tai*20)
M.hp -= damage
view(M) << "[M] was hit by Haretsu Horimono Nendo for [damage] damage!"
src.Frozen = 1
for (var/turf/areas/X in range(src,5))
X.overlays+='explosion.dmi'
sleep(5)//Wait a little bit
X.overlays+='dirt.dmi'
sleep(30)
X.overlays-=X.overlays
M.Killer = Gowner
M.Death(usr)
sleep(5)
del(src)
In response to Cybork
Okay, so now your problems are:

1) You're only looping through turfs of the type /turf/areas. Are there really any /turf/areas to loop through?

2) For every turf you're sleeping, so it will be sleeping for 3.5 seconds for each of the (up to) 25 turfs. You need to shunt off each iteration of that for() loop into its own thread:

for(askldjfs)
spawn()
skldjflaksjf


3) You're using usr still, in M.Death(usr). I assume the Gowner variable is what you want to be using instead.