Author: wolffy.au
Author Website:

Requirements: No addons required

Version: 20090414

Short description:

Date: 2009-04-20 18:54


Comments: (0)
Rating:



 

AI Transport
by
wolffy.au


Description:
Basically, you have an AI driver of any land vehicle or helicopter - and you can give the guy directions.

Example:
You need a lift to the front line, everyone jumps in the HumV and you 'Give Directions' to the driver of where to go. Once you get there, jump out and send him back to base for the next guy.


Usage:
Add the following to your AI vehicle's INIT line -
this addAction ["Give Directions", "GiveDirections.sqf"];

Add the following to you Init.sqf file:
_script = [] execVM "GiveDirections.sqf";
waitUntil {scriptDone _script;};

Here's the contents of the GiveDirections.sqf:
//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: (AEF)Wolffy.au [2CAV]
// Created: 20090326
// Version: 20090326 - Initial release
// Version: 20090410 - Added helicopter support
// Version: 20090414 - Fixed AI flying into trees on take off and
// hover on landing (helps on slopes)
// Contact: http://www.aef-hq.com.au
// Purpose: Give directions to any AI transport inc helis
///////////////////////////////////////////////////////////////////
if (isServer) then {
    PV_AID = [];
    PublicVariable "PV_AID";
    [] spawn {
        while {true} do {
            waitUntil {(count PV_AID) != 0};
            _driver = PV_AID select 0;
            _pos = PV_AID select 1;
            if (vehicle _driver iskindof "Helicopter") then {
                _driver move (position _driver);
                _driver flyInHeight 50;
                waitUntil {(getPos _driver select 2) + (_driver distance (getPos _driver)) > 40};
            };
            _driver move _pos;
            // Originally from Myke's cep_move.sqf
            if (vehicle _driver iskindof "Helicopter") then {
                _driver flyInHeight 50;
                _land = "HeliHEmpty" createVehicle _pos;
                waitUntil {(_driver distance _land) < 150};
                _driver land "GET OUT";
                waitUntil {(getPos _driver select 2) + (_driver distance (getPos _driver)) < 5};
                 _driver flyInHeight 3;
                deletevehicle _land;
            };
            PV_AID = [];
            PublicVariable "PV_AID";
        };
    };
};

if (count _this > 0) then {
    _driver = _this select 0;
    _id = floor random 10000;
    //hint format["%1", _id];
    call compile format["click%1 = [];", _id];
    titleText ["Click on your map where you would like the driver to move to.", "PLAIN DOWN", 1];
    onMapSingleClick format["click%1 = _pos; onMapSingleClick """"", _id];
    waitUntil {call compile format["(count click%1) > 0", _id]};
    waitUntil {(count PV_AID) == 0};
    call compile format["PV_AID = [_driver, click%1]", _id];
    _driver sideChat "Moving out";
    PublicVariable "PV_AID";
};


Note:
Tested successfully in MP with both LB and BH.


Changelog:
Updated
- Found that AI would take off straight into trees, now they climb vertically 50m first and then move out.
- Helis will hover at around 3m which helps on steep sloping LZ's

v20090326
- Initial release

v20090410
- Added helicopter support


Credits & thanks:
Some code from Myke's CEP (thanks Myke).


Forum topic:
- Armaholic forums




Enable javascript to be able to download from Armaholic please!



Tags: No tags