Author Topic: "units Want To Go Off The Map" Revisited  (Read 1737 times)

Offline spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
"units Want To Go Off The Map" Revisited
« 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.............



"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
"units Want To Go Off The Map" Revisited
« Reply #1 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.
« Last Edit: February 20, 2006, 12:12:29 PM by Eddy-B »
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz

Offline spirit1flyer

  • Hero Member
  • *****
  • Posts: 621
"units Want To Go Off The Map" Revisited
« Reply #2 on: February 20, 2006, 11:17:27 AM »
thanks for the help, That cleared up my problem  :P  
"Until you stalk and overrun You can't devour anyone"


Loyal Xfir supporter