Jump to content

Andre Aerial Patrol - [Coconut Release] - Any Map


Donnovan

Recommended Posts

11 minutes ago, Donnovan said:

Be sure to disabel the _CUF function in infiStar, or most of your bots will not work properly. Can you check is _CUF is set to false?

Made the change and they are moving! Thank you very much Donnovan ...

I have one concern though - I do not have infistar on the live server could this be the reason they are not patrolling? Is there a way around this?  

Link to comment
Share on other sites

Bricktop.

Sometimes, the helis spawn too close to each other and immedietly collide and fall to the ground (sea) then the surviving heli(s) just hang around aimlessly at the spawn point, I assume because the way points don't get set properly if they crash immediatly after spawning.

Changing

		_motor = createVehicle [_heli select 0,_spawn,[],50,"FLY"];

To

		_motor = createVehicle [_heli select 0,_spawn,[],150,"FLY"];

gives them a  bigger area to spawn in and thus seem less prone to spawning too near each other. I also added a 5 minute sleep at the very top of the code just to make sure that all the mods on the server had stabilised before this script ran. It seemed to help.

My code at the moment

Spoiler

if (isServer) then {
    // Add 5min delay to alow DZAI etc to sort itself out otherwise 1st heli seems to be created without a pilot
    // so it immedietly crashes and then there are no waypoints set for the convoy so it just hovers above
    // the create point
    uiSleep (60*5);
    
    _gridN = 15;
    _mapSize = 15360; //CHERNARUS
    donn_hwps = [];

    for "_i" from 1 to (_gridN - 1) do {
        _wpx = (_i/_gridN)*_mapSize;

        for "_y" from 1 to (_gridN - 1) do {
            _wpy = (_y/_gridN)*_mapSize;
            if !(surfaceIsWater [_wpx,_wpy]) then {donn_hwps = donn_hwps + [[_wpx,_wpy,0]];};
        };

    };

    donn_heliConvy = [
        /*0*/["UH1H_DZ",0,["100Rnd_762x51_M240","100Rnd_762x51_M240"],3],
        /*1*/["UH1H_DZ",4,[],4],
        /*2*/["Mi17_TK_EP1",5,["100Rnd_762x51_M240","100Rnd_762x51_M240"],5],
        /*3*/["CH_47F_EP1_DZE",6,["100Rnd_762x51_M240","4000Rnd_762x51_M134","4000Rnd_762x51_M134"],6],
        /*4*/["AH6J_EP1_DZ",1,[],2] //ARMED (PILOT)
    ];

    //HELI MAIN CONFIG BEGIN
    _heliFormation =[[0,0,2],[2,2],[4,4,4,4,4],[3,3,3],[3],[1,1]];
    _heliAltitude =[[60,60,115],[100,100],[50,50,50,50,50],[100,90,110],[100],[115,115]];
    _heliSpeed =["NORMAL","NORMAL","FULL","LIMITED","NORMAL","FULL"];
    //HELI MAIN CONFIG END
    _spawn = [100,100,400];

    donn_heli_HD = {
        _heliHurt = _this select 0;
        _damage = _this select 2;

        if !(canMove _heliHurt) then {

            if (_heliHurt getVariable "dncmv") then {
                _heliHurt setVariable ["dncmv",false,false];
                {if (random 100 > 50) then {_x action ["Eject",_heliHurt];} else {_x setPos getPos _heliHurt;};} forEach crew _heliHurt;
            };

        };
    
        _damage
    };

    donn_heli_unit_HD = {
        _hurtedOne = _this select 0;
        _damage = _this select 2;
        _ofender = _this select 3;
        _grp = group _hurtedOne;
        
        if (combatMode _grp != "RED" && isPlayer _ofender) then {
            {_x enableAi "TARGET";} forEach units _grp;
            {_x enableAi "AUTOTARGET";} forEach units _grp;
            _grp reveal [_ofender,1.5];
            _grp setCombatMode "RED";_grp setBehaviour "COMBAT";
        };
        
        _damage
    };    
    
    donn_heli_unitKill = {
        _unit = _this select 0;
        _role = assignedVehicleRole _unit;
    
        if ((assignedVehicleRole _unit) select 0 == "Driver") then {
            _vehEject = assignedVehicle _unit;
            {if (random 100 > 40) then {_x action ["Eject",_vehEject];} else {_x setPos getPos _vehEject};} forEach crew _vehEject;
        };
        
        if ({alive _x} count units group _unit == 0) then {donn_heliGrps = donn_heliGrps - [group _unit];};
        _unit setVariable ["cashMoney",12500 + (round random 5) * 1000,true];
    };
    
    donn_makeAeroRoute = {
        _origin = _this select 0;
        _heli_group = _this select 1;
        _speed = _this select 2;
        _posBefore = _origin;
        _posNow = _origin;
        _wp = _heli_group addWaypoint [_posNow,0,0];
        _wp setWaypointCompletionRadius 65;
        _wp setWaypointType "MOVE";
        _wp setWaypointSpeed _speed;
        _posNext = [0,0,0];
    
        for "_c" from 1 to 5 do {
            _distToBefore = 0;
            _distToNext = 0;
            _found = false;
        
            for "_x" from 1 to 200 do {
                _posNext = donn_hwps call BIS_fnc_selectRandom;
                _distToNext = _posNow distance _posNext;
                _distToBefore = _posNext distance _posBefore;
                if (_distToNext > 3000 && _distToBefore > 4000) exitWith {};
                uiSleep 0.001;
            };
            
            if (!_found) then {_posNext = donn_hwps call BIS_fnc_selectRandom;};
            _wp = _heli_group addWaypoint [_posNext,0,_c];
            _wp setWaypointCompletionRadius 65;
            _wp setWaypointType "MOVE";
            _wp setWaypointSpeed _speed;
            _posNow = _posNext;
        };
        
        _wp = _heli_group addWaypoint [_origin,0,6];
        _wp setWaypointCompletionRadius 65;
        _wp setWaypointType "CYCLE";
        _wp setWaypointSpeed _speed;
    };
    
    donn_heliGrps = [];
    
    [] spawn {
    
        while {{!isNull _x} count donn_heliGrps > 0} do {
        
            {
                _grp = _x;
                _forceIn = true;
                {if (_grp knowsAbout _x >= 1.5) then {_grp reveal [_x,4];_forceIn = false;};} forEach playableUnits;
                
                if (_forceIn) then {
                
                    if (combatMode _grp != "BLUE") then {
                        {_x disableAi "TARGET";uiSleep 0.001;} forEach units _grp;
                        {_x disableAi "AUTOTARGET";uiSleep 0.001;} forEach units _grp;
                        _grp setCombatMode "BLUE";_grp setBehaviour "CARELESS";
                    };
                    
                    {if (vehicle _x == _x) then {[_x] orderGetIn true;uiSleep 0.001;};} forEach units _grp;
                };
            } forEach donn_heliGrps;    
            
            uiSleep 10;
        };
        
        diag_log "[COMBOIOS AEREOS] FIM.";
    };
    
    for "_cs" from 1 to (count _heliFormation) do {
        diag_log ("[HELI CONVOY] Initialized Spawn! " + str _cs);
        _heli_group = createGroup EAST;
        donn_heliGrps = donn_heliGrps + [_heli_group];
        _convoy = _heliFormation select (_cs-1);
        _convoyH = _heliAltitude select (_cs-1);
        _convoyS = _heliSpeed select (_cs-1);
        _qtd = count _convoy;
        _helis = [];
        {_helis = _helis + [donn_heliConvy select _x];} forEach _convoy;
        
        for "_n" from 1 to _qtd do {
            private ["_firstDriver"];
            _heli = _helis select (_n-1);
            _flyHeight = _convoyH select (_n-1);
            _motor = createVehicle [_heli select 0,_spawn,[],150,"FLY"];
            {deleteVehicle _x;} forEach crew _motor;
            _motor removeAllEventHandlers "handleDamage";
            _motor addEventHandler ["handleDamage",{_this call donn_heli_HD}];
            _motor setVariable ["dncmv",true,false];
            _motor setVariable ["dnishp",true,true];
            _motor setVariable ["dnishpq",_heli select 3,true];
            _motor setFuel 1;
            _motor setVehicleLock "LOCKED";
            _motor flyInHeight _flyHeight;
            _ammos = _heli select 2;
            {_ammo = _x;for "_a" from 1 to 8 do {_motor addMagazineTurret [_ammo,[_forEachIndex]];};} forEach _ammos;
            _driverCount = 1;
            _turreterCount = count _ammos;
            _cargorsCount = _heli select 1;
            _crewCount = _driverCount + _turreterCount + _cargorsCount;
            _gunnerPos = 0;
            
            for "_y" from 1 to _crewCount do {
                _unit = _heli_group createUnit ["TK_Special_Forces_EP1",[50,50,0],[],50,"PRIVATE"];
                
                /*
                // Being clever and spawning a different pilot to the crew seems to cause the heli to spawn without a pilot
                // Must work out why!!
                if (_y == 1) then {
                     _unit = _heli_group createUnit ["TK_Soldier_Pilot_EP1",[50,50,0],[],50,"PRIVATE"];
                };
                
                if (_y > 1) then {
                    _unit = _heli_group createUnit [["TK_Soldier_TWS_EP1",
                                 "TK_Special_Forces_EP1",
                                 "TK_Soldier_Officer_EP1",
                                 "TK_Soldier_Crew_EP1",
                                 "TK_Soldier_Sniper_EP1"] call BIS_fnc_selectRandom
                                 ,[50,50,0],[],50,"PRIVATE"];
                };
                */
                _unit removeAllEventHandlers "killed";
                _unit removeAllEventHandlers "handleDamage";
                _unit addEventHandler ["killed",{_this call donn_heli_unitKill;}];
                _unit addEventHandler ["handleDamage",{_this call donn_heli_unit_HD}];
                [_unit] joinSilent _heli_group;
                _unit setSkill 0.85;
                /*
                removeAllWeapons _unit;
                {_unit removeMagazine _x} forEach magazines _unit;
                _unit addWeapon "RPK_74";
                _unit selectWeapon "RPK_74";
                for "_pa" from 1 to 2 do {_unit addMagazine "75Rnd_545x39_RPK";};            
                */
                removeAllWeapons _unit;
                {_unit removeMagazine _x} forEach magazines _unit;
                _weapons = ["G36C","G36C_camo","G36A_camo","G36K_camo","M4A3_CCO_EP1","M16A4_ACG","M4SPR","M4A1_Aim"] call BIS_fnc_selectRandom;
                _unit addWeapon _weapons;
                _unit selectWeapon _weapons;
                for "_pa" from 1 to 3 do {_unit addMagazine "30Rnd_556x45_Stanag";};            
                                
                if (_y == 1) then {
                    _unit assignAsDriver _motor;
                    _unit moveInDriver _motor;
                    _unit setSkill ["aimingAccuracy",0.65];
                };
                
                if (_y > 1 && _y <= 1 + _turreterCount) then {
                    _unit assignAsGunner _motor;
                    _unit moveInTurret [_motor,[_gunnerPos]];
                    _gunnerPos = _gunnerPos + 1;
                    _unit setSkill ["aimingAccuracy",1];
                };
                
                if (_y > 1 + _turreterCount) then {
                    _unit assignAsCargo _motor;
                    _unit moveInCargo _motor;
                    _unit setSkill ["aimingAccuracy",0.65];
                };
                
            };
            
            {_x disableAi "TARGET";uiSleep 0.001;} forEach units _heli_group;
            {_x disableAi "AUTOTARGET";uiSleep 0.001;} forEach units _heli_group;
            _heli_group setCombatMode "BLUE";_heli_group setBehaviour "CARELESS";
            // _sphere = createVehicle ["Sign_sphere100cm_EP1",[0,0,0],[],0,"CAN_COLLIDE"];
            // _sphere attachTo [_motor,[0,0,3]];
        };
        
        [donn_hwps call BIS_fnc_selectRandom,_heli_group,_convoyS] call donn_makeAeroRoute;
        uiSleep (60*20);
        
    };
    
};

 

 

Link to comment
Share on other sites

I think I have identified the problem with asigning different skins to the pilot, it seems that because the heli's are spawned in the air, timing is critical and it's taking too long for the pilot to be loaded before the heli crashes, I've watched it happen... Heli spawns ... heli crashes ... pilot & crew spawns next to the crashed heli and marches off into the sunset.

If the OP doesn't mind I'll look to optimise the code for speed.

 

Link to comment
Share on other sites

Here's my modified version of the serverside code i'm running on my servers.

I've changed it to create ALL the crew members before deleteing the default crew and then adding our crew.

I also create the pilot with a "TK_soldier_pilot_EP1" skin then randomise the selection of the rest of the crew, I chose a selection from the TK forces as these skins are not available to players on my servers but you can change them to whatever you want. I've also added Tang0's random weapon code

I also added comments to the code as I understand it.

 

Spoiler

// *********************************
// Airpatrol.sqf
// Author: Donnavan
// Creates Airbourne convoys
// Modifications
// Random Weapon selection by Tang0
// Random crew skins by Albertus Smythe
// *********************************

if (isServer) then {
    // Add 5min delay to alow DZAI etc to sort itself out otherwise 1st heli seems to be created without a pilot
    // so it immedietly crashes and then there are no waypoints set for the convoy so it just hovers above
    // the create point
    uiSleep (60*5);

    _gridN = 15;
    _mapSize = 15360; //CHERNARUS
    donn_hwps = [];

    for "_i" from 1 to (_gridN - 1) do {
        _wpx = (_i/_gridN)*_mapSize;

        for "_y" from 1 to (_gridN - 1) do {
            _wpy = (_y/_gridN)*_mapSize;
            if !(surfaceIsWater [_wpx,_wpy]) then {donn_hwps = donn_hwps + [[_wpx,_wpy,0]];};
        };

    };

    // define a list of heli's to make up convoys from.
    // [ Vehicle_name,Passenger count,[ammo for each gunpoint],number of Loot points]
    // Passenger count is in addition to the pilot and gunners on the heli's gun points.
    // Empty ammo array means the Heli is unarmed and won't shoot but will land and disembark crew.
    donn_heliConvy = [
        /*0*/["UH1H_DZ",0,["100Rnd_762x51_M240","100Rnd_762x51_M240"],3],
        /*1*/["UH1H_DZ",4,[],4],
        /*2*/["Mi17_TK_EP1",5,["100Rnd_762x51_M240","100Rnd_762x51_M240"],5],
        /*3*/["CH_47F_EP1_DZE",6,["100Rnd_762x51_M240","4000Rnd_762x51_M134","4000Rnd_762x51_M134"],6],
        /*4*/["AH6J_EP1_DZ",1,[],2] //ARMED (PILOT)
    ];

    //HELI MAIN CONFIG BEGIN
    _heliFormation =[[ 0, 0,  2],[  2,  2],[ 4, 4, 4, 4, 4],[  3, 3,  3], [  3]  ,[  1,  1]]; // Define the helis in each of the convoys
    _heliAltitude  =[[60,60,115],[100,100],[50,50,50,50,50],[100,90,110], [100]  ,[115,115]]; // define the aproximate height they fly at. 
    _heliSpeed     =[ "NORMAL"  , "NORMAL",     "FULL"     , "LIMITED"  ,"NORMAL", "FULL"  ]; // define the convoy speed 
    //HELI MAIN CONFIG END
    _spawn = [100,100,400]; // Initial spawn location

    donn_heli_HD = {
        _heliHurt = _this select 0;
        _damage   = _this select 2;

        if !(canMove _heliHurt) then {

            if (_heliHurt getVariable "dncmv") then {
                _heliHurt setVariable ["dncmv",false,false];
                {if (random 100 > 50) then {_x action ["Eject",_heliHurt];} else {_x setPos getPos _heliHurt;};} forEach crew _heliHurt;
            };

        };

        _damage
    };

    donn_heli_unit_HD = {
        // Put group into combat RED mode if heli damaged by player
        _hurtedOne = _this select 0;
        _damage    = _this select 2;
        _ofender   = _this select 3;
        _grp       = group _hurtedOne;

        if (combatMode _grp != "RED" && isPlayer _ofender) then {
            {_x enableAi "TARGET";} forEach units _grp;
            {_x enableAi "AUTOTARGET";} forEach units _grp;
            _grp reveal [_ofender,1.5];
            _grp setCombatMode "RED";_grp setBehaviour "COMBAT";
        };

        _damage
    };

    donn_heli_unitKill = {
        _unit = _this select 0;
        _role = assignedVehicleRole _unit;

        if ((assignedVehicleRole _unit) select 0 == "Driver") then {
            // If driver is killed eject the crew.
            _vehEject = assignedVehicle _unit;
            {if (random 100 > 40) then {_x action ["Eject",_vehEject];} else {_x setPos getPos _vehEject};} forEach crew _vehEject;
        };

        if ({alive _x} count units group _unit == 0) then {donn_heliGrps = donn_heliGrps - [group _unit];};
        _unit setVariable ["cashMoney",12500 + (round random 5) * 1000,true];
    };

    donn_makeAeroRoute = {
        // Set route for convoy
        _origin     = _this select 0;
        _heli_group = _this select 1;
        _speed      = _this select 2;
        _posBefore  = _origin;
        _posNow     = _origin;
        _wp         = _heli_group addWaypoint [_posNow,0,0];
        _wp setWaypointCompletionRadius 65;
        _wp setWaypointType "MOVE";
        _wp setWaypointSpeed _speed;
        _posNext = [0,0,0];

        for "_c" from 1 to 5 do {
            _distToBefore = 0;
            _distToNext   = 0;
            _found        = false;

            for "_x" from 1 to 200 do {
                _posNext        = donn_hwps call BIS_fnc_selectRandom;
                _distToNext     = _posNow distance _posNext;
                _distToBefore   = _posNext distance _posBefore;
                if (_distToNext > 3000 && _distToBefore > 4000) exitWith {};
                uiSleep 0.001;
            };

            if (!_found) then {_posNext = donn_hwps call BIS_fnc_selectRandom;};
            _wp = _heli_group addWaypoint [_posNext,0,_c];
            _wp setWaypointCompletionRadius 65;
            _wp setWaypointType "MOVE";
            _wp setWaypointSpeed _speed;
            _posNow = _posNext;
        };

        _wp = _heli_group addWaypoint [_origin,0,6];
        _wp setWaypointCompletionRadius 65;
        _wp setWaypointType "CYCLE";
        _wp setWaypointSpeed _speed;
    };

    donn_heliGrps = [];

    [] spawn {

        while {{!isNull _x} count donn_heliGrps > 0} do {

            {
                _grp     = _x;
                _forceIn = true;
                {if (_grp knowsAbout _x >= 1.5) then {_grp reveal [_x,4];_forceIn = false;};} forEach playableUnits;

                if (_forceIn) then {

                    if (combatMode _grp != "BLUE") then {
                        {_x disableAi "TARGET";uiSleep 0.001;} forEach units _grp;
                        {_x disableAi "AUTOTARGET";uiSleep 0.001;} forEach units _grp;
                        _grp setCombatMode "BLUE";_grp setBehaviour "CARELESS";
                    };

                    {if (vehicle _x == _x) then {[_x] orderGetIn true;uiSleep 0.001;};} forEach units _grp;
                };
            } forEach donn_heliGrps;

            uiSleep 10;
        };

        diag_log "[COMBOIOS AEREOS] FIM.";
    };

    for "_cs" from 1 to (count _heliFormation) do {
        diag_log ("[HELI CONVOY] Initialized Spawn! " + str _cs);
        _heli_group     = createGroup EAST;
        donn_heliGrps   = donn_heliGrps + [_heli_group];
        _convoy         = _heliFormation select (_cs-1);
        _convoyH        = _heliAltitude  select (_cs-1);
        _convoyS        = _heliSpeed     select (_cs-1);
        _qtd            = count _convoy;
        _helis = [];

        {_helis = _helis + [donn_heliConvy select _x];} forEach _convoy;

        for "_n" from 1 to _qtd do {
            _heli       = _helis    select (_n-1);
            _flyHeight  = _convoyH  select (_n-1);
            _motor      = createVehicle [_heli select 0,_spawn,[],150,"FLY"];
            _crew       =[];

            _motor removeAllEventHandlers "handleDamage";
            _motor addEventHandler ["handleDamage",{_this call donn_heli_HD}];
            _motor setVariable ["dncmv",true,false];
            _motor setVariable ["dnishp",true,true];
            _motor setVariable ["dnishpq",_heli select 3,true];
            _motor setFuel 1;
            _motor setVehicleLock "LOCKED";
            _motor flyInHeight _flyHeight;

            _ammos = _heli select 2;
            {_ammo = _x;for "_a" from 1 to 8 do {_motor addMagazineTurret [_ammo,[_forEachIndex]];};} forEach _ammos;
            _driverCount    = 1;
            _turreterCount  = count _ammos;
            _cargorsCount   = _heli select 1;
            _crewCount      = _driverCount + _turreterCount + _cargorsCount;
            _gunnerPos      = 0;

            // Originally the default crew were deleted then our crew were created, modified and added him to the helicopter one at a time.
            // This led to there, occasionally being enough of a delay between deleting the pilot and inserting the new one for the helicopter
            // to fall to the ground and crash then all the crew were spawned on the ground as they couldn't get into a crashed vehicle.
            // Now we're creating all our crew into an array before deleting the default crew then adding our crew from the array, this should 
            // minimise the time the helicopter is without crew, although the overall time may be slightly longer as we're looping through the crew twice.
            for "_y" from 1 to _crewCount do {
                // Finally figured it out !!, you have to declare _unit as private here. otherwise it is created inside the If{} statement
                // as private to the if{} structure and therefore not visible outside of it, so although the crew member is created 
                // the line '_unit removeAllEventHandlers "killed";' creates a new variable called _unit because it effectively doesn't
                // know about the original _unit variable. Everything errors from then on becouse the visible _unit it isn't the crewman object.
                private "_unit";

                //_unit = _heli_group createUnit ["TK_Special_Forces_EP1",[50,50,0],[],50,"PRIVATE"];
                
                if (_y == 1) then {
                    //Skin for pilot
                    _unit = _heli_group createUnit ["TK_Soldier_Pilot_EP1",[50,50,0],[],50,"PRIVATE"];


                };

                if (_y > 1) then {
                    // Selection of skins for other crew.
                    _unitskin = ["TK_Soldier_TWS_EP1",
                                 "TK_Special_Forces_EP1",
                                 "TK_Soldier_Officer_EP1",
                                 "TK_Soldier_Crew_EP1",
                                 "TK_Soldier_Sniper_EP1"] call BIS_fnc_selectRandom;
                                                     
                    _unit = _heli_group createUnit [_unitskin,[50,50,0],[],50,"PRIVATE"];
                };
                
                _unit removeAllEventHandlers "killed";
                _unit removeAllEventHandlers "handleDamage";
                _unit addEventHandler ["killed",{_this call donn_heli_unitKill;}];
                _unit addEventHandler ["handleDamage",{_this call donn_heli_unit_HD}];
                [_unit] joinSilent _heli_group;
                _unit setSkill 0.85;

                /*
                removeAllWeapons _unit;
                {_unit removeMagazine _x} forEach magazines _unit;
                _unit addWeapon "RPK_74";
                _unit selectWeapon "RPK_74";
                for "_pa" from 1 to 2 do {_unit addMagazine "75Rnd_545x39_RPK";};
                */
                // remove default weapon from crew man and add a random STANAG weapon & magazines.
                removeAllWeapons _unit;
                {_unit removeMagazine _x} forEach magazines _unit;
                _weapons = ["G36C","G36C_camo","G36A_camo","G36K_camo","M4A3_CCO_EP1","M16A4_ACG","M4SPR","M4A1_Aim"] call BIS_fnc_selectRandom;
                _unit addWeapon _weapons;
                _unit selectWeapon _weapons;

                for "_pa" from 1 to 3 do {_unit addMagazine "30Rnd_556x45_Stanag";};
                
                _crew set [_y-1,_unit];
            };
                
            {deleteVehicle _x;} forEach crew _motor;  // moved in order to delete any default crew immediatly before adding the new crew.

            for "_y" from 1 to _crewCount do {
                _unit = _crew select (_y-1);
            
                if (_y == 1) then {
                    //First crewman is pilot
                    _unit assignAsDriver _motor;
                    _unit moveInDriver _motor;
                    _unit setSkill ["aimingAccuracy",0.65];
                };

                if (_y > 1 && _y <= 1 + _turreterCount) then {
                    // Assign a crewman to each turret.
                    _unit assignAsGunner _motor;
                    _unit moveInTurret [_motor,[_gunnerPos]];
                    _gunnerPos = _gunnerPos + 1;
                    _unit setSkill ["aimingAccuracy",1];
                };

                if (_y > 1 + _turreterCount) then {
                    //Assign the rest of the crew as passengers
                    _unit assignAsCargo _motor;
                    _unit moveInCargo _motor;
                    _unit setSkill ["aimingAccuracy",0.65];
                };

            };

            {_x disableAi "TARGET";uiSleep 0.001;} forEach units _heli_group;
            {_x disableAi "AUTOTARGET";uiSleep 0.001;} forEach units _heli_group;
            _heli_group setCombatMode "BLUE";_heli_group setBehaviour "CARELESS";
            // Uncomment next two lines if you want a red shere attached to your convoy's helicopters
            // _sphere = createVehicle ["Sign_sphere100cm_EP1",[0,0,0],[],0,"CAN_COLLIDE"];
            // _sphere attachTo [_motor,[0,0,3]];
        };

        [donn_hwps call BIS_fnc_selectRandom,_heli_group,_convoyS] call donn_makeAeroRoute;

        uiSleep (60*20);

    };

};

 

 

