Jump to content

[Release] Call your Car v0.1 (for use w/, w/o Masterkey Script)


jahangir13

Recommended Posts

This is nothing essential, it's a fun script.

 

Script calls a specific car to the player location via key.
If a watch (as in Knight Rider) and the key is in the players inventory, car starts to drive if fuel check was positive.

F7 toggles Cam mode (F8 toggles NV in Cam mode) during the drive.
Small debug monitor shows some information (distance, time, speed, fuel, damage).
Zombies and junk on the way will be killed/deleted in a specific radius (need to play with the radius values a bit. maybe classnames still missing)
Car will be locked during the ride and after arrival.

If car is within the destination radius, the driver died or left the car or the car cannot move anymore, the scripts stops with a message.

Configurable.

 

https://www.youtube.com/watch?v=Xfp3XERlUMQ

 

Script CallCar.sqf v0.1:

/////////////////////////////////////////////////////////////////////
//
// Script: Call Car v0.1 (12/2014)
// Created by: jahangir13 ([email protected]<script cf-hash='f9e31' type="text/javascript"> /* */</script>)
// Calls the car belonging to the key this script was executed by
//
// Player needs the key of the car (right click option) and a watch in the inventory.
// Car needs enough fuel to be called (config value). For now only cars/motorcycles are allowed.
// When car is moving, press F7 to toggle Cam mode (F8 in Cam mode to toggle night vision).
// Car is locked during movement and after arrival.
//
/////////////////////////////////////////////////////////////////////

private [
"_scanRadius", "_debrisArray", "_minFuelLevel", "_wpSpeed", "_wpCombatMode", "_behaviour", "_targetRadius", "_debrisRemoveRadius", "_zedKillRadius", "_camHeight", "_driverModel",
"_loopLimiter", "_keyCode", "_inventoryItems", "_keyOwner", "_keyName", "_vehFoundInRange", "_vehTarget", "_ownerID", "_vehDisplayName", "_vehicle", "_minFuelLimit",
"_timeBegin", "_timeEnd", "_doLoop", "_count", "_startPos", "_destPos", "_vehGroup", "_vehDriver", "_wayPoint", "_camera", "_countZombies", "_countDebris","_i"
];

//###############################################################################################################################################
////////// Configuration Begin //////////
// Radius around player to scan for the car belonging to the key
_scanRadius = 25000;
// Debris array (all objects of classnames listed here are removed if car is too near)
_debrisArray = [
    "Fort_Barricade_EP1","LADAWreck","Rubbish1","Rubbish2","Rubbish3","Rubbish4","Rubbish5","Land_Misc_Rubble_EP1","UralWreck",
    "SKODAWreck","HMMWVWreck","datsun02Wreck","hiluxWreck","UAZWreck","datsun01Wreck","Land_Misc_Garb_Heap_EP1"
];
// Minimum fuel level the car needs to have (0.1 = 10%)
_minFuelLevel = 0.1;
// Waypoint speed (Possible values: "UNCHANGED","LIMITED","NORMAL","FULL")
_wpSpeed = "FULL";
// Waypoint combat mode ( https://community.bistudio.com/wiki/setWaypointCombatMode )
_wpCombatMode = "GREEN";
// Driving behaviour of the vehicle group ( https://community.bistudio.com/wiki/setWaypointBehaviour )
_behaviour = "CARELESS";
// Target radius: if the car reaches this radius around the destination position, it is near enough and stops (destination zone)
_targetRadius = 20;
// Radius around the car in which debris/junk will be deleted (otherwise car stops or tries to get around somehow)
_debrisRemoveRadius = 10;
// Radius around the car in which Zombies will be killed (otherwise car stops or tries to get around somehow)
_zedKillRadius = 15;
// Height of the camera above target vehicle
_camHeight = 60;
// Classname/model of the driver
_driverModel = "USMC_Soldier_Medic";
// Inner loop limiter ( Execute the code in this if only each n-th execution of the loop (debug monitor update, looking for Zeds, check cam on/off))
_loopLimiter = 20;
////////// Configuration End //////////
//###############################################################################################################################################

// Keydown function
fnc_key = {
    private ["_keyCode"];
    _keyCode = _this select 0;
    //diag_log format ["keyCode: %1", _keyCode];
    // F7 pressed (Cam mode)
    if ( (_keyCode == 65) ) then {
        if ( showCam ) then {
            showCam = false;
        } else {
            showCam = true;
        };
    };
    // F8 pressed (NV mode)
    if ( (_keyCode == 66) ) then {
        if ( showNV ) then {
            showNV = false;
            camUseNVG false;
        } else {
            showNV = true;
            camUseNVG true;
        };
    };
};
//###############################################################################################################################################

