aussie battler

[Release] Recruit Ai Bodyguards

61 posts in this topic

Posted (edited)

Description: Recruit Ai Body guards from your XM8 or from placed objects on the map.

How it works: Deploy a statue from your Xm8 using beef parts. Scroll on the spawned statue & choose "Recruit Bodyguard". The statue despawns & an ai will appear in your group.

Rules: Can't deploy the ai guard in a safe zone. Ai despawns on restarts. Ai only attacks mission ai (only tested on DMS Ai).

Command Ai movement:
1. Press ESC>Configure>Controls>Show:Command

2. Change the "ACTION" of "Select Unit 1" to the key of your choice (I used "semicolon"). Press "OK" and go back to the game.

3. Press "semicolon" to select your Ai, then hit "space bar"

4. Move your mouse to the position you wish the Ai to hold or vehicle you wish the Ai to enter. Now hit the "space bar" :)

Command Ai to drive:

1. Exist a vehicle from a passenger seat.
2. Order the Ai will hop in the vehicle.
3. Get in the vehicle & mark waypoints on the map. You can also take over driving.

(thanks to @TheDaddy for the Ai driving tip)

I would like to change the ai behaviour to help kill other Exile Players out of the players group & also command the Ai. Let me know if you have any ideas.

Install: Recruit Ai from your XM8.

  1. Install ExAd by @Janski https://goo.gl/VBxFFa

  2. Drop the DeployVehicle folder into your.mission\ExAdClient\XM8\Apps\DeployVehicle   found here https://github.com/aussie-battler/Salty-Dog-Exile-Recruit-Ai
    Make sure you drop the Deploy Vehicle server file in your @ExileServer/addons folder found here https://github.com/aussie-battler/Salty-Dog-Exile-Recruit-Ai/tree/master/ExileSever/addons

  3. In config.cpp search for class CFGXM8 

         Add the following to extraApps[] = { };
 

Spoiler

"ExAd_Unit"

        The line should now read: extraApps[] = {"ExAd_Unit"};

  1. Underneath the extraApps line add:

         

Spoiler

class ExAd_Unit
 {
 	title = "Attack Soldier: x2 Beef Parts needed";
 	config = "ExAdClient\XM8\Apps\DeployVehicle\guard.sqf";
 	logo = "ExAdClient\XM8\Apps\DeployVehicle\dog.paa";
 	bambiState = 0;
 	vehicleClass = "Land_AncientStatue_01_F";
 	recipe[] = {{"Exile_Item_BeefParts",1}};
 	packable = 1;
 	autoCleanUp = 1;
 	quickFunction = "['ExAd_Unit'] call ExAd_XM8_DV_fnc_spawnVehicle";
 	onLoad = "ExAdClient\XM8\Apps\DeployVehicle\guard.sqf";
 };

      5.  In config.cpp search for BeefParts and change the line to:

           

Spoiler

class Exile_Item_BeefParts                                 { quality = 1; price = 50000; sellPrice = 14;};              // change the buy/sell price to whatever suits.

  1. In config.cpp find class CfgInteractionMenus and add this below it:

Spoiler

 class Bodyguard
 {
 targetType = 2;
 target = "Land_AncientStatue_01_F";

 class Actions 
 {
 	class Body_guard: ExileAbstractAction
 	{
 		title = "Recruit Bodyguard";
 		condition = "('Exile_Item_BeefParts' in (magazines player) && !ExilePlayerInSafezone)";
 		action = "ExAdClient\XM8\Apps\DeployVehicle\bodyguard.sqf";
 	};
 };
 };

Optional Extra: RECRUIT AI FROM PLACED OBJECTS ON THE MAP.

  1. You will need to place objects (I chose a statue Land_AncientStatue_01_F) around the map using M3Editor and mark them on the map in your mission.sqm file.

Follow this tutorial by @BetterDeadThanZed: https://goo.gl/MZZ6ph

Want to make changes?

  1. Change the XM8 logo at:

your.mission\ExAdClient\XM8\Apps\DeployVehicle\dog.paa

In config.cpp under "class ExAd_Unit", change the line to suit your logo name

logo = "ExAdClient\XM8\Apps\DeployVehicle\dog.paa";

  1. Change the soldiers at:

your.mission\ExAdClient\XM8\Apps\DeployVehicle\bodyguard.sqf (line 7)

Here are the classnames: https://community.bistudio.com/wiki/Arma_3_CfgVehicles_GUER

Infistar Settings (thanks to @1Man):
Add "Craft Vehicle" to the allowedActions section:

allowedActions[] = {"Break free","Use AutoLockPicker","Craft Vehicle","Hack UAV"};

Future Updates:

Would love the ai to attack players not in your group. Not sure how to command the ai, I tried keybinding commands (like target) but it didn't work.
Let me know if you have ideas on how to do this.

