Jump to content

Recommended Posts

I wrote a simple script to automate the IDAP de-mining drone.

 

You can use it for cutscenes etc, or just sheer laziness.

 

You input the drone, a centre position to start, and a radius.

 

It will disarm bigger mines/satchels/uxos first so that they detonate the smaller ones (saves you some time).

 

It won't work on underwater mines or underwater mines that have been placed on the land (for good reason).

 

It only carries 4 de-mining bombs so it will automatically land where it started and rearm.  Once it is finished it lands and turns itself off.

 

I was going to put in a rearm from crate option, but the magazine classname it uses doesn't have a picture so it errors whenever you look in the crate.  In the end I cut that rubbish out and just had it land, pause for a few seconds to simulate rearming then taking off again.  

 

I couldn't get it to change altitude reliably (because Arma), so even though the flyInHeight is set to 10, it seems to hover at about 50 metres.  I think it's ok for what it is though.

 

Thanks to Evil Organ for gifting me the DLC, which was really nice of him  :thumbsup:

 

Feel free to improve on this and so on.  :)

 

Script:

fnc_demine = {
    params ["_drone","_origin","_radius"];
    private _startPos = ASLtoAGL getPosASL _drone;
    _drone setBehaviour "careless";
    _drone setSpeedMode "limited";
    _drone flyInHeight 10;
    _drone removeAllEventHandlers "fired";
    _drone addEventHandler ["fired",{
        (_this select 0) setVariable ["deminer",_this select 6];
    }];
    private _pad = _drone getVariable ["pad",objNull];
    if (not isNull _pad) then {
        deleteVehicle _pad
    };
    _pad = createVehicle ["Land_HelipadEmpty_F",_startPos,[],0,"can_collide"];
    _drone setVariable ["pad",_pad];
    private _noMags = false;
    private _mines = [];
    waitUntil {
        _mines = allMines select {_x distance2D _origin < _radius and {not (getTerrainHeightASL getPosWorld _x < 0)} and {toLower typeOf _x find "underwater" == -1}};
        if not (_mines isEqualTo []) then {
            _mines = _mines apply {
                [
                    getNumber (configFile >> "CfgAmmo" >> typeOf _x >> "hit"),
                    _x
                ]
            };
            _mines sort false;
            _mines = _mines apply {_x select 1};
            private _mine = _mines select 0;
            _drone doMove ((ASLtoAGL getPosASL _mine) vectorAdd [0,0,50]);
            waitUntil {
                sleep 5;
                (vectorMagnitude velocity _drone < 1 and {unitReady _drone}) or {fuel _drone isEqualTo 0} or {not (canMove _drone)} or {not alive _drone}
            };
            _drone fire "BombDemine_01_F";
            waitUntil {
                sleep 0.5;
                isNull (_drone getVariable ["deminer",objNull])
            };
            _mags = magazinesAmmoFull _drone;
            _noMags = if ([] isEqualTo _mags) then {true} else {if(_mags select 0 select 1 > 0) then {false} else {true}};
            sleep 3;
        };
        _mines isEqualTo [] or {_noMags} or {fuel _drone isEqualTo 0} or {not (canMove _drone)} or {not alive _drone}
    };
    call {
        if (_noMags) exitWith {
            _drone doMove ASLtoAGL getPosASL (_drone getVariable ["pad",objNull]);
            waitUntil {
                unitReady _drone or {fuel _drone isEqualTo 0} or {not (canMove _drone)} or {not alive _drone}
            };
            _drone land "land";
            waitUntil {
                sleep 0.5;
                isTouchingGround _drone
            };
            sleep 3;
            _drone removeMagazines "PylonRack_4Rnd_BombDemine_01_F";
            _drone addMagazine "PylonRack_4Rnd_BombDemine_01_F";
            if (alive _drone) then {
                [_drone,_origin,_radius] spawn fnc_demine
            }
        };
        if (_mines isEqualTo []) exitWith {
            _drone doMove _startPos;
            waitUntil {
                 unitReady _drone or {fuel _drone isEqualTo 0} or {not (canMove _drone)} or {not alive _drone}
            };
            _drone land "land";
            waitUntil {
                sleep 0.5;
                isTouchingGround _drone;
            };
            _drone engineOn false;
            _pad = _drone getVariable ["pad",objNull];
            if (not isNull _pad) then {
                deleteVehicle _pad
            };
        }
    }
};

 

 

 

Here's a test mission (I don't think you need to own the dlc to play it as you don't technically use the assets)

 

https://drive.google.com/open?id=0B1kzYgzONxC0RGN6cE9VMVlUZnM

 

0,0,0 to start demining!

  • Like 10

Share this post


Link to post
Share on other sites

Clever little script....

....clever little drone.

  • Like 7

Share this post


Link to post
Share on other sites

its nice hehe i put this in my Specialiste bag lol . But i try to modifie it to explode only one mine, the closest... you have a idea? you are bette than me for this :dummy: 

 

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

×