Blitzen88   18 Posted January 2, 2022 Greetings,  Im trying to figure out how to create an AI unit via an addaction (which I've figured out) BUT to also have an addaction where a created unit will join the player.  This is what I have:  /*========================================================================================== Arma III - AI Unit "Purchase" Created by Blitzen =========================================================================================== * Spawn AI units to refill/replace dead units * This script will change the type of unit based upon the player's side * Requires named Flags: FlagWest, FlagEast, FlagAAF * Call with: [this] execVM "Scripts\UnitRecruitment\Recruitment_Unit.sqf" ===========================================================================================*/ _Flag = _this select 0; _Flag allowDamage false; //West //--------------------------------------- if (side Player isEqualTo West) then { _FlagWest = _this select 0; _FlagWest setObjectTexture [ 1, "a3\data_f\flags\flag_nato_co.paa"]; _FlagWest addAction ["Spawn Squad Leader", {"B_Soldier_SL_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Squad Leader _FlagWest addAction ["Spawn Team Leader", {"B_Soldier_TL_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Team Leader _FlagWest addAction ["Spawn Rifleman", {"B_Soldier_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Rifleman _FlagWest addAction ["Spawn Rifleman AT", {"B_Soldier_LAT_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Rifleman AT _FlagWest addAction ["Spawn Grenadier", {"B_Soldier_GL_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Grenadier _FlagWest addAction ["Spawn AutoRifleman", {"B_Soldier_AR_F" createUnit [getpos FlagWest, CreateGroup West];}]; // AutoRifleman _FlagWest addAction ["Spawn Asst. AutoRifleman", {"B_Soldier_AAR_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Asst. AutoRifleman _FlagWest addAction ["Spawn Heavy Gunner", {"B_HeavyGunner_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Heavy Gunner _FlagWest addAction ["Spawn Marksman", {"B_soldier_M_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Marksman _FlagWest addAction ["Spawn Sharpshooter", {"B_Sharpshooter_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Sharpshooter _FlagWest addAction ["Spawn Ammobearer", {"B_Soldier_A_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Ammobearer _FlagWest addAction ["Spawn Medic", {"B_medic_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Medic _FlagWest addAction ["Spawn Missle Specialist", {"B_Soldier_AT_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Missle Specialist _FlagWest addAction ["Spawn Asst. Missle Specialist", {"B_Soldier_AAT_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Asst. Missle Specialist _FlagWest addAction ["Spawn Asst. Gunner", {"B_support_AMG_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Asst. Gunner _FlagWest addAction ["Spawn Gunner (HMG)", {"B_support_MG_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Gunner (HMG) _FlagWest addAction ["Spawn Gunner (GMG)", {"B_support_GMG_F" createUnit [getpos FlagWest, CreateGroup West];}]; // Gunner (GMG) }; How could I create basically the same thing but have the unit join the player? Would the same syntax work with groups and vehicles?  Thank you Share this post Link to post Share on other sites
gc8   977 Posted January 2, 2022 If you change the CreateGroup West to group player then they will join the player's group Share this post Link to post Share on other sites
Blitzen88   18 Posted January 2, 2022 3 minutes ago, gc8 said: If you change the CreateGroup West to group player then they will join the player's group Well that would be an easy fix.  How can I refer to a created unit? For instance if I want that unit to copy the player’s loadout? Also, how could I move the player into a created vehicle as a driver, etc? Share this post Link to post Share on other sites
gc8   977 Posted January 2, 2022 2 minutes ago, Blitzen88 said: Well that would be an easy fix.  How can I refer to a created unit? For instance if I want that unit to copy the player’s loadout? Also, how could I move the player into a created vehicle as a driver, etc?  you need to use the first syntax of createunit to get the reference  to make player the driver:  player moveindriver _vehicle  Share this post Link to post Share on other sites
avibird 1   155 Posted January 2, 2022 Hello  I have it setup to using radio triggers very easy setup. I have a platoon with 20 man that can be broken down to two squads via radio trigger. The squad leaders can call for the entire platoon to be one group or two squads. Each squad has three team leaders that can call for specific teams with radio triggers. ie assault weapons and logistics teams for each squad. It uses the join group command. I can have anywhere from 1-6 different groups. Now my units are playable/switchable units from the editor each with variable names that you need to use to call to join and disband your groups as you need. The question is can you use set variable names how are you spawning the units into the game? Share this post Link to post Share on other sites
Blitzen88   18 Posted January 2, 2022 23 minutes ago, gc8 said:  you need to use the first syntax of createunit to get the reference  to make player the driver:  player moveindriver _vehicle  If the vehicle is created, I would have to get the driver of the vehicle and delete him before the player is moved in? Share this post Link to post Share on other sites
gc8   977 Posted January 2, 2022 2 minutes ago, Blitzen88 said: If the vehicle is created, I would have to get the driver of the vehicle and delete him before the player is moved in?  good question, try and see 🙂 Share this post Link to post Share on other sites
Branko Draulic   0 Posted October 10, 2023 On 1/2/2022 at 7:14 PM, Blitzen88 said: Greetings,  Im trying to figure out how to create an AI unit via an addaction (which I've figured out) BUT to also have an addaction where a created unit will join the player.  This is what I have:  How could I create basically the same thing but have the unit join the player? Would the same syntax work with groups and vehicles?  Thank you Thank You for your post. Is it possible to improve the script giving to the different kind of units a custom loadout? I'm trying to understand how to add the instructions like removeAllWeapons _unit; removeAllItems _unit; removeAllAssignedItems _unit; removeUniform _unit; removeVest _unit; removeBackpack _unit; removeHeadgear _unit; removeGoggles _unit; _unit addWeapon "arifle_MXM_F"; _unit addPrimaryWeaponItem "muzzle_snds_H"; _unit addPrimaryWeaponItem "acc_pointer_IR"; _unit addPrimaryWeaponItem "optic_DMS"; _unit addPrimaryWeaponItem "30Rnd_65x39_caseless_mag"; _unit addPrimaryWeaponItem "bipod_01_F_snd"; etcetera Share this post Link to post Share on other sites
JCataclisma   80 Posted October 10, 2023 (edited) 1 hour ago, Branko Draulic said:  Is it possible to improve the script giving to the different kind of units a custom loadout? I'm trying to understand how to add the instructions like r  You could try something like the code below, which I use to add different kinds of damage to units regarding their side in the game. Or use "select" in different ways, for instance replace what's after "isKindOf" for the name you can find in "view in config file" (right-click on editor), or even change its syntax for {typeOF _x in "classNameHere"} if you'd rather use class names. // "7" in the three lines below is the distance - in meters - to the search for units around the player private _nearbyEastTroops = nearestObjects [player, ["Man"], 7] select {_x isKindOf 'SoldierEB'}; // for OPFOR private _nearbyGuerTroops = nearestObjects [player, ["Man"], 7] select {_x isKindOf 'SoldierGB'}; // for Independent private _nearbyBlueTroops = nearestObjects [player, ["Man"], 7] select {_x isKindOf 'SoldierWB'}; // for NATO // you could change the specific actions for each type of units in the lines between the "{ ..... } forEach ..." { removeAllWeapons _x; _x addPrimaryWeaponItem "muzzle_snds_H"; _x addPrimaryWeaponItem "acc_pointer_IR"; } forEach _nearbyEastTroops; { removeAllWeapons _x; _x addPrimaryWeaponItem "muzzle_snds_H"; _x addPrimaryWeaponItem "acc_pointer_IR"; } forEach _nearbyGuerTroops; { removeAllWeapons _x; _x addPrimaryWeaponItem "muzzle_snds_H"; _x addPrimaryWeaponItem "acc_pointer_IR"; } forEach _nearbyBlueTroops;  Edited October 10, 2023 by JCataclisma Share this post Link to post Share on other sites
JCataclisma   80 Posted October 10, 2023 1 hour ago, Branko Draulic said:  Is it possible to improve the script giving to the different kind of units a custom loadout? I'm trying to understand how to add the instructions like  Another example, this is what I use to randomly force units to wear some pre-defined civilian uniforms, so you could change those for arrays of wepons, items, etc. inside the "[...]":  _headgearArray = [ "H_Construction_basic_orange_F", "H_Construction_earprot_orange_F", "H_Cap_Orange_IDAP_F", "H_Hat_tan", "H_Bandanna_surfer", "H_Cap_red" ]; _vestArray = [ "V_Plain_medical_F", "V_Safety_orange_F" ]; _uniformArray = [ "U_C_Scientist", "U_C_Poor_2_sick", "U_NikosBody", "U_C_Poloshirt_redwhite", "U_C_Journalist", "U_OrestesBody" ]; _randomHeadgear = _headgearArray call BIS_fnc_selectRandom; _randomVest = _vestArray call BIS_fnc_selectRandom; _randomUniform = _uniformArray call BIS_fnc_selectRandom; (_unit) addHeadgear _randomHeadgear; (_unit) addVest _randomVest; (_unit) forceAddUniform _randomUniform; And there are users here, like PierreMGI and GuntherSeverloh who already have sorts of loadouts and modules for several types of stuff to use - check their signatures. Share this post Link to post Share on other sites
Branko Draulic   0 Posted October 12, 2023 Thanks @JCataclisma for your suggestions.  Share this post Link to post Share on other sites
Branko Draulic   0 Posted October 13, 2023 I was wondering if it is possible to add setUnitLoadout (getUnitLoadout) in the following line _FlagWest addAction ["Spawn Squad Leader", {"B_Soldier_SL_F" createUnit [getpos FlagWest, CreateGroup West];}]; to copy the loadout of a named unit in the scenario. Should be an easy solution for a newbie like me.  ===============================================  This one seems to work this addAction ["Arruola Cecchino Ricognitore", {"B_RangeMaster_F" createUnit [getpos newunits, group player, "unit1 = this"]; unit1 setUnitLoadout (getUnitLoadout ai12)}];   Share this post Link to post Share on other sites