Jump to content
avibird 1

What AI Recruitment Scripts do you use.

Recommended Posts

I only found a few AI Recruitment Scripts for ARMA3.

 

1.Bon's Infantry Recruitment

2.Simple AI Recruitment Dialog / Script

3.[FOCK] AI Recruit - Cheap and cheer full [ALPHA]

 

4. using ZEUS (not really good for static mission design)

5. using MCC  (not really good for static mission design)

 

Bon's with its dynamically built subfaction system is great.

Dadds Army Simple AI Recruitment is very nice as well but both of them you can't just limited the Recruitment to a particular unit at  multiple set locations  ie only a pilot at an airbase or a tank crew at an armor depot position.

 

There is a way with both of them but I would have to make second  set of folders files and scripts to run the them with only one unit class in the script. As is I am trying to reduce the number of folders files and scripts in my little project :unsure:

 

 

 

 

Share this post


Link to post
Share on other sites

Nobody else uses AI recruitment scripts in there missions. Still looking for more recruitment scripts to review.

Share this post


Link to post
Share on other sites

This what we are using right now. Would like to make it a function and improve the code. Needs to work on dedicated, MP, or hosted.

 

Spoiler

if (!isDedicated) then {

	[] spawn {

		while {true} do {
		
		_allAIUnits = allUnits select {_x distanceSqr getpos player < 900};
		
			if (count _allAiUnits > 0) then {{
				if( side player == side _x && alive _x && group _x != group player && leader player == player && _x isKindOf "Man" && vehicle _x == _x && (leader _x != _x || count (units group _x) == 1) ) then {
					if(isNil {_x getVariable "sa_join_squad_action_id"}) then {
						_actionId = _x addAction ["Join My Squad", { 
							if(isNil {(_this select 0) getVariable "sa_original_group"}) then {
								(_this select 0) setVariable ["sa_original_group",group (_this select 0)];
							};
							[_this select 0] join player; 
							(_this select 0) removeAction (_this select 2);
							(_this select 0) setVariable ["sa_join_squad_action_id",nil];
						}, nil, 0, false];
						_x setVariable ["sa_join_squad_action_id",_actionId];
					};
				} else {
					if(!isNil {_x getVariable "sa_join_squad_action_id"}) then {
						_x removeAction (_x getVariable "sa_join_squad_action_id");
						_x setVariable ["sa_join_squad_action_id",nil];
					};
				};
				
				if( side player == side _x && alive _x && group _x == group player && leader player == player && _x isKindOf "Man" && vehicle _x == _x && _x != player ) then {
					if(isNil {_x getVariable "sa_leave_squad_action_id"}) then {
						_actionId = _x addAction ["Leave My Squad", { 
							if(!isNil {(_this select 0) getVariable "sa_original_group"}) then {
								[_this select 0] join ((_this select 0) getVariable "sa_original_group"); 
								(_this select 0) setVariable ["sa_original_group",nil];
							} else {
								[_this select 0] join grpNull; 
							};
							(_this select 0) removeAction (_this select 2);
							(_this select 0) setVariable ["sa_leave_squad_action_id",nil];
						}, nil, 0, false];
						_x setVariable ["sa_leave_squad_action_id",_actionId];
					};
				} else {
					if(!isNil {_x getVariable "sa_leave_squad_action_id"}) then {
						_x removeAction (_x getVariable "sa_leave_squad_action_id");
						_x setVariable ["sa_leave_squad_action_id",nil];
					};
				};
				
			} forEach _allAiUnits;
			sleep 10;
			};

		};

	};

};

 

 

Share this post


Link to post
Share on other sites

Recruiting with my addon. If better rating than a friend unit (condition), temporary zoom (right click) on it to recruit/dismiss this unit.

Share this post


Link to post
Share on other sites

@Jnr4817

This should work in SP/MP

Add in init.sqf (or initPlayerLocal.sqf):

 

[] spawn {
  if (!hasInterface) exitWith {};
  waitUntil {!isNull player};
  while {true} do {
    {
      _x setVariable ["addedAction",true];
      _x setVariable ["oldGrp",if (group _x == group player) then [{grpNull},{group _x}]];
      _x addAction [if (group player isEqualTo group _x) then [{"Leave my squad"},{"Join my squad"}], {
        params ["_unit","_player","_id"];
        _ActMenu = (_unit actionParams _id) select 0;
         _unit setUserActionText [_id,_ActMenu];
        if (_ActMenu isEqualTo "Join my squad") then {
          _ActMenu = "Leave my squad";
          [_unit] join group _player;
        } else {
          _ActMenu = "Join my squad";
          [_unit] join (_unit getVariable ["oldGrp",grpNull]);
        };
        _unit setUserActionText [_id,_ActMenu];
      },nil,0.8,false,true,"side _this isEqualTo side _target"];
    } forEach (allunits select { !(_x getVariable ["addedAction",false]) && !isPlayer _x});
    sleep 2;
  };
};

 

Works on AIs only infantry only, for 15 m distance and the unit under cursor (targeted).

  • Like 3

Share this post


Link to post
Share on other sites

Alternate solution for farther distance (so addAction must be on player).

In initPlayerLocal.sqf:


 

addedAction = {
  player addAction ["Join my squad",{
    params ["_player","_caller","_id"];
    _ActMenu = (_player actionParams _id) select 0;
    _player setVariable ["idThis",_id];
    if (_ActMenu isEqualTo "Join my squad") then {
      [cursorTarget] join group _player;
    } else {
      [cursorTarget] join (cursorTarget getVariable ["oldGrp",grpNull]);
    };
  },nil,0.8,false,true,"",
  "if ((!isNull cursorTarget) && {isNil {cursorTarget getVariable 'oldGrp'}}) then {
     cursorTarget setVariable ['oldGrp',if (group cursorTarget == group_this) then [{grpNull},{group cursorTarget}]]
   };
   if (!isnil {_this getvariable 'idThis'}) then {
     _this setUserActionText [(_this getvariable 'idThis'),if (group cursorTarget == group _this) then [{'Leave my squad'},{'Join my squad'}]]
   };
   side cursorTarget == playerSide
   && cursorTarget distanceSqr _this < 40000"
  ];
};

call addedAction;
player addEventHandler ["respawn", {call addedAction}];

 

 

  • Like 2

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

×