Link to comment
Share on other sites

21 hours ago, Jyggs said:

Is there a way to add a Humanity count to the crew inside the helicopters?  I've noticed that killing them do not add humanity nor they count towards bandits/murder kills.

This is not tested because i dont have this script, but this "should" work

look for this line

if ({alive _x} count units group _unit == 0) then {donn_heliGrps = donn_heliGrps - [group _unit];};
        _unit setVariable ["cashMoney",12500 + (round random 5) * 1000,true];

add this bellow

if ({alive _x} count units group _unit == 0) then {donn_heliGrps = donn_heliGrps - [group _unit];};
        _unit setVariable ["humanity",50,true];

50 is the amount of humanity.

Looking at it, the script should "get" your humanity first before adding any value.  I would suggest testing it first before putting it on a live server.

let me know if it works or not

Link to comment
Share on other sites

8 hours ago, theduke said:

This is not tested because i dont have this script, but this "should" work

look for this line


if ({alive _x} count units group _unit == 0) then {donn_heliGrps = donn_heliGrps - [group _unit];};
        _unit setVariable ["cashMoney",12500 + (round random 5) * 1000,true];

add this bellow


if ({alive _x} count units group _unit == 0) then {donn_heliGrps = donn_heliGrps - [group _unit];};
        _unit setVariable ["humanity",50,true];

