Outpost Universe Forums

Projects & Development => Outpost 2 Programming & Development => Topic started by: spirit1flyer on February 18, 2006, 08:17:54 PM

Title: "units Want To Go Off The Map" Revisited
Post by: spirit1flyer on February 18, 2006, 08:17:54 PM
okay I think I finaly got how to get units to go to where I want "to a corner anyway" by using
Code: [Select]
 fighters.SetRect(MAP_RECT(37,37,38,38));

but I do have a question.
It seems to me that to make the unit stop on one square, I have to keep the first two numbers the same and the second 2 numbers one number away, Now that appears like all I will get is the ablity to just go from point A too point B. Am I wrong?  how do I get it so I could put a unit, Not moving! on somewhere like, point C
Code: [Select]
.........................
..................C.....
.........................
B.......................
.........................
.........................
.........................
..........A.............



Title: "units Want To Go Off The Map" Revisited
Post by: Eddy-B on February 19, 2006, 07:47:54 AM
SetRect gives the group a command to stay within the specified rect. This rect can be of ANY size. If you supply a rect with only 1 tile in it, the unit(s) of the group stay within that 1 tile. The first 2 are X1 and Y1: the topleft corner of the rectangle; they do not have to be identical. The second 2 are X2 and Y2: the bottom right corner of the rectangle.
If X1=X2 and/or Y1=Y2 the rectangle is empty, i.e. a line of 0 width. You have to make sure that X2 is at least X1+1. The same goes for Y: Y2 must be at least Y1+1.

If you want the unit(s) to go to point C, you'd SetRect( MAP_RECT( x+31, y-1, x+32, y ))  where (x,y) are the coordinates of point C.
If C is ( 20, 5 ) you should make it: SetRect( MAP_RECT( 51, 4, 52, 5))

Keep in mind that if the group contains more then 1 unit, and your SetRect is only ONE tile, those units will "fight" for that 1 spot. The game engine will try to put all those units onto that 1 spot, which of course makes the units move around each other indefinately switching places all the time.


You can also create a SetRect that creates a small boxed area, that way the game engine will still keep the vehicle within the specified area, but from time to time it moves the vehicle to another spot within the rectangle. This gives your mission a more natural look when units are moving a bit.
Title: "units Want To Go Off The Map" Revisited
Post by: spirit1flyer on February 20, 2006, 11:17:27 AM
thanks for the help, That cleared up my problem  :P