Jump to content
Sign in to follow this  
ADuke

Randomizing Headgear via Config Eventhanbdler

Recommended Posts

Hi,

So as my title states, I am trying to randomize the class of headgear that gets added to my unit. I am doing this in the config of the unit.

I came to realize, after much trial and error, that headgear config entries can not take eventhandlers, otherwise I would have randomized hiddentextures, as is done so very well in the config of the Takistani Militia from Operation Arrowhead.

So, what I am trying to do is take the following pieces of headgear....

class AD_Shemagh1a: H_HelmetB

{

displayName = "Shemagh w/ Face Cover";

picture = "\ad_opfor\data\ui\icon_ad_shemagh_ca.paa";

model = "\AD_Opfor\AD_Shemagh1.p3d";

hiddenSelections[] = {"Camo"};

hiddenSelectionsTextures[] = {"\ca\characters_e\loc\data\loc_opfor01_3_co.paa"};

class ItemInfo: HeadgearItem

{

mass = 5;

uniformModel = "\AD_Opfor\AD_Shemagh1.p3d";

modelSides[] = {6};

armor = "3*0.05";

passThrough = 0.95;

};

};

class AD_Shemagh1b: AD_Shemagh1a

{

displayName = "Shemagh w/ Face Cover";

picture = "\ad_opfor\data\ui\icon_ad_shemagh_ca.paa";

model = "\AD_Opfor\AD_Shemagh1.p3d";

hiddenSelectionsTextures[] = {"\ca\characters_e\loc\data\loc_opfor01_2_co.paa"};

class ItemInfo: HeadgearItem

{

mass = 5;

uniformModel = "\AD_Opfor\AD_Shemagh1.p3d";

modelSides[] = {6};

armor = "3*0.05";

passThrough = 0.95;

};

};

class AD_Shemagh1c: AD_Shemagh1a

{

displayName = "Shemagh w/ Face Cover";

picture = "\ad_opfor\data\ui\icon_ad_shemagh_ca.paa";

model = "\AD_Opfor\AD_Shemagh1.p3d";

hiddenSelectionsTextures[] = {"\ca\characters_e\loc\data\loc_opfor01_1_co.paa"};

class ItemInfo: HeadgearItem

{

mass = 5;

uniformModel = "\AD_Opfor\AD_Shemagh1.p3d";

modelSides[] = {6};

armor = "3*0.05";

passThrough = 0.95;

};

};

class AD_Shemagh1d: AD_Shemagh1a

{

displayName = "Shemagh w/ Face Cover";

picture = "\ad_opfor\data\ui\icon_ad_shemagh_ca.paa";

model = "\AD_Opfor\AD_Shemagh1.p3d";

hiddenSelectionsTextures[] = {"\ca\characters_e\loc\data\loc_ind01_2_co.paa"};

class ItemInfo: HeadgearItem

{

mass = 5;

uniformModel = "\AD_Opfor\AD_Shemagh1.p3d";

modelSides[] = {6};

armor = "3*0.05";

passThrough = 0.95;

};

};

class AD_Shemagh1e: AD_Shemagh1a

{

displayName = "Shemagh w/ Face Cover";

picture = "\ad_opfor\data\ui\icon_ad_shemagh_ca.paa";

model = "\AD_Opfor\AD_Shemagh1.p3d";

hiddenSelectionsTextures[] = {"\ca\characters_e\loc\data\loc_ind01_3_co.paa"};

class ItemInfo: HeadgearItem

{

mass = 5;

uniformModel = "\AD_Opfor\AD_Shemagh1.p3d";

modelSides[] = {6};

armor = "3*0.05";

passThrough = 0.95;

};

};

};

and randomize which is given to the following soldier...

class AD_Taliban_SL : O_Soldier_SL_F

{

faction = AD_Addons_Opfor;

vehicleClass = "AD_Taliban";

uniformClass = "Officer_uniform1";

displayName = "Squad Leader";

class EventHandlers

{

init = "[_this select 0] execVM ""\ad_opfor\scripts\random_shemagh1.sqf""";

respawn = "[_this select 0] execVM ""\ad_opfor\scripts\random_shemagh1.sqf""";

};

camouflage = 1.0;

Weapons[] =

{

"AK_47_M",

"Makarov",

"Throw",

"Put"

};

respawnWeapons[] =

{

"AK_47_M",

"Makarov",

"Throw",

"Put"

};

magazines[] =

{

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"MiniGrenade",

"MiniGrenade",

"8Rnd_9x18_Makarov",

"8Rnd_9x18_Makarov",

"8Rnd_9x18_Makarov"

};

respawnmagazines[] =

{

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"30Rnd_762x39_AK47",

"MiniGrenade",

"MiniGrenade",

"8Rnd_9x18_Makarov",

"8Rnd_9x18_Makarov",

"8Rnd_9x18_Makarov"

};

Items[] = {};

RespawnItems[] = {};

linkedItems[] = {"V_TacVest_oli", "AD_SHemagh1a", "ItemMap", "ItemCompass", "ItemWatch", "ItemRadio", "ItemGPS"};

respawnLinkedItems[] = {"V_TacVest_oli", "AD_SHemagh1a", "ItemMap", "ItemCompass", "ItemWatch", "ItemRadio", "ItemGPS"};

armor = 10;

armorStructural = 6;

Which is being done by the following script.....

random_shemagh1.sqf

_unit = _this select 0;

_headGear = ["AD_Shemagh1a","AD_Shemagh1b","AD_Shemagh1c","AD_Shemagh1d","AD_Shemagh1e"] select floor random 5;

_unit addheadgear _headgear;

hint "script completed";

But it is not working right, I have worked over both the config and script numerous times, but still no joy.

If anyone more knowledgable than myself can shed some light on this I would appreciate it.

-AD

Edited by ADuke

Share this post


Link to post
Share on other sites

You shouldn't need [_this select 0] when running the script if it's being called from the unit's own unit when it spawns, it should probably just use this

Share this post


Link to post
Share on other sites

If you haven't solved this yet, or if you have and others are wondering how to do this, try the following. I use a random headgear script for some of my units, and this is how I do it:

In the following script, replace Item0, Item1, etc with the names of your headgear items, and save the file as whatever you wish to call it.

_Unit = _this select 0;
_HeadGear = ["Item0","Item1","Item2","Item3","Item4","Item5"];
_CountH = count _HeadGear;
RemoveHeadgear _unit;
_unit AddHeadgear (_headgear select floor random _CountH);

Then, put the following in the unit's config:

	class EventHandlers: EventHandlers	
	{
			init =  "[(_this select 0)] execVM ""\AddonName\ScriptName.sqf""";	

	};

It's important to note that whatever your unit's parent class is, must have 'class eventhandlers;' in its config entry, since this EventHandlers script has a parent EventHandlers class. I create a base unit (with a private scope so it can't be placed/created in-game) with 'class Eventhandlers;' in its config, then base the rest of my units off that one, so they're inheriting its attributes.

Share this post


Link to post
Share on other sites

^^

Not multiplayer compatible. Just look at the official BIS Offroad randomization script to see how to get MP compatible random stuff init script.

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  

×