Jump to content
Sign in to follow this  
Ethridge

Have a unit spawn with random weapons in config.

Recommended Posts

Hello, im making a addon that adds new units, and I want them to spawn with random weapons, drawing from a pool of certain weapons, how would I do this? It needs to be done internally in the addon.

 

Share this post


Link to post
Share on other sites
_newGroup = createGroup blufor;
_unit = _newGroup createUnit ["className", _somePosition, [], 0, "NONE"];
_allWeapons ["M16A2", "M16A2GL", "m16a4", "M4A1", "M4A1_AIM_CAMO", "G36A", "G36C"];
_weapon = _allWeapons select floor random count _allWeapons;

_unit removeWeapon primaryWeapon _unit;
_unit addWeapon _weapon;

This code is untested though and I couldn't come up with a generic solution for adding the correct magazines, but I hope this helps as a starter.

 

Also, if you're trying to do this in MP, notice that in ArmA 3 there are command called removeWeaponGlobal and addWeaponGlobal, so I wouldn't assume that removeWeapon and addWeapon remove/add the weapon globally in ArmA 2.

Share this post


Link to post
Share on other sites

Thanks! How do you recommend I run this? It would need to be internally in the addon.

 

Share this post


Link to post
Share on other sites

Well, you write your addon adds new units. I don't know what code your addon already consist of, so I can't really make a precise statement, but simply put this code where you would create/add the unit.

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  

×