Jump to content
acoustic

Creating random uniform/mask/gun combination for AI unit?

Recommended Posts

Some sort of a script that gets units equipment from a predefined pool would be extremely helpful. Looked around but couldn't find anything.

Share this post


Link to post
Share on other sites

Something like:

params ["_unit"];

_uniformPool =
[
	"",
	"",
	"",
	""
];

_vestPool =
[
	"",
	"",
	"",
	""
];

_backpackPool =
[
	"",
	"",
	"",
	""
];

_headgearPool =
[
	"",
	"",
	"",
	""
];

_gogglesPool =
[
	"",
	"",
	"",
	""
];

// lazy quick checks

if (count _uniformPool > 0) then // just in case :P
{
	_unit forceAddUniform (selectRandom _uniformPool);
};

if (count _vestPool > 0) then
{
	_unit addVest (selectRandom _vestPool);
};

if (count _backpackPool > 0) then
{
	_unit addBackpackGlobal (selectRandom _backpackPool);
};

if (count _headgearPool > 0) then
{
	_unit addHeadgear (selectRandom _headgearPool);
};

if (count _gogglesPool > 0) then
{
	_unit addGoggles (selectRandom _gogglesPool);
};
// in AI init:
0 = [this] execVM "loadouts.sqf";

You will need to add classnames in yourself, I am feeling very lazy since it is gone 3 am. Above is just one way of doing it. I personally create config with pre-defined loadouts (for certain cases) but that might be a bit overwhelming if you are new to scripting SQF. Feel free to dive in though! Something like (rough example):

class config_loadouts
{
	loadouts[] =
	{
	};
	class testLoadout
	{
		name = "Test Loadout";
		uniform = "";
		vest = "";
		backpack = "";
		headgear = "";
		goggles = "";
		weapons[] = {};
		magazines[] = {};
		items[] = {};
		condition = "";
	};
};

I then use getMissionConfig to fetch all this and do some stuff with code, lol.

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

  • Like 1

Share this post


Link to post
Share on other sites

I often use THIS SCRIPT which is basically ready to go: add classnames and boom, you're in business.

It even let you re-dress randomly more than one faction at the time with different gear.

  • Like 1

Share this post


Link to post
Share on other sites

Is there a way to do it without using class names,? I basiclly want to create a totally random unit that will be equipped with random stuff from the mods I have installed. And there are a lot of them!!!

(basiclly using the randomise gear button from virtual arsenal in the editor)

 

 

Share this post


Link to post
Share on other sites
3 hours ago, Lefterboy123 said:

Is there a way to do it without using class names,? I basiclly want to create a totally random unit that will be equipped with random stuff from the mods I have installed. And there are a lot of them!!!

(basiclly using the randomise gear button from virtual arsenal in the editor)

 

Sure it's possible if you don't mind some silly combinations like this:

hNqQXS8.jpg

 

Made something similar a while ago without including backpacks for some reason, should get you started:


_unit = player;
removeallweapons _unit;
removeUniform _unit;
removeVest _unit;
removeBackpack _unit;
removeHeadgear _unit;

_allHeadgear = ("getNumber (_x >> 'scope') >= 2 AND getNumber (_x >> 'ItemInfo' >> 'type') isEqualTo 605" configClasses (configFile >> "CfgWeapons")) apply {configName _x};
_allUniforms = ("getNumber (_x >> 'scope') >= 2 AND getNumber (_x >> 'ItemInfo' >> 'type') isEqualTo 801" configClasses (configFile >> "CfgWeapons")) apply {configName _x};
_allVests = ("getNumber (_x >> 'scope') >= 2 AND getNumber (_x >> 'ItemInfo' >> 'type') isEqualTo 701" configClasses (configFile >> "CfgWeapons")) apply {configName _x};
_allRifles = ("getNumber (_x >> 'scope') >= 2 AND getNumber (_x >> 'type') isEqualTo 1" configClasses (configFile >> "CfgWeapons")) apply {configName _x};
_allHandguns = ("getNumber (_x >> 'scope') >= 2 AND getNumber (_x >> 'type') isEqualTo 2" configClasses (configFile >> "CfgWeapons")) apply {configName _x};

_unit addHeadgear selectRandom _allHeadgear;
_unit forceAddUniform selectRandom _allUniforms;
_unit addVest selectRandom _allVests;
[_unit,selectRandom _allRifles,6] call BIS_fnc_addWeapon;
[_unit,selectRandom _allHandguns,2] call BIS_fnc_addWeapon;

Cheers

  • Thanks 1

Share this post


Link to post
Share on other sites
 
Sure it's possible if you don't mind some silly combinations like this:
hNqQXS8.jpg
 
Made something similar a while ago without including backpacks for some reason, should get you started:
_unit = player;removeallweapons _unit;removeUniform _unit;removeVest _unit;removeBackpack _unit;removeHeadgear _unit;_allHeadgear = ("getNumber (_x >> 'scope') >= 2 AND getNumber (_x >> 'ItemInfo' >> 'type') isEqualTo 605" configClasses (configFile >> "CfgWeapons")) apply {configName _x};_allUniforms = ("getNumber (_x >> 'scope') >= 2 AND getNumber (_x >> 'ItemInfo' >> 'type') isEqualTo 801" configClasses (configFile >> "CfgWeapons")) apply {configName _x};_allVests = ("getNumber (_x >> 'scope') >= 2 AND getNumber (_x >> 'ItemInfo' >> 'type') isEqualTo 701" configClasses (configFile >> "CfgWeapons")) apply {configName _x};_allRifles = ("getNumber (_x >> 'scope') >= 2 AND getNumber (_x >> 'type') isEqualTo 1" configClasses (configFile >> "CfgWeapons")) apply {configName _x};_allHandguns = ("getNumber (_x >> 'scope') >= 2 AND getNumber (_x >> 'type') isEqualTo 2" configClasses (configFile >> "CfgWeapons")) apply {configName _x};_unit addHeadgear selectRandom _allHeadgear;_unit forceAddUniform selectRandom _allUniforms;_unit addVest selectRandom _allVests;[_unit,selectRandom _allRifles,6] call BIS_fnc_addWeapon;[_unit,selectRandom _allHandguns,2] call BIS_fnc_addWeapon;

Cheers

Brilliant thank you very much, I am going for a bit of silly . I'm trying to create a free for all with Ai type of mission.

Sent from my D6503 using Tapatalk

  • Like 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

×