ID:1267205
 
(See the best response by Neimo.)
Essentially, I'm trying to make a fireball which spreads around nearby mobs in a semi-random fashion. Everything seems to work fine, except that it doesn't call anything after spawn().

Code:
mob
proc
Damage(mob/a,mob/e)//a=fireball , e=enemy hit by fireball
if(a.m_eff) Effect(a,e)//m_eff is a text string given to the projectile ("fire" in this case)
e.m_hp-=a.m_dmg
Deathcheck(a,e)
Effect(mob/a,mob/e)
if(a.m_eff=="fire")
Burn(a.owner,e,80)//owner being the person who shot the fireball
Burn(mob/a,mob/e,chance)//a=mob that shot the fireball , e is the mob hit , chance is the %chance that the fire will spread
world<<"debug 1"
var/list/burnlist=new()
for(var/mob/enemy/e2 in oview(e,2))
burnlist+=e2
world<<"debug 2"
var/list/toburn=new()
var/per=1
while(per&&burnlist.len>0)
world<<"debug 3"
var/temp=pick(burnlist)//randomly select mobs from nearby...
toburn+=temp
burnlist-=temp
if(rand(1,100)>chance)
per=0//...until it (by random percentage) stops
for(var/mob/burn in toburn)//within those special few chosen to be lit on fire
world<<"debug 4"
spawn(rand(1,15))//see how long it's gonna take for the fire to spread
world<<"debug 5"
burn.overlays+='burn.dmi'//light 'em up
Burn(a,burn,chance/2)//now make them spread to other mobs, at a reduced percentage
Deathcheck(mob/a,mob/e)
if(e.m_hp<=0)
a.blocked=0
if(a.owner) a.owner<<"gold!"
del e


Now, when I execute, and shoot a fireball into a group of mobs, I get this:
debug 1 // the initially hit mob check to see who it's lighting on fire
debug 2
debug 2
debug 2 //there are 5 mobs around it
debug 2
debug 2
debug 3
debug 3 //it picks 3 of those
debug 3
debug 4
debug 4 //it selects those 3...
debug 4
//and does nothing with them.


As you can see, nothing after the spawn() is even looked at.

Any help would be appreciated.
Have you tried removing the spawn()?
In response to Zohan98
Yes, and it executes fine, except that there is no delay - the whole point of this is for the fire to spread slowly, so that won't exactly work for me.

I have also tried replacing it with a sleep(), but that produced the expected stopping of everything.
I'm going to build this on my machine, ill be back with you.
why are
                   world<<"debug 5"
Burn(a,burn,chance/2)//now make them spread to other mobs, at a reduced percentage

Indented?
They don't have to be indented after spawn()...
In response to Zohan98
They're indented to happen after the spawn() time.
In response to Neimo
The same task would be preformed if they weren't indented...
Just curious..
In response to Zohan98
Zohan98 wrote:
why are
>                    world<<"debug 5"
> Burn(a,burn,chance/2)//now make them spread to other mobs, at a reduced percentage
>

Indented?
They don't have to be indented after spawn()...

Um, yes they do... That's what differs spawn() from sleep() - spawn() pauses, and runs anything indented after it, but lets anything NOT indented continue on with no delay.

it's sleep() that requires no indentation, and halts the entire proc for the duration of the sleep()
In response to Zohan98
Best response
If your code isn't indented in the spawn(), the spawn() would be redundant.
In response to Larduck
Larduck wrote:
Zohan98 wrote:
why are
> >                    world<<"debug 5"
> > Burn(a,burn,chance/2)//now make them spread to other mobs, at a reduced percentage
> >

Indented?
They don't have to be indented after spawn()...

Um, yes they do... That's what differs spawn() from sleep() - spawn() pauses, and runs anything indented after it, but lets anything NOT indented continue on with no delay.

it's sleep() that requires no indentation, and halts the entire proc for the duration of the sleep()

Zohan98 wrote:
The same task would be preformed if they weren't indented...
Just curious..


In response to Zohan98
Zohan98 wrote:
The same task would be preformed if they weren't indented...
Just curious..

No, if it weren't indented, then it would NOT pause, it would run everything after the spawn() immediately, and then, after the spawn() delay, it would run anything indented (nothing) and would thus DO nothing.
In response to Larduck
It would pause...
I just tested it.
In response to Larduck
Oh I get what you're saying. My apologies.
In response to Zohan98
Zohan98 wrote:
It would pause...
I just tested it.
mob
verb
TEST()
spawn(20)
world<<"1"
world<<"2"

Run this. Tell me what you get first.
In response to Larduck
I know, I just realized it.
In response to Larduck
proc
Burn(mob/a, mob/b, chance)
var/list/players = new
var/list/the_unlucky = new
var/mob/u
for(var/mob/enemy/m in oview(b.loc, 2))
players.Add(m)
for(var/i = 1 to players.len)
u = pick(players)
the_unlucky.Add(u)
players.Remove(u)
if(rand(1, 100) > chance)
break
for(var/mob/m in the_unlucky)
spawn(rand(1, 15))
world << m
In response to Neimo
Still having the same issue, - spawn() doesn't work. So I completely changed systems. Works now.
Just for reference, this sort of problem can come up when the owner of the Burn proc (src) is deleted before the spawn completes. This can often occur if src is a mob and gets deleted/killed, logs off, or any number of behaviors.

In this code example, you've defined a mob/proc but really all you need is a proc. You never reference src or any src variables (that I can see) and you're passing in both the attacker and the target as variables at the top (a and e).