Jump to content
Sign in to follow this  
Eclipse4349

How to make AI capture the flag in CTF

Recommended Posts

I am working on a complete overhaul of CTF, in which I added respawning vehicles and ammo crates with every weapon and ammotype. I have AI squads which have waypoints to areas of Utes and some objective once they get there, such as seek and destroy or attacking/defending the airfield, where I have an attack chopper and jet for each side. All squads will enter a vehicle and use that vehicle to proceed to the next waypoint(s), if the vehicle is at its starting location. If not, they will simply move on to their next waypoint without it. I did this via triggering a trigger which assigns the AI to the vehicle and orders them to get in, which is activated when a trigger detecting anything placed at the vehicle spawn and a trigger at the "loading area" that detects Blufor presence are both activated. Everything is working great. All the squads get in their respective Humvee/APC/Tank and go about their business. I have one humvee load that goes to the airfield, and, once a trigger for no opfor in the area is activated, they will move up to the chopper/jet, disembark, then board the chopper/jet and search and destroy elsewhere, leaving a driver and gunner in the humvee to do the same. Basically, I have the AI commanded to behave like a human player cooperating in a team to play CTF.

The ONLY thing that isnt working, after DAYS of figuring all this out, with oustanding support from the community, is: THE AI WILL NEVER CAP THE FLAG. I am using the commands that are in the stock CTF template from BIS, and the same squad is still assigned to take the flag, using the same conditions and triggers as the template. The AI will go the flag and sit there. If I take it, we get our next waypoint to OUr flag, and once I get to our flag area with the enemy flag, we get a point. Works fine, functionally. But the AI will never do it themselves.

I am thinking that the "move" waypoint that tells them to take the flag if the conditions provided by BIS are right, IE, the flag is still there and they are within 6m of it, etc, are useless, because they are never standing in the correct position for the "take flag" command to do anything when the waypoint is first activated. I noticed while playing the ctf template from BIS that the AI also never caps the flag, but will get to the flag area and basically sit there guarding it. Do I need to, at the waypoint with the "take flag" command associated with it, add in a getpos "flag" and setpos [AI players] to that position, and setdirection "facing the flagpole from that direction", THEN the take flag command? How would I do that?

Once I get this working and duplicate the setup and AI behavior for the OpFor, I will PBO it and post it in the User Missions area!

Thanks a lot for all the help so far. I am learning a lot :)

Edited by Eclipse4349

Share this post


Link to post
Share on other sites

I have the same problem...

class Waypoints

{

items=1;

class Item0

{

position[]={8781.5693,215.88217,11574.553};

combatMode="YELLOW";

formation="WEDGE";

speed="FULL";

combat="SAFE";

expCond="this";

expActiv="this action [""Take Flag"", VlajkaUSA]";

class Effects

{

};

showWP="NEVER";

};

};

Share this post


Link to post
Share on other sites

Anyone have a thought on this?

---------- Post added at 10:05 PM ---------- Previous post was at 09:12 PM ----------

	class Item1
	{
		side="EAST";
		class Vehicles
		{
			items=1;
			class Item0
			{
				position[]={8917.0107,213.99904,11655.723};
				azimut=438.91199;
				id=7;
				side="EAST";
				vehicle="RU_Soldier";
				player="PLAY CDG";
				leader=1;
				rank="COLONEL";
				skill=0.60000002;
				text="R1";
			};
		};
		class Waypoints
		{
			items=5;
			class Item0
			{
				position[]={8781.5352,215.87788,11574.606};
				combatMode="RED";
				speed="NORMAL";
				combat="AWARE";
				expCond="(local this) and this != player and (this distance VlajkaUSA < 6)";
				expActiv="this action [""TAKE FLAG"", VlajkaUSA]";
				class Effects
				{
				};
				showWP="NEVER";
			};
			class Item1
			{
				position[]={8781.5,215.87337,11574.644};
				type="HOLD";
				class Effects
				{
				};
				showWP="NEVER";
			};
			class Item2
			{
				position[]={8804.7461,214.04544,11690.536};
				speed="FULL";
				combat="AWARE";
				class Effects
				{
				};
				showWP="NEVER";
			};
			class Item3
			{
				position[]={8804.7744,214.04535,11690.532};
				type="HOLD";
				class Effects
				{
				};
				showWP="NEVER";
			};
			class Item4
			{
				position[]={8781.4629,215.86873,11574.606};
				type="CYCLE";
				class Effects
				{
				};
				showWP="NEVER";
			};
		};
	};


	class Item1
	{
		position[]={8781.5352,215.87788,11574.606};
		age="ACTUAL";
		id=3;
		side="EMPTY";
		vehicle="FlagCarrierUSA";
		lock="UNLOCKED";
		skill=0.2;
		text="VlajkaUSA";
		init="this setflagside west";
	};

The AI will NEVER take the flag, just stands near the pole.

Share this post


Link to post
Share on other sites

You have the action named wrong, try this:

unitName action ["TAKEFLAG", VlajkaUSA];

Share this post


Link to post
Share on other sites

hmmm that means the BIS template CTF is broken. They have "Take Flag" instead of "takeflag".. The latter does work!!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×