ID:1502964
 
(See the best response by Koshigia.)
Code:
mob/proc/Vega(var/IS,var/damage)    //the arguments inside the () allow us to easily customize the proc
//The Icon States for this proc are Kept in Projectiles.dmi
//Simply add a new icon state and name it to match the skill and youre good to go!
var/obj/Supplemental/Projectile/P=new() //first we'll make a new projectile
P.icon_state=IS //this sets the icon state to whatever we need
P.damage=damage //this will set up the damage that we passed in through the arguments
P.Owner=src //set its owner to the person that shot it
P.dir=src.dir //make it face the same direction as the attacker
P.loc=src.loc //locate it on the player
walk(P,src.dir) //this will get P moving in the direction u shot it
spawn(5) del P
for(var/turf/X in range(1,P))
spawn(9)
X.overlays += /obj/Explosion
for(var/mob/M in range(1,P))
M.HP-=src.Str*3
spawn(12)
X.overlays.Cut()


obj
Explosion
icon = 'Projectiles.dmi'
icon_state = "explode"

Problem description:
Well, I am using Projectiles as skills in my game and I thought about adding explosion effect(area damage) to a certain skill. but somehow it wouldn't affect any monster it targets not even and for some reason it would only lower my own HP.


Best response
Basically whats goin on in your code is that as soon as you launch the projectile, it's checking for mobs within range of 1 (before it even has a chance of moving via the call to walk() ). That is why only you are being damaged. Read up on the documentation for sleep() and spawn(). As a quick note, sleep "pauses" the current procedure in place for a set period of time before continuing. Spawn() creates a new thread for any code indented beneath it, but continues to run the current procedure without interruption. So...

..
world << "Are"
spawn(5)
world << "You"
world << "There"
...


That would show you...
Are
There
You

I hope this helps!
Well, it gives me same results when I remove
spawn(5) del P

Apologies if you were trying to point something and I don't understand it yet.

*Edited to make more clear*

sleep() and spawn() are similar, yet completely opposite in one aspect. Consider the following...

mob/verb/test1()
world << "this is a test"
sleep(10)
world << "end of test"

mob/verb/test2()
world << "this is a test"
spawn(10)
world << "Wait... what happened!"
world << "end of test"


Try to run those two simple verbs in your game and see what happens. Note the differences in code and syntax for each one.

Ahh !
Got it Thank you, got it working tho. funny how the difference between both procs is quite tricky.
In response to Yazan20
No worries. That's the fun in it! Keep those tools in your head. Never know when you'll need it again =D