Jump to content
John Douglas

How to make AI Hunt a player down while he is on the move?

Recommended Posts

Note from Moderator: Messages moved from here

I am trying to get this Arma 3 script working in Arma 2.

 

 

This topic has been an excellent source while providing a fun script to play, modify and explore. 

I am now attempting to place "Marker1" on the map to display the calculated position of "wp",previously local variable, and during testing I have also attempted to confirm these co-ords on the screen with the hint format command.

I have butchered the code a little with the use of global variables and I'm using in Arma2.

 

_null = this spawn
{  
PublicVariable"PlayerVictum" ; PublicVariable"wp" ;
Hunt_players_fnc =
{   PlayerVictum = "";   
{    if (isPlayer _x AND alive _x) then {PlayerVictum = _x};   } foreach (playableUnits + switchAbleUnits);   
wp = _this addWaypoint [getPos PlayerVictum, (100 + (floor(random 200)))];
wp setWaypointStatements ["true", "_null = (group this) spawn Hunt_players_fnc;"];   
wp setWaypointType "SAD";   
wp setWaypointCombatMode "RED";   
wp setWaypointSpeed "FULL";
};
_null = (group _this) spawn Hunt_players_fnc;

while {alive player} do  { "Marker1" setmarkerpos (getpos wp);
hint format ["%1", position wp];  
sleep 3;  }  

};




 

Edited by Dedmen
Note about thread origin added
  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, John Douglas said:

This topic

 

Hello there John Douglas and welcome also to Bis Forums !

 

This topic is very old and due this the codes used have change .

So if you want to have a group / unit to hunt someone , there is this available :

 

https://community.bistudio.com/wiki/BIS_fnc_stalk

 

This is a pic of my WIP GF Auto Population Script - Mod :

On 2/3/2019 at 11:08 AM, GEORGE FLOROS GR said:

Get prepared for anything , not just being afk , or chilling out in a base or house, the Enemy will try to kill every player on the Mission.

 

You can get the idea .

This is one behaviour and sigle unit spawn  from over 70 possible ( selected ) spawn type possibility.

jy2brvW.png

 

It will be available very soon !

  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you,

 

And here's one of my solutions as such. Just add  "Marker1" to your map !

 

_null = this spawn                                                      
{           
Hunt_players_fnc =  
{   _player = "";           
{        if (isPlayer _x AND alive _x) then {_player = _x};         
} foreach (playableUnits + switchAbleUnits);            
_Rad = (200 + (floor(random 250)));  
_wp = _this addWaypoint [getPos _player, (_Rad)];         
_wp setWaypointStatements ["true", "_null = (group this) spawn Hunt_players_fnc;"];           
_wp setWaypointType "SAD";         
_wp setWaypointCombatMode "RED";           
_wp setWaypointSpeed "FULL";           
_wpSAD = getWpPos(_wp);    

"Marker1" setmarkerpos (_wpSAD);
hint format ["Player Position: %1\nS&D _WP: %2", getpos(_player),_wpSAD];
sleep 3;
};
_null = (group _this) spawn Hunt_players_fnc; 
};

 

However,

 

I am now trying to format this to an sqf file i.e. "HuntPlayersFunction.sqf" file, and execute from the players Initialization box using:   null = [this] execVM "HuntPlayersFunction.sqf";

 

If someone helps me with this I promise to go away to my box for a week . . . LOL

 

Thanks in advance

Share this post


Link to post
Share on other sites
1 hour ago, John Douglas said:

However,

 

I am now trying to format this to an sqf file i.e. "HuntPlayersFunction.sqf" file, and execute from the players Initialization box using:   null = [this] execVM "HuntPlayersFunction.sqf";

 

If someone helps me with this I promise to go away to my box for a week . . . LOL

 

Thanks in advance

 

The function you have wont do anything by executing it from a players init, even with execVM.
It must be executed on all AI groups that you want to hunt down the players.

You said in a previous comment that you were using this on ArmA 2. Is that correct?

Share this post


Link to post
Share on other sites
13 minutes ago, Maff said:

@Mr H. I think he may be using ArmA 2, not ArmA 3.

Nope. He posted in Arma 3 Editing section. So he better not be talking about Arma 2.

  • Thanks 1
  • Haha 1

Share this post


Link to post
Share on other sites

Thanks Maff and MrH,

 

Because I found the ref to the original  code in Arma3 I continued the discussion there. . . .But I'm using Arma2. So maybe I should have used a new post. Sorry.

 

I can re-post there if you like Dedmen?
 

Share this post


Link to post
Share on other sites

I just wanted to clarify that you were using ArmA 2 as, most if not all, ArmA 3 functions won't work in ArmA 2.

Also, there are scripting commands that are only available in ArmA 3.

 

I would recommend re-posting in ARMA 2 & OA : MISSIONS - Editing & Scripting.

 

In the meantime, check out the following links from @kylania.

 

Spawn something in front of the player
AI spawned waves from random direction

 

I learned a lot from these scripts back in the day.

Edited by Maff
  • Thanks 1

Share this post


Link to post
Share on other sites

I've moved the thread to the correct section and edited the first post to reference to the old thread.

 

23 hours ago, John Douglas said:

I am now trying to format this to an sqf file i.e. "HuntPlayersFunction.sqf" file, and execute from the players Initialization box using:   null = [this] execVM "HuntPlayersFunction.sqf"; 

The script itself already creates a script function.
You should just paste this code:

Hunt_players_fnc = {
_player = "";           
{
    if (isPlayer _x AND alive _x) then {_player = _x};         
} foreach (playableUnits + switchAbleUnits);            
_Rad = (200 + (floor(random 250)));  
_wp = _this addWaypoint [getPos _player, (_Rad)];         
_wp setWaypointStatements ["true", "_null = (group this) spawn Hunt_players_fnc;"];           
_wp setWaypointType "SAD";         
_wp setWaypointCombatMode "RED";           
_wp setWaypointSpeed "FULL";           
_wpSAD = getWpPos(_wp);    

"Marker1" setmarkerpos (_wpSAD);
hint format ["Player Position: %1\nS&D _WP: %2", getpos(_player),_wpSAD];
sleep 3;
};
(group _this) spawn Hunt_players_fnc; 

Into your "HuntPlayersFunction.sqf" file.
And then execute

if (local this) then {
    _null = this execVM "HuntPlayersFunction.sqf";
}

From One unit per AI group's init script.

 

The "if (local this)" makes sure the code only runs once on the server. Otherwise it would run for every player, meaning it might run dozens of times if you have a dozen players.

  • Thanks 1

Share this post


Link to post
Share on other sites

This is just awesome . . . . Thanks guys with your persistence, and thanks to demonized for what I'm finding as an interesting piece of code to study and use. Apologies for the initial confusion.

Of course it worked off the bat and I couldn't stop playing into the early hours, hence the late response with enthusiasm. Better than Xmas morning for me gentleman.....lol

And now I'm off to explore . . . .more code too, that is! 

  • Haha 1

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

×