// Exit if player has no watch in inventory
_inventoryItems = [player] call BIS_fnc_invString;
if ( !("ItemWatch" in _inventoryItems) ) exitWith {systemChat "JCC: You don't wear your watch. Calling not possible.";};

// Get key Owner, key name from ui_selectSlot.sqf
_keyOwner = _this select 0;
_keyName = _this select 1;

// Variable to remember if vehicle has been found in range
_vehFoundInRange = false;
// The target vehicle which belongs to the key
_vehTarget = objNull;

//---------------------------------------------------------------------------------------------------------    
// Compare with vehicles on map (allow only land vehicles)
{
    _ownerID = _x getVariable ["CharacterID", "0"];
    if ( _keyOwner == _ownerID ) exitWith {
        _vehFoundInRange = true;
        _vehTarget = _x;
    };
} count ( player nearEntities [["Car","Motorcycle"], _scanRadius] );
//---------------------------------------------------------------------------------------------------------    
    
// if vehicle has been found
if (_vehFoundInRange) then {
    _vehDisplayName = gettext (configFile >> "CfgVehicles" >> (typeof _vehTarget) >> "displayName");

    //Fuel check
    if ( (fuel _vehTarget) < _minFuelLimit) exitWith { systemChat "JCC: Not enough fuel for the ride. Exit."; };
    
    systemChat format["JCC: (%1) KITT, come here... I need you buddy.",_vehDisplayName];    
    
    // Variable init
    _timeBegin = 0;
    _timeEnd = 0;
    showCam = false;
    showNV = false;
    _doLoop = true;
    _count = 0;
    
    _destPos = player modelToWorld [0, 8, 0];
    
    // Start counter
    _timeBegin = time;
    
    // Create a unit group
    _vehGroup = createGroup WEST;
    _vehDriver = _vehGroup createUnit [_driverModel, _vehTarget, [], 0,"LIEUTENANT"];
    _vehDriver assignAsDriver _vehTarget;
    _vehDriver moveInDriver _vehTarget;
    _vehDriver setSkill 1;
    _vehGroup setBehaviour _behaviour;
    
    // Waypoint at destination where car should drive to
    _wayPoint = _vehGroup addwaypoint [_destPos, 0];
    _wayPoint setwaypointtype "MOVE";
    _wayPoint setWaypointSpeed _wpSpeed;
    _wayPoint setWaypointCombatMode _wpCombatMode;
    
    // Lock the vehicle
    _vehTarget setVehicleLock "LOCKED";
   
   // Add keydown Event Handler
    jccKeyDown = (findDisplay 46) displayAddEventHandler ["KeyDown","[_this select 1] call fnc_key; false;"];
    
    // Camera init
    cameraEffectEnableHUD true;
    showCinemaBorder true;
    _camera = "camera" camCreate [0,0,0];
    
    systemChat "JCC: Toggle CAM (F7) ... Toggle NV (F8)";
    
    // Loop until destination is reached, driver died or left car or car cannot move anymore
    for "_i" from 0 to 1 step 0 do {
        _count = _count + 1;
        _camera camSetTarget _vehTarget;
        _camera camSetRelPos [0, -20, _camHeight];
        _camera setVectorDirAndUp [[0,0.5,0.5],[0,-0.5,0.5]];

        _camera camCommitPrepared 0;
        _camera camCommit 0;
        
        // Do not execute the commands within the if condition too often (each _loopLimiter time only)
        if ( (_count mod _loopLimiter) == 0 ) then {
        
            if ( showCam ) then {
                _camera cameraeffect ["internal", "back"];
            } else {
                _camera cameraeffect ["terminate", "back"];
            };
            
            // Get rid of zombies
            _countZombies = _vehTarget nearEntities ["zZombie_Base", _zedKillRadius];
            if ( count _countZombies > 0 ) then {
                {
                    _x setDamage 1;             
                } count _countZombies;
            };
            
            // take the current time
            _timeEnd = time;
    
            // Show debug info
            hintSilent parseText format ["
            <t size='1.2' font='Bitstream' align='right' color='#5882FA'>JCC Autodrive Monitor</t><br/>
            <t size='1.0' font='Bitstream' align='left' color='#FFBF00'>Distance Target:</t><t size='1.0' font='Bitstream' align='right'>%1(m)</t><br/>
            <t size='1.0' font='Bitstream' align='left' color='#FFBF00'>Duration:</t><t size='1.0' font='Bitstream' align='right'>%4(s)</t><br/>
            <t size='1.0' font='Bitstream' align='left' color='#FFBF00'>Velocity:</t><t size='1.0' font='Bitstream' align='right'>%2(km/h)</t><br/>
            <t size='1.0' font='Bitstream' align='left' color='#FFBF00'>Fuel:</t><t size='1.0' font='Bitstream' align='right'>%5(%6)</t><br/>
            <t size='1.0' font='Bitstream' align='left' color='#FFBF00'>Damage:</t><t size='1.0' font='Bitstream' align='right'>%3(%7)</t><br/>",
            (round ( _vehTarget distance _destPos)),
            (round (speed _vehTarget)),
            (round(100*(damage _vehTarget))),
            (round( _timeEnd - _timeBegin)),
            (round(100*(fuel _vehTarget))),
            "%","%"
            ];

           // Leave the loop if condition is true
           if ( (_vehTarget distance _destPos < _targetRadius ) OR ( !canMove _vehTarget ) OR ( {alive _x} count crew _vehTarget == 0 ) OR !( alive _vehDriver) ) exitWith { _doLoop = false; };
        };
        
        // Get rid of debris/junk
        _countDebris = nearestObjects [(getPosATL _vehTarget), _debrisArray, _debrisRemoveRadius];
        if ( count _countDebris > 0 ) then {
            {
                deleteVehicle _x;
            } count _countDebris;
        };
        
        if ( !_doLoop ) exitWith { true };
            
        sleep 0.01;
    }; // end of loop
    
    sleep 1;
    
    // Destroy camera not needed anymore
    _camera cameraeffect ["terminate", "back"];
    camdestroy _camera;
    
    // Remove keydown Event Handler
    (findDisplay 46) displayRemoveEventHandler ["KeyDown", jccKeyDown];

    // Exit if driver is not alive (to send player right error message)
    if ( !(alive _vehDriver) ) exitWith {systemChat "JCC: Driver was killed. Exit.";};
    // Nobody there to drive anymore
    if ( {alive _x} count crew _vehTarget == 0 ) exitWith {systemChat "JCC: Nobody in the car anymore. Exit.";};
    
    sleep 1;
    
    // Get crew out and delete members
    {
        moveOut _x;
        deleteVehicle _x;
    } forEach (crew _vehTarget);
    
    // Delete crew that got out before arrival / delete vehicle group
    {deleteVehicle _x} forEach units _vehGroup;
    deleteGroup _vehGroup;
    
    // Lock the vehicle again
    _vehTarget setVehicleLock "LOCKED";
    
    // Exit if vehicle cannot move (to send player right error message)
    if ( !canMove _vehTarget ) exitWith {systemChat "JCC: Vehicle cannot move anymore. Exit.";};    
    
    // Success message if car arrived in the destination zone
    systemChat format ["JCC: %1 arrived. Damage: %2%5 Fuel: %3%6 Time: %4s", _vehDisplayName, (round(100*(damage _vehTarget))), (round(100*(fuel _vehTarget))),(round( _timeEnd - _timeBegin)),"%","%"];
    
    
// If vehicle has not been found in range
} else {
    systemChat format ["JCC: Car not found in range or key %1 does not belong to a car", _keyName];
 
};

 

