ID:171439
 
Hello all. here is a code that i made the other night from scratch, which is supposed to mak a boulder at all the looserock areas in the world. But it only makes a boulder at the very first area and not the other. Can someone tell me how to fix this so that it makes a boulder fall at ALL the looserock areas?

Heres my code:

area
looserock
icon = 'cliffs.dmi'
proc
nboulder()
var/obj/B=new/obj/boulder
B.loc = locate(/area/looserock)
walk(B,SOUTH)
spawn(50)
nboulder()

obj/boulder
icon = 'boulder.dmi'
density = 1
Bump(mob/M)
M.loc = locate(3,3,1)
M.rhealth = M.health
M << "You were crushed by a falling boulder!"
del(src)

I think your problem is that you keep spawning the rocks at /area/looserock, but sense there's never a dense object in that location, it always spawns there. You can prevent that with:
area
looserock
icon = 'cliffs.dmi'
proc
nboulder()
var/obj/B=new/obj/boulder
B.loc = locate(x,y,z)//Here's the change
walk(B,SOUTH)
spawn(50)
nboulder()

obj/boulder
icon = 'boulder.dmi'
density = 1
Bump(mob/M)
M.loc = locate(3,3,1)
M.rhealth = M.health
M << "You were crushed by a falling boulder!"
del(src)


See if that helps.
The location of a area is just 1 point.

One thing you could do is loop trough all the turfs in the area and randomly pick one. I'm not on a computer with BYOND right now and dont have much time but this would be a way maybe:

var/list/nl = new
var/area/looserock/l //not sure this works
for(var/turf/t in l) //not sure this works
// put any restrictions here
nl.Add(t)
var/turf/nt = pick(nl) // didnt look up this proc but think its like this
var/obj/B=new/obj/boulder
B.loc = locate(nt.x , nt.y , nt.x) // t.loc would result in the area's loc i think
walk(B,south)
spawn(50) nboulder()


NOTE: I just wrote this quickly, it probably wont work, and it probably gives you lotsa errors but its here to show how you could do it and the general way of doing it.

Hope it atleast helped you A BIT

Greetz Fint
In response to Crashed
Nope dident help. It stilll does exactly the same thing, only now it seems to delay in the rock falling more.
In response to Reinhartstar
Are you sure you're placing more than one /area/looserock on the map?
In response to Crashed
Im positive i am. But it still dosent work. SO i still need help bad.
In response to Reinhartstar
Are you calling nboulder() at New()? How are you calling it at FIRST?
In response to Crashed
this is how im calling it from the start:

world
mob = /mob/pc

New()
..()
for(var/area/looserock/L in world)
spawn() L.nboulder()


In response to Reinhartstar
Don't even locate() an /area. Instead, simply create it in src (the area).