Jump to content
Blitzen88

Create AI Unit and Create AI Unit to Join Player Group

Recommended Posts

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

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
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
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

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
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
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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×