Jump to content

ChaIie

How to use BIS_fnc_stalk?

Recommended Posts

Hello everyone,

 

Since days i try to build up a scenario where a set of enemys (for instance 1 heli, 2 tanks etc) starts on on side of the island while im on the other. for respawns, i already synced everything to a MGI system . But the issue is i have no idea how to make the AI chase me where ever i go. I already tried a script from here, but it only sets a waypoint to my spawn. 

I always came across the  BIS_fnc_stalk  https://community.bistudio.com/wiki/BIS_fnc_stalk . But i have no idea how to build it up. 

If i use the first example  [ _stalking = [BIS_grpStalkers, BIS_grpPlayer] spawn BIS_fnc_stalk; ]  what do i have to do with it? does it belong into the init from the enemy AI? do i have to change names? 

Also can i add behavior to SAD or destroy to this?

 

Thanks for any help 

Share this post


Link to post
Share on other sites

You could put example above in an init field, or activate it in a trigger, or a script. 

 

For this to work using the example above, you would have to name the group that will stalk the player, BIS_grpStalkers, and the player's group, BIS_grpPlayer. 

Share this post


Link to post
Share on other sites

A way I have used stalk is to place in the hunting unit's (BIS_grpStalkers) 2nd waypoint On Activation field:

_stalking = [BIS_grpStalkers, BIS_grpPlayer] spawn BIS_fnc_stalk;

or for MP:

_stalking = [BIS_grpStalkers, group (allPlayers select 0)] spawn BIS_fnc_stalk;

 

I can't remember why it doesn't work in first waypoint...I place first waypoint real close and 2nd waypoint also close.

I have never dealt with behavior other than setting speed, stance, and behavior in the edited unit and/or waypoint. They seem to close with me and engage just fine.

Share this post


Link to post
Share on other sites
  On 12/23/2021 at 5:01 PM, stburr91 said:

You could put example above in an init field, or activate it in a trigger, or a script. 

 

For this to work using the example above, you would have to name the group that will stalk the player, BIS_grpStalkers, and the player's group, BIS_grpPlayer. 

 

I don't know what im doing wrong but it doesn't want to work 

FuJA0S5.jpg Is this the way to change the group names? otherwise i dont know how 

if i put the example into a trigger , the enemy doesn't even start move . same when i make 2 waypoints into a trigger field for the enemy (they just fly to the 2 waypoint and stop there).  

Share this post


Link to post
Share on other sites

When using multiple groups, the groups get identified individually, and the script is run for each instance of a stalking: group A pursuing group B.  Don't limit yourself to BIS_grpStalkers and BIS_grpPlayer, those are example identifiers given for a single group stalking (BIS_grpStalkers) and a single group to be stalked (BIS_grpPlayer).

 

Identify a group to do stalking, and a group for them to stalk (it can be the same group another is already pursuing).  Run the script for the two groups.  You can do it in unit init fields, or in an init script, or a trigger.

A_1_handle = [grpA, grp1] Spawn BIS_fnc_stalk;  // grpA pursues grp1
B_1_handle = [grpB, grp1] Spawn BIS_fnc_stalk;  // grpB pursues grp1
C_1_handle = [grpC, grp1] Spawn BIS_fnc_stalk;  // grpC pursues grp1
D_2_handle = [grpD, grp2] Spawn BIS_fnc_stalk;  // grpD pursues grp2
E_2_handle = [grpE, grp2] Spawn BIS_fnc_stalk;  // grpE pursues grp2

The condition code is optional, a condition to end the stalking.  It gets checked each iteration (default 10 seconds) using isNil, as in: isNil {WhateverThisCodeReturns}, then whether the return is true or false.  Because isNil evaluates the expression, and it could be a complex expression, it can first be used to set the stalking group's current waypoint to SAD before returning the true/false condition.  But be very careful about that, 1) there can be no suspension, 2) don't make the code complex, keep it simple, and 3) the final code must be the return giving TRUE or FALSE, for ending the stalking.  Example:

// grpB pursues grp1 until all units in grp1 are dead, then returns to base (original start position).
B_1_handle = [grpB, grp1,10,0,{[grpB,currentWaypoint grpB] setWaypointType "SAD"; {Alive _x} Count (Units grp1) == 0},(Position Leader grpB)] Spawn BIS_fnc_stalk;

Zoom on a leader in editor, there is also a box for editing the group he is in.  You can name his group there.  Or old school, in a leader init field you can put "myGroupName = group this;"

 

Edited by opusfmspol
added condition example
  • Like 5
  • Thanks 1

Share this post


Link to post
Share on other sites

It looks like you are only changing the callsign in the editor.

You need to name each group...

@opusfmspol saves the day.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Ah i see what i did wrong. when i put the name into the variable name from the group it works. Gonna test around now also with mulitple groups

 

Also another question now, is there any simple way to reveal myself to the AI or change the behavior to SAD? 

i guess https://community.bistudio.com/wiki/reveal is correct but what should i do here? 

Share this post


Link to post
Share on other sites
  On 12/24/2021 at 4:16 AM, ChaIie said:

is there any simple way to reveal myself to the AI or change the behavior to SAD? 

i guess https://community.bistudio.com/wiki/reveal is correct but what should i do here? 


Aye.
reveal is a good command, but it depends where and when you need the command.
You are still using BIS_fnc_stalk, right?

The SAD waypoint is is just setBehaviour "COMBAT" and setCombatMode "RED".
See Task Attack.

You need to be specific.
There are so many ways of doing something in Arma.

  • Like 1

Share this post


Link to post
Share on other sites
  On 12/24/2021 at 4:34 AM, Maff said:

but it depends where and when you need the command.
You are still using BIS_fnc_stalk, right?

I use BIS_fnc_stalk right now. It works pretty good so far, but i feel like the enemy heli (for instance) hovers above me for a while. it only attacks when im like run around on a open field (even when i set it to combat and Fire at will in the editor). Is there a good way to make them more aggresiv? so i thought reveal could help here.

 

excuse me if i do some mistakes.. im relatively new to all this 

Share this post


Link to post
Share on other sites
  On 12/24/2021 at 4:51 AM, ChaIie said:

I use BIS_fnc_stalk right now. It works pretty good so far, but i feel like the enemy heli (for instance) hovers above me for a while. it only attacks when im like run around on a open field (even when i set it to combat and Fire at will in the editor). Is there a good way to make them more aggresiv? so i thought reveal could help here.

I don't think BIS_fnc_stalk was intended for helicopters hunting a group or player.

You can learn a lot by looking at the function;
 

  Reveal hidden contents


If you need further help, then feel free to ask.

 

  On 12/24/2021 at 4:51 AM, ChaIie said:

excuse me if i do some mistakes.. im relatively new to all this 

No worries. One day you may help me. Or someone more important.

  • Like 2

Share this post


Link to post
Share on other sites
  On 12/24/2021 at 5:40 AM, Maff said:

I don't think BIS_fnc_stalk was intended for helicopters hunting a group or player.

What do i need to use instead? i still think that reveal may come handy here but i have no idea how to set it up 

_soldierOne reveal [_soldierTwo, 1.5];

If this is correct, where do the soldierOne/Two parameters belong? i tried it with the variable name of the player and enemy but it makes no difference, do i need to put the group names in here? also is the 1.5   the range where they spot me? 

 

  On 12/24/2021 at 5:40 AM, Maff said:

No worries. One day you may help me. Or someone more important

really want to learn it but its kinda difficult with a whole new program language

Share this post


Link to post
Share on other sites
  On 12/24/2021 at 6:21 AM, ChaIie said:

What do i need to use instead? i still think that reveal may come handy here but i have no idea how to set it up 

_soldierOne reveal [_soldierTwo, 1.5];

If this is correct, where do the soldierOne/Two parameters belong? i tried it with the variable name of the player and enemy but it makes no difference, do i need to put the group names in here? also is the 1.5   the range where they spot me? 

 

really want to learn it but its kinda difficult with a whole new program language


There are a fair few methods of AI hunting players.
G00gle.

They may not suit your needs, but they will get you on the track. Believe me.

Don't worry. 


 

  • Like 1

Share this post


Link to post
Share on other sites

For helos, here's copy of a script I've used in my missions for years to have a helo circle a team, usually a support helo though.  Should the helo be enemy, when it becomes aware of the circled unit or team, it will engage.  The radius, angle and height can be adjusted to suit.

 

The script's credit belongs to @demonized, @neokika and @jkhaaja, one of their postings in the forums years ago was where I picked it up, and it was so long I don't recall the forum post.

 

The leader being circled:  ldr

The helo doing the circling:  transport

 

  Reveal hidden contents

 

  • Like 2

Share this post


Link to post
Share on other sites

So pleased to see this is a recent thread as I'm just now coming back to AMRA3 (after a LONG time away!) and want to use this function too.

I've personally got it working in the most basic fashion;

  • Triger activates.
  • Hunters go looking for Hunted.
  • Hunters kill hunted.
  • Hunters stay put(!)

I cant make them 'return' home though.  Not even when they kill Hunted!

My main question is; can I send them home if the trigger turns false?  
So, if Hunted leaves the trigger area, Hunter goes back to base. 
If Hunted goes back in to the trigger, Hunter comes out again.
and so on.

Any help anyone could offer would be much appreciated.
 

  • Like 1

Share this post


Link to post
Share on other sites

Having the trigger repeatable, and set to spawn the function when activated, should take care of the Hunter pursuing the Hunted each time the Hunted enters the zone.

 

The function's condition (select 4) and return (select 5) params are what would make the Hunter RTB whenever the Hunted leaves the zone.  The function's params are:

[
	select 0: GROUP - The group that is the Hunter.  Default: grpNull.
	select 1: GROUP - The group that will be Hunted.  Default: grpNull.
	select 2: (OPTIONAL) - NUMBER: How often (in seconds) the Hunter updates their waypoint at the Hunted leader's pos.  Default: 10 (minimum 5).
	select 3: (OPTIONAL) - NUMBER: Radius (in meters) of the Hunter's new waypoint from the Hunted leader's pos.  Default: 0 meters.
	select 4: (OPTIONAL) - CODE: Condition that gets evaluated to end the hunt.  Default {false}.
	select 5: (OPTIONAL) - STRING or ARRAY (POSITION) or OBJECT or NUMBER: Where the Hunter goes when the hunting ends.  Default: 0.
		Can be one of:
			STRING: Name of a marker.
			ARRAY:  Position (Hunter gets a waypoint with position inserted: [_position,0]).
			OBJECT: Existing object (Hunter gets a waypoint with object position inserted: [(GetPos _object),0]).
			NUMBER:	0 - Hunter returns to original given waypoints.
				1 - Hunter stays at current position, searching around.
				2 - Hunter returns to the position they began hunting from (when the script began).
]

As I mentioned previously, the condition code (select 4) gets evaluated using isNil, which can be used to run a complex expression if necessary, but at the end must be an expression returning true or false.

 

And in this discussion I had mentioned before that there can be a problem with using 0 (which is default) for the return parameter (select 5), when empty groups are getting deleted.

 

Hope this helps.

  • Like 1

Share this post


Link to post
Share on other sites
  On 12/24/2021 at 5:40 AM, Maff said:

No worries. One day you may help me. Or someone more important.

This is why I love this forum.  @Maff is a stand up guy!

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
  On 1/11/2022 at 10:53 PM, opusfmspol said:

Having the trigger repeatable, and set to spawn the function when activated, should take care of the Hunter pursuing the Hunted each time the Hunted enters the zone.

 

The function's condition (select 4) and return (select 5) params are what would make the Hunter RTB whenever the Hunted leaves the zone.  The function's params are:

[
	select 0: GROUP - The group that is the Hunter.  Default: grpNull.
	select 1: GROUP - The group that will be Hunted.  Default: grpNull.
	select 2: (OPTIONAL) - NUMBER: How often (in seconds) the Hunter updates their waypoint at the Hunted leader's pos.  Default: 10 (minimum 5).
	select 3: (OPTIONAL) - NUMBER: Radius (in meters) of the Hunter's new waypoint from the Hunted leader's pos.  Default: 0 meters.
	select 4: (OPTIONAL) - CODE: Condition that gets evaluated to end the hunt.  Default {false}.
	select 5: (OPTIONAL) - STRING or ARRAY (POSITION) or OBJECT or NUMBER: Where the Hunter goes when the hunting ends.  Default: 0.
		Can be one of:
			STRING: Name of a marker.
			ARRAY:  Position (Hunter gets a waypoint with position inserted: [_position,0]).
			OBJECT: Existing object (Hunter gets a waypoint with object position inserted: [(GetPos _object),0]).
			NUMBER:	0 - Hunter returns to original given waypoints.
				1 - Hunter stays at current position, searching around.
				2 - Hunter returns to the position they began hunting from (when the script began).
]

As I mentioned previously, the condition code (select 4) gets evaluated using isNil, which can be used to run a complex expression if necessary, but at the end must be an expression returning true or false.

 

And in this discussion I had mentioned before that there can be a problem with using 0 (which is default) for the return parameter (select 5), when empty groups are getting deleted.

 

Hope this helps.


So sorry!  I only just saw this response!
I'll give it a whirl.
cheers dude.

Share this post


Link to post
Share on other sites
  On 12/24/2021 at 3:06 AM, opusfmspol said:

// grpB pursues grp1 until all units in grp1 are dead, then returns to base (original start position). B_1_handle = [grpB, grp1,10,0,{[grpB,currentWaypoint grpB] setWaypointType "SAD"; {Alive _x} Count (Units grp1) == 0},(Position Leader grpB)] Spawn BIS_fnc_stalk;

 

Rather than having grpB eliminate grp1, how do I get grpB to return to base when within 200m of nearest player (using MP dedicated)?

Share this post


Link to post
Share on other sites
  On 7/29/2022 at 11:27 PM, Soapbox0331 said:

 

Rather than having grpB eliminate grp1, how do I get grpB to return to base when within 200m of nearest player (using MP dedicated)?

take a look on this page:

 

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

 

Ex 2: private _stalking = [grp1, group player, nil, nil, { player distance BIS_Heli < 100 }, "BIS_mrkRetreatMarker"] spawn BIS_fnc_stalk;

  • Thanks 1

Share this post


Link to post
Share on other sites
  On 7/30/2022 at 7:41 AM, Play3r said:

take a look on this page:

 

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

 

Ex 2: private _stalking = [grp1, group player, nil, nil, { player distance BIS_Heli < 100 }, "BIS_mrkRetreatMarker"] spawn BIS_fnc_stalk;

 

Thanks @Play3r. Script (pretty sure I got this from someone in the BI community) I am using for spawning a group and having them stalk works (called from trigger, MP dedicated server):

 

if !(isServer) exitWith {};

_spawnPoints = ["marker_LZ1"];
_unitsInGroup = ["vn_o_men_nva_65_16"];

_spawnMarker = _spawnpoints select (floor random (count _spawnpoints));

_unksSpawnPosition = getMarkerPos _spawnMarker; //[x,y,z]

newGroup = createGroup [east,true];
_newLeader = "vn_o_men_nva_65_16" createUnit [_unksSpawnPosition,newGroup,"newLeader = this"];
sleep 1;

{
    _newUnit = _x createUnit [_unksSpawnPosition,newGroup,"newUnit = this"];
    sleep .4;
}forEach _unitsInGroup;
sleep 1;
newGroup setBehaviour "STEALTH";
_stalk = [newGroup,group (allPlayers select 0), 300, 200, nil, nil] spawn BIS_fnc_stalk;

 

 

The idea would be the stalkers get under 200m from players and move to CP marker simulating reporting what they found. I have tried a couple of variants but I don't think I have my mind around identifying the AI and nearest player (BLUFOR) for the purposes of using the "distance" method:

_stalk = [newGroup,group (allPlayers select 0), 300, 200, {(something defining AI) distance (something identifying nearest player) < 200, "marker_CP"] spawn BIS_fnc_stalk;

 

Any ideas?

 

 

Share this post


Link to post
Share on other sites

why not try "player distance NewGroup"

in the "player distance Bis_heli" ??

Iwould do that, but i cant test it before the weekend but maybe you can ?

  • Like 1

Share this post


Link to post
Share on other sites
  On 8/2/2022 at 12:25 PM, Play3r said:

why not try "player distance NewGroup"

in the "player distance Bis_heli" ??

Iwould do that, but i cant test it before the weekend but maybe you can ?

This is the error I am getting using it this way: "Error distance : Type Group, expected Array,Object,Location"

Share this post


Link to post
Share on other sites
  On 8/7/2022 at 11:35 AM, Soapbox0331 said:

This is the error I am getting using it this way: "Error distance : Type Group, expected Array,Object,Location"

The distance command won't compare a group to a unit (the player in your case).  If NewGroup is a group, then this would be a valid condition:

player distance (leader NewGroup) < 200

 

  • Thanks 2

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

×