Jump to content
vihkr

Keeping AI Infantry Units in Hard Cover Scenario Design

Recommended Posts

I carefully placed several squads into bunkers and improved positions. But when the scenario starts, they're wiggling and crawling all over the place and never stay put. I've tried Hold waypoints and differing formations. What's the trick here? Why do they leave their positions and lie down in an open field?

Share this post


Link to post
Share on other sites

Ai needs to be put in restraints to stop making their own decisions.

To make them stay in place use this in the objects init field:

doStop this;
this disableAI "PATH";

This will make the unit stay stationary at the position of placement, it is still able to turn around but won't move on its own.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

Ok thanks.

 

Can I trigger a script to change it back to this; or does sending a new waypoint via trigger clear it so it starts behaving "normally" again?

Share this post


Link to post
Share on other sites

To revert the changes you can do a few things, mainly depends on when you want them to go back to normal.

 

A hit eventhandler could be an alternative:

//unit init field:
doStop this;
this disableAI "PATH";

this addEventhandler ["Hit",{
	params ["_unit"];
	_unit dofollow leader _unit;
	_unit enableAI "PATH";
	_unit removeEventhandler ["Hit",_thisEventHandler];
}];

This will make the unit act normal again after being hit.

 

Cheers

  • Like 3

Share this post


Link to post
Share on other sites
30 minutes ago, vihkr said:

And it follows that I could substitute Hit with any other EventHandler from here, ya?

Yep.  Another good one to consider is "FiredNear" EH, if you want to keep them in place, until the first shot is fired near them.

  • Like 1

Share this post


Link to post
Share on other sites
On 07/06/2018 at 9:26 AM, fn_Quiksilver said:

 

note that that Local event handler has to be added on the "receiving" machine before locality is transferred.

Please explain?

Share this post


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

Please explain?

 

the “addEventHandler” command has no network propagation (but “addMPEventHandler” does), so the code is executed only on the machine which the event handler was added.

 

so if you want some code executed by the “new owner” machine, the event first has to exist on that machine for anything to happen

Share this post


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

 

the “addEventHandler” command has no network propagation (but “addMPEventHandler” does), so the code is executed only on the machine which the event handler was added.

 

so if you want some code executed by the “new owner” machine, the event first has to exist on that machine for anything to happen

 

Clear thanks. Just coming to grips with SQF. It reminds me of bash shell scripting. According to their wiki, addMPEventHandler will propagate globally to all connected clients. Do I need to instruct connected clients to accept scenario custom scripts like this one or does it happen automatically?

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

×