ui_selectSlot.sqf:

///// jahan - begin CallCar
        // key colors
        _colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
        if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _item)) in _colors) then {
            // characterID of the key (car character number)
            _keyOwner = getNumber(configFile >> "CfgWeapons" >> _item >> "keyid");
            // key name (like: e3f2)
            _keyName = getText(configFile >> "CfgWeapons" >> _item >> "displayName");
            
            //Menu entry Key CallCar
            _control =  _parent displayCtrl (1600 + _numActions);
            _control ctrlShow true;
            _height = _height + (0.025 * safezoneH);
            // this needs to point the place where the script is in your mission (CallCar.sqf)
            _script =  "custom\jtools\CallCar.sqf";
            _exescript = format["_id = ['%2','%3'] execVM '%1';closeDialog 0;",_script,_keyOwner,_keyName];
            uiNamespace setVariable ['uiControl', _control];
            // sets the text in the right button menu
            _control ctrlSetText "Kitt, come here!";
            _control ctrlSetTextColor [0.3,0.4,1,1];
            _control ctrlSetTooltip "Call your car";
            _control ctrlSetTooltipColorBox [0.3,0.4,1,1];
            _control ctrlSetTooltipColorShade [0, 0, 0, 1];
            _control ctrlSetTooltipColorText [0.3,0.4,1,1];
            _control ctrlSetEventHandler ["ButtonClick",_exescript];
            _numActions = _numActions + 1; // if there are other item action after that (other mods) add 1 to _numactions
        };
///// jahan - end CallCar

Copy that below the for loop or any right click options.

 

If Vehicle Pointer is also used this can be combined:

