Advertisement
Erwin23p

Garage.sqf

Sep 23rd, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 8.99 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////
  2. //      ElcaGarage v0.1                                     //
  3. //                                                          //
  4. //      USE: Write this in the garage init                  //
  5. //      null = [this] execVM "GarageInit.sqf";      //
  6. //                                                          //
  7. //////////////////////////////////////////////////////////////
  8.  
  9. //  VARIABLES
  10. _veh = _this select 0;
  11. _veh_type = (typeOf _veh);
  12.  
  13.  
  14. if (isnil "Elca_Variables") then
  15. {
  16.     Elca_Variables = true;
  17.    
  18.     Action_Priority = 20;
  19.    
  20.     Max_Speed = 10;
  21.    
  22.     Max_Alt = 2;
  23.    
  24.     Max_Distance = 3;
  25.        
  26.     //Black screen during in or out of garage
  27.     Black_Screen = true;
  28.    
  29.     //Usage of doors and animation
  30.     //Doors = false
  31.  
  32.     Supported_Vehicles_SMALL = ["C_Quadbike_01_F", "C_Scooter_Transport_01_F"];
  33.     Supported_Vehicles_MID = ["C_Offroad_01_F", "C_SUV_01_F", "C_Offroad_02_unarmed_F","C_Rubberboat","C_Van_01_fuel_F","B_GEN_Offroad_01_gen_F"];
  34.     Supported_Vehicles_BIG = ["C_Truck_02_transport_F","C_Truck_02_fuel_F"];
  35.  
  36.     Supported_Vehicles_ALL = Supported_Vehicles_SMALL + Supported_Vehicles_MID + Supported_Vehicles_BIG;
  37. };
  38. // 
  39.  
  40. if (isnil "Elca_Functions") then
  41. {
  42.     Elca_Functions = true;
  43.    
  44.     dev_trying =    //  Ignore
  45.     {
  46.         _blocking = [];
  47.         {
  48.             hint "New object found!";
  49.             _blocking = _blocking + [_x];
  50.             _arrow_1 = "Sign_Arrow_Large_Blue_F" createVehicle (_x modelToWorld [0,0,2]);
  51.             sleep 2;
  52.             _pos = getPos _x;
  53.             _bbr = boundingBoxReal _x;
  54.             _p1 = [_bbr select 0 select 0, _bbr select 0 select 1];
  55.             _p2 = [_bbr select 1 select 0, _bbr select 1 select 1];
  56.            
  57.             hint str _p1;
  58.             _arrow_2 = "Sign_Arrow_Blue_F" createVehicle _p1;
  59.             sleep 5;
  60.             hint str _p2;
  61.             _arrow_3 = "Sign_Arrow_Blue_F" createVehicle (getPos _p2);
  62.             sleep 5;
  63.             {
  64.                 deleteVehicle _x;
  65.             } forEach [_arrow_1,_arrow_2,_arrow_3];
  66.         } forEach nearestObjects [q1, Supported_Vehicles_ALL, 20, true];
  67.        
  68.         while {true} do
  69.             {
  70.                 sleep (random [5,10,2]);
  71.                
  72.                 {
  73.                     if !(_x in nearestObjects [q1, Supported_Vehicles_ALL, 20, true]) then
  74.                     {
  75.                         _blocking = _blocking - [_x];
  76.                     };
  77.                 } forEach (_blocking);
  78.                 {
  79.                     hint "New object found!";
  80.                     _blocking = _blocking + [_x];
  81.                     _arrow_1 = "Sign_Arrow_Large_Blue_F" createVehicle (_x modelToWorld [0,0,2]);
  82.                     sleep 2;
  83.                     _pos = getPos _x;
  84.                     _bbr = boundingBoxReal _x;
  85.                     _p1 = [_bbr select 0 select 0, _bbr select 0 select 1];
  86.                     _p2 = [_bbr select 1 select 0, _bbr select 1 select 1];
  87.                    
  88.                     hint str _p1;
  89.                     _arrow_2 = "Sign_Arrow_Blue_F" createVehicle (getPos _p1);
  90.                     sleep 5;
  91.                     hint str _p2;
  92.                     _arrow_3 = "Sign_Arrow_Blue_F" createVehicle (getPos _p2);
  93.                     sleep 5;
  94.                     {
  95.                         deleteVehicle _x;
  96.                     } forEach [_arrow_1,_arrow_2,_arrow_3];
  97.                 } forEach nearestObjects [q1, Supported_Vehicles_ALL, 20, true];
  98.                 hint str (count _blocking);
  99.             };
  100.     };
  101.    
  102.     Elca_fnc_movement =
  103.     {
  104.         if (_obj distance _pos1 < Max_Distance) then
  105.                 {
  106.                     move_pos = _pos3;
  107.                 } else {
  108.                 if (_obj distance _pos2 < Max_Distance) then
  109.                     {
  110.                         move_pos = _pos4;
  111.                     } else {
  112.                     if (_obj distance _pos3 < (Max_Distance + 2)) then
  113.                         {
  114.                             move_pos = _pos1;
  115.                         } else {
  116.                         if (_obj distance _pos4 < (Max_Distance + 2)) then
  117.                             {
  118.                                 move_pos = _pos2;
  119.                             } else { hint "Error in Elca_fnc_movement" };
  120.                                 }
  121.                             }
  122.                         };
  123.         if (Black_Screen) then {
  124.             cutText ["","BLACK FADED",1];
  125.             _obj setPos move_pos;
  126.             sleep 1;
  127.             cutText [" ","BLACK IN",1];
  128.             } else {
  129.             _obj setPos move_pos;
  130.             };
  131.     };
  132.    
  133.     Elca_move =
  134.     {  
  135.         _obj = _this select 0;
  136.         _kind = _this select 1;
  137.         switch (_kind) do
  138.         {
  139.             case 1:
  140.             {
  141.                 _pos1 = pad1 modelToWorld [0,-2.3,0];
  142.                 _pos2 = pad2 modelToWorld [0,-2.3,0];
  143.                 _pos3 = pad1 modelToWorld [0,2,0];
  144.                 _pos4 = pad2 modelToWorld [0,2,0];
  145.                 call Elca_fnc_movement;
  146.             };
  147.  
  148.             case 2:
  149.             {
  150.                 _pos1 = pad1 modelToWorld [0,-4,0];
  151.                 _pos2 = pad2 modelToWorld [0,-4,0];
  152.                 _pos3 = pad1 modelToWorld [0,4,0];
  153.                 _pos4 = pad2 modelToWorld [0,4,0];
  154.                 call Elca_fnc_movement;
  155.             };
  156.            
  157.             case 3:
  158.             {
  159.                 _pos1 = pad1 modelToWorld [0,-5.5,0];
  160.                 _pos2 = pad2 modelToWorld [0,-5.5,0];
  161.                 _pos3 = pad1 modelToWorld [0,4,0];
  162.                 _pos4 = pad2 modelToWorld [0,4,0];
  163.                 call Elca_fnc_movement;
  164.             };
  165.         };
  166.     };
  167. };
  168.  
  169.    
  170.  
  171. if (_veh_type in Supported_Vehicles_SMALL) then
  172. {
  173.     _cond_1 = "((((_target getRelDir pad1) <= 40) OR ((_target getRelDir pad1) >= 320)) OR (((_target getRelDir pad1) <= 220) AND ((_target getRelDir pad1) >= 140))) AND (_target distance (pad1 modelToWorld [0,-2.3,0]) < Max_Distance) AND ((speed _target) <= Max_Speed) AND (((getPos _target) select 2) <= Max_Alt) AND ((driver _target == player) OR (vehicle player == player))";
  174.     _cond_2 = "((((_target getRelDir pad2) <= 40) OR ((_target getRelDir pad2) >= 320)) OR (((_target getRelDir pad2) <= 220) AND ((_target getRelDir pad2) >= 140))) AND (_target distance (pad2 modelToWorld [0,-2.3,0]) < Max_Distance) AND ((speed _target) <= Max_Speed) AND (((getPos _target) select 2) <= Max_Alt) AND ((driver _target == player) OR (vehicle player == player))";
  175.     _cond_3 = "(_target distance (pad1 modelToWorld [0,2,0]) < 3) OR (_target distance (pad2 modelToWorld [0,2,0]) < 3) AND ((driver _target == player) OR (vehicle player == player)) AND !((_target distance (pad1 modelToWorld [0,-2.3,0]) < Max_Distance) OR (_target distance (pad2 modelToWorld [0,-2.3,0]) < Max_Distance))";
  176.    
  177.     _veh addAction [
  178.     "<t color=""#7FFF00"">Enter left garage</t>",
  179.     {
  180.         [_this select 0, _this select 3] spawn Elca_move;
  181.     },1,Action_Priority,true,true,"",_cond_1,3];
  182.    
  183.     _veh addAction [
  184.     "<t color=""#7FFF00"">Enter right garage</t>",
  185.     {
  186.         [_this select 0, _this select 3] spawn Elca_move;
  187.     },1,Action_Priority,true,true,"",_cond_2,3];
  188.    
  189.     _veh addAction [
  190.     "<t color=""#FF0000"">Exit garage</t>",
  191.     {
  192.         [_this select 0,_this select 3] spawn Elca_move;
  193.     },1,5,true,true,"",_cond_3,3];
  194. };
  195.  
  196. if (_veh_type in Supported_Vehicles_MID) then
  197. {
  198.     _cond_1 = "((((_target getRelDir pad1) <= 15) OR ((_target getRelDir pad1) >= 345)) OR (((_target getRelDir pad1) <= 195) AND ((_target getRelDir pad1) >= 165))) AND (_target distance (pad1 modelToWorld [0,-4,0]) < Max_Distance) AND ((speed _target) <= Max_Speed) AND (((getPos _target) select 2) <= Max_Alt) AND ((driver _target == player) OR (vehicle player == player))";
  199.     _cond_2 = "((((_target getRelDir pad2) <= 15) OR ((_target getRelDir pad2) >= 345)) OR (((_target getRelDir pad2) <= 195) AND ((_target getRelDir pad2) >= 165))) AND (_target distance (pad2 modelToWorld [0,-4,0]) < Max_Distance) AND ((speed _target) <= Max_Speed) AND (((getPos _target) select 2) <= Max_Alt) AND ((driver _target == player) OR (vehicle player == player))";
  200.     _cond_3 = "(_target distance (pad1 modelToWorld [0,3.2,0]) < 3) OR (_target distance (pad2 modelToWorld [0,3.2,0]) < 3) AND ((driver _target == player) OR (vehicle player == player)) AND !((_target distance (pad1 modelToWorld [0,-4,0]) < Max_Distance) OR (_target distance (pad2 modelToWorld [0,-4,0]) < Max_Distance))";
  201.    
  202.     _veh addAction [
  203.     "<t color=""#7FFF00"">Enter left garage</t>",
  204.     {
  205.         [_this select 0, _this select 3] spawn Elca_move;
  206.     },2,Action_Priority,true,true,"",_cond_1,3];
  207.    
  208.     _veh addAction [
  209.     "<t color=""#7FFF00"">Enter right garage</t>",
  210.     {
  211.         [_this select 0, _this select 3] spawn Elca_move;
  212.     },2,Action_Priority,true,true,"",_cond_2,3];
  213.    
  214.     _veh addAction [
  215.     "<t color=""#FF0000"">Exit garage</t>",
  216.     {
  217.         [_this select 0,_this select 3] spawn Elca_move;
  218.     },2,5,true,true,"",_cond_3,3];
  219. };
  220.  
  221. if (_veh_type in Supported_Vehicles_BIG) then
  222. {
  223.     _cond_1 = "((((_target getRelDir pad1) <= 10) OR ((_target getRelDir pad1) >= 350)) OR (((_target getRelDir pad1) <= 190) AND ((_target getRelDir pad1) >= 170))) AND (_target distance (pad1 modelToWorld [0,-5.5,0]) < Max_Distance) AND ((speed _target) <= Max_Speed) AND (((getPos _target) select 2) <= Max_Alt) AND ((driver _target == player) OR (vehicle player == player))";
  224.     _cond_2 = "((((_target getRelDir pad2) <= 10) OR ((_target getRelDir pad2) >= 350)) OR (((_target getRelDir pad2) <= 190) AND ((_target getRelDir pad2) >= 170))) AND (_target distance (pad2 modelToWorld [0,-5.5,0]) < Max_Distance) AND ((speed _target) <= Max_Speed) AND (((getPos _target) select 2) <= Max_Alt) AND ((driver _target == player) OR (vehicle player == player))";
  225.     _cond_3 = "(_target distance (pad1 modelToWorld [0,4,0]) < 4) OR (_target distance (pad2 modelToWorld [0,4,0]) < 4) AND ((driver _target == player) OR (vehicle player == player)) AND !((_target distance (pad1 modelToWorld [0,-4,0]) < Max_Distance) OR (_target distance (pad2 modelToWorld [0,-4,0]) < Max_Distance))";
  226.    
  227.     _veh addAction [
  228.     "<t color=""#7FFF00"">Enter left garage</t>",
  229.     {
  230.         [_this select 0, _this select 3] spawn Elca_move;
  231.     },3,Action_Priority,true,true,"",_cond_1,5];
  232.    
  233.     _veh addAction [
  234.     "<t color=""#7FFF00"">Enter right garage</t>",
  235.     {
  236.         [_this select 0, _this select 3] spawn Elca_move;
  237.     },3,Action_Priority,true,true,"",_cond_2,5];
  238.    
  239.     _veh addAction [
  240.     "<t color=""#FF0000"">Exit garage</t>",
  241.     {
  242.         [_this select 0,_this select 3] spawn Elca_move;
  243.     },3,5,true,true,"",_cond_3,5];
  244. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement