randomSoldierLoadOut

  • Offline soulkobk
  • First Blood
  • ***
  • Posts: 94
  • soulkobk.blogspot.com.au

randomSoldierLoadOut

« posted: Oct 10, 2016, 06:52 AM »
Sick and tired of the same AI at every mission that have the exact same load out? Then you may want to check this new script out, which you can find at the link...

https://github.com/soulkobk/ArmA_Scripts/blob/master/randomSoldierLoadOut/randomSoldierLoadOut.sqf

Code: [Select]
This script will load out each AI unit randomly with...

+ Uniform (default/guarenteed addition)
+ Head Gear (percentage chance addition)
+ Vest (percentage chance addition)
+ Back Pack (percentage chance addition)
+ Primary Weapon (default/guarenteed addition)
+ Primary Weapon Muzzle (percentage chance addition)
+ Primary Weapon Pointer (percentage chance addition)
+ Primary Weapon Optic (percentage chance addition)
+ Health Kit(s) (percentage chance addition) - unit will also have 'Medic' trait
+ Grenade(s) (percentage chance addition)
+ Rocket Launcher (percentage chance addition) - unit will also have a back pack added

The script does a 100% random load out (using probability) to each individual AI soldier (as shown above).

It works extremely well, and gives the players more enticement to actually do missions (along side my new crate load out script), as by default, the AI now have semi-decent to decent gear, therefore they will be harder to kill, but the reward is better.

Any questions, let me know.

-soul.
  • Offline dekela
  • First Blood
  • ***
  • Posts: 79

Re: randomSoldierLoadOut

« Reply #1 posted: Oct 11, 2016, 01:20 PM »
i am running this and it is awesome. everyone loves AI with a multitude of weapons and gear to collect when killed
  • Offline Mokey
  • Fractured Wasteland
  • Elite
  • ******
  • Posts: 576
  • Http://www.Fractured-Gaming.com

Re: randomSoldierLoadOut

