ante185 2 Posted February 11, 2014 OK, I know there are lots of scripts for this that you can use for missions and such but I am making a small unit addon and those I've found have I been unsuccessful at modify for my needs... I've managed to get the script that gives civvies random hats (randomize_civ1) to give my units random uniforms, vest and headgear randomize_equipment /* File: randomize_equipment.sqf [u][i]don't ask why but I changed this...[/i][/u] Author: pettka, modified for a different purpose by "ante" Description: Randomizes a headgear form _headgear array and puts it to civilian's headgear slot upon startup of mission. _rnd1 is used to have some civilians without any headgear _rnd2 is used to determine particular headgear from array Parameter(s): None Returns: Nothing */ _uniform = ["U_B_CombatUniform_mcam", "U_B_CombatUniform_mcam_tshirt", "U_B_CombatUniform_mcam_worn", "U_BG_Guerilla1_1", "U_BG_Guerilla2_1", "U_BG_Guerilla2_2", "U_BG_Guerilla3_1", "U_BG_leader", "U_I_CombatUniform_shortsleeve", "U_I_CombatUniform_tshirt", "U_I_OfficerUniform"]; _headgear = ["H_MilCap_dgtl", "H_Shemag_khk", "H_Beret_blk", "H_Booniehat_dgtl", "H_Booniehat_mcamo", "H_HelmetB", "H_HelmetB_paint", "H_HelmetIA", "H_HelmetIA_net", "H_HelmetSpecB_paint2", "H_HelmetCrew_I"]; _vest = ["V_TacVestCamo_khk", "V_TacVestIR_blk", "V_TacVestIR_blk", "V_Rangemaster_belt", "V_BandollierB_blk", "V_BandollierB_oli", "V_BandollierB_rgr", "V_Chestrig_blk", "V_HarnessO_brn", "V_Rangemaster_belt", "V_TacVest_blk"]; _headCount = count _uniform; if (isServer) then { BIS_randomSeed1 = []; BIS_randomSeed2 = []; _rnd1 = floor random 3; _this setVariable ["BIS_randomSeed1", _rnd1, TRUE]; _rnd2 = floor random _headCount; _this setVariable ["BIS_randomSeed2", _rnd2, TRUE]; }; waitUntil {!(isNil {_this getVariable "BIS_randomSeed1"})}; waitUntil {!(isNil {_this getVariable "BIS_randomSeed2"})}; _randomSeed1 = _this getVariable "BIS_randomSeed1"; _randomSeed2 = _this getVariable "BIS_randomSeed2"; _magazines = magazines _this; _items = items _this; // Medkits, ToolKits etc. _assitems = assignedItems _this; // NVG's, GPS etc. if (_randomSeed1 < 6) then { Removeuniform _this; Removeheadgear _this; Removevest _this; _this adduniform (_uniform select _randomSeed2); _this addheadgear (_headgear select _randomSeed2); _this addvest (_vest select _randomSeed2); }; {_this addItem _x} forEach _items; {_this addMagazine _x} forEach _magazines; {_this addItem _x} forEach _assitems; {_this assignItem _x} forEach _assitems; This works fine but every attempt I've made to make it hand out weapons have failed Also a bit of topic but class pmc_F : pmcs { faceType = "Man_A3"; faction = pmc_blue; vehicleClass = "Men"; scope = public; displayName = EISP pmc (Unarmed); portrait = "\A3\characters_f\data\ui\portrait_comBarHead_civ_man_ca.paa"; modelSides[] = {3}; nakedUniform = "U_NikosBody"; weapons[] = {"Throw", "Put"}; respawnWeapons[] = {"Throw", "Put"}; magazines[] = {"HandGrenade", "HandGrenade"}; respawnMagazines[] = {"HandGrenade", "HandGrenade"}; linkedItems[] = {"V_BandollierB_blk", "H_Booniehat_dgtl", "ItemMap", "ItemCompass", "ItemWatch", "ItemRadio"}; respawnLinkedItems[] = {"V_BandollierB_blk", "H_Booniehat_dgtl", "ItemMap", "ItemCompass", "ItemWatch", "ItemRadio"}; [u]class EventHandlers : EventHandlers { init = "(_this select 0) execVM ""\characters_a_pmc\randomize_equipment.sqf"""; }; [/u] }; How do I add ANOTHER script to that? Because having everything in the same sqf is a bit unwieldy(?) and not as usefull as if it was split up. I would be really thankful for any help! Share this post Link to post Share on other sites
lappihuan 178 Posted February 11, 2014 I think this will work: class EventHandlers : EventHandlers { init = "(_this select 0) execVM ""\characters_a_pmc\randomize_equipment.sqf"""; init = "(_this select 0) execVM ""\characters_a_pmc\randomize_weapon.sqf"""; }; For weapons and gear, don't you make classes like rifleman or marksman or medic etc. with the specific gear and weapons in the config? If you want to modify the equip script, look at the add commands like addItem etc. For weapons you need to replace them with addWeapon etc. -> search in the wiki for all the related commands. Also the classname array with the items must be replaced with one that holds weapon classnames. Share this post Link to post Share on other sites
ante185 2 Posted February 11, 2014 I think I tried having two init's but I got member already defined error. While you are correct in the fact that you can add weapons and equipment inside the configs if I do it this way I can get hilarious results :P this should work right? if (_randomSeed1 < 6) then { _this addweapon (_weapon select _randomSeed2); }; but I still need to make sure the weapon gets the right magazines Share this post Link to post Share on other sites
lappihuan 178 Posted February 12, 2014 (edited) Ok, you are right with the already defined error. You could try: class EventHandlers : EventHandlers { init = "(_this select 0) execVM ""\characters_a_pmc\randomize_equipment.sqf"";(_this select 0) execVM ""\characters_a_pmc\randomize_weapon.sqf"""; }; But its only a guess... To solve your Magazine problem, you could make a second array (_magazines = [x,y,z]; ) with the same order like the Weapon array. So if your randomSeed1 is 4 your _weapon 4 is a MX and your _magazines 4 is 5.56 etc. You get the idea? Edited February 12, 2014 by Lappihuan Share this post Link to post Share on other sites
ante185 2 Posted February 12, 2014 I'll try that out with the init But _randomSeed2 is always random, just because a unit has U_B_CombatUniform_mcam and H_MilCap_dgtl doesn't mean it will get the V_TacVestCamo_khk vest, that's was what I've observed. rather odd if you ask me. I have to figure out how to check what weapon the unit gets _getweapon = _weaponsarray select _randomSeed2; _this addweapon _getweapon if _getweapon == "arifle_mx_f" { _this addmagazine "30Rnd_65x39_caseless_mag"}; something like this yeah? Share this post Link to post Share on other sites
lappihuan 178 Posted February 12, 2014 yes, but your if syntax is wrong. it would be like that: if (_getweapon == "arifle_mx_f") then { _this addmagazine "30Rnd_65x39_caseless_mag" } but in your case i suggest you to use switch case: switch (_getweapon) do { case "arifle_mx_f": {_this addmagazine "30Rnd_65x39_caseless_mag"}; case "myRifleClassname": {_this addmagazine "myMagazineClassname"}; }; further information about swich here. Share this post Link to post Share on other sites
ante185 2 Posted February 12, 2014 Thank you! I am going to test that straight away, and the switch case thing looks to be pretty damn useful!!! ---------- Post added at 13:02 ---------- Previous post was at 12:13 ---------- Just one final thing, how do I repeat the part the gives out magazines? If I have to use the ForEach thing then I need to know how as I have no clue and the wiki isn't helping me that much... switch (_getweapon) do { case "arifle_mx_f": {_this addmagazine "30Rnd_65x39_caseless_mag"} foreach [1,2,3,4,5]; }; or can I attach it to the end like this? to make the whole thing repeat 5 times? switch (_getweapon) do { case "arifle_mx_f": {_this addmagazine "30Rnd_65x39_caseless_mag"}; } foreach [1,2,3,4,5]; Share this post Link to post Share on other sites
lappihuan 178 Posted February 12, 2014 use the addMagazine Array command for multiple magazine adds. Share this post Link to post Share on other sites
ante185 2 Posted February 12, 2014 I am sorry but what? How do you mean? addmagazine can only define what magazine and how many bullets it is supposed to hold? Share this post Link to post Share on other sites
lappihuan 178 Posted February 12, 2014 (edited) woops, you are right. ^^ Search in the function library for BIS_fnc_addMagazines or something like that. I can't ceck it because im at work.. Edit: just saw your question inside the code.. none of those would work. And forEach is not the right thing to do this. A for loop with a random end var would be the right one. But as i said, BIS provides a function in the function library to add multiple magazines and it checks if space is aviable etc. so this will be the best solution. Edited February 12, 2014 by Lappihuan Share this post Link to post Share on other sites
ante185 2 Posted February 12, 2014 (edited) in BIS_fnc_addWeapon (might be weapons) they got some code that gives two magazines but I am going to test something a bit more simpler, copy pasting should work to produce multiple magazines right? it'll be more dynamic as I can change what magazine number 4 could be and so on. thanks for the help still! Edited February 12, 2014 by ante185 Share this post Link to post Share on other sites
lappihuan 178 Posted February 12, 2014 Yes it was BIS_fnc_addWeapon ^^ This would actually make your script much simpler and better if you add the magazines at the same time you add the weapon. The function automaticly takes the correct magazines in the chosen amount. Use it like that: [_this, "myWeaponClassname", 4] call BIS_fnc_addWeapon; Parameters are described as this: _this select 0: <object> unit that is issued new equipment _this select 1: <string> weapon classname _this select 2: <scalar> number of magazines _this select 3 (Optional): <scalar> index of magazine class in weapon's config (default 0) OR <string> magazine classname Share this post Link to post Share on other sites