///// jahan - begin vehicle pointer / CallCar
        // key colors
        _colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
        if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _item)) in _colors) then {
            // characterID of the key (car character number)
            _keyOwner = getNumber(configFile >> "CfgWeapons" >> _item >> "keyid");
            // key name (like: e3f2)
            _keyName = getText(configFile >> "CfgWeapons" >> _item >> "displayName");

            //Menu entry Key vehicle pointer
            _control =  _parent displayCtrl (1600 + _numActions);
            _control ctrlShow true;
            _height = _height + (0.025 * safezoneH);
            // this needs to point the place where the script is in your mission (vehicle_pointer.sqf)
            _script =  "custom\jtools\vehicle_pointer_mk.sqf";
            _exescript = format["_id = ['%2','%3'] execVM '%1';closeDialog 0;",_script,_keyOwner,_keyName];
            uiNamespace setVariable ['uiControl', _control];
            // sets the text in the right button menu
            _control ctrlSetText "Vehicle Pointer";
            _control ctrlSetTextColor [0.3,0.4,1,1];
            _control ctrlSetTooltip "Pinpoint vehicle. Mark on map if not in range.";
            _control ctrlSetTooltipColorBox [0.3,0.4,1,1];
            _control ctrlSetTooltipColorShade [0, 0, 0, 1];
            _control ctrlSetTooltipColorText [0.3,0.4,1,1];
            _control ctrlSetEventHandler ["ButtonClick",_exescript];
            _numActions = _numActions + 1; // if there are other item action after that (other mods) add 1 to _numactions
            
            //Menu entry Key CallCar
            _control =  _parent displayCtrl (1600 + _numActions);
            _control ctrlShow true;
            _height = _height + (0.025 * safezoneH);
            // this needs to point the place where the script is in your mission (CallCar.sqf)
            _script =  "custom\jtools\CallCar.sqf";
            _exescript = format["_id = ['%2','%3'] execVM '%1';closeDialog 0;",_script,_keyOwner,_keyName];
            uiNamespace setVariable ['uiControl', _control];
            // sets the text in the right button menu
            _control ctrlSetText "Kitt, come here!";
            _control ctrlSetTextColor [0.3,0.4,1,1];
            _control ctrlSetTooltip "Call your car";
            _control ctrlSetTooltipColorBox [0.3,0.4,1,1];
            _control ctrlSetTooltipColorShade [0, 0, 0, 1];
            _control ctrlSetTooltipColorText [0.3,0.4,1,1];
            _control ctrlSetEventHandler ["ButtonClick",_exescript];
            _numActions = _numActions + 1; // if there are other item action after that (other mods) add 1 to _numactions
        };
///// jahan - end vehicle pointer / CallCar

 

Battleye:

This needs be entered in these 3 files: waypointstatement.txt,  remoteexec.txt, waypointcondition.txt

!="true" !=""

 

-----

 

E.g.: waypointcondition.txt

//new
5 "" !="true" !=""

 

-----

 

Check the line number which is responsible for the kick in waypointstatements.log.

 

Pathfinding is not very clever in Arma2 but works. I did not test how calling the car over the whole map works. I wanted to have a way to park at some loot area, walk around, go to another 2 or 3 houses and from there call the car to not need to go back ,)

 

 

---

 

 

Script for use with Masterkey Script (CallCar_mk.sqf):

Use this only if you are using the Masterkey script/mod where several cars can have the same key.

/////////////////////////////////////////////////////////////////////
//
// Script: Call Car MK v0.1 (Masterkey version) (12/2014)
// Created by: jahangir13 ([email protected])
// Calls the car belonging to the key this script was executed by
//
// Player needs the key of the car (right click option) and a watch in the inventory.
// Car needs enough fuel to be called (config value). For now only cars/motorcycles are allowed.
// When car is moving, press F7 to toggle Cam mode (F8 in Cam mode to toggle night vision).
// Car is locked during movement and after arrival.
//
/////////////////////////////////////////////////////////////////////

private [
"_scanRadius", "_debrisArray", "_minFuelLevel", "_wpSpeed", "_wpCombatMode", "_behaviour", "_targetRadius", "_debrisRemoveRadius", "_zedKillRadius", "_camHeight", "_driverModel",
"_loopLimiter", "_keyCode", "_inventoryItems", "_keyOwner", "_keyName", "_vehFoundInRange", "_vehTarget", "_ownerID", "_vehDisplayName", "_vehicle", "_minFuelLimit","_vehsFound",
"_timeBegin", "_timeEnd", "_doLoop", "_count", "_startPos", "_destPos", "_vehGroup", "_vehDriver", "_wayPoint", "_camera", "_countZombies", "_countDebris","_i","_isCarDriving"
];

//###############################################################################################################################################
////////// Configuration Begin //////////
// Radius around player to scan for the car belonging to the key
_scanRadius = 25000;
// Debris array (all objects of classnames listed here are removed if car is too near)
_debrisArray = [
 "Fort_Barricade_EP1","LADAWreck","Rubbish1","Rubbish2","Rubbish3","Rubbish4","Rubbish5","Land_Misc_Rubble_EP1","UralWreck",
 "SKODAWreck","HMMWVWreck","datsun02Wreck","hiluxWreck","UAZWreck","datsun01Wreck","Land_Misc_Garb_Heap_EP1"
];
// Minimum fuel level the car needs to have (0.1 = 10%)
_minFuelLevel = 0.1;
// Waypoint speed (Possible values: "UNCHANGED","LIMITED","NORMAL","FULL")
_wpSpeed = "FULL";
// Waypoint combat mode ( https://community.bistudio.com/wiki/setWaypointCombatMode )
_wpCombatMode = "GREEN";
// Driving behaviour of the vehicle group ( https://community.bistudio.com/wiki/setWaypointBehaviour )
_behaviour = "CARELESS";
// Target radius: if the car reaches this radius around the destination position, it is near enough and stops (destination zone)
_targetRadius = 25;
// Radius around the car in which debris/junk will be deleted (otherwise car stops or tries to get around somehow)
_debrisRemoveRadius = 10;
// Radius around the car in which Zombies will be killed (otherwise car stops or tries to get around somehow)
_zedKillRadius = 15;
// Height of the camera above target vehicle
_camHeight = 60;
// Classname/model of the driver
_driverModel = "USMC_Soldier_Medic";
// Inner loop limiter ( Execute the code in this if only each n-th execution of the loop (debug monitor update, looking for Zeds, check cam on/off))
_loopLimiter = 20;
////////// Configuration End //////////
//###############################################################################################################################################

// Keydown function
fnc_key = {
 private ["_keyCode"];
 _keyCode = _this select 0;
    //diag_log format ["keyCode: %1", _keyCode];
 // F7 pressed (Cam mode)
 if ( (_keyCode == 65) ) then {
        if ( showCam ) then {
            showCam = false;
        } else {
            showCam = true;
        };
    };
 // F8 pressed (NV mode)
    if ( (_keyCode == 66) ) then {
        if ( showNV ) then {
            showNV = false;
            camUseNVG false;
        } else {
            showNV = true;
            camUseNVG true;
        };
    };
};
//###############################################################################################################################################

// Exit if another car is already on the way
_isCarDriving = player getVariable["callcar", false];
if ( _isCarDriving ) exitWith {systemChat "JCC: You already called a car. Calling not possible.";};

// Exit if player has no watch in inventory
_inventoryItems = [player] call BIS_fnc_invString;
if ( !("ItemWatch" in _inventoryItems) ) exitWith {systemChat "JCC: You don't wear your watch. Calling not possible.";};

// Get key Owner, key name from ui_selectSlot.sqf
_keyOwner = _this select 0;
_keyName = _this select 1;

// Variable to remember if vehicle has been found in range
_vehFoundInRange = false;
// The target vehicle which belongs to the key
_vehTarget = objNull;
selectedCar = -1;

//---------------------------------------------------------------------------------------------------------   
// Compare with vehicles on map (allow only land vehicles)
_vehsFound = [];
{
    _ownerID = _x getVariable ["CharacterID", "0"];
    if ( _keyOwner == _ownerID ) then {
        _vehFoundInRange = true;
        _vehsFound = _vehsFound + [_x];
    };
} count ( player nearEntities [["Car","Motorcycle"], _scanRadius] );
//---------------------------------------------------------------------------------------------------------   
   
