Jump to content
Sign in to follow this  
Ice_Rhino

AI Faking looking through Binoculars

Recommended Posts

Hi,

I am creating a sniper mission. One of the things I want is 4 AI units to be looking a certain direction looking through Binoculars. How would I go about this?

Thanks in Advance

Ice Rhino

Share this post


Link to post
Share on other sites
_aiUnits = [ai1, ai2, ai3, ai4];

{
_x selectWeapon "Binocular";
//removeAllWeapons _x;//<<<You may or may not need this...
_x setDir #;//<<<<Define the direction you want them to look, to the player?, to another unit down range?, to a marker?, to a specific object?

} foreach _aiUnits;

Share this post


Link to post
Share on other sites
Thanks JS. Where do I put said code?

KR

IR

Make an sqf call it whatever you would like, then name your fours ai's accordingly, and then in the init.sqf call it via this:

nul = [] execVM "scriptName.sqf";

Share this post


Link to post
Share on other sites

[color="#FF8040"]unit [color="#191970"][b]addWeapon[/b][/color] [color="#7A7A7A"]"Binocular"[/color][color="#8B3E2F"][b];[/b][/color][color="#006400"][i]//adds binoculars to unit's inventory if they don't already (optional)[/i][/color]
unit [color="#191970"][b]selectWeapon[/b][/color] [color="#7A7A7A"]"Binocular"[/color][color="#8B3E2F"][b];[/b][/color][color="#006400"][i]//selects binoculars[/i][/color]
unit [color="#191970"][b]setFormDir[/b][/color] [color="#FF0000"]360[/color][color="#8B3E2F"][b];[/b][/color][color="#006400"][i]//sets unit direction to 360 degrees, value can be 0-360[/i][/color][/color]

use any for addweapon and selectweapon:

"Laserdesignator"

"Rangefinder"

"Binocular"

See:

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

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

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

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

Also noted:

AI might engage enemy if spotted, putting away binoculars and using gun. This may or may not be desirable.

---------- Post added at 21:36 ---------- Previous post was at 21:33 ----------

_aiUnits = [ai1, ai2, ai3, ai4];

{
_x selectWeapon "Binocular";
//removeAllWeapons _x;//<<<You may or may not need this...
_x setDir #;//<<<<Define the direction you want them to look, to the player?, to another unit down range?, to a marker?, to a specific object?

} foreach _aiUnits;

setdir is not reliable, ai will return to original direction (also unrealistic instant turn). use setFormDir

It should also be noted that if you are going to use removeAllWeapons you need to add binoculars too. Otherwise the unit wont be able to equip binoculars if he doesn't have any. Order of commands is key:

[color="#FF8040"]unit [color="#191970"][b]removeAllWeapons[/b][/color][color="#8B3E2F"][b];[/b][/color]
unit [color="#191970"][b]addWeapon[/b][/color] [color="#7A7A7A"]"Binocular"[/color][color="#8B3E2F"][b];[/b][/color]
unit [color="#191970"][b]selectWeapon[/b][/color] [color="#7A7A7A"]"Binocular"[/color][color="#8B3E2F"][b];[/b][/color][/color]

---------- Post added at 21:41 ---------- Previous post was at 21:36 ----------

Thanks JS. Where do I put said code?

KR

IR

For my version you can also put it in the init field of each unit in editor, but use This in place of unit

Edited by Benargee

Share this post


Link to post
Share on other sites

Or if you don't have to watch them do it, just force them into the animation (init line):

this setCaptive true; this addWeapon "Binocular"; this setCombatMode "BLUE"; this disableAI "ANIM"; 0 = this spawn {waitUntil {time > 0}; _this switchMove "AmovPknlMstpSoptWbinDnon"};

They won't change direction or even react to enemies, if that's what you want.

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  

×