Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Neviothr

Making AI units actively chase the player?

Recommended Posts

Basically what I want is for AI units to chase, look and actively hunt for the player after initial contact. Then, if the player managed to survive, and if there are 2 or less AI in a group, I want them (the AI) to hold position.

 

So far I've got this, but it doesn't seem to be working, even after some time in contact, the AI still only maneuvers slightly.

 

Init.sqf:

execVM "skill.sqf";
execVM "chase.sqf";

Skill.sqf

{
_x setSkill ["aimingAccuracy", 0.40];
_x setSkill ["aimingShake", 0.40];
_x setSkill ["aimingSpeed", 0.45];
_x setSkill ["spotDistance", 0.60];
_x setSkill ["spotTime", 0.65];
_x setskill ["courage",1];
_x setSkill ["reloadSpeed", 1];
_x setSkill ["commanding", 0.90];
_x setSkill ["general", 1];
_x allowFleeing 0;
_x setCombatMode "RED";
} forEach allUnits;

Chase.sqf:

while {true} do
{
	_know = (opfor) knowsAbout (player);

	waitUntil {_know > 2} do
		{
		(leader chaser) doMove (getPos player);
		sleep 5;
		};
sleep 4;
};

Thank you for your help :)

Share this post


Link to post
Share on other sites

WaitUntil syntax is wrong. Do you want something like this?

while {true} do
	{
	waitUntil
		{
		sleep 5;
		
		_know = (opfor) knowsAbout (player);
		
		(_know > 2)
		};

	(leader chaser) doMove (getPos player);
	};
  • Like 1

Share this post


Link to post
Share on other sites

 

WaitUntil syntax is wrong. Do you want something like this?

while {true} do
	{
	waitUntil
		{
		sleep 5;
		
		_know = (opfor) knowsAbout (player);
		
		(_know > 2)
		};

	(leader chaser) doMove (getPos player);
	};

 

That worked, thanks man!

Share this post


Link to post
Share on other sites

Place yourself on the map and name yourself  blue1

 

Place an enemy on the map and name him red1

 

Way over on the other side of the map,  on an out of the way road - place an independent  and name him green1

 

Place a trigger on the map near to green1. Make the trigger repeatable. 

 

Give green1 a series of waypoints so that he constantly runs through the waypoint, it fires, he turns around and runs through it again and so on forever.

 

In the trigger place this code:........red1 move getPos player; red1 setCombatMode "RED";

 

The trigger will fire over and over again and the enemy will come chasing you.

 

If there are 3 or more enemy you have little chance of escape!

 

 

 

 

 

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

×