« Reply #2 posted: Oct 11, 2016, 01:54 PM »
Referencing this:
Code: [Select]
_opticsDisallow =
[
"optic_Aco", // ACO (Red)
"optic_ACO_grn", // ACO (Green)
"optic_ACO_grn_smg", // ACO SMG (Green)
"optic_Aco_smg", // ACO SMG (Red)
"optic_AMS", // AMS (Black)
"optic_AMS_khk", // AMS (Khaki)
"optic_AMS_snd", // AMS (Sand)
"optic_Arco", // ARCO
"optic_Arco_blk_F", // ARCO (Black)
"optic_Arco_ghex_F", // ARCO (Green Hex)
"optic_DMS", // DMS
"optic_DMS_ghex_F", // DMS (Green Hex)
"optic_ERCO_blk_F", // ERCO (Black)
"optic_ERCO_khk_F", // ERCO (Khaki)
"optic_ERCO_snd_F", // ERCO (Sand)
"optic_Hamr", // RCO
"optic_Hamr_khk_F", // RCO (Khaki)
"optic_Holosight", // Mk17 Holosight
"optic_Holosight_blk_F", // Mk17 Holosight (Black)
"optic_Holosight_khk_F", // Mk17 Holosight (Khaki)
"optic_Holosight_smg", // Mk17 Holosight SMG
"optic_Holosight_smg_blk_F", // Mk17 Holosight SMG (Black)
"optic_KHS_blk", // Kahlia (Black)
"optic_KHS_hex", // Kahlia (Hex)
"optic_KHS_old", // Kahlia (Old)
"optic_KHS_tan", // Kahlia (Tan)
"optic_LRPS", // LRPS
"optic_LRPS_ghex_F", // LRPS (Green Hex)
"optic_LRPS_tna_F", // LRPS (Tropic)
"optic_MRCO", // MRCO
"optic_MRD", // MRD
"optic_Nightstalker", // Nightstalker
"optic_NVS", // NVS
"optic_SOS", // MOS
"optic_SOS_khk_F", // MOS (Khaki)
"optic_tws", // TWS
"optic_tws_mg", // TWS MG
"optic_Yorris" // Yorris J2
];
&&
Code: [Select]
if ((_opticProbability > random 99) || (_opticProbability == 100)) then
{
_soldierPrimaryOptics = []; _soldierPrimaryOptics = getArray (configFile >> "CfgWeapons" >> _soldierPrimaryWeapon >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
_soldierPrimaryOptics = _soldierPrimaryOptics - _opticsDisallow;
if ((count _soldierPrimaryOptics) >= 1) then
{
_soldierPrimaryOptic = selectRandom _soldierPrimaryOptics;
_soldier addPrimaryWeaponItem _soldierPrimaryOptic;
};
};

In the list, you're telling it NOT to include these optics (_opticsDisallow) on the AI. Does this mean, anything NOT on this list is able to be added to the AI?

THe only reason why I ask, is because I'm not sure what this is
Code: [Select]
getArray (configFile >> "CfgWeapons" >> _soldierPrimaryWeapon >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
Posts once, edits post 40 times in 60 seconds. STUPID FAT FINGERS!

https://github.com/Fractured-Gaming-Official/Frac_v1.3.Stratis
  • Offline soulkobk
  • First Blood
  • ***
  • Posts: 94
  • soulkobk.blogspot.com.au

Re: randomSoldierLoadOut

« Reply #3 posted: Oct 11, 2016, 03:03 PM »
I would like to suggest that everyone read the header information I put in to my scripts, as I don't intend on giving much support or answer the same questions over-and-over (PM's included).

Regarding _opticsDisallow...

Code: [Select]
*See _opticsDisallow option to REMOVE optics from the random optic list.
The * comment states that anything in that list will be REMOVED from the overall optic list for each and any primary weapon.

If you also see the code, it grabs ALL available optics for said weapon, and then removes the _opticsDisallow optics from the array...

Code: [Select]
_soldierPrimaryOptics = []; _soldierPrimaryOptics = getArray (configFile >> "CfgWeapons" >> _soldierPrimaryWeapon >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
_soldierPrimaryOptics = _soldierPrimaryOptics - _opticsDisallow;

I don't mean to come across as being "short", but please please please read the information provided in the headers of my scripts.

Thanks.

-soul.
  • Offline Mokey
  • Fractured Wasteland
  • Elite
  • ******
  • Posts: 576
  • Http://www.Fractured-Gaming.com

Re: randomSoldierLoadOut

« Reply #4 posted: Oct 11, 2016, 03:27 PM »
Lol,
Code: [Select]
*See _opticsDisallow option to REMOVE optics from the random optic list.
My question wasn't the removal of it, more so the allowance of which optics. Because there is no define "allowedOptics" in the script. Which you answered in the below quote.

Quote
If you also see the code, it grabs ALL available optics for said weapon, and then removes the _opticsDisallow optics from the array...

THIS
answers my question.


This was the main purpose of asking:
Which you answered.
Quote
The only reason why I ask, is because I'm not sure what this is
Code: [Select]
getArray (configFile >> "CfgWeapons" >> _soldierPrimaryWeapon >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
Thanks.
-Mokey
Posts once, edits post 40 times in 60 seconds. STUPID FAT FINGERS!

https://github.com/Fractured-Gaming-Official/Frac_v1.3.Stratis
  • Offline Mokey
  • Fractured Wasteland
  • Elite
  • ******
  • Posts: 576
  • Http://www.Fractured-Gaming.com

Re: randomSoldierLoadOut

« Reply #5 posted: Oct 11, 2016, 04:55 PM »
Anyways, I got it working for most of my missions. However on a few custom missions that have a different set up, it's only working on 1 AI (Leader I'm Assuming).

https://github.com/Fractured-Gaming-Official/Frac_v1.3.Stratis/blob/307fcc708c04c4cf8375cdde659aa61b932f7d15/server/missions/factoryMethods/createUnits/Group1.sqf#L112-L117

This is the setup of the AI loadout.
Code: [Select]
// Leader
_leader = _group createUnit ["C_man_polo_1_F", [(_pos select 0) + 10, _pos select 1, 0], [], 1, "Form"];
removeAllAssignedItems _leader;
_leader addUniform "U_C_Scientist";
_leader addVest "V_TacVest_blk_POLICE";
_leader addBackpack "B_FieldPack_ocamo";
_leader addMagazine "10Rnd_762x51_Mag";
_leader addWeapon "srifle_DMR_01_F";
_leader addPrimaryWeaponItem "optic_Holosight";
_leader addMagazine "10Rnd_762x51_Mag";
_leader addMagazine "10Rnd_762x51_Mag";
_leader addMagazine "Titan_AT";
_leader addWeapon "launch_I_Titan_short_F";
_leader addMagazine "Titan_AT";
_leader addHeadgear "H_Cap_police";
_leader addGoggles "G_Balaclava_blk";


// Soldier2
_man2 = _group createUnit ["C_man_polo_2_F", [(_pos select 0) - 30, _pos select 1, 0], [], 1, "Form"];
removeAllAssignedItems _man2;
_man2 addUniform "U_C_Scientist";
_man2 addVest "V_TacVest_blk_POLICE";
_man2 addBackpack "B_FieldPack_ocamo";
_man2 addMagazine "10Rnd_762x51_Mag";
_man2 addWeapon "srifle_DMR_01_F";
_man2 addPrimaryWeaponItem "optic_Holosight";
_man2 addMagazine "10Rnd_762x51_Mag";
_man2 addMagazine "Titan_AT";
_man2 addWeapon "launch_I_Titan_short_F";
_man2 addMagazine "Titan_AT";
_man2 addHeadgear "H_Cap_police";
_man2 addGoggles "G_Balaclava_blk";

// Soldier3
_man3 = _group createUnit ["C_man_polo_3_F", [_pos select 0, (_pos select 1) + 30, 0], [], 1, "Form"];
removeAllAssignedItems _man3;
_man3 addUniform "U_C_Scientist";
_man3 addVest "V_TacVest_blk_POLICE";
_man3 addMagazine "10Rnd_762x51_Mag";
_man3 addPrimaryWeaponItem "optic_Holosight";
_man3 addWeapon "srifle_DMR_01_F";
_man3 addMagazine "10Rnd_762x51_Mag";
_man3 addMagazine "10Rnd_762x51_Mag";
_man3 addHeadgear "H_Cap_police";
_man3 addGoggles "G_Balaclava_blk";

// Soldier4
_man4 = _group createUnit ["C_man_polo_4_F", [_pos select 0, (_pos select 1) + 40, 0], [], 1, "Form"];
removeAllAssignedItems _man4;
_man4 addUniform "U_C_Scientist";
_man4 addVest "V_TacVest_blk_POLICE";
_man4 addMagazine "10Rnd_762x51_Mag";
_man4 addWeapon "srifle_DMR_01_F";
_man4 addPrimaryWeaponItem "optic_Holosight";
_man4 addMagazine "10Rnd_762x51_Mag";
_man4 addMagazine "10Rnd_762x51_Mag";
_man4 addHeadgear "H_Cap_police";
_man4 addGoggles "G_Balaclava_blk";


// Soldier5
_man5 = _group createUnit ["C_man_polo_5_F", [_pos select 0, (_pos select 1) + 40, 0], [], 1, "Form"];
removeAllAssignedItems _man5;
_man5 addUniform "U_C_Scientist";
_man5 addVest "V_TacVest_blk_POLICE";
_man5 addMagazine "10Rnd_762x51_Mag";
_man5 addWeapon "srifle_DMR_01_F";
_man5 addPrimaryWeaponItem "optic_Holosight";
_man5 addMagazine "10Rnd_762x51_Mag";
_man5 addMagazine "10Rnd_762x51_Mag";
_man5 addHeadgear "H_Cap_police";
_man5 addGoggles "G_Balaclava_blk";


// Soldier6
_man6 = _group createUnit ["C_man_polo_4_F", [_pos select 0, (_pos select 1) - 30, 0], [], 1, "Form"];
removeAllAssignedItems _man6;
_man6 addUniform "U_C_Scientist";
_man6 addVest "V_TacVest_blk_POLICE";
_man6 addWeapon "srifle_DMR_01_F";
_man6 addPrimaryWeaponItem "optic_Holosight";
_man6 addMagazine "10Rnd_762x51_Mag";
_man6 addMagazine "10Rnd_762x51_Mag";
_man6 addHeadgear "H_Cap_police";
_man6 addGoggles "G_Balaclava_blk";


_leader = leader _group;

{
_x spawn refillPrimaryAmmo;
// _x spawn addMilCap;
_x call setMissionSkill;
_x addRating 9999999;
_x addEventHandler ["Killed", server_playerDied];
} forEach units _group;
Posts once, edits post 40 times in 60 seconds. STUPID FAT FINGERS!

https://github.com/Fractured-Gaming-Official/Frac_v1.3.Stratis
  • Offline soulkobk
  • First Blood
  • ***
  • Posts: 94
  • soulkobk.blogspot.com.au

Re: randomSoldierLoadOut

« Reply #6 posted: Oct 12, 2016, 04:05 AM »
With the _opticsDisallow variable, I grabbed the optic list from the config file (APEX), and pasted those in. Some are commented out as to allow them to be equipped on to the primary weapon should that weapon have any compatible optics, as every weapon is different.

  • equip primary weapon
  • get config entry for primary weapon muzzle (percentage chance)
  • get config entry for primary weapon pointer (percentage chance)
  • get config entry for primary weapon optic (percentage chance)
  • remove all _opticDisallow optics from optic array (eg TWS and KnightStalker)

Therefore, if the TWS is in the optic array for said primary weapon, then the _opticDisallow portion removes the TWS from the array (before it randomly chooses one) in order to disallow it. There is no need for an _opticAllow array.

I'm not sure on how else to explain things.

Quote
However on a few custom missions that have a different set up, it's only working on 1 AI (Leader I'm Assuming).

See the forEach loop at the end of the script? You need to add in...

Code: [Select]
[_x] call randomSoldierLoadOut;
...at the beginning of the loop (top).

Code: [Select]
{
[_x] call randomSoldierLoadOut;
_x spawn refillPrimaryAmmo;
_x call setMissionSkill;
_x addRating 9999999;
_x addEventHandler ["Killed", server_playerDied];
} forEach units _group;

That way, each and every AI unit from the _group will be randomly loaded out with gear (overrides the manual config above) from the [_x] call randomSoldierLoadOut; command.

You could also change the top portion of the script should you need.

Example,

Change...

Code: [Select]
// Leader
_leader = _group createUnit ["C_man_polo_1_F", [(_pos select 0) + 10, _pos select 1, 0], [], 1, "Form"];
removeAllAssignedItems _leader;
_leader addUniform "U_C_Scientist";
_leader addVest "V_TacVest_blk_POLICE";
_leader addBackpack "B_FieldPack_ocamo";
_leader addMagazine "10Rnd_762x51_Mag";
_leader addWeapon "srifle_DMR_01_F";
_leader addPrimaryWeaponItem "optic_Holosight";
_leader addMagazine "10Rnd_762x51_Mag";
_leader addMagazine "10Rnd_762x51_Mag";
_leader addMagazine "Titan_AT";
_leader addWeapon "launch_I_Titan_short_F";
_leader addMagazine "Titan_AT";
_leader addHeadgear "H_Cap_police";
_leader addGoggles "G_Balaclava_blk";

To...

Code: [Select]
_leader = _group createUnit ["C_man_polo_1_F", [(_pos select 0) + 10, _pos select 1, 0], [], 1, "Form"];
As there would be no need for a manual loadOut... my script/function does that for you in the forEach loop.

I hope I explained myself clear enough.

-soul.




  • Offline Mokey
  • Fractured Wasteland
  • Elite
  • ******
  • Posts: 576
  • Http://www.Fractured-Gaming.com

Re: randomSoldierLoadOut

« Reply #7 posted: Oct 12, 2016, 05:03 AM »
Loud and clear...

Thanks for all the help.
Posts once, edits post 40 times in 60 seconds. STUPID FAT FINGERS!

https://github.com/Fractured-Gaming-Official/Frac_v1.3.Stratis
  • Offline soulkobk
  • First Blood
  • ***
  • Posts: 94
  • soulkobk.blogspot.com.au

Re: randomSoldierLoadOut

« Reply #8 posted: Oct 12, 2016, 05:11 AM »
Loud and clear...

Thanks for all the help.

No problem :)

