Jump to content
Sign in to follow this  
Ice_Rhino

AI to stalk player group

Recommended Posts

Hi (Again)

Is there a way to get enemy forces to stalk and then attack the human player group. My group is called 'bluplagro'

Thanks

Toni

IR

Share this post


Link to post
Share on other sites

//Place this code anywhere in your init.sqf
[] spawn {	
 if (!isServer) exitWith {};
while {true} do {	
	{
		if (getNumber (configfile >> "CfgVehicles" >> typeOf _x >> "side") in [0,2]) then {
			_x doMove getPosATL (leader myGrp);
		};
	} forEach allUnits;
    sleep 60;
};
};

or

//Place this code anywhere in your init.sqf 
[] spawn {	
while {true} do {	
	{
		if (side _x in [Opfor, Independent]) then {
			_x doMove getPosATL (leader bluplagro);
		};
	} forEach allUnits;
	sleep 60;
};
};

or

//Place this code anywhere in your init.sqf
[] spawn {	
  if (!isServer) exitWith {};
while {true} do {	
	{
		if (side _x != side (leader bluplagro)) then {
			_x doMove getPosATL (leader bluplagro);
		};
	} forEach allUnits;
	sleep 60;
};
};

or

Could mess around with behaviours and such. w/e...

[] spawn {	
while {true} do {	
	{
		if (side _x in [Opfor, Independent]) then {
			_x doMove getPosATL (leader bluplagro);
			if (_x distance (leader bluplagro) < 100 && {behaviour _x != "COMBAT"}) then {
				(group _x) setBehaviour "COMBAT";
			} else {
				(group _x) setBehaviour "AWARE";
			};
		};
	} forEach allUnits;
  sleep 60;
};
};

Edited by Iceman77

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

How about the opposite-ish? Any script to make AI retreat to new position when player pushes closer than distance y?

Share this post


Link to post
Share on other sites
How about the opposite-ish? Any script to make AI retreat to new position when player pushes closer than distance y?

Untested, probably better ways.

// Put anywhere in your init.sqf
[] spawn {
while {true} do {
	{
		if (_x distance player < 200 && {side _x != side player}) then {
			_x doMove (player modelToWorld [0,1000,0]);
		};
	} forEach allUnits;
  sleep 30;
};
};

Share this post


Link to post
Share on other sites

hmm. I am testing this with bcombat and vcom AI with mixed results. Is there such a thing as forcemove command which stops them from doing anything while retreating?

Share this post


Link to post
Share on other sites
See post #10.

Once I get another chance I'll test with _x disableAI "FSM"; //then re enable it?

Thanks for the tips/

Share this post


Link to post
Share on other sites

This + Bcombat seems to be the sweet spot for the type of AI behavior I was looking for. Not too agressive but not always turning their back on bullets flying either. Play tested on PR Afghanistan Village with POMI PMC and very much a treat.

[] spawn {

while {true} do {

{

if (_x distance player < 250 && {side _x != side player}) then {

_x disableAI "AUTOTARGET";

_x disableAI "TARGET";

_x doMove (player modelToWorld [0,300,0]);

};

} forEach allUnits;

sleep 10;

_x enableAI "AUTOTARGET";

_x enableAI "TARGET";

};

};

Iceman thanks for your help!

Share this post


Link to post
Share on other sites
This + Bcombat seems to be the sweet spot for the type of AI behavior I was looking for. Not too agressive but not always turning their back on bullets flying either. Play tested on PR Afghanistan Village with POMI PMC and very much a treat.

[] spawn {

while {true} do {

{

if (_x distance player < 250 && {side _x != side player}) then {

_x disableAI "AUTOTARGET";

_x disableAI "TARGET";

_x doMove (player modelToWorld [0,300,0]);

};

} forEach allUnits;

sleep 10;

_x enableAI "AUTOTARGET";

_x enableAI "TARGET";

};

};

Iceman thanks for your help!

You may consider to add:

(group_x) setCombatMode "GREEN"; // Temporarily HOLD fire
_x dowatch objNull; // Force disengage
_x disableAI "FSM"; 

EDIT: by the way, till now i hardly saw any visible effects caused by disableAI "FSM", but it's probably worth adding.

Share this post


Link to post
Share on other sites

Thanks fabrizio_T. Will give this a try.

Didn't notice much with disableAI "FSM" either after much testing.

Share this post


Link to post
Share on other sites

Anyone care to try this out:

[] spawn {
   while {true} do {
       {
           if (_x distance player < 250 && {side _x != side player}) then {
               _x disableAI "AUTOTARGET";
_x disableAI "TARGET";

(group_x) setCombatMode "GREEN"; // Temporarily HOLD fire
_x dowatch objNull; // Force disengage
//_x disableAI "FSM";

_chance = round(random 5);

switch _chance do
{
case 0:
{
_x doMove (player modelToWorld [300,300,0]);
};

case 1:
{
_x doMove (player modelToWorld [300,-300,0]);
};

case 2:
{
_x doMove (player modelToWorld [-300,300,0]);
};

case 3:
{
_x doMove (player modelToWorld [-250,250,0]);
};

case 4:
{
_x doMove (player modelToWorld [250,250,0]);
};

case 5:
{
_x doMove (player modelToWorld [250,-250,0]);
};
};

           };
       } forEach allUnits;
     sleep 30;
_x enableAI "AUTOTARGET";
_x enableAI "TARGET";
//_x enableAI "FSM";
     //sleep 60;
    };
};  

Edited by sttosin

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  

×