Thanks to @Janski for making the cool EXAD XM8 Apps and @BetterDeadThanZed for the custom buildings to server addons script.

Enjoy!! aussie

 

OPTIONAL EXTRA:

Spawn the Ai from a mobile phone thanks to @1Man

If you want to allow owners to pick another option I have this if you want to add it.

config.cpp

Spoiler

Under class CfgInteractionMenus

    class Bodyguard
    {
        targetType = 2;
        target = "Land_SatellitePhone_F";
        class Actions
        {
            class Body_guard: ExileAbstractAction
            {
                title = "Deploy AI";
                condition = "('Exile_Item_MobilePhone' in (magazines player) && !ExilePlayerInSafezone)";
                action = "ExAdClient\XM8\Apps\DeployVehicle\bodyguard.sqf";
            };
        };
    };

Under class CfgXM8

    class ExAd_Unit
    {
        title = "AI Support";
        config = "ExAdClient\XM8\Apps\DeployVehicle\guard.sqf";
        logo = "ExAdClient\XM8\Apps\JX\icon_man.paa";
        bambiState = 0;
        vehicleClass = "Land_SatellitePhone_F";
        recipe[] = {{"Exile_Item_MobilePhone",1}};
        autoCleanUp = 1;
        quickFunction = "['ExAd_Unit'] call ExAd_XM8_DV_fnc_spawnVehicle";
        onLoad = "ExAdClient\XM8\Apps\DeployVehicle\guard.sqf";
    };

guard.sqf

Spoiler

ExAd_DV_DESPAWN_IDLE_TIME = 300;

ExAd_XM8_DV_fnc_itemsInCargo = {
    params ["_container","_itemArray","_item","_amount","_response"];

    _item = toLower (_itemArray select 0);
    _amount = _itemArray select 1;

    _response = false;
    {
        if(_item == toLower _x)then{
            _amount = _amount - 1;
        };
        if(_amount <= 0)exitWith{_response = true}
    }forEach magazines player;

    _response    
};

ExAd_XM8_DV_fnc_itemsMissing = {
    params["_recipe","_recipeStr"];
    
    _recipeStr = "";
    {
        private["_amount","_configName","_displayName","_text"];
        _amount = if(count _x > 1)then{_x select 1}else{1};
        _text = [_x select 0] call ExAd_XM8_DV_fnc_getDisplayName;
        _recipeStr = _recipeStr + format["%1x : %2<br />",(if(_amount < 0)then{((-1) * _amount)}else{_amount}), _text];
    }forEach _recipe;
    
    _response = format["You need <br />%1",_recipeStr];

    _response
};

ExAd_XM8_DV_fnc_getDisplayName = {
    params["_class","_configName","_displayName"];
    _configName = _class call ExileClient_util_gear_getConfigNameByClassName;
    _displayName = getText(configFile >> _configName >> _class >> "displayName");
    _text = if(count _displayName > 0)then{_displayName}else{_class};

    _text
};

ExAd_XM8_DV_fnc_canPack = {
    ( ExileClientInteractionObject getVariable["ExAd_DV_Packable", false] )
};

ExAd_XM8_DV_fnc_pack = {
    [ExileClientInteractionObject] spawn {
        params["_obj"];
    
        disableUserInput true;
        player playActionNow "Medic";

        uiSleep 3;
        ["despawnDeployableVehicle", [netId _obj]] call ExAd_fnc_serverDispatch;
        uiSleep 1;

        ["SuccessTitleAndText", ["Vehicle Packed"]] call ExileClient_gui_toaster_addTemplateToast;
        disableUserInput false;
    };
};

ExAd_XM8_DV_fnc_spawnVehicle = {
    params["_slideClass","_bambiState","_delopyRecipe","_vehicleClass"];

    try
    {    
        _bambiState = if(isNumber(missionConfigFile >> "CfgXM8" >> _slideClass >> "bambiState")) then
        {
            if(getNumber(missionConfigFile >> "CfgXM8" >> _slideClass >> "bambiState") > 0)then{true}else{false}
        } else {true};

        if(_bambiState && !ExileClientPlayerIsBambi) then { throw "You can only spawn vehicles as a bambi!"};

        _delopyRecipe = getArray(missionConfigFile >> "CfgXM8" >> _slideClass >> "recipe");
        if(count _delopyRecipe > 0) then
        {
            {
                if(count _x > 1) then
                {
                    _amount = if(_x select 1 == -1)then{1}else{_x select 1};
                    if!([player, [_x select 0, _amount]] call ExAd_XM8_DV_fnc_itemsInCargo) then
                    {
                        throw ([_delopyRecipe] call ExAd_XM8_DV_fnc_itemsMissing);
                    };
                } else {
                    if!([player, _x select 0] call ExileClient_util_playerEquipment_contains) then
                    {
                        throw ([_delopyRecipe] call ExAd_XM8_DV_fnc_itemsMissing);
                    }
                }
            }forEach _delopyRecipe;

            {
                _count = if(count _x > 1)then{(_x select 1)}else{1};
                for "_i" from 1 to _count do {
                    [player, _x select 0] call ExileClient_util_playerCargo_remove
                }
            }forEach _delopyRecipe;
        };

        _vehicleClass = getText(missionConfigFile >> "CfgXM8" >> _slideClass >> "vehicleClass");
        if!(isClass(configFile >> "CfgVehicles" >> _vehicleClass ))then { throw "The vehicle class doesn't exist"};

        [_slideClass] spawn {
            params["_slideClass"];
            disableUserInput true;
            player playActionNow "Medic";

            uiSleep 3;
            ["spawnDeployableVehicle", [netId player, _slideClass]] call ExAd_fnc_serverDispatch;
            uiSleep 1;
            ["SuccessTitleAndText", ["Request AI w/ scroll option"]] call ExileClient_gui_toaster_addTemplateToast;
            ExileClientXM8CurrentSlide = "extraApps";
            disableUserInput false;
        };    

        ["extraApps", 1] call ExileClient_gui_xm8_slide;
        closeDialog 0;


    }
    catch{
        [_exception] spawn {
            UISleep 0.5;
            ["ErrorTitleAndText", ["ExAd - Deploy Vehicle", _this select 0]] call ExileClient_gui_toaster_addTemplateToast;
            ["extraApps", 1] call ExileClient_gui_xm8_slide;
        };
    };
};

bodyguard.sqf

Spoiler

private ["_statue","unit","unitList"];
    if ("Exile_Item_MobilePhone" in (magazines player)) then
    {
    player removeItem "Exile_Item_MobilePhone";
    disableUserInput true;
    player playMove "AinvPknlMstpSnonWnonDr_medic3";
    unitList = ["B_soldier_AT_F","B_soldier_AA_F"];
    unit = group player createUnit [unitList select (round(random ((count unitList) - 2))), getPos player, [], 0, "FORM"];
    ["SuccessTitleAndText",["AI Deployed"]] call ExileClient_gui_toaster_addTemplateToast;
    _statue = nearestObject [player, "Land_SatellitePhone_F"];
    deleteVehicle _statue;
    disableUserInput false;
    };
    else
    {
    ["ErrorTitleAndText", ["You need a MobilePhone..."]] call ExileClient_gui_toaster_addTemplateToast;
    };
};

Changelog:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

6.09.17 Updated the Ai skill level which can be set in Exile.Mission/ExAdClient/XM8/Apps/DeployVehicle/bodyguard.sqf

Currently it is set to:

Spoiler

    _unit setskill ["aimingAccuracy",0.9];
    _unit setskill ["aimingShake",0.9];
    _unit setskill ["aimingSpeed",0.9];
    _unit setskill ["spotDistance",0.9];
    _unit setskill ["spotTime",0.9];
    _unit setskill ["courage",1.0];
    _unit setskill ["reloadSpeed",1.0];
    _unit setskill ["commanding",1.0];
    _unit setskill ["general",0.9];
    _unit setCombatMode "RED";
    _unit allowFleeing 0;

To learn more about Ai skill settings head to http://www.exilemod.com/topic/13096-guide-how-to-configure-the-ai-properly/
by Tobias Solem

Thanks to @TheDaddy for the idea.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

6.09.17 Updated instructions on commanding the Ai to move & stay.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

20170731154131_1.jpg

20170731153857_1.jpg

20170731154509_1.jpg

20170731154233_1.jpg

Edited by aussie battler
5 people like this

Share this post


Link to post
Share on other sites
Advertisement

i dont know why i cant test this on your server salty dog malden. i get kicked i dont know. 

Share this post


Link to post
Share on other sites

Posted (edited)

@Its me ZovkT SteamName: ✪Its me Zovk     Ping too high (318/ 280 ms)
 

Edited by aussie battler
1 person likes this

Share this post


Link to post
Share on other sites

ah shit :D  ^^ Germany its a little bit Long way hehe ;)  can  you whitelist me for the Test ? ^^ 

Share this post


Link to post
Share on other sites

@Its me ZovkT I have lifted the ping kick for you. Let me know when you are done so I can change it back. You spawn in with 100k in your locker.

Spawn a quad from your XM8, head to trader & buy x2 packets of beef parts. Head outside of the safezone & hit 6, more and hit the recruit ai button.

Probably worth heading towards a mission before you spawn one.

Good luck.

Share this post


Link to post
Share on other sites

Posted (edited)

@Its me ZovkT 

Head to Arudy after you pick up beef parts from the trader. I have left lots of spawn statues at the church for you.

20170801020835_1.jpg

20170801020607_1.jpg

20170801022014_1.jpg

Edited by aussie battler

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.