Jump to content
Sign in to follow this  
sproyd

How to script AI team mates equipping NVGs and IR Lasers

Recommended Posts

I have a mission where a team is inserted at dusk and over the course of the mission it becomes dark. The playable characters (incl AI) are equipped with weapon-mounted flashlights at the start of the mission but carry NVGs and IR Lasers in their backpacks. Of course its easy for human players to equip NVG and swap the flashlights for IR Lasers if they want but the AI appear to be happy running blind.

How can I script the AI to take the NVGs from their backpack and equip them and how do I get them to swap out their weapon attachments. I want them to do this when it gets dark - so I guess I would need to set some sort of timer before they do that action?

Thanks for your help.

Share this post


Link to post
Share on other sites

Not tested, but something like this might work, or you can just add the item then assign through a script.

if (daytime < 4 && daytime > 20) then {
   {_x assignItem "nvgoggles"} foreach units group player;
};

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Thanks Cobra. I tried this script in my init.sqf but can't get it to work.

To test it, instead of using daytime I used the following and stood on the beach for 3 minutes to see if the AI equipped NVGs. They didn't. Any ideas?

if (time > 180) then  {
{_x assignItem "NVGoggles"} foreach units group player;
};

Share this post


Link to post
Share on other sites

Okay so I sort of managed to get it to work - created a trigger which repeatedly checks the time and once its "dark" it activates the following

{
_x assignItem "NVGoggles";
_x removeItemFromPrimaryWeapon "acc_flashlight";
_x addPrimaryWeaponItem "acc_pointer_IR";
_x enableIRLasers true;
}
foreach units group player;

Main Question: In addition to AI units this also applies to human units in the group including the player - is there a way I can make this only trigger on AI controlled units so human players maintain autonomy?

Second Question: Also, while I can get the AI to equip NVGs from their backpacks rather than magically creating them on their heads I couldn't get them to remove the flashlight from their weapons and add the IR pointer from their backpacks onto their weapons using AssignItem. Any idea why? I had to use the commands above to literally delete the flashlight attachment and create a new attachment out of thin air on the weapon.

Third Question: Is there a cleaner way of doing this than putting it in a repeatedly checking trigger? It wouldn't fire in my init.sqf?

Fourth Question: enableIRLasers true - does this just mean that the AI are permitted to use IR if they feel the need? Because it doesn't force on IR as far as I can tell which would be nice so I can see what the AI are pottering around doing.

THANKS!

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  

×