Advertisement
READTHESCROLL

ExileEtV3.sqf

Sep 23rd, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 7.71 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. Copy script and paste in your editor of choice. Save as ExileEtV.sqf
  8.  
  9. Place script in your mission file in a folder called "addons".
  10.  
  11. Paste this at the VERY BOTTOM of init.sqf. Merge with existing and move to bottom of init.sqf if you already have a
  12. if (!isDedicated and hasInterface) then block.
  13.  
  14. if (!isDedicated and hasInterface) then {
  15.     // waitUntil Client Is Actually Loaded In Game
  16.     waitUntil {!isNil "ExileClientLoadedIn"};
  17.     [] execVM "addons\ExileEtV.sqf";
  18.     // waitUntil ExileEtVInitialized is populated by ExileEtV.sqf
  19.     waitUntil {!isNil "ExileEtVInitialized"};
  20.     [player] call EtV_actions;
  21. };
  22.  
  23. */
  24. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  25.  
  26.  
  27.  
  28. EtV_ChargeCheck =
  29. {
  30.  
  31.     _charge = _this select 0;
  32.     _unit = _this select 1;
  33.     _hasIt = _charge in (magazines _unit);
  34.     _nearVehs = nearestObjects [_unit,["Air","Ship","LandVehicle","Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"],5];
  35.  
  36.     _return = (_hasIt && count _nearVehs > 0 && alive _unit  && !ExilePlayerInSafezone);
  37.     _return
  38. };
  39.  
  40. EtV_TouchOff =
  41. {
  42.     _array = _this select 3;
  43.     _unit = _array select 0;
  44.     _explosives = _unit getVariable ["charges",[]];
  45.     SZ_Markers = [
  46.         "TraderCityMarker",
  47.         "TraderZoneSilderas",
  48.         "TraderZoneFolia"
  49.     ];
  50.     SZ_Radius = 300;
  51.     if(alive _x && !ExilePlayerInSafezone) then { //Checks if player is not in safe zone
  52.         if ({_explosives distance getMarkerPos _x < SZ_Radius} count SZ_Markers > 0) then { //Checks if demo charge is in sz marker
  53.             deleteVehicle _explosives; //Deletes explosive if it is in sz
  54.             call ExileClient_gui_safezone_fired; //Hint message
  55.         }
  56.         else //Demo charge is not in safe zone & player is not in safe zone. Proceed...
  57.         {
  58.             _nearVehicle = (nearestObjects [_x,["Air","Ship","LandVehicle","Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static","Exile_Construction_WoodDoor_Reinforced_Static","Exile_Construction_WoodGate_Reinforced_Static"],5]) select 0;
  59.             "HelicopterExploSmall" createVehicle (position _x);
  60.             deleteVehicle _x;
  61.  
  62.             _existingDamage = damage _nearVehicle;
  63.             if ((typeOf _nearVehicle) in ["Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"]) then //Wooden Gates/Doors
  64.                 {
  65.                     _nearVehicle setDamage _existingDamage + 0.10;
  66.                 };
  67.             if ((typeOf _nearVehicle) in ["Air","Ship","LandVehicle"]) then //Vehicles
  68.                 {
  69.                     _nearVehicle setDamage _existingDamage + 1;
  70.                 };
  71.             if ((typeOf _nearVehicle) in ["Exile_Construction_WoodDoor_Reinforced_Static","Exile_Construction_WoodGate_Reinforced_Static"]) then //Reinforced Gates/Doors
  72.                 {
  73.                     _nearVehicle setDamage _existingDamage + 0.05;
  74.                 };
  75.             _destroyed = damage _nearvehicle > 0.99;
  76.             if ((typeOf _nearVehicle) in ["Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static","Exile_Construction_WoodDoor_Reinforced_Static","Exile_Construction_WoodGate_Reinforced_Static"] == (_destroyed)) then //if (_destroyed) then
  77.                 {
  78.                     _nearVehicle call ExileServer_object_construction_database_delete;
  79.                 }
  80.                 else
  81.                 {
  82.                     _nearVehicle call ExileServer_object_vehicle_remove;
  83.                 };
  84.             };
  85.         };
  86.     } forEach _explosives;
  87.     _unit setVariable ["charges",[]];
  88.  
  89. };
  90.  
  91. EtV_UnitCheck =
  92. {
  93.     private "_return";
  94.     _unit = _this select 0;
  95.     _explosives = _unit getVariable ["charges",[]];
  96.     if(count _explosives > 0) then
  97.     {
  98.         _return = true;
  99.     }
  100.     else
  101.     {
  102.         _return = false;
  103.     };
  104.  
  105.     _return
  106. };
  107.  
  108. EtV_TimedCharge =
  109. {
  110.     _explosive = _this select 0;
  111.     _unit = _this select 1;
  112.     //_illogic = group server createUnit ["logic", Position _explosive, [], 0, "FORM"];
  113.     _grp = createGroup sidelogic;
  114.     _illogic = _grp createUnit ["logic", Position _explosive, [], 0, "FORM"];
  115.     [_illogic] join _grp;
  116.     _illogic attachTo [_explosive];
  117.     while {alive _explosive} do
  118.     {
  119.         waitUntil {!isNil {_illogic getVariable "timer"};};
  120.         if(_illogic getVariable "timer" == 0) exitWith
  121.         {
  122.             _charges = _unit getVariable ["charges",[]];
  123.             _unit setVariable ["charges",_charges - [_explosive]];
  124.             "HelicopterExploSmall" createVehicle (position _explosive);
  125.             deleteVehicle _explosive;
  126.         };
  127.         sleep 1;
  128.         _oldTime = _illogic getVariable "timer";
  129.         _illogic setVariable ["timer",_oldTime - 1];
  130.     };
  131. };
  132.  
  133. EtV_AttachCharge =
  134. {
  135.     _array = _this select 3;
  136.     _charge = _array select 0;
  137.     _unit = _array select 1;
  138.     private "_class";
  139.  
  140.     _unit removeMagazine _charge;
  141.     _unit playMove "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon";
  142.  
  143.     switch _charge do
  144.     {
  145.         case "DemoCharge_Remote_Mag":
  146.         {
  147.             _class = "DemoCharge_Remote_Ammo";
  148.         };
  149.  
  150.  
  151.  
  152.  
  153.     };
  154.  
  155.     _nearVehicle = (nearestObjects [_unit,["Air","Ship","LandVehicle","Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"],5]) select 0;
  156.     _explosive = _class createVehicle [0,0,0];
  157.     _explosive attachTo [_unit,[0,0,0],"leftHand"];
  158.     _random0 = random 180;
  159.     _random1 = random 180;
  160.     [_explosive,_random0,_random1] call BIS_fnc_SetPitchBank;
  161.     [_explosive,_nearVehicle,_unit,_random0,_random1] spawn
  162.     {
  163.         _explosive = _this select 0;
  164.         _nearVehicle = _this select 1;
  165.         _unit = _this select 2;
  166.         _random0 = _this select 3;
  167.         _random1 = _this select 4;
  168.  
  169.         sleep 1.5;
  170.  
  171.         if ((typeOf _nearVehicle) in ["Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"]) then
  172.         {
  173.             _explosive attachTo [_nearVehicle, [0,0,0.6]];
  174.         }
  175.         else
  176.         {
  177.             _explosive attachTo [_nearVehicle, [0,0,0.2]];
  178.         };
  179.  
  180.         [_explosive,_random0,_random1] call BIS_fnc_SetPitchBank;
  181.         _unit setVariable ["charges",(_unit getVariable ["charges",[]]) + [_explosive]];
  182.         //[_explosive,_unit] spawn EtV_TimedCharge;
  183.     };
  184. };
  185.  
  186. EtV_ClosestExplosive =
  187. {
  188.     _unit = _this select 0;
  189.     _charges = _unit getVariable ["charges",[]];
  190.     _newArray = [];
  191.     {_newArray = _newArray + [player distance _x];} forEach _charges;
  192.     _closest = _newArray call BIS_fnc_lowestNum;
  193.     _selection = _newArray find _closest;
  194.     _charge = _charges select _selection;
  195.     _charge
  196. };
  197.  
  198. EtV_Timer =
  199. {
  200.     private "_explosive";
  201.     _array = _this select 3;
  202.     _unit = _array select 0;
  203.     _explosive = [_unit] call EtV_ClosestExplosive;
  204.     _illogic = (nearestObjects [_explosive,["Logic"],50]) select 0;
  205.     if(!isNil "_illogic") then
  206.     {
  207.         _oldTime = _illogic getVariable ["timer",0];
  208.         _illogic setVariable ["timer",_oldTime + 30];
  209.         _newTime = _illogic getVariable "timer";
  210.         hint format ["Explosive timer set to %1 seconds.",_newTime];
  211.     };
  212. };
  213.  
  214. EtV_UnitCheckTimer =
  215. {
  216.     private "_return";
  217.     _unit = _this select 0;
  218.     _explosives = _unit getVariable ["charges",[]];
  219.     _return = false;
  220.     {if(_unit distance _x <= 5) exitWith {_return = true;};} forEach _explosives;
  221.     _return
  222. };
  223.  
  224. //[unit] spawn EtV_Actions;
  225. EtV_Actions =
  226. {
  227.     private ["_unit"];
  228.     _unit = _this select 0;
  229.  
  230.     _unit addAction ["<t color=""#FFE496"">" +"Attach Explosives", EtV_AttachCharge, ["DemoCharge_Remote_Mag",_unit], 1, true, true, "","['DemoCharge_Remote_Mag',_target] call EtV_ChargeCheck"];
  231.     _unit addAction ["<t color=""#CC3300"">" +"Set-Off Explosives", EtV_TouchOff, [_unit], 1, true, true, "","[_target] call EtV_UnitCheck"];
  232.     //_unit addAction ["<t color=""#CC3300"">" +"Set Timer for 30 Sec", EtV_Timer, [_unit], 1, true, true, "","[_target] call EtV_UnitCheckTimer"];
  233. };
  234.  
  235. //=======================
  236.  
  237.  
  238. //[player] call EtV_Actions;
  239. ExileEtVInitialized = true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement