Is it possible to make AI recruitable?

slicky131

New Member
To Anyone,

Is there a way to make the AI recruitable to my players. I don't care if the recruitable AI disappear once the player is killed or log off. I'm using Dayz 1.8.0.3
 
Thanks, that's just what I need. I'll try you if it works, once I figure out the instructions, kind of confusing.
 
Axman actually posted a script here to do just that vin the dzai forum. I used it , modified some, worked perfect. I believe it was on the dzai thread on the first page
 
Axman actually posted a script here to do just that vin the dzai forum. I used it , modified some, worked perfect. I believe it was on the dzai thread on the first page


I looked for it, and couldn't find it. I messaged Axman, and he's looking for the code. Do you have a copy of the code handy?
 

This is the part I don't understamd:

Andthen after the }; add this so the server and client initialize it properly (between };andif(!isDedicated)then{)

[] execVM "dbgroups\init.sqf";

Inthis section before the };
if(!isDedicated)then{

add this
[] execVM "dbgroups\scripts\scp_srvractions.sqf";
[] execVM "dbgroups\scripts\scp_adjustrating.sqf";
DBUpdClient=true;// update survivor variables
publicVariable "DBUpdClient";
 
Code:
/*   
    INITILIZATION
*/
DBGroupsStarted = false;
DBMaxSurvivors = 3;    // change this to the number of survivors you want, the more you add the lower your server and client FPS
startLoadingScreen ["","RscDisplayLoadCustom"];
cutText ["","BLACK OUT"];
enableSaving [false, false];

//REALLY IMPORTANT VALUES
dayZ_instance = 1;                    //The instance
dayzHiveRequest = [];
initialized = false;
dayz_previousID = 0;
PVDZ_plr_LoginRecord = nil;

dzn_ns_bloodsucker = true;        // Make this false for disabling bloodsucker spawn
dzn_ns_bloodsucker_den = 1;    // Spawn chance of bloodsuckers, max 400, ignore if dzn_ns_bloodsucker set to false
ns_blowout = true;            // Make this false for disabling random EVR discharges (blowout module)
ns_blowout_dayz = true;        // Leave this always true or it will create a very huuuge mess
ns_blow_delaymod = 0.82;        // Multiplier of times between each EVR dischargers, 1x value default (normal pre-0.74 times)
dayzNam_buildingLoot = "CfgBuildingLootNamalsk";    // can be CfgBuildingLootNamalskNOER7 (function of this pretty obvious), CfgBuildingLootNamalskNO50s (CfgBuildingLootNamalskNOER7 + no 50 cals), CfgBuildingLootNamalskNOSniper (CfgBuildingLootNamalskNOER7 + no sniper rifles), default is CfgBuildingLootNamalsk

//call compile preprocessFileLineNumbers "\nst\ns_dayz\code\init\variables.sqf"; //Initilize the Variables (IMPORTANT: Must happen very early)
call compile preprocessFileLineNumbers "fixes\variables.sqf"; //Initilize the Variables (IMPORTANT: Must happen very early)
progressLoadingScreen 0.1;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\publicEH.sqf";    //Initilize the publicVariable event handlers
progressLoadingScreen 0.2;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\medical\setup_functions_med.sqf"; //Functions used by CLIENT for medical
progressLoadingScreen 0.4;
call compile preprocessFileLineNumbers "custom\compiles.sqf"; //Compile custom compiles
progressLoadingScreen 1.0;

"filmic" setToneMappingParams [0.153, 0.357, 0.231, 0.1573, 0.011, 3.750, 6, 4]; setToneMapping "Filmic";

/* BIS_Effects_* fixes from Dwarden */
BIS_Effects_EH_Killed = compile preprocessFileLineNumbers "\z\addons\dayz_code\system\BIS_Effects\killed.sqf";
BIS_Effects_AirDestruction = compile preprocessFileLineNumbers "\z\addons\dayz_code\system\BIS_Effects\AirDestruction.sqf";
BIS_Effects_AirDestructionStage2 = compile preprocessFileLineNumbers "\z\addons\dayz_code\system\BIS_Effects\AirDestructionStage2.sqf";

BIS_Effects_globalEvent = {
    BIS_effects_gepv = _this;
    publicVariable "BIS_effects_gepv";
    _this call BIS_Effects_startEvent;
};

BIS_Effects_startEvent = {
    switch (_this select 0) do {
        case "AirDestruction": {
                [_this select 1] spawn BIS_Effects_AirDestruction;
        };
        case "AirDestructionStage2": {
                [_this select 1, _this select 2, _this select 3] spawn BIS_Effects_AirDestructionStage2;
        };
        case "Burn": {
                [_this select 1, _this select 2, _this select 3, false, true] spawn BIS_Effects_Burn;
        };
    };
};

"BIS_effects_gepv" addPublicVariableEventHandler {
    (_this select 1) call BIS_Effects_startEvent;
};

if ((!isServer) && (isNull player) ) then
{
waitUntil {!isNull player};
waitUntil {time > 3};
};

if ((!isServer) && (player != player)) then
{
  waitUntil {player == player};
  waitUntil {time > 3};
};

if (isServer) then {
    DBPV_SrvrUnits = [];
    publicVariable "DBPV_SrvrUnits";
    DBCurSurvivors = 0;
    publicVariable "DBCurSurvivors";
    DBSGroups = false;
    publicVariable "DBSGroups";
    DBUpdClient = false;
    publicVariable "DBUpdClient";
    _serverMonitor =     [] execVM "\z\addons\dayz_code\system\server_monitor.sqf";
    axe_server_lampObjs =    compile preprocessFileLineNumbers "custom_scripts\fnc_returnLampWS.sqf";
    "axeLampObjects" addPublicVariableEventHandler {_id = (_this select 1) spawn axe_server_lampObjs}; 
};

[] execVM "dbgroups\init.sqf";   < ------------------------------ this is what he means

if (!isDedicated) then {
    if (isClass (configFile >> "CfgBuildingLootNamalsk")) then {
        0 fadeSound 0;
        [] execVM "Scripts\kh_actions.sqf";
        [] execVM "fixes\effects.sqf";
        [] execVM "dbgroups\scripts\scp_srvractions.sqf";  <-------------
        [] execVM "dbgroups\scripts\scp_adjustrating.sqf"; <-------------
        DBUpdClient = true;        // update survivor variables <-------------
        publicVariable "DBUpdClient"; <-------------
        _nul = [] execVM "DZAI_Client\dzai_initclient.sqf";
        //debug monitor
        [] execVM "custom_monitor.sqf";
        waitUntil {!isNil "dayz_loadScreenMsg"};
        dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");
       
        _id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
        _playerMonitor =  [] execVM "\nst\ns_dayz\code\system\player_monitor.sqf";
        //StreetLights
        [] execVM "custom_scripts\street_lights.sqf";
        //radio
        [0.35, 600] execVM "Scripts\radioChatter.sqf";
        _nul = [] execVM "loginCamera.sqf";
        [] execVM "nosidechat.sqf";
    } else {
        endLoadingScreen;
        0 fadeSound 0;
        0 cutText ["You are running an incorrect version of DayZ: Namalsk, please download newest version from http://www.nightstalkers.cz/", "BLACK"];
    };
};

// Logo watermark: adding a logo in the bottom left corner of the screen with the server name in it
if (!isNil "dayZ_serverName") then {
    [] spawn {
        waitUntil {(!isNull Player) and (alive Player) and (player == player)};
        waituntil {!(isNull (findDisplay 46))};
        5 cutRsc ["wm_disp","PLAIN"];
        ((uiNamespace getVariable "wm_disp") displayCtrl 1) ctrlSetText dayZ_serverName;
    };
};
 
Ah its mission* because their is now a dzai forum so the thread is deleted.

You can do it .. Create an add action that is active if cursor target equals the units you want recruit able. It activates a recruit.sqf

Recruit.sqf takes the cursor target and does
[Cursortarget ]join silent (group player);

Its about 10 lines of code total.

I will post a working script in a while, they don't pay me to chat on the internet:eek::eek:
 
All we are lacking is a add action.
For testing, just add one in to your self actions that's statically on and we can post one that checks the units your looking at before adding the action. This one will be on , walk up to air and see if he joins you. He should then have an option to dismiss.
Player addaction ["recruit","scripts\ai_recruit.sqf" ]

This is ai _recruit.sqf
Code:
private ["_ai","s_player_dismiss"];
_ai = _this select 3;
[_ai] join (group player);
s_player_dismiss = _ai addAction ["<t color='#949494'>Dismiss</t>","scripts\ai_dismiss.sqf",[],-10,false,true,""];

This is ai_dismiss.Sqf
Code:
_unit = _this select 0;
_dismissedgroup = createGroup west;
[_unit] join _dismissedgroup;
_dismissedgroup selectleader _unit;
_wp = _dismissedgroup addWaypoint [position player, 0];
_wp setWaypointType "DISMISS";
_unit action ["eject",vehicle _unit];
sleep 2;

hint format["%1 has been dismissed",getText (configFile >> "CfgVehicles" >> typeOf _unit >> "displayname")];
//deleteVehicle _unit;
player removeAction s_player_dismiss;
s_player_dismiss = -1;
 
All we are lacking is a add action.
For testing, just add one in to your self actions that's statically on and we can post one that checks the units your looking at before adding the action. This one will be on , walk up to air and see if he joins you. He should then have an option to dismiss.
Player addaction ["recruit","scripts\ai_recruit.sqf" ]

This is ai _recruit.sqf
Code:
private ["_ai","s_player_dismiss"];
_ai = _this select 3;
[_ai] join (group player);
s_player_dismiss = _ai addAction ["<t color='#949494'>Dismiss</t>","scripts\ai_dismiss.sqf",[],-10,false,true,""];

This is ai_dismiss.Sqf
Code:
_unit = _this select 0;
_dismissedgroup = createGroup west;
[_unit] join _dismissedgroup;
_dismissedgroup selectleader _unit;
_wp = _dismissedgroup addWaypoint [position player, 0];
_wp setWaypointType "DISMISS";
_unit action ["eject",vehicle _unit];
sleep 2;

hint format["%1 has been dismissed",getText (configFile >> "CfgVehicles" >> typeOf _unit >> "displayname")];
//deleteVehicle _unit;
player removeAction s_player_dismiss;
s_player_dismiss = -1;

ok, I created 2 files ai_recruit.sqf and ai_dismiss.sqf. I placed them both in my missions folder. Now, what do I do? Do I have to add something in init
 
You need to have an action to give you ability to execute the scripts. For testing, i would add in your fn_selfactions.
player addaction["recruit","ai_recruit.sqf"];
The option should be displayed constantly which is not what you want, but for testing it will work. Then when you are close to an ai and looking at them, click your Recruit option. the ai should join you. And then when you look at the ai you will have a menu to dismiss them.
If it works, then you can replace the addaction with one that only shows up when you are actually looking at an AI that you can recruit, like select a few skins only of recruitable units.

All this is off the top of my head and it should work but most likely will need something. If it doesn't work, then post your arma2oaserver.rpt log and we will find out where the errors are.
 
I
You need to have an action to give you ability to execute the scripts. For testing, i would add in your fn_selfactions.
player addaction["recruit","ai_recruit.sqf"];
The option should be displayed constantly which is not what you want, but for testing it will work. Then when you are close to an ai and looking at them, click your Recruit option. the ai should join you. And then when you look at the ai you will have a menu to dismiss them.
If it works, then you can replace the addaction with one that only shows up when you are actually looking at an AI that you can recruit, like select a few skins only of recruitable units.

All this is off the top of my head and it should work but most likely will need something. If it doesn't work, then post your arma2oaserver.rpt log and we will find out where the errors are.

I tried this , although it brought up a constant for action , it didn't work. I even tried it in a scroll initialization screen and it still didn't work. I think the .sqf needs some working on. Do you want to give it a re-work?
 
Back
Top