-soul.
  • Offline CREAMPIE
  • Armaholic
  • Veteran
  • ******
  • Posts: 1077
  • ^_^;;

Re: randomSoldierLoadOut

« Reply #9 posted: Oct 21, 2016, 05:22 PM »
Cool ^^
- from the grassy knoll -

Re: randomSoldierLoadOut

« Reply #10 posted: Nov 15, 2016, 12:08 AM »
Just curious could this script also be used for randomPlayerLoadOut? If so how?
  • Offline soulkobk
  • First Blood
  • ***
  • Posts: 94
  • soulkobk.blogspot.com.au

Re: randomSoldierLoadOut

« Reply #11 posted: Nov 15, 2016, 05:03 AM »
Just curious could this script also be used for randomPlayerLoadOut? If so how?

Yes. As per your PM request, I answered it.

-soul.
  • Offline Ltc-Bullet
  • First Blood
  • ***
  • Posts: 53
  • Founder of EZ Company Gaming

Re: randomSoldierLoadOut

« Reply #12 posted: Nov 15, 2016, 05:36 PM »
This is a cool script i have it on my server and is working great love it ...Thanks Soulkobk  :) 8)
  • Offline bodybag
  • Hardened
  • ****
  • Posts: 109
  • Gameaholic.se

Re: randomSoldierLoadOut

« Reply #13 posted: Nov 23, 2016, 01:31 AM »
Awsome soul, great job man :)