Outpost Universe Forums

Projects & Development => Outpost 2 Programming & Development => Topic started by: Sirbomber on July 08, 2009, 11:36:23 PM

Title: Getting Ai Units To Patrol
Post by: Sirbomber on July 08, 2009, 11:36:23 PM
Okay, I've been having this problem for awhile now.  The documentation for AI patrols is so crappy it may as well not exist.

I know I need to call SetPatrolMode(struct PatrolRoute &waypts); on the fight group I want to patrol, but before that I need to setup the PatrolRoute struct:

Code: [Select]
struct OP2 PatrolRoute 
{
int unknown1;
LOCATION *waypoints;
};

What I really want to know is how do I tell OP2 which waypoints I want the units patrolling between?  At first I thought waypoints was an array, but apparently it isn't.  What should I do?
Title: Getting Ai Units To Patrol
Post by: Eddy-B on July 09, 2009, 01:02:17 AM
Quote
Okay, I've been having this problem for awhile now.  The documentation for AI patrols is so crappy it may as well not exist.
Have you checked my coverage of the topic?
Should be somewhere in the coding section..
Title: Getting Ai Units To Patrol
Post by: Sirbomber on July 09, 2009, 07:10:56 AM
Yes, it wasn't very helpful.

Someone just tell me how to setup the waypoints and I'll be happy.
Title: Getting Ai Units To Patrol
Post by: Eddy-B on July 09, 2009, 11:51:15 AM
I can look it up in my source, but the struct you posted is pretty self-evident:
create an array of locations:
LOCATION waypoints[]={  waypoint1, waypoint2, waypoint3 };



[EDIT]Ok, looked it up!

here's a small piece of source code, taken directly from Renegades, mission 1. It sets up 3 patrol routes, using waypoints. Study it, and LEARN!

Code: [Select]
EXPORT void SetPatrols()
{
LOCATION scoutRoute1[]=
{
  LOCATION(120, 14),
  LOCATION( 96,  6),
  LOCATION(125, 36),
  LOCATION(142, 41),
  LOCATION(142, 15),
  LOCATION( -1, -1)
};

LOCATION scoutRoute2[]=   // scout right map
{
  LOCATION(136, 47),
  LOCATION( 91, 55),
  LOCATION( 84, 23),
  LOCATION(141, 14),
  LOCATION( -1, -1)
};

LOCATION scoutRoute3[]=   // scout enemy base
{
  LOCATION(138, 24),
  LOCATION( 90, 58),
  LOCATION( 34, 60),
  LOCATION( 49, 26),
  LOCATION( 50,  8),
  LOCATION( 85, 23),
  LOCATION(133, 10),
  LOCATION( -1, -1)
};

PatrolRoute route1,route2,route3;
FightGroup patrol1,patrol2,patrol3;
IUnit u;

patrol1=CreateFightGroup(Player[1]);
route1.waypoints=scoutRoute1;
patrol1.SetPatrolMode(route1);

patrol2=CreateFightGroup(Player[1]);
route2.waypoints=scoutRoute2;
patrol2.SetPatrolMode(route2);

patrol3=CreateFightGroup(Player[1]);
route3.waypoints=scoutRoute3;
patrol3.SetPatrolMode(route3);

TethysGame::CreateUnit(u,mapScout,LOCATION(158,2),1,mapNone,West);
patrol1.TakeUnit(u);
TethysGame::CreateUnit(u,mapScout,LOCATION(158,4),1,mapNone,SouthWest);
patrol2.TakeUnit(u);
TethysGame::CreateUnit(u,mapScout,LOCATION(158,6),1,mapNone,SouthWest);
patrol3.TakeUnit(u);
}
Title: Getting Ai Units To Patrol
Post by: Sirbomber on July 09, 2009, 12:23:11 PM
Excellent.  I see what I was doing wrong now.  Thanks.
Title: Getting Ai Units To Patrol
Post by: Eddy-B on July 09, 2009, 12:28:44 PM
forgot the (-1,-1) at the end ?
Title: Getting Ai Units To Patrol
Post by: Sirbomber on July 09, 2009, 02:43:35 PM
No, I did the array wrong.  At least I was right about it being an array though...