Advertisement
READTHESCROLL

ExileEtV.sqf

Sep 21st, 2015
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 6.38 KB | None | 0 0
  1. /*
  2. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3.         Stealthstick's "Explosive-To-Vehicle" Script adapted by second_coming and DarthRogue to
  4.         Allow players to attach their explosive charges to any vehicle or lockable Epoch door.
  5.         Modified for Exile by READTHESCROLL & Darth_Rogue
  6. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  7. NOTE: THIS VERSION IS WOOD DOORS/WOOD GATES ONLY.
  8.  
  9. Copy script and paste in your editor of choice. Save as ExileEtV.sqf
  10.  
  11. Place script in your mission file in a folder called "addons".
  12.  
  13. Paste this at the VERY BOTTOM of init.sqf. Merge with existing and move to bottom of init.sqf if you already have a
  14. if (!isDedicated and hasInterface) then block.
  15.  
  16. if (!isDedicated and hasInterface) then {
  17.         // waitUntil Client Is Actually Loaded In Game
  18.         waitUntil {!isNil "ExileClientLoadedIn"};
  19.         [] execVM "addons\ExileEtV.sqf";
  20.         // waitUntil S2VInitialized is populated by ExileEtV.sqf
  21.         waitUntil {!isNil "ExileEtVInitialized"};
  22.         [player] call EtV_actions;
  23. };
  24.  
  25. */
  26. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  27.  
  28.  
  29. EtV_ChargeCheck =
  30. {
  31.  
  32.     _charge = _this select 0;
  33.     _unit = _this select 1;
  34.     _hasIt = _charge in (magazines _unit);
  35.     _nearVehs = nearestObjects [_unit,["Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"],5];
  36.  
  37.     _return = (_hasIt && count _nearVehs > 0 && alive _unit  && !ExilePlayerInSafezone);
  38.     _return
  39. };
  40.  
  41. EtV_TouchOff =
  42. {
  43.     _array = _this select 3;
  44.     _unit = _array select 0;
  45.     _explosives = _unit getVariable ["charges",[]];
  46.     {
  47.         if(alive _x && !ExilePlayerInSafezone) then
  48.         {
  49.             _nearVehicle = (nearestObjects [_x,["Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"],5]) select 0;
  50.             "HelicopterExploSmall" createVehicle (position _x);
  51.             deleteVehicle _x;
  52.             _existingDamage = damage _nearVehicle;
  53.             _nearVehicle setDamage _existingDamage + 0.08;
  54.             _destroyed = damage _nearvehicle > 0.99;
  55.             if ((typeOf _nearVehicle) in ["Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"] == (_destroyed)) then //if (_destroyed) then
  56.                 {
  57.                     _nearVehicle call ExileServer_object_construction_database_delete;
  58.                 };
  59.         };
  60.     } forEach _explosives;
  61.     _unit setVariable ["charges",[]];
  62.  
  63. };
  64.  
  65. EtV_UnitCheck =
  66. {
  67.     private "_return";
  68.     _unit = _this select 0;
  69.     _explosives = _unit getVariable ["charges",[]];
  70.     if(count _explosives > 0) then
  71.     {
  72.         _return = true;
  73.     }
  74.     else
  75.     {
  76.         _return = false;
  77.     };
  78.  
  79.     _return
  80. };
  81.  
  82. EtV_TimedCharge =
  83. {
  84.     _explosive = _this select 0;
  85.     _unit = _this select 1;
  86.     //_illogic = group server createUnit ["logic", Position _explosive, [], 0, "FORM"];
  87.     _grp = createGroup sidelogic;
  88.     _illogic = _grp createUnit ["logic", Position _explosive, [], 0, "FORM"];
  89.     [_illogic] join _grp;
  90.     _illogic attachTo [_explosive];
  91.     while {alive _explosive} do
  92.     {
  93.         waitUntil {!isNil {_illogic getVariable "timer"};};
  94.         if(_illogic getVariable "timer" == 0) exitWith
  95.         {
  96.             _charges = _unit getVariable ["charges",[]];
  97.             _unit setVariable ["charges",_charges - [_explosive]];
  98.             "HelicopterExploSmall" createVehicle (position _explosive);
  99.             deleteVehicle _explosive;
  100.         };
  101.         sleep 1;
  102.         _oldTime = _illogic getVariable "timer";
  103.         _illogic setVariable ["timer",_oldTime - 1];
  104.     };
  105. };
  106.  
  107. EtV_AttachCharge =
  108. {
  109.     _array = _this select 3;
  110.     _charge = _array select 0;
  111.     _unit = _array select 1;
  112.     private "_class";
  113.  
  114.     _unit removeMagazine _charge;
  115.     _unit playMove "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon";
  116.  
  117.     switch _charge do
  118.     {
  119.         case "DemoCharge_Remote_Mag":
  120.         {
  121.             _class = "DemoCharge_Remote_Ammo";
  122.         };
  123.  
  124.  
  125.  
  126.  
  127.     };
  128.  
  129.     _nearVehicle = (nearestObjects [_unit,["Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"],5]) select 0;
  130.     _explosive = _class createVehicle [0,0,0];
  131.     _explosive attachTo [_unit,[0,0,0],"leftHand"];
  132.     _random0 = random 180;
  133.     _random1 = random 180;
  134.     [_explosive,_random0,_random1] call BIS_fnc_SetPitchBank;
  135.     [_explosive,_nearVehicle,_unit,_random0,_random1] spawn
  136.     {
  137.         _explosive = _this select 0;
  138.         _nearVehicle = _this select 1;
  139.         _unit = _this select 2;
  140.         _random0 = _this select 3;
  141.         _random1 = _this select 4;
  142.  
  143.         sleep 1.5;
  144.  
  145.         if ((typeOf _nearVehicle) in ["Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"]) then
  146.         {
  147.             _explosive attachTo [_nearVehicle, [0,0,0.6]];
  148.         };
  149.  
  150.         [_explosive,_random0,_random1] call BIS_fnc_SetPitchBank;
  151.         _unit setVariable ["charges",(_unit getVariable ["charges",[]]) + [_explosive]];
  152.         [_explosive,_unit] spawn EtV_TimedCharge;
  153.     };
  154. };
  155.  
  156. EtV_ClosestExplosive =
  157. {
  158.     _unit = _this select 0;
  159.     _charges = _unit getVariable ["charges",[]];
  160.     _newArray = [];
  161.     {_newArray = _newArray + [player distance _x];} forEach _charges;
  162.     _closest = _newArray call BIS_fnc_lowestNum;
  163.     _selection = _newArray find _closest;
  164.     _charge = _charges select _selection;
  165.     _charge
  166. };
  167.  
  168. EtV_Timer =
  169. {
  170.     private "_explosive";
  171.     _array = _this select 3;
  172.     _unit = _array select 0;
  173.     _explosive = [_unit] call EtV_ClosestExplosive;
  174.     _illogic = (nearestObjects [_explosive,["Logic"],50]) select 0;
  175.     if(!isNil "_illogic") then
  176.     {
  177.         _oldTime = _illogic getVariable ["timer",0];
  178.         _illogic setVariable ["timer",_oldTime + 30];
  179.         _newTime = _illogic getVariable "timer";
  180.         hint format ["Explosive timer set to %1 seconds.",_newTime];
  181.     };
  182. };
  183.  
  184. EtV_UnitCheckTimer =
  185. {
  186.     private "_return";
  187.     _unit = _this select 0;
  188.     _explosives = _unit getVariable ["charges",[]];
  189.     _return = false;
  190.     {if(_unit distance _x <= 5) exitWith {_return = true;};} forEach _explosives;
  191.     _return
  192. };
  193.  
  194. //[unit] spawn EtV_Actions;
  195. EtV_Actions =
  196. {
  197.     private ["_unit"];
  198.     _unit = _this select 0;
  199.  
  200.     _unit addAction ["<t color=""#FFE496"">" +"Attach Explosives", EtV_AttachCharge, ["DemoCharge_Remote_Mag",_unit], 1, true, true, "","['DemoCharge_Remote_Mag',_target] call EtV_ChargeCheck"];
  201.     _unit addAction ["<t color=""#CC3300"">" +"Set-Off Explosives", EtV_TouchOff, [_unit], 1, true, true, "","[_target] call EtV_UnitCheck"];
  202.     _unit addAction ["<t color=""#CC3300"">" +"Set Timer for 30 Sec", EtV_Timer, [_unit], 1, true, true, "","[_target] call EtV_UnitCheckTimer"];
  203. };
  204.  
  205. //=======================
  206.  
  207.  
  208. //[player] call EtV_Actions;
  209. ExileEtVInitialized = true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement