Jump to content

Recommended Posts

cool little script to make ai units join you in-game:

 

  1. Place your player on the map
  2. Place as many AI units you desire
  3. Name each the AI unit a specific Variable Name. Example: AIsoldier_1, AIsoldier_2, AIsoldier_3, etc. The Variable Name should be unique and placed in each ai attribute (under Variable Name)
  4. Place a no space trigger 

under "Trigger: Expression"
        Condition

player distance AIsoldier_1 <2

        On Activation:

[AIsoldier_1] join player;

 

You will have to walk up to the ai unit (within 2 meters according to this script) to have it join your squad.

Picture

  • Like 1

Share this post


Link to post
Share on other sites

@Dyeg0,

Check this out,

Spoiler

player spawn { "auto recruit nearby units";
	waitUntil {sleep 1;
		if ( (_this nearEntities ["Man", 3]) - [_this] isEqualTo []) then {false} else {
			private _recruit= ((_this nearEntities ["Man", 3])- [_this]) select 0;
			if (	side _recruit == side _this && group _recruit !=group _this	) then {
				[_recruit] join _this;
				false
			}else{false}
		}
	}
}

Simple recruit addAction,


[player, "Recruit Unit",
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
    "side cursorTarget == side _this && cursorTarget distance _this < 3 && group cursorTarget != group _this", "alive cursorTarget",{},{},{

    params ["_target", "_caller", "_actionId", "_arguments"];
    [cursorTarget] join _target;

},{},[],2,0,false,true] call BIS_fnc_holdActionAdd;

 


Have fun!

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Into init field of each AI which should join if player gets near:

this setVariable ["saro_joinable", true];

 

set the trigger to:  none, none, repeatable

 

Condition:

not ( (units side player) findIf { _x getVariable ["saro_joinable", false] and { _x distance player < 2 } } < 0 )

 

On Activation:

[] spawn
{
 private _near_men = player nearEntities ["Man", 2];
 private _marked_men = _near_men select { _x getVariable ["saro_joinable", false] };
 private _man = _marked_men select 0;
 _man setVariable ["saro_joinable", false];
 [_man] join player;
};

 

Now if you reach any of the AI which was marked with the init field enrtry it will join players group.

Share this post


Link to post
Share on other sites
12 hours ago, Dyeg0 said:

Name each the AI unit a specific Variable Name. Example: AIsoldier_1, AIsoldier_2, AIsoldier_3, etc. The Variable Name should be unique and placed in each ai attribute (under Variable Name)

Why naming multiple units? Your code let AISoldier_1 join players group if player is near. nothing else. no reason to name the other AI.

Share this post


Link to post
Share on other sites
8 hours ago, sarogahtyp said:

Why naming multiple units? Your code let AISoldier_1 join players group if player is near. nothing else. no reason to name the other AI.

I guess he means that you have to make a trigger for all Ai units (AIsoldier_1, AIsoldier_2, AIsoldier_3)

 

Cheers

  • Thanks 1

Share this post


Link to post
Share on other sites
6 hours ago, Play3r said:

I guess he means that you have to make a trigger for all Ai units (AIsoldier_1, AIsoldier_2, AIsoldier_3)

 

Cheers

Exactly what I meant. TY.

  • Thanks 1

Share this post


Link to post
Share on other sites
On 7/18/2021 at 9:59 AM, sarogahtyp said:

Into init field of each AI which should join if player gets near:


this setVariable ["saro_joinable", true];

 

set the trigger to:  none, none, repeatable

 

Condition:


not ( (units side player) findIf { _x getVariable ["saro_joinable", false] and { _x distance player < 2 } } < 0 )

 

On Activation:


[] spawn
{
 private _near_men = player nearEntities ["Man", 2];
 private _marked_men = _near_men select { _x getVariable ["saro_joinable", false] };
 private _man = _marked_men select 0;
 _man setVariable ["saro_joinable", false];
 [_man] join player;
};

 

Now if you reach any of the AI which was marked with the init field enrtry it will join players group.

 

Hi Sarogahtyp

 

The Condition text give me a error : invalid number in expression.

 

I have take the text and copied it in to notepad ++ 

before taking it to the trigger.

 

can you guide me about what there could be wrong in what i do.

 

Play3r

Share this post


Link to post
Share on other sites

Check the copied condition text for invisible characters or rewrite it manually.

 

  • Thanks 1

Share this post


Link to post
Share on other sites
On 7/17/2021 at 3:20 PM, wogz187 said:

@Dyeg0,

Check this out,

  Hide contents


player spawn { "auto recruit nearby units";
	waitUntil {sleep 1;
		if ( (_this nearEntities ["Man", 3]) - [_this] isEqualTo []) then {false} else {
			private _recruit= ((_this nearEntities ["Man", 3])- [_this]) select 0;
			if (	side _recruit == side _this && group _recruit !=group _this	) then {
				[_recruit] join _this;
				false
			}else{false}
		}
	}
}

Simple recruit addAction,



[player, "Recruit Unit",
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
    "side cursorTarget == side _this && cursorTarget distance _this < 3 && group cursorTarget != group _this", "alive cursorTarget",{},{},{

    params ["_target", "_caller", "_actionId", "_arguments"];
    [cursorTarget] join _target;

},{},[],2,0,false,true] call BIS_fnc_holdActionAdd;

 


Have fun!

 

 

 

   How could I make Join Group  vs  Unit?  and join on Group Leader ?    btw awesome work.

 

 

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

×