ID:155973
 
Is it possible to have like a command where like it checks like a certain area. Here is a Diagram to show what I am talking about:

http://img651.imageshack.us/img651/235/testpf.png
Well you can easily just use the coordinates of each tile you want to check. For instance.. If you wanted to check what was two squares ahead of the player and to the left 2 squares it could be described like this :

(usr.x+2,usr.y+2,usr.z)


This now gives the exact location of that tile. So.. You want a few tiles so just save them all as variables like this :

var/Tile1 = locate(usr.x+2,usr.y+2,usr.z)
var/Tile2 = locate(usr.x+1,usr.y+1,usr.z)

//etc etc etc


The rest should be pretty basic but if you need any more help just drop another post.
In response to Kyle_ZX
Can u put it into a like view? XD sorry I need idoit guide.
In response to DeltaMaster
mob
proc
NewView()
var/mob/Tile1 = locate(usr.x+1,usr.y+1,usr.z)
var/mob/Tile2 = locate(usr.x,usr.y,usr.z) // Add needed locations from here on.
var/mob/Tile3 = locate(usr.x,usr.y,usr.z)
var/mob/Tile4 = locate(usr.x,usr.y,usr.z)
var/mob/Tile5 = locate(usr.x,usr.y,usr.z)
var/mob/Tile6 = locate(usr.x,usr.y,usr.z)
var/mob/Tile7 = locate(usr.x,usr.y,usr.z)
var/mob/Tile8 = locate(usr.x,usr.y,usr.z)
var/mob/Tile9 = locate(usr.x,usr.y,usr.z)
var/mob/Tile10 = locate(usr.x,usr.y,usr.z)
var/mob/Tile11 = locate(usr.x,usr.y,usr.z)
var/mob/Tile12 = locate(usr.x,usr.y,usr.z)
var/mob/Tile13 = locate(usr.x,usr.y,usr.z)
var/mob/Tile14 = locate(usr.x,usr.y,usr.z)
del Tile1 // Whatever you want to do with that mob.


I'm not going to do it for you if that's what you're asking.
view("5x2")
You can specify a rectangle like that with a text string instead of supplying an integer.
In response to Loduwijk
I was going to reply with this until I realized that it's much more tedious code to have a result shown in the OP's picture.

Not the best way, but the easiest I can think of off the top of my head.
mob/proc/get_rectangle_ahead()

. = view(src, 2)

var turf/t

var dirs[] = list(dir, turn(dir,-45), turn(dir,45)) // This is a list of valid directions.
for(t in .)
if(!(get_dir(src, t)in dirs))
.-= t // This results in all the turfs ahead of you.
In response to Kyle_ZX
That I think is the absolute worst possible way to go about this. Don't give advice to people on the Developers Forums if you yourself are not an experienced developer and advocate bad practices.

To the OP:
for(var/turf/T in Block(locate(x-3,y+2,z),locate(x+3,y+1,z))
//From here you can do whatever you want with that range
//Ex: Finding all mobs in this area
var/mob/M = locate() in T
if(M) M<<"Watchout [M]! Your in [src]'s area!"


I'd say using Block() and specifying the range you check(By top left tile, to bottom left tile) would be a simple way of achieving this.
In response to Bakasensei
for(var/obj/cards/C in Block(locate(x-3,y+2,z),locate(x+3,y+1,z))
del(C)


It seems when I put this in, it always comes up with errors. Errors include
loading Duel Monsters Game.dme
Verbs\Verbs.dm:6:error: name: missing comma ',' or right-paren ')'
Dueling Code\Dueling Proc.dm:27:error: list started here
Verbs\Verbs.dm:13:warning: empty 'else' clause
Verbs\Verbs.dm:16:warning: empty 'else' clause
Verbs\Verbs.dm:27:warning: empty 'else' clause
Duel Monsters Game.dme:40:error: unbalanced }
In response to DeltaMaster
add an end parenthesis in the for, he forgot one

block() is really slow also, but you're not using too big of an area so it shouldn't matter.
In response to ANiChowy
It still doesn't work.

Here is the code now:

for(var/obj/cards/C in block(locate(usr.x-3,usr.y+2,usr.z),locate(usr.x+3,usr.y+2,usr.z)))
if(C.own == 1)
del(C)
else
return
In response to DeltaMaster
What, specifically, isn't working?

Also, the block() proc works with the lower-left corner of the block for the first argument, and the top-right corner for the second.
In response to DeltaMaster
DeltaMaster wrote:
It still doesn't work.

Here is the code now:

for(var/obj/cards/C in block(locate(usr.x-3,usr.y+2,usr.z),locate(usr.x+3,usr.y+2,usr.z)))
> if(C.own == 1)
> del(C)
> else
> return


block() returns a list of turfs, which your card objects won't be explicitly included in (unlike with view()). What you have to do is loop through the turfs in the block, and then use locate() to check for a card object in each turf (as Bakasensei showed you, so look at his code more carefully. Just instead of mobs, you'll be locating /obj/cards)
In response to Kaiochao
Kaiochao wrote:
I was going to reply with this until I realized that it's much more tedious code to have a result shown in the OP's picture.

Ah, right. Well then, perhaps you could do something like...
mob/proc/get_view_ahead(a,b, distance)
var/turf/T = src
for(var/i = 1 to distance)
T = get_step(T, dir)
return view(a,b)

Then you could do get_view_ahead("5x2", src, 2) to get a 5x2 viewing offset by two tiles in the direction you are facing. Oh, and you'd have to account for the direction if you want to rotate the rectangle, that is, you'd have to be able to change it from 5x2 to 2x5.

Also, this will not take the mob's special view status into consideration. For example, if the mob has see_invisible or a change to its sight variable or anything else, the view from the turf's point of view is not going to take that into account.

Kaiochao's version will work for the specific situation in the picture you showed, and mine will allow for different translations if you don't want it just directly ahead. Mine, as I said, requires you to handle the special cases where you need to rotate the rectangle according to your direction (north/south vs east/west), but Kaiochao's takes care of that automatically.