Jump to content
Sign in to follow this  
zephyrdark

Keep The Keys - Vehicle Sabotage Script

Recommended Posts

Hey everyone.

I'm still pretty novice when comes to scripting. Lately been working on some new scripts. This script here makes it so if the players leave a vehicle with no friendly units nearby, after x amount of time the vehicle has a chance of being sabotaged. Currently the vehicle can have a tire damaged, fuel siphoned, or an IED planted nearby.

Requires ACE for the IEDs.

/*
Keep the Keys script by Blackpython of TacticalGamer.com
##############
Execution Line:
nul=[_veh,_range,_side,_prob,_time]execVM "KeepTheKeys.sqf";
_VEH is the vehicle you want the script to watch. Assign "this" if the script is applied on a vehicle.
_RANGE is the distance from the vehicle that the assigned side can be before the script performs its mischief. Default 50m
_SIDE is the side that you want to be able to defend the vehicle. Default: West (BLUFOR)
_PROB is the chance of an action occuring. A number from 0 to 1. Defualt: .25 (25%)
_TIME is the time between each instance of the script running. Defualt: 300 Seconds (5 Minutes)
#############
*/


private ["_dis","_veh","_range","_prob","_time","_distArray","_TFArray","_desert","_chance","_ranNum","_num2","_fuelTotal","_fuel","_caseTire","_vehPos","_ied","_iedDir","_side"];


_veh = _this select 0;
_range = if (count _this > 1)  then {_this select 1} else {50};
_side = if (count _this > 2) then {_this select 2} else {west};
_prob = if (count _this > 3)  then {_this select 3} else {.25};
_time = if (count _this > 4)  then {_this select 4} else {300};
_distArray = [];
_TFArray = [];
sleep 1;

while {true} do
{
   if (!isServer) exitWith {};
   _distArray = nil;
   _TFArray = nil;
   _distArray = [];
   _TFArray = [];
   sleep _time;
   {if (side _x == _side) then {_dis = _x distance _veh}; _distArray = _distArray + [_dis];} forEach allUnits;
   {if (_x > _range) then {_TFArray = _TFArray + [0]} else {_TFArray = _TFArray + [1]};} forEach _distArray;
   if (!(1 in _TFArray)) then {_desert = true} else {_desert = false};
   _ranNum = random 1;
   if (_ranNum <= _prob) then {_chance = true} else {_chance = false};
   if (_desert && _chance) then 
   {
       _num2 = floor(random 3);
       switch (_num2) do
       {
           case 0: //Fuel Alteration Result
           {
               _fuelTotal = fuel _veh;
               if (_fuelTotal >= .1) then
               {
                   _fuel = (_fuelTotal * .20);
                   _veh setFuel _fuel;
               };
           };
           case 1: //Flat Tire Result
           {
               _caseTire = floor(random 4);
               switch (_caseTire) do
               {
                   case 0:
                   {
                       _veh setHit ["wheel_1_1_steering", .9];
                   };
                   case 1:
                   {
                       _veh setHit ["wheel_1_2_steering", .9];
                   };
                   case 2:
                   {
                       _veh setHit ["wheel_2_1_steering", .9];
                   };
                   case 3:
                   {
                       _veh setHit ["wheel_2_2_steering", .9];
                   };
               };
           };
           case 2: //IED result
           {
               _vehPos = getpos _veh;
               _iedDir = random 360;
               _ied = "Land_IED_v1_PMC" createVehicle _vehPos;
               _ied setVariable ["direction", _iedDir]; // Set tripwire direction
               _ied setVariable ["length", 3]; // Set tripwire length
           };            
       };
       _distArray = nil;
       _TFArray = nil;
       _distArray = [];
       _TFArray = [];
   };
};

Mediafire Download Link: http://www.mediafire.com/?kje89ajefhav7jk

Share this post


Link to post
Share on other sites

O.o

I like.

So if say some people were out in a zombie wasteland, with rebels running around and stuff, I guess you can never know what could happen to your vehicle if you leave it out in the middle of a large town...

I'll check it out.

Thanks

Craig

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
Sign in to follow this  

×