50 is the amount of humanity.

Looking at it, the script should "get" your humanity first before adding any value.  I would suggest testing it first before putting it on a live server.

let me know if it works or not

No it's not working properly. I'm guessing because that line is used for the cashMoney reward, and the only way to get the coin reward is to actually loot the body (in my case "Check Wallet"). So maybe it's not working because it expects you to loot the body for "humanity"? I'm not sure myself, just making a guess why is not working.

I was looking to a similar line on another script  (WAI 2.2.0) as a reference, but I cannot understand well how it works because it calls variables from another SQF file and it confuses me. 

Link to comment
Share on other sites

46 minutes ago, Jyggs said:

No it's not working properly. I'm guessing because that line is used for the cashMoney reward, and the only way to get the coin reward is to actually loot the body (in my case "Check Wallet"). So maybe it's not working because it expects you to loot the body for "humanity"? I'm not sure myself, just making a guess why is not working.

I was looking to a similar line on another script  (WAI 2.2.0) as a reference, but I cannot understand well how it works because it calls variables from another SQF file and it confuses me. 

this might help you achieve what you are looking for...Essentially all i did was copy the way the humanity was being called and changed the variable to cashmoney

 

Link to comment
Share on other sites

13 minutes ago, theduke said:

this might help you achieve what you are looking for...Essentially all i did was copy the way the humanity was being called and changed the variable to cashmoney

 

