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 11

Share this post


Link to post
Share on other sites

Clever little script....

....clever little drone.

  • Like 8

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

Hi das attorney! I've tried to download the test mission, but didn't succeed... Is the mission still accessible? Could you please provide me with a link?

 

I'm new to scripting and am still struggling with the basics -that's why I don't know how to run the script in my scenario. So I thought to have a look at the test scenario to find out...

Share this post


Link to post
Share on other sites

Hey EO, that was fast! Thanx for the link - the download worked! So, now let's see, if I can make this script work for me 🙂

  • Like 1

Share this post


Link to post
Share on other sites

Finally I've got this script to work in my scenario. But strangely, the drone lands after firing 4 de-mining charges, but it won't reload and start again to eliminate the rest of the mines. I think, this is also true in the original scenario, provided by Das. So, I'm not sure - am I missing something...?

Share this post


Link to post
Share on other sites

There is a bug with   uav land "land".  I didn't test with all UAVs but the demine one is broken after this command for final landing.

Share this post


Link to post
Share on other sites

Thanx pierrengi for your reply - that's a pity, but in the same time I^m glad to hear it's not because of me...;-)

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

×