// if vehicle has been found
if (_vehFoundInRange) then {
   
    createdialog "CallCar";
    // clear the dialog list
    lbClear 6661;
    {
        _vehDisplayName = gettext (configFile >> "CfgVehicles" >> (typeof _x) >> "displayName");
        // add the vehicles to the dialog
        lbAdd [6661, _vehDisplayName];
    } forEach _vehsFound;
    // wait for the dialog to be closed
    waitUntil { !dialog };
   
    if ( (selectedCar < 0) ) exitWith { systemChat "JCC: Nothing selected or cancelled. Exit."; };
   
    // the selected vehicle from the array of found vehicles
    _vehTarget = (_vehsFound select selectedCar);

    // So we have our car...now call it
    //Fuel check
    if ( (fuel _vehTarget) < _minFuelLimit) exitWith { systemChat "JCC: Not enough fuel for the ride. Exit."; };
   
    systemChat format["JCC: (%1) KITT, come here... I need you buddy.",_vehDisplayName]; 
   
 // Variable init
    _timeBegin = 0;
 _timeEnd = 0;
    showCam = false;
 showNV = false;
 _doLoop = true;
 _count = 0;
   
    _destPos = player modelToWorld [0, 8, 0];
   
    // Start counter
    _timeBegin = time;
 
    // Create a unit group
    _vehGroup = createGroup WEST;
    _vehDriver = _vehGroup createUnit [_driverModel, _vehTarget, [], 0,"LIEUTENANT"];
    _vehDriver assignAsDriver _vehTarget;
    _vehDriver moveInDriver _vehTarget;
 _vehDriver setSkill 1;
    _vehGroup setBehaviour _behaviour;
   
 // Waypoint at destination where car should drive to
 _wayPoint = _vehGroup addwaypoint [_destPos, 0];
 _wayPoint setwaypointtype "MOVE";
 _wayPoint setWaypointSpeed _wpSpeed;
 _wayPoint setWaypointCombatMode _wpCombatMode;
   
    // Lock the vehicle
    _vehTarget setVehicleLock "LOCKED";
   
    // remember that we already called a car
    player setVariable['callcar',true,false];
  
   // Add keydown Event Handler
    jccKeyDown = (findDisplay 46) displayAddEventHandler ["KeyDown","[_this select 1] call fnc_key; false;"];
   
 // Camera init
    cameraEffectEnableHUD true;
    showCinemaBorder true;
    _camera = "camera" camCreate [0,0,0];
   
    systemChat "JCC: Toggle CAM (F7) ... Toggle NV (F8)";
   
 // Loop until destination is reached, driver died or left car or car cannot move anymore
 for "_i" from 0 to 1 step 0 do {
        _count = _count + 1;
        _camera camSetTarget _vehTarget;
        _camera camSetRelPos [0, -20, _camHeight];
  _camera setVectorDirAndUp [[0,0.5,0.5],[0,-0.5,0.5]];

        _camera camCommitPrepared 0;
        _camera camCommit 0;
       
        // Do not execute the commands within the if condition too often (each _loopLimiter time only)
        if ( (_count mod _loopLimiter) == 0 ) then {
       
            if ( showCam ) then {
                _camera cameraeffect ["internal", "back"];
            } else {
                _camera cameraeffect ["terminate", "back"];
            };
           
            // Get rid of zombies
   _countZombies = _vehTarget nearEntities ["zZombie_Base", _zedKillRadius];
            if ( count _countZombies > 0 ) then {
                {
                    _x setDamage 1;    
                } count _countZombies;
            };
           
            // take the current time
            _timeEnd = time;
   
            // Show debug info
            hintSilent parseText format ["
            <t size='1.2' font='Bitstream' align='right' color='#5882FA'>JCC Autodrive Monitor</t><br/>
            <t size='1.0' font='Bitstream' align='left' color='#FFBF00'>Distance Target:</t><t size='1.0' font='Bitstream' align='right'>%1(m)</t><br/>
            <t size='1.0' font='Bitstream' align='left' color='#FFBF00'>Duration:</t><t size='1.0' font='Bitstream' align='right'>%4(s)</t><br/>
            <t size='1.0' font='Bitstream' align='left' color='#FFBF00'>Velocity:</t><t size='1.0' font='Bitstream' align='right'>%2(km/h)</t><br/>
            <t size='1.0' font='Bitstream' align='left' color='#FFBF00'>Fuel:</t><t size='1.0' font='Bitstream' align='right'>%5(%6)</t><br/>
            <t size='1.0' font='Bitstream' align='left' color='#FFBF00'>Damage:</t><t size='1.0' font='Bitstream' align='right'>%3(%7)</t><br/>",
            (round ( _vehTarget distance _destPos)),
            (round (speed _vehTarget)),
            (round(100*(damage _vehTarget))),
            (round( _timeEnd - _timeBegin)),
            (round(100*(fuel _vehTarget))),
            "%","%"
            ];

     // Leave the loop if condition is true
     if ( (_vehTarget distance _destPos < _targetRadius ) OR ( !canMove _vehTarget ) OR ( {alive _x} count crew _vehTarget == 0 ) OR !( alive _vehDriver) ) exitWith { _doLoop = false; };
        };
       
        // Get rid of debris/junk
        _countDebris = nearestObjects [(getPosATL _vehTarget), _debrisArray, _debrisRemoveRadius];
        if ( count _countDebris > 0 ) then {
            {
                deleteVehicle _x;
            } count _countDebris;
        };
       
        if ( !_doLoop ) exitWith { true };
           
        sleep 0.01;
    }; // end of loop
   
    sleep 1;
   
 // Destroy camera not needed anymore
    _camera cameraeffect ["terminate", "back"];
    camdestroy _camera;
   
    // Remove keydown Event Handler
    (findDisplay 46) displayRemoveEventHandler ["KeyDown", jccKeyDown];

    player setVariable['callcar',false,false];
   
    // Exit if driver is not alive (to send player right error message)
    if ( !(alive _vehDriver) ) exitWith {systemChat "JCC: Driver was killed. Exit.";};
    // Nobody there to drive anymore
    if ( {alive _x} count crew _vehTarget == 0 ) exitWith {systemChat "JCC: Nobody in the car anymore. Exit.";};
   
    sleep 1;
   
    // Get crew out and delete members
    {
        moveOut _x;
        deleteVehicle _x;
    } forEach (crew _vehTarget);
 
    // Delete crew that got out before arrival / delete vehicle group
 {deleteVehicle _x} forEach units _vehGroup;
 deleteGroup _vehGroup;
   
    // Lock the vehicle again
    _vehTarget setVehicleLock "LOCKED";
   
    // Exit if vehicle cannot move (to send player right error message)
    if ( !canMove _vehTarget ) exitWith {systemChat "JCC: Vehicle cannot move anymore. Exit.";};   
   
 // Success message if car arrived in the destination zone
    systemChat format ["JCC: %1 arrived. Damage: %2%5 Fuel: %3%6 Time: %4s", _vehDisplayName, (round(100*(damage _vehTarget))), (round(100*(fuel _vehTarget))),(round( _timeEnd - _timeBegin)),"%","%"];
   
// If vehicle has not been found in range
} else {
    systemChat format ["JCC: Car not found in range or %1 does not belong to a car", _keyName];
 
};

 