OK I got it working. Yeah I was using that exact line as my reference when I was trying to figure it out earlier. I got it working after a few trials and errors.

Find this line:

donn_heli_unitKill = {
        _unit = _this select 0;

Add this below the _unit line:

		_player = _this select 1;
		_humanity = _player getVariable["humanity",0];  //Reads the player's current humanity count
		_gain = _unit getVariable ["humanity",50];  //Sets Humanity reward value. 50 humanity per AI kill.

 

Then Find this line...:

if ({alive _x} count units group _unit == 0) then {donn_heliGrps = donn_heliGrps - [group _unit];};
_unit setVariable ["cashMoney",50 + (round random 5) * 500,true];

 

Now add this line right below:   (Note: make sure it's before the closing bracket for the donn_heli_unitKill = {  )

//Humanity Reward
if ({alive _x} count units group _unit == 0) then {donn_heliGrps = donn_heliGrps - [group _unit];};
_player setVariable ["humanity",(_humanity + _gain),true];  //Player's Current Humanity + Humanity Reward per kill

 

TheDuke, thanks a lot for your help.  Hope this helps anyone else that wants to add humanity rewards on kills.

Link to comment
Share on other sites

I am currently trying to change the heli's used in this for more ...... dangerous ..... ones but everytime I change a heli classname, a few spawn as they should but then I get a "Unit not in cargo" error and the whole thing stops working.

Basically, I want heli's that have missiles and 4000 round M134 guns because players are treating the current array like instant money, as they are too easy to shoot down. Also, once a heli runs out of fuel or is damaged so that it has to land, the AI pile out of it, form a nice line and head for the nearest road whereby they proceed to take a nice Sunday stroll until someone drives over them. 

     donn_heliConvy = [
        /*0*/["UH1H_DZ",0,["100Rnd_762x51_M240","100Rnd_762x51_M240"],3],
        /*1*/["UH1H_DZ",4,[],4],
        /*2*/["Mi17_TK_EP1",5,["100Rnd_762x51_M240","100Rnd_762x51_M240"],5],
        /*3*/["CH_47F_EP1_DZE",6,["100Rnd_762x51_M240","4000Rnd_762x51_M134","4000Rnd_762x51_M134"],6],
        /*4*/["AH6J_EP1_DZ",1,[],2] //ARMED (PILOT)
    ];

What can I successfully change those to, to make it a bit more of a challenge for players and how can I make it so that once AI voluntarily get out of a downed heli, they go nuts and run around shooting players?

I have also managed to make it so that AI from these heli's when shot give humanity to players and a random amount of gold coins. If anyone needs that bit of code, here it is : 

   donn_heli_unitKill = {
        _unit = _this select 0;
		_player = _this select 1;
		_humanity = _player getVariable["humanity",0];  					//Reads the player's current humanity count.
		_gain = _unit getVariable ["humanity",20];  						//Sets humanity reward value. 20 humanity per AI kill.
		_cash = _player getVariable ["cashMoney",0]; 						//Reads coin value currently held by player.
		_reward = _unit getVariable ["cashMoney", round(random 20) * 500];	//Gives random amount of coins per AI kill.
        _role = assignedVehicleRole _unit;

        if ((assignedVehicleRole _unit) select 0 == "Driver") then {
            // If driver is killed eject the crew.
            _vehEject = assignedVehicle _unit;
            {if (random 100 > 40) then {_x action ["Eject",_vehEject];} else {_x setPos getPos _vehEject};} forEach crew _vehEject;
        };

        if ({alive _x} count units group _unit == 0) then {donn_heliGrps = donn_heliGrps - [group _unit];};
        _player setVariable ["humanity",(_humanity + _gain),true];  //Players current humanity + humanity reward per kill.

        if ({alive _x} count units group _unit == 0) then {donn_heliGrps = donn_heliGrps - [group _unit];};
        _player setVariable ["cashMoney",(_cash + _reward),true];	//Player's current coins + coin reward per kill.
    };

 

 

 

Link to comment
Share on other sites

this is what i use in mine for a bit more power

    donn_heliConvy = [
        /*0*/["UH1H_DZ",0,["100Rnd_762x51_M240","100Rnd_762x51_M240"],3],
        /*1*/["UH1H_DZ",4,[],4],
        /*2*/["Mi17_UN_CDF_EP1",5,["100Rnd_762x54_PK","100Rnd_762x54_PK"],5],
        /*3*/["CH_47F_EP1_DZE",6,["100Rnd_762x51_M240","4000Rnd_762x51_M134","4000Rnd_762x51_M134"],6],
        /*4*/["AH6J_EP1_DZ",1,[],2],        //ARMED (PILOT)
        /*5*/["UH60M_EP1_DZE",0,["2000Rnd_762x51_M134","2000Rnd_762x51_M134"],3],
        /*6*/["UH1Y_DZE",0,["2000Rnd_762x51_M134","2000Rnd_762x51_M134"],3],
        /*7*/["UH1H_TK_EP1",0,["100Rnd_762x51_M240","100Rnd_762x51_M240"],3],
        /*8*/["BAF_Merlin_DZE",4,[],4],
        /*9*/["Mi24_V",4,[],4],        //ARMED (PILOT)    
        /*10*/["pook_H13_amphib_CIV",1,[],1],
        /*11*/["pook_H13_transport_UNO",2,["100Rnd_762x51_M240"],2],
        /*12*/["AH64D",1,[],1],        //ARMED (PILOT)        
        /*13*/["Mi17_rockets_RU",5,["100Rnd_762x54_PK","100Rnd_762x54_PK","100Rnd_762x54_PK"],5]        
    ];

Link to comment
Share on other sites

On 2/21/2016 at 7:43 AM, ElDubya said:

I am currently trying to change the heli's used in this for more ...... dangerous ..... ones but everytime I change a heli classname, a few spawn as they should but then I get a "Unit not in cargo" error and the whole thing stops working.

Basically, I want heli's that have missiles and 4000 round M134 guns because players are treating the current array like instant money, as they are too easy to shoot down. Also, once a heli runs out of fuel or is damaged so that it has to land, the AI pile out of it, form a nice line and head for the nearest road whereby they proceed to take a nice Sunday stroll until someone drives over them. 

     donn_heliConvy = [
        /*0*/["UH1H_DZ",0,["100Rnd_762x51_M240","100Rnd_762x51_M240"],3],
        /*1*/["UH1H_DZ",4,[],4],
        /*2*/["Mi17_TK_EP1",5,["100Rnd_762x51_M240","100Rnd_762x51_M240"],5],
        /*3*/["CH_47F_EP1_DZE",6,["100Rnd_762x51_M240","4000Rnd_762x51_M134","4000Rnd_762x51_M134"],6],
        /*4*/["AH6J_EP1_DZ",1,[],2] //ARMED (PILOT)
    ];

What can I successfully change those to, to make it a bit more of a challenge for players and how can I make it so that once AI voluntarily get out of a downed heli, they go nuts and run around shooting players?

I have also managed to make it so that AI from these heli's when shot give humanity to players and a random amount of gold coins. If anyone needs that bit of code, here it is : 


   donn_heli_unitKill = {
        _unit = _this select 0;
		_player = _this select 1;
		_humanity = _player getVariable["humanity",0];  					//Reads the player's current humanity count.
		_gain = _unit getVariable ["humanity",20];  						//Sets humanity reward value. 20 humanity per AI kill.
		_cash = _player getVariable ["cashMoney",0]; 						//Reads coin value currently held by player.
		_reward = _unit getVariable ["cashMoney", round(random 20) * 500];	//Gives random amount of coins per AI kill.
        _role = assignedVehicleRole _unit;

        if ((assignedVehicleRole _unit) select 0 == "Driver") then {
            // If driver is killed eject the crew.
            _vehEject = assignedVehicle _unit;
            {if (random 100 > 40) then {_x action ["Eject",_vehEject];} else {_x setPos getPos _vehEject};} forEach crew _vehEject;
        };

        if ({alive _x} count units group _unit == 0) then {donn_heliGrps = donn_heliGrps - [group _unit];};
        _player setVariable ["humanity",(_humanity + _gain),true];  //Players current humanity + humanity reward per kill.

        if ({alive _x} count units group _unit == 0) then {donn_heliGrps = donn_heliGrps - [group _unit];};
        _player setVariable ["cashMoney",(_cash + _reward),true];	//Player's current coins + coin reward per kill.
    };

 

 

 

Did you add Tango's  donn_heliConvy (added helis) and if so did it work for you?

Link to comment
Share on other sites

Here is some information that I use for different maps, if anyone wants to use it.

if (isServer) then {
    _gridN = 20; // Default Was 15
    //_mapSize = 15360; //CHERNARUS
    //_mapSize = 12750; //Namalsk
    _mapSize = 10240; //Fallujah, Takistan, FATA and  Panthera2

Link to comment
Share on other sites

  • 1 month later...

Hey,

 

Our server runs this script and it's pretty decent, finding dead choppers down the bottom left side of the map with AI swimming in the water, any ideas what would cause this?

 

When I watch and see the choppers spawning in, it looks like the crew is created but the chopper just plummets to the ocean. Also I see a lot of the time the choppers are just idling somewhere randomly and not doing much.

 

 

20160423203716_1.jpg

Link to comment
Share on other sites

On 23/04/2016 at 9:40 AM, salival said:

Hey,

 

Our server runs this script and it's pretty decent, finding dead choppers down the bottom left side of the map with AI swimming in the water, any ideas what would cause this?

 

When I watch and see the choppers spawning in, it looks like the crew is created but the chopper just plummets to the ocean. Also I see a lot of the time the choppers are just idling somewhere randomly and not doing much.

 

 

20160423203716_1.jpg

 

As far as I could tell this is due to a timing issue where the default crew (particularly the pilot) are deleted and the delay before adding the new pilot means the heli is pilotless too long and crashes, there is also a possibility that the helis spawn so close to each other they crash into one another.

Both of these I addressed in my modified code see post #9 on page 4 it's not bog standard but I've commented it and the changes I made. It's been running on all my servers since the start of February without issue.

 

 

 

 

Link to comment
Share on other sites

17 hours ago, Albertus Smythe said:

 

As far as I could tell this is due to a timing issue where the default crew (particularly the pilot) are deleted and the delay before adding the new pilot means the heli is pilotless too long and crashes, there is also a possibility that the helis spawn so close to each other they crash into one another.

Both of these I addressed in my modified code see post #9 on page 4 it's not bog standard but I've commented it and the changes I made. It's been running on all my servers since the start of February without issue.

 

 

 

 

Hey,

 

We are running your code at present (have been for a bit) and we have been fiddling with the code to get it working better which it is.

It's no longer dumping AI into the ocean in such great amounts, maybe once or twice per restart, I'll keep an eye on it and see what it does

Cheers for the reply

Link to comment
Share on other sites

Try the following to randomise things up a bit.

After   

 _heliSpeed     =[ "NORMAL","NORMAL","FULL","LIMITED","NORMAL","FULL", "NORMAL","NORMAL","NORMAL","LIMITED","FULL","NORMAL" ]; // define the convoy speed

note: I've added extra convoys

add   

_heliGroupTot  = count _heliFormation;

Then scoot down and comment out this line

for "_cs" from 1 to (count _heliFormation) do {

and replace it with this  

 while {1 == 1}  do {
        _cs = floor( random _heliGroupTot);
        _cs = _cs+1;

A convoy will be randomly selected from your _heliFormation array each time a new convoy is created.

Next project is to limit the number of convoys in the air at the same time.

Link to comment
Share on other sites

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
×
×
  • Create New...