ID:165265
 
Alright, I'm having some trouble with what I thought was a really simple system: deleting objects when they reach the edge of the map. So here's what's happening. I have a mob proc that creates an object at the player's location, and then I walk() it in the direction the player is facing. What I'm trying to do is make the object delete itself when it reaches the edge of the map. The best I could do was delete the fireball when the player was standing at the edge of the map, which made it look like you didn't shoot at all. I just can't figure out how to do this, and it's really bothering me, because I thought it would be really simple. Thanks.
just throw an area, turf, or somthing around the outside of the map.....

like...

area/deletezone

then have it check within the fireball shooting proc if there is the area or turf or whatever within its loc... ex: (this should be in the shooting proc)

var/obj/fireball/F=new/obj/fireball(usr.loc)
//The var designation is just an example idk how yours is set up so dont use that part.
if(locate(/area/deletezone/) in F.loc)
del F


Or something to that issue :P.




In response to Bladeshifter
Bladeshifter wrote:
just throw an area, turf, or somthing around the outside of the map.....

like...

area/deletezone

That's not possible unless you extend your map, and then it's not really so much the outside of the map as a wide border area.

Lummox JR
In response to Bladeshifter
Yeah, but I don't wanna have to make a new area. I just want to be able to use the coordinates.
Seraphrevan wrote:
Alright, I'm having some trouble with what I thought was a really simple system: deleting objects when they reach the edge of the map. So here's what's happening. I have a mob proc that creates an object at the player's location, and then I walk() it in the direction the player is facing. What I'm trying to do is make the object delete itself when it reaches the edge of the map. The best I could do was delete the fireball when the player was standing at the edge of the map, which made it look like you didn't shoot at all. I just can't figure out how to do this, and it's really bothering me, because I thought it would be really simple. Thanks.

Since the correct way to do a projectile is to make it responsible for its own movement anyway, just give it a proc to do its own walking, so it can check for the edge of the map.
obj/projectile
var/mob/owner
density = 1

New(newloc, mob/owner)
// this is one of the few times you need to use src.var:
// src.owner = the obj's owner var (obj var)
// owner = the proc argument (local var)
src.owner = owner
dir = owner.dir
spawn(-1) Go()

proc/Go()
while(src)
var/turf/T = get_step(loc, dir)
if(!T) del(src) // here's the trick you need
step(src, dir)

Bump(atom/obstacle)
...
del(src)


Lummox JR
In response to Lummox JR
Alright, I tried something like that, I just modified it a little bit, but now, the projectile doesn't seem to be created at all, but I get no error messages.

[Edit]Alright, I just ran some more test, and it turns out that the projectile DOES get created, but it doesn't actually appear on screen. I did some more tests, and the offending code snippet is the turf part. The code works fine without it, the projectile gets fired. But as soon as I add that part to make the projectile delete itself, the projectile fails to appear. I still haven't found out what's wrong.[/Edit]

[Solved]Because there was no lag between each step(), the fireball just travelled off-screen so quickly that it wasn't visible. I added a sleep(1), and that fixed it.[/Solved]