-
Content Count
41 -
Joined
-
Last visited
-
Medals
Community Reputation
29 ExcellentAbout egbert
-
Rank
Lance Corporal
Profile Information
-
Gender
Not Telling
-
egbert started following Random pick in an array and _forEachIndex and [WIP] OFrP : Operation Frenchpoint
-
Random pick in an array and _forEachIndex
egbert replied to egbert's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Thanks a lot Serena, and sorry for my late answer, I wasn't around till today ! I'll will give it a try and let you know ! Thanks! Edit : It works perfectly, thank you for your help Serena and 7erra ! -
Random pick in an array and _forEachIndex
egbert replied to egbert's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi Serena, thanks for your reply ! So, do I need to write these 3 "private" at the beginning of my code ? Instead of this : private ["_pos_jose","_random_pos_jose"]; -
Random pick in an array and _forEachIndex
egbert replied to egbert's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Aaand it works like a charm ! I guess I was overcomplexing the thing ! Thanks a lot 7erra ! You rock ! -
Random pick in an array and _forEachIndex
egbert posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi there ! I'm not very good at scripting and I try to make this happen : I have a unit created in a group spawning at some position : _vip = createGroup [EAST, true]; _jose = _vip createUnit ["O_G_Soldier_F", [25304.1,21805.5,0.1], [],0,"CAN_COLLIDE"]; I would like to move this _jose in a position randomly picked in an array of 8 positions, so I wrote : _pos_jose = [[24871.3,23103.8,1.3],[24869.2,23099.7,1.4],[24852.4,23106.2,0.3],[24843.9,23082.7,0.1],[24837.9,23206.3,0.4],[24868.6,23219.4,3.1],[24655.2,23186.9,0.2],[24876.7,23097.9,0.1]]; _random_pos_jose = _pos_jose select (floor (random (count _pos_jose))); _jose setPosAtl _random_pos_jose; So far so good, but now I would like to add some directions to _jose (each direction match the index of the above array so first dir in the array is the good one for the first position in the array above) : _dir_jose = [138,63,70,117,44,128,172,205]; And furthermore, I would like to add a bodyguard to this _jose, but in a different group. This bodyguard (named _gdc1) is also already spawned I just would like to move him near _jose. I guess the logic is quite the same than for directions. The trick is, as the position of _jose is randomly picked, I don't know how to get the right index picked in the first array and select it for the other arrays. I tried this, but without success, the position of _gdc1 is always the same (the first one in the _pos_gdc1 array, so I guess index 0) : private ["_pos_jose","_random_pos_jose"]; _pos_jose = [[24871.3,23103.8,1.3],[24869.2,23099.7,1.4],[24852.4,23106.2,0.3],[24843.9,23082.7,0.1],[24837.9,23206.3,0.4],/*masure_foret*/[24868.6,23219.4,3.1],[24655.2,23186.9,0.2],[24876.7,23097.9,0.1]]; _dir_jose = [138,63,70,117,44,128,172,205]; _pos_gdc1 = [[24874.2,23106,1.3],[24866.6,23095.8,1.5],[24852,23111.7,0.1],[24846.8,23079.4,0.1],[24847.7,23202.8,0.1],[24872.1,23214.8,3.1],[24665.9,23173.6,0.2],[24884.3,23099.6,0.1]]; _dir_gdc1 = [321,298,10,145,271,137,76,102]; _random_pos_jose = _pos_jose select (floor (random (count _pos_jose))); { _jose setPosAtl _random_pos_jose; _jose setDir (_dir_jose select _forEachIndex); _gdc1 setPosATL (_pos_gdc1 select _forEachIndex); _gdc1 setDir (_dir_gdc1 select _forEachIndex); } forEach _pos_jose; I can't figure where I'm wrong, since as I said first, I'm not good at scripting SQF (or every other language to tell the truth). If anybody does have a clue, it will be highly appreciated ! Thanks in advance ! -
Many many thanks to you Xjoker_ ! It works like a charm ! And I went a bit deeper in the comprehension of SQF syntax, thanks to your code ! I just added something like removeBackpack _x; right after your comment in the last paragraph, otherwise my unit spawned with his original backpack at his feet. Thanks again !
-
Thanks Tajin for your reply ! Well, I guess it would be a bit easier, but not as much random as the kind of function I had in mind. And maybe a lot more work, especially because I also use external mods, and if some classnames of some, let's say, uniform changes, it's a pain in the a** to search and replace all the classnames in all the sqf files. With my function, I only have to write it once. But yes, I swear, if I fail to write and use my function, I will do that. (I say "my function" but obviously I take no credit for that, I'm unable to properly write a function by myself !)
-
Thank you for your reply Xjoker_ ! Yeah, creating a function out of this is probably the best thing to do ! I will definitely do that ! But I forgot to explain that some of my units, according to their class, should pick specific weapons among an array. In the bit of code you wrote, I miss this idea of if "KICC_RIFLEMAN", then select randomly in Rifleman stuff, if "KICC_MACHINEGUNNER", then select randomly in MG stuff... to get me on the right track, and my poor knowledge won't help me. In my first code, there was this (I don't understand how it works, I just copied it from another codes from far more talented people than me) : switch ( typeOf _x) do { case ("KICC_RIFLEMAN") : { give this give that etc... }; case ("KICC_MACHINEGUNNER") : { give this give that etc... }; }; Thanks again for your time !
-
Hi there ! I'm trying to make a MP mission where all my IAs spawn from a SQF file. But I also want these IAs equiped with a random custom loadout, from another SQF file if possible (I already managed to call and equip IA in one SQF file, but I really would like to separate those files so I can adapt any mission easily). This was my original SQF, which was working : params ["_type", "_x"]; if (isServer || isDedicated) then { //Garde robe et armurerie dispo _weaponList = [ ["arifle_Mk20_ACO_pointer_F","30Rnd_556x45_Stanag"], ["hgun_PDW2000_Holo_F","30Rnd_9x21_Mag"], ["SMG_02_ACO_F","30Rnd_9x21_Mag_SMG_02"], ["SMG_05_F","30Rnd_9x21_Mag_SMG_02"], ["hlc_rifle_aks74u_MTK","hlc_30Rnd_545x39_B_AK"], ["arifle_AKM_F","30Rnd_762x39_Mag_F"], ["hlc_rifle_aks74","hlc_30Rnd_545x39_B_AK"], ["arifle_CTAR_blk_F","30Rnd_580x42_Mag_F"], ["hlc_rifle_aku12","hlc_30Rnd_545x39_B_AK"] ]; _weaponListMg = [ ["LMG_Mk200_pointer_F","200Rnd_65x39_cased_Box"], ["Weapon_LMG_Zafir_F","150Rnd_762x54_Box"], ["hlc_rifle_rpk","hlc_75Rnd_762x39_m_rpk"], ["LMG_03_F","200Rnd_556x45_Box_F"] ]; _weaponListGl = [ ["arifle_AK12_GL_F","30Rnd_762x39_Mag_F"], ["hlc_rifle_ak74m_gl","hlc_30Rnd_545x39_B_AK"], ["arifle_Mk20_GL_plain_F","30Rnd_556x45_Stanag"] ]; _weaponListTp = [ ["srifle_EBR_F","20Rnd_762x51_Mag"], ["srifle_DMR_01_F","10Rnd_762x54_Mag"], ["srifle_DMR_04_F","10Rnd_127x54_Mag"], ["arifle_AK12_F","30Rnd_762x39_Mag_F"], ["srifle_DMR_07_blk_F","20Rnd_650x39_Cased_Mag_F"], ["srifle_DMR_06_olive_F","20Rnd_762x51_Mag"] ]; // select from the array _weapon = _weaponList call BIS_fnc_selectRandom; _weaponMg = _weaponListMg call BIS_fnc_selectRandom; _weaponGl = _weaponListGl call BIS_fnc_selectRandom; //Création des markers //Sentinelles camp spawn_S01 = ["spawn_S01",[24654.3,23183.1],"colorOPFOR","ELLIPSE",0] call LM_fnc_markerCreation; spawn_S02 = ["spawn_S02",[24642,23158.3],"colorOPFOR","ELLIPSE",0] call LM_fnc_spawnCreation; //Création des groupes //Sentinelles camp S01 = [getMarkerPos "spawn_S01", EAST, ["KICC_FUSILIER"],[],[],[0.1,0.4],[],[],183 ] call BIS_fnc_spawnGroup; S02 = [getMarkerPos "spawn_S02", EAST, ["KICC_FUSILIER","KICC_FUSILIER"],[[0,0,0],[1,1,0]],[],[0.1,0.4],[],[1,0.6],0 ] call BIS_fnc_spawnGroup; {_x disableAI "MOVE"} forEach units S02; //Habillage des groupes _allunits = units S01 + units S02; { switch ( typeOf _x) do { case ("KICC_FUSILIER") : { removeAllWeapons _x; removeAllItems _x; removeAllAssignedItems _x; removeUniform _x; removeVest _x; removeBackpack _x; removeHeadgear _x; removeGoggles _x; _x forceAddUniform (["U_I_C_Soldier_Bandit_2_F","U_I_C_Soldier_Bandit_3_F","U_C_WorkerCoveralls","U_C_Man_casual_3_F","U_BG_Guerrilla_6_1","U_C_Poor_1","U_BG_Guerilla2_2","U_BG_Guerilla2_1","U_BG_Guerilla2_3","U_BG_Guerilla3_1","U_C_HunterBody_grn","U_I_C_Soldier_Para_1_F","U_I_C_Soldier_Para_2_F","U_I_C_Soldier_Para_3_F","U_I_C_Soldier_Para_4_F","U_I_C_Soldier_Camo_F","U_BG_leader","U_BG_Guerilla1_1"] call BIS_fnc_selectRandom); _x addVest (["V_PlateCarrier1_blk","V_PlateCarrier1_rgr_noflag_F","V_PlateCarrier1_tna_F","V_Chestrig_blk","V_Chestrig_rgr","V_Chestrig_khk","V_Chestrig_oli","V_PlateCarrierIA1_dgtl","V_HarnessOGL_brn","V_HarnessOGL_ghex_F","V_HarnessO_brn","V_HarnessO_ghex_F","V_HarnessO_gry","V_Rangemaster_belt","V_TacVestIR_blk","V_BandollierB_blk","V_BandollierB_cbr","V_BandollierB_ghex_F","V_BandollierB_rgr","V_BandollierB_khk","V_BandollierB_oli","V_TacChestrig_cbr_F","V_TacChestrig_grn_F","V_TacChestrig_oli_F","V_Tacblk","V_Tacbrn","V_Taccamo","V_Tackhk","V_Tacoli","V_I_G_resistanceLeader_F"] call BIS_fnc_selectRandom); _x addHeadgear (["H_Cap_red","H_Cap_blu","H_Cap_oli","H_Cap_headphones","H_Cap_tan","H_Cap_blk","H_Cap_brn_SPECOPS","H_Cap_blk_Raven","H_Cap_oli_hs","H_MilCap_ocamo","H_MilCap_mcamo","H_MilCap_oucamo","H_MilCap_rucamo","H_MilCap_gry","H_MilCap_dgtl","H_MilCap_blue","H_Bandanna_khk","H_Bandanna_khk_hs","H_Bandanna_cbr","H_Bandanna_gry","H_Shemag_khk","H_Shemag_tan","H_Shemag_olive","H_Shemag_olive_hs","H_ShemagOpen_khk","H_ShemagOpen_tan","H_Beret_blk","H_Beret_grn","H_Beret_ocamo","H_Watchcap_blk","H_Watchcap_cbr","H_Watchcap_khk","H_Watchcap_camo","H_Watchcap_sgg","H_TurbanO_blk"] call BIS_fnc_selectRandom); _x addGoggles (["G_Balaclava_blk","G_Balaclava_oli","G_Bandanna_blk","G_Bandanna_oli","G_Aviator","G_Spectacles","G_Squares_Tinted","G_Squares","G_Squares","G_Shades_Blue","G_Shades_Red","G_Shades_Green","G_Shades_Red","G_Sport_BlackWhite","G_Sport_Blackyellow","G_Sport_Checkered","G_Sport_Greenblack","G_Sport_Red"] call BIS_fnc_selectRandom); _x addItemToVest "MiniGrenade"; _x addItemToVest "MiniGrenade"; _x addItemToVest "Chemlight_blue"; for "_i" from 0 to 6 do {_x addMagazine (_weapon select 1); }; _x addWeapon (_weapon select 0); for "_i" from 1 to 2 do {_x addItemToVest "16Rnd_9x21_Mag";}; _x addWeapon "hgun_Rook40_F"; _x addPrimaryWeaponItem "acc_flashlight"; }; }; }forEach _allunits; }; And so I would like to keep AI spawn in one file, and AI loadout in another file. I hope this bit of code isn't too messy. In order to mix Ai spawn and custom loadout I picked some ideas from Larrow --> here . If anyone have any clue how to make this happen, it would be very nice, I've made several missions with guerilla oriented faction, editing every unit manually, and I feel I could save so much time with a working code/function like this ! Thanks in advance !
-
Add WP to randomly spawned unit.
egbert replied to egbert's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Wow, that seem really interesting too ! I'm a big noob in scripting, so I don't know which method is the less demanding in ressources. I intend to play this mission on a dedicated server, with max 15 players. Thanks a lot Grumpy for this new approach, it more looks like what I did before whining here, but instead of delete two of the 3 units, I was hiding them. Problem was they could still open fire on players... I will definitely give it a try too, and see which has better performances. Thanks again ! -
Add WP to randomly spawned unit.
egbert replied to egbert's topic in ARMA 3 - MISSION EDITING & SCRIPTING
So nice, it works perfectly ! For the record, I used this code : if (isServer) then { _positions = [ [10915.8,7847.88,0.279678], [11270.8,7876.25,0.573982], [10946,9523,0.581001] ]; _waypoints = [ [[10929.9,7867.38,0], [10961.2,7857.93,0], [11008.4,7857.93,0]], [[11247.2,7871.59,0], [11202.3,7881.77,0], [11162.2,7888.05,0]], [[10921.4,9554.32,0], [10915.6,9572.28,0], [10891.4,9570.19,0]] ]; _i = floor(random(count _positions)); jose setPosATL (_positions select _i); {(group jose) addWaypoint [_x,0] } forEach (_waypoints select _i); }; Thank you very much Silent for your help ! And thank you also for your part in the development of ACE 3, we use it almost every day with my team, we could not play without it now ! -
Add WP to randomly spawned unit.
egbert replied to egbert's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Nice ! Thanks a lot Silent ! So, with your piece of code, I wonder if the waypoints will be chosen randomly too ? In that case, maybe the alternative way that you mention, keeping the waypoints in a nested array with the positions will fits me better ! Thank you verymuch anyway, I'll test it asap ! -
Add WP to randomly spawned unit.
egbert replied to egbert's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Thanks MKD3-FHI, this code is indeed interesting for a patrol. But I don't want my spawned unit to patrol, I would like him to follow a specified path to vehicule if there is a threat aroud him, and if not, he stays where he is (I plan to add a FiredNear eventhandler to this unit to trigger the activation of these waypoints I desperatly try to add). The thing is, and this is where I'm stuck, this path won't be the same if my unit spawns in position 1, or position 2, or 3. I guess I have to name the 3 possible positions my unit can spawn, and then use a kind of case condition to link these spawn positions with the sets of waypoints. Something like : case my unit spawn to "pos_1" then your waypoints are : marker_1.1, marker_1.2 etc... case my unit spawn to "pos_2" then your waypoints are : marker_2.1, marker_2.2 etc... And finally, if you hear shot fire, then you flee using these waypoints. Something like that. But thanks anyway mate, it's nice of you, any help is most welcome ! -
addeventhandler when communicate on specified frequency with TFR
egbert replied to egbert's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Wow thanks a lot M1ke ! I'll try to manage it with the link you gave me, and if I fail I'll ask in the TFR thread. Thank you very much ! -
addeventhandler when communicate on specified frequency with TFR
egbert posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi there ! I'm relatively noob when it comes to scripting, and I discovered eventhandlers lately, which is a bad mix. Noob + eventhandler = not a good idea. Well, anyway, I'd love to inject some realism in one of my mission, and therefore trigger a chopper evac when one of my team player make a call on a specified frequency with Task Force Radio. So basically, teamplayer say blabla with a long-range radio, on freq 51, and the eventhandler get it, and spawn my evac (which is the nice COB_fnc_extraction, credit : the talented Cobra4v320). Anyone already did that before or have a clue to make it work ? Thanks in advance ! -
Hi there ! I'm trying to add some WP to a unit spawned in an array of three positions randomly picked. So basically, what I would like to do is to add a set of waypoints to each of the 3 positions where my unit can spawn. When the unit spawn to one of these 3 pos, a set of waypoints spawns with my unit, so if a shot is fired near my unit, it triggers the activation of the WP's. I use this code for the random position : if (isServer) then { _positions = [ [10915.8,7847.88,0.279678], [11270.8,7876.25,0.573982], [10946,9523,0.581001] ]; _pos = selectRandom _positions; jose setPosATL _pos; }; Anyone got a clue to make it work ? Thanks in advance !