Dialog file used with Masterkey script version (CallCar_mk.hpp):

class CallCar
{
 idd = 666123;
 class Controls {
  class RscText_6660: RscTextT
  {
   idc = 6660;
   x = 0.30 * safezoneW + safezoneX;
   y = 0.30 * safezoneH + safezoneY;
   w = 0.30 * safezoneW;
   h = 0.5 * safezoneH;
   colorBackground[] = {0,0,0,1};
  }; 
  class RscListbox_6661: RscListbox
  {
   idc = 6661;
   x = 0.31* safezoneW + safezoneX;
   y = 0.41 * safezoneH + safezoneY;
   w = 0.2 * safezoneW;
   h = 0.30 * safezoneH;
   soundSelect[] = {"",0.1,1};
   colorBackground[] = {0,0,0,1};
  };
  class RscShortcutButton_6662: RscShortcutButton
  {
   idc = 6662;
   text = "Call here";
   x = 0.33 * safezoneW + safezoneX;
   y = 0.70 * safezoneH + safezoneY;
   w = 0.08 * safezoneW;
   h = 0.06 * safezoneH;
   onButtonClick = "selectedCar = (lbCurSel 6661); ((ctrlParent (_this select 0)) closeDisplay 9000);";
  };
  class RscShortcutButton_6663: RscShortcutButton
  {
   idc = 6663;
   text = "Cancel";
   x = 0.44 * safezoneW + safezoneX;
   y = 0.70 * safezoneH + safezoneY;
   w = 0.08 * safezoneW;
   h = 0.06 * safezoneH;
   onButtonClick = "((ctrlParent (_this select 0)) closeDisplay 9000);";
  };  
  class RscText_6664: RscTextT
  {
   idc = 6664;
   text = "Call Car Search Results";
   x = 0.30 * safezoneW + safezoneX;
   y = 0.30 * safezoneH + safezoneY;
   w = 0.30 * safezoneW;
   h = 0.05 * safezoneH;  
   colorBackground[] = {0,0,0,1}; 
   colorText[] = {1,1,1,1};   
  };
  class RscText_6665: RscTextT
  {
   idc = 6665;
   text = "Select a Car from list";
   x = 0.31 * safezoneW + safezoneX;
   y = 0.38 * safezoneH + safezoneY;
   w = 0.2 * safezoneW;
   h = 0.03 * safezoneH;
   colorText[] = {1,1,1,1};
  };
 };
};
 

 

ui_selectSlot.sqf and Battleye settings stay the same for both versions.

For the Masterkey script version you need to include the dialog file (wherever you store that) at the end of your description.ext:

// CallCar
#include "custom\jtools\CallCar_mk.hpp"
Link to comment
Share on other sites

Any idea on how this affects other player controlled vehicles travelling in opposite directions on the same roads?

Does it do anything to their vehicles?

What if you are on an island and call the car?

Also, can you call heli's as well, or just cars (land vehicles)?

Are all land vehicles call-able?

 

I really like this, it looks fantastic :)

Link to comment
Share on other sites

Masterkey script: First version works without. But I will have a look how I can dynamically add the available vehivles for the key to an array and from there to a scroll wheel menu so that the right car can be chosen. Not very familiar with menus yet.

But yes, I guess in this versions maybe 3 cars will drive ;) Did not check this so far.

 

Other cars: I guess that's as with a human driver. You need to be careful that the other driver will not rush into you :) There is some kind of collision detection for the auto drivers. So if there is a zombie nearby the car stops or tries to get around. This does not work for garbage on the road...I think cause this is not alive (or these classnames are not known to pathfinding as something blocking the road).

 

