ID:168669
 
I was wondering if there was a way to check if there is a certain area. For example I want to be able to determine if there is a certain area lets say three tiles north and 2 tiles west of the mob. I know I would have to use the mobs location and work off of that but I don't really know what proc to use to check for an area in a tile the the mob is not on.
Drumersl wrote:
I was wondering if there was a way to check if there is a certain area. For example I want to be able to determine if there is a certain area lets say three tiles north and 2 tiles west of the mob. I know I would have to use the mobs location and work off of that but I don't really know what proc to use to check for an area in a tile the the mob is not on.

You can crudly use locate() and get a turf.

proc/get_turf(atom/ref) // ref is the starting point
return locate(ref.x+2, ref.y-2, ref.z) // two steps up, two steps west


~~> Dragon Lord
In response to Unknown Person
I got it to work! Thanks for your help! Again.
i just created another proc:
proc
get_area(turf/ref)
return (ref.loc)

in which i ran the result of the proc you created through and I now have a crude way of checking for areas. I could probably just combine the the two procs.
proc
get_area(mob/ref,var/psx as num,var/psy as num)
var/t = locate(ref.x+(psx), ref.y+(psy), ref.z)
return (t.loc)
In response to Drumersl
On a related note, is it possible to keep a tiles previous turf while adding another one on top. In Dream Maker you can put two turfs on top of each other and it will keep the lower one as long as you can see part of it. Is that possible in game?
Right now I am using:
new/turf/wall/woodwall/S(locate(usr.x+0, usr.y+1, usr.z))

to create a wall turf. I can't just make the walls into objects either because they use directional blocking, which from my experience fails when used with objects.
In response to Drumersl
You can't literally have two turfs on top of each other. DM lets you do it if the icon isn't filled completly, but there isn't actually two turfs. The turf(s) on the bottom get put on the top turf's underlays, so it is competly visual.

If you need to see something behind it, use objs.

~~> Dragon Lord
In response to Unknown Person
ah ok, well thanks again for your help.
In response to Drumersl

Alright one last question, I hope. I want to be able to affect an objects location right at runtime (src.loc), or at least I think I do based on an error I got. To solve my directional blocking object problem, I redefined the New() proc so that gives the turf its on the objects tbit value, (the directional blocking var) in other words:
obj/wall
New()
..()
spawn() // Added this and now it works fine
src.loc:tbitbak = src.loc:tbit
src.loc:ntbitbak = src.loc:ntbit
src.loc:tbit = src.tbit
src.loc:ntbit = src.ntbit
Del()
src.loc:tbit = src.loc:tbitbak
src.loc:ntbit = src.loc:ntbitbak
..()

This code works fine while the code is running, its just when loading the wall objects at the game start, all the locs are null. How do I get around this.
Here is the object saving code (in case thatis the problem:
var/list/objs = list ()
world/
New()
..()
if(fexists("map.sav"))
var/savefile/F = new ("map.sav")
F["objs"] >> objs
for(var/obj/o in objs)
o.loc = locate(o.lastx, o.lasty, o.lastz)
objs.Cut()
return ..()

Del()
..()
var/savefile/F = new("map.sav")
for(var/obj/o in world)
if(istype(o.loc.loc,/area/house/))
if(!istype(o.loc.loc,/area/house/house_res))
o.lastx = o.x
o.lasty = o.y
o.lastz = o.z
objs.Add(o)
F["objs"] << objs
return ..()