ID:269321
 
D:
I need something to check the whole world the way view() does.
(for(var/blah in world) goes from left to right and stuff)
How would you go about doing this?
I was thinking creating an obj everytime view() gets to its limit, and making a view proc off of the obj...but it might not work, so I wanna' know before I work on it. :p
D:
I need something to check the whole world the way view() does.
(for(var/blah in world) goes from left to right and stuff)
How would you go about doing this?
I was thinking creating an obj everytime view() gets to its limit, and making a view proc off of the obj...but it might not work, so I wanna' know before I work on it. :p

If you need to keep line of sight restrictions based on the center you'll have problems. However if you just want to get everything within a specified range you could just use block() to get the turfs within a certain range then check all their contents.
In response to Theodis
Theodis wrote:
D:
I need something to check the whole world the way view() does.
(for(var/blah in world) goes from left to right and stuff)
How would you go about doing this?
I was thinking creating an obj everytime view() gets to its limit, and making a view proc off of the obj...but it might not work, so I wanna' know before I work on it. :p

If you need to keep line of sight restrictions based on the center you'll have problems. However if you just want to get everything within a specified range you could just use block() to get the turfs within a certain range then check all their contents.

You could always, however, do your own line-of-sight routines based on the techniques available at http://roguelikedevelopment.org. Sadly you can't replace BYOND's automatic line-of-sight stuff with your own, but you can always use a homemade LOS calculator for other purposes.

Lummox JR
In response to Theodis
Er, I gave what you said a shot and:
    largerange(atom/center,range)
var/list/l=list()
for(var/turf/a in block(locate(center.x-range,center.y-range,center.z),locate(center.x+range,center.y+range,center.z)))
l+=a
l+=a.contents
for(var/i in l)world<<l
return l


Yet, it finds nothing in the list D: (nothing gets sent to the world). I did for(var/turf/t in largerange(src,10)). And nothing got sent out D: Sorry for being bothersome or something. But, what's the problem?
[edit]Realised all I needed was a turf (code edit)
[edit]I fixed it, and block isn't what I want, it goes like:
#########
Not:
###
###
###

Any other ways to imitate view(), just a large range number at the end?
In response to Lummox JR
What if you created temporary new objects and made the proc check their view() as well? The player wouldn't see anything, but you could expand the area. I don't know how to do it at the moment. But it sounds like a cool idea (at least I think so lol).
In response to Rockinawsome
Rockinawsome wrote:
What if you created temporary new objects and made the proc check their view() as well? The player wouldn't see anything, but you could expand the area. I don't know how to do it at the moment. But it sounds like a cool idea (at least I think so lol).

Can't be done, because the view angle would be off. If A can see B and B can see C, it doesn't necessarily follow that A can see C.

Lummox JR
In response to Lummox JR
I'm trying to get the visual sense of what you're saying, you're most probably right, I just can't picture what you're saying yet. Hehe, perhaps a cheesy text map to help me out?

like:

M = mob O = object X=view of Mob V=view of Object

VVVVV
VXOXV
VVXXXXXVV
VVOXMXOVV
VVXXXXXVV
VXOXV
VVVVV

Or...something like that....Cripes...that looks terrible.
Well, it lets me think that everything in oview of M would be done twice (because of the view of the objects), so you'd have to control it with an if statement and a variable so it only happens once.
I don't know...
In response to Rockinawsome
I don't know...

  B      C
|-------
|
A |


The dashes are a wall. A can see B and B can see C but the wall blocks A from seeing C.
In response to Theodis
O, I get it now. Alright. Thanks.
In response to Hell Ramen
This works for me: (Of course, it doesn't do any LOS checking, just returns a big block of stuff and the stuff in that stuff, minus the Ref, their stuff and location if you use longoview(). <s>Range doesn't accept text, so you can't use "11x13" for the range, like you can with view().</s>

[Edit 2] Range does accept text now. You can enter a single number for the range, or you can use a text string, or even world.view or client.view. The format for text ranges is the same as world.view: ex: "11x13".

#define neighbors(X, Y, Z, XRange, YRange) (\
block(\
locate(\
max( ( (X) - (XRange) ), 1),\
max( ( (Y) - (YRange) ), 1),\
(Z)\
),\
locate(\
min( ( (X) + (XRange) ), world.maxx),\
min( ( (Y) + (YRange) ), world.maxy),\
(Z)\
)\
)\
)


proc
longview(atom/Ref, Range)
var/list/R, X, Y
if(istext(Range))
R = textview2nums(Range)
X = R["X"]; Y = R["Y"]
X = (X || Range)
Y = (Y || Range)
var/list/longview = new
longview += Ref.contents
for(var/turf/T in neighbors(Ref.x, Ref.y, Ref.z, X, Y))
longview += T
if(T == Ref) continue
longview += T.contents
return longview

longoview(atom/Ref, Range)
var/list/R, X, Y
if(istext(Range))
R = textview2nums(Range)
X = R["X"]; Y = R["Y"]
X = (X || Range)
Y = (Y || Range)
var/list/longoview = new
for(var/turf/T in neighbors(Ref.x, Ref.y, Ref.z, X, Y))
if((T == Ref) || (T == Ref.loc)) continue
longoview += T
longoview += T.contents
return longoview

textview2nums(View)
if(!istext(View)) return View
var/xpos = findtext(View, "x")
if(!xpos) return View
var/X = round(text2num(copytext(View, 1, xpos))/2)
var/Y = round(text2num(copytext(View, xpos +1))/2)
return list("X"=X, "Y"=Y)


You will still have to figure out how to tell if the things in this list can be seen by the Ref. >.>

~X
[Edit] Wait, what about shooting the atom? If you can use a missle to hit the atom, then it goes to reason that you can see it. Not always true for view(), but it might work. It would probably be rather slow, though, relatively speaking.