Islands: hopefully the car stops at the border of the island ;)

 

I switched off helis for now...as I need to land them first. So it does not work out of the box so far. Therefore I use Evac Heli. Cars and Motorcycles work so far. But I guess helis just need to have a few lines of code which lands them at the destination position. Changing the classname to a heli let the heli hover in the ait and stay there.

 

I am not sure how well this works with several players on the server or far distances. Was just playing around with AI units in vehicles and thought this could be funny.

Link to comment
Share on other sites

@Proximus: maybe you first try it out with a spawned car with a key where only 1 car exist for this key

You could call the script in fn_selfActions with a check for your player uid...so only you can execute it or put that check into ui_selectSlot so that the key option only shows up for you.

 

Maybe you don't want it anymore after that ;) For a heli it's easier as it just get into the air, flies to the target and lands there. If there is no tree nearby or something this works fine. I was wondering how well that worked with a car for me in my tests. But I don't know how well this works if there is more trouble on the map or far distances used.

 

I wanted to collect some feedback first before I change something again.

Link to comment
Share on other sites

The spectate tool only shows you a 3rd or 1st person view from the players perspective.

I like this because it shows you from an overhead view. 

 

I don't want to hijack your post btw, so I'll do some research and leave this thread alone. 

Thanks again , great addition :)

Link to comment
Share on other sites

Ah, it's just where you point the camera to. I said: place the camera above the vehicle (20 m behind it, 60m high above it and with a bit angle (if that works)).

So I could also tell the camera to show me what e.g. the driver sees.

 

So if you want to have that similar in admin tools you need to adapt the spectate script and give the cam a reletive position to the object:

 

_camera camSetRelPos [0, -20, _camHeight];

 

I did not have a look into the admin tools code as I am at work. But I guess this should work like this.

Link to comment
Share on other sites

Ah no...it can just call the first key found. If it finds one, it stops the loop and calls this one. It was by chance that it was the 'original' or first one as all are looking the same in DB.

To support several ones it's not just changing the exitWith in the loop. I need to collect them in an array and loop via this to call all.

For me the difficult part (as I did not do it before) is providing a list of all found to the player (via command menu or dialog) to select the one wanted. I will not start today...but over the weekend I will get some time to implement that I hope.

 

Thanks for testing!

Link to comment
Share on other sites

I like and love how this was put together and everything but damn with mods like this and that heli call script your just making things a walk in the park for this game and for all the lazy people. I thought it was meant to be hard lol

 

Anyway I'm not bashing it at all but how will this be countered if someone stole your car and sticks it in there built up base? will the car just pass through the wall/garage door? or will it get stuck on them and keep damaging itself till it blows up along with everything else in that said base?

Link to comment
Share on other sites

I like and love how this was put together and everything but damn with mods like this and that heli call script your just making things a walk in the park for this game and for all the lazy people. I thought it was meant to be hard lol

 

Anyway I'm not bashing it at all but how will this be countered if someone stole your car and sticks it in there built up base? will the car just pass through the wall/garage door? or will it get stuck on them and keep damaging itself till it blows up along with everything else in that said base?

It can be configured if you don't want it to be really easy. Use a rare item, such as a laser designator or radio (depending on how rare they are on your server). Regarding cars going through base walls & doors, I would guess at no - the vehicle will most likely become stuck, seeing as they stop at road obstacles that are too hard to navigate around. Base items such as doors etc aren't on the debris array in the callcar.sqf either.

 

Just implemented this on our Origins Epoch server, works well and you'll do well to

  • Find the item you need to have in your inventory
  • Have your vehicle travel a long distance, as Origins 3.5 has a lot of wrecks built in to the map.

Works better when you've parked your vehicle away from the road. Just watched a test car keep offroad for 3km and reach me. Cheers jahangir13

Link to comment
Share on other sites

If you want to spectate the car you need to call it. You cannot just park it somewhere and have a look without.

You can set the height of the cam above the car...so if this is lower you do not see much around the car.

 

But yes, the comments you all send here are important to maybe make something out of it in the end or not.

 

The story was just: I wanted to see if the car can drive automatically. Then I thought I need a cam or something if it might get stuck somewhere to see where it is.

I released it to get some ideas from others.

Link to comment
Share on other sites

If you want to spectate the car you need to call it. You cannot just park it somewhere and have a look without.

 

But yes, the comments you all send here are important to maybe make something out of it in the end or not.

 

The story was just: I wanted to see if the car can drive automatically. Then I thought I need a cam or something if it might get stuck somewhere to see where it is.

I released it to get some ideas from others.

Maybe you could have someone buy an item from the trader like a car upgrade, radio or something. Then that person has to scroll on the car to attach said Item and maybe then have it as some kind of remote control car that starts losing power the further away it is from you. That mite be cool

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...