Jump to content

Recommended Posts

Hello everyone!

I'm building a Coop mission and wanted to try a particular setting- a training camp.

The location is Altis, Kamino Firing range. The aim is to have a group of (eight) soldiers running up and down the beach in exercise formation, without their weapons drawn. Once they detect the players (BLUFOR), they are to engage as normal.

In other words, I would like them to run as in this video:
https://www.youtube.com/watch?v=hbzJnncsK18

However, I am having trouble with keeping the soldiers running in formation using waypoints or disableAI scripting commands. It seems that BI's default AI that so helpfully makes AI soldiers run in a natural way is preventing them from rigidly following waypoints and sticking to a precise formation (without weapons drawn). 

How would I do this? 

Feel free to ask if anything is unclear. 

Share this post


Link to post
Share on other sites

@Melody_Mike 

Here is the solution courtesy of the @RickOShay YT channel
Take a look from minute 4:00 of his video below.

I downloaded his mission and it works perfect.

 

Spoiler

 

 

Share this post


Link to post
Share on other sites

Thank you Gentlemen!

@wogz187 : The "careless' behavior setting is *certainly* an improvement, but unfortunately not robust enough. Even on a perfectly level surface, after 10 meters, individual soldiers noticeably vary their pace and direction (in any formation). After 50 meters it resembles regular ARMA formation movement. It's great that they don't draw their weapons, but as I understand it, on 'careless' the AI also does not respond to threats normally. A trigger or 'safe' behavior could fix this but wouldn't solve the first thing. Thank you, however.

@Turco_AR : Goodness this looks to be exactly what I was searching for! The author even posted the running script in a response. Possibly foolish question: I couldn't find the mission linked on the author's Youtube channel, and I can't find the user "RickOShay" in Steam. Where could I find/download the mission?

Share this post


Link to post
Share on other sites

@Melody_Mike,
Okay.

Put this function in your init and start your group as "SAFE"

you_fnc_march= 
{ 
_grp = group _this; 
_currentState = behaviour _this; 
 
if (_currentState=="SAFE") exitWith { 
	{_x disableAI "ALL";_x switchMove "AmovPercMrunSnonWnonDf";} foreach units _grp; 
		}; 
if (_currentState=="AWARE") exitWith { 
	{_x enableAI "ALL"; _x switchmove "";} foreach units _grp; 
		}; 
};

When you need to switch the animation,

_leader = leader marchingGroup;// group name
_leader setbehavior "AWARE";// or "SAFE" to toggle
_leader call you_fnc_march;

To put this in a trigger make sure to name the _leader and remove the comments.

Have fun!

  • Like 2

Share this post


Link to post
Share on other sites

Thank you for the script.
I will need to tweak this.

The animation doesn't kick in until every soldier has entered the formation (perhaps I should just split the groups and start them in formation), and having them walk with their pistols drawn looks awkward (perhaps spawn weapons in inventory when their behavior changes to "COMBAT" ?). See video for context:

Appreciate you helping with my "homework", though!

Share this post


Link to post
Share on other sites

@Melody_Mike,

The animation didn't kick in at all.

 

The animation will supersede anything else the unit is doing and disregard formation completely.

 

Unless you have them arranged specifically, when the animation does start, they'll just go off in whatever direction they're facing (this could be corrected with more code).

Paste both the function and the function call into your debug menu to see the effect right away.

Share this post


Link to post
Share on other sites

Alright, I feel like a complete dunce here. I didn't really know what to expect with the marching animation. But now I am having trouble executing your code properly(!)

Cannot get your "call" script to be accepted in a trigger OnActivation field or Debug console:

_leader = leader marchingGroup; 
_leader setbehavior "AWARE";
_leader call you_fnc_march;

The game insists there is a missing " ; ". 
I thought perhaps the game didn't get an object reference. I obviously named the group leader as _leader , but also tried renaming him (and changing the script) to leader1 . No change.
I have never used the "call" function before, so after browsing the BI Wiki, figured it may be missing curly braces around you_fnc_march . No change.
What beginner scripting insight am I missing? :P

Share this post


Link to post
Share on other sites

@Melody_Mike,
It's this,

Quote

To put this in a trigger make sure to name the _leader and remove the comments.

theLead = leader marchingGroup;

theLead setbehavior "SAFE";

theLead call you_fnc_march;

have fun!

The code is extracted from here,
1) Name a unit and set behavior to "SAFE"
2) Set the variable "anim_type" to your selected animation (anim_type=1)
3) call the function on the unit
To return the unit to normal either set "anim_type" to 0 and call the function again OR set the unit behavior to "AWARE" and call the function again.

Spoiler

MMF_fnc_anims= 
{

_grp = group _this; 
_currentState = behaviour _this;
_thisMove=["", "AmovPercMrunSnonWnonDf", "Acts_A_M01_briefing", "Acts_AidlPercMstpSloWWrflDnon_warmup_1_loop", "Acts_AidlPsitMstpSsurWnonDnon_loop", "Acts_AidlPsitMstpSsurWnonDnon04", "Acts_B_M05_briefing", "Acts_CivilHiding_2", "Acts_CivilInjuredGeneral_1", "Acts_CivilShocked_1"] select anim_type;
 
	if (_currentState=="SAFE") then { 
		{_x disableAI "ALL";_x switchMove _thisMove;} foreach units _grp;};
 
	if (_currentState=="AWARE") exitWith { 
		{_x enableAI "ALL"; _x switchmove "";} foreach units _grp;};

if (anim_type==4 or anim_type==5) exitWith {{_x allowDamage false; removeAllWeapons _x; removeHeadgear _x; _x unlinkItem "NVGoggles"; removeAllItems _x; _x setcaptive true;} foreach units _grp;};
};

 

 

Share this post


Link to post
Share on other sites

onActivation:

 

_leader =  leader marchingGroup;

_group = group _leader;

_group setBehaviourStrong “AWARE“;

[_leader] call you_fnc_march;

 

 

it's behaviOUr not behaviOr!

 

  • 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

×