Advertisement
Guest User

VZ_ACE_LOADSCRIPT

a guest
Aug 26th, 2017
20
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //========================Add Action to crate and vehicle for load
  2. //========================First go to crate and select it to be loaded
  3. //========================Then go to the vehicle which it shall be loaded into
  4. //========================Load the fucker in
  5.  
  6. // Defining specific types of cargo containers, assume Land_CargoBox_V1_F has a grid of 6x6 and go from there.
  7. // For any non square-ish container follow pattern: when placed in the editor without being rotated, the side that is towards north = x, sides east or west = y.
  8. // Then estimate how many subunits of Land_CargoBox_V1_F the object has.
  9. // This is necessary for determining if object has to be rotated when loaded to avoid clipping.
  10.  
  11. VZ_LOG_Container_2x2 = [
  12.     "FlexibleTank_01_forest_F",
  13.     "FlexibleTank_01_sand_F",
  14.     "Land_MetalBarrel_F",
  15.     "Land_MetalBarrel_empty_F",
  16.     "Land_BarrelEmpty_F",
  17.     "Land_BarrelEmpty_grey_F",
  18.     "Land_BarrelSand_F",
  19.     "Land_BarrelSand_grey_F",
  20.     "Land_BarrelTrash_F",
  21.     "Land_BarrelTrash_grey_F",
  22.     "Land_BarrelWater_F",
  23.     "Land_BarrelWater_grey_F"
  24. ];
  25.  
  26. VZ_LOG_Container_2x3 = [
  27.     "Land_MetalCase_01_medium_F",
  28.     "Land_PlasticCase_01_medium_F",
  29.     "Box_NATO_Support_F",
  30.     "Box_NATO_Ammo_F",
  31.     "Box_NATO_AmmoOrd_F",
  32.     "Box_NATO_Grenades_F",
  33.     "Box_East_Support_F",
  34.     "Box_East_Ammo_F",
  35.     "Box_T_East_Ammo_F",
  36.     "Box_East_AmmoOrd_F",
  37.     "Box_East_Grenades_F",
  38.     "Box_IND_Support_F",
  39.     "Box_IND_Ammo_F",
  40.     "Box_IND_AmmoOrd_F",
  41.     "Box_IND_Grenades_F",
  42.     "Land_PlasticCase_01_small_F",
  43.     "ACE_Box_82mm_Mo_Combo",
  44.     "ACE_Box_82mm_Mo_HE",
  45.     "ACE_Box_82mm_Mo_Illum",
  46.     "ACE_Box_82mm_Mo_Smoke",
  47.     "ACE_Box_Ammo",
  48.     "ACE_Box_Misc",
  49.     "rhsusf_ammo_crate"
  50. ];
  51.  
  52. VZ_LOG_Container_2x4 = [
  53.     "Land_MetalCase_01_large_F",
  54.     "Land_PlasticCase_01_large_F",
  55.     "Box_NATO_Uniforms_F",
  56.     "Box_CSAT_Uniforms_F",
  57.     "Box_AAF_Uniforms_F",
  58.     "Box_NATO_Equip_F",
  59.     "Box_CSAT_Equip_F",
  60.     "Box_AAF_Equip_F",
  61.     "Box_GEN_Equip_F"  
  62. ];
  63.  
  64. VZ_LOG_Container_3x2 = [
  65.     "Box_IED_Exp_F",
  66.     "Box_Syndicate_Ammo_F"
  67. ];
  68.  
  69. VZ_LOG_Container_3x4 = [
  70.     "Land_WoodenCrate_01_F"
  71. ];
  72.  
  73. VZ_LOG_Container_4x2 = [
  74.     "Box_Syndicate_Wps_F",
  75.     "ACE_medicalSupplyCrate",
  76.     "ACE_medicalSupplyCrate_advanced",
  77.     "rhs_weapons_crate_ak_ammo_545x39_standard",
  78.     "rhs_weapons_crate_ak_ammo_545x39",
  79.     "rhs_mags_crate",
  80.     "rhs_gear_crate",
  81.     "rhsgref_weapons_crate"
  82. ];
  83.  
  84. VZ_LOG_Container_4x3 = [
  85.     "Box_IND_Wps_F",
  86.     "Box_T_East_Wps_F",
  87.     "Box_East_Wps_F",
  88.     "Box_T_NATO_Wps_F",
  89.     "Box_NATO_Wps_F",
  90.     "rhs_7ya37_1_single"
  91. ];
  92.  
  93. VZ_LOG_Container_6x2 = [
  94.     "Box_NATO_WpsLaunch_F",
  95.     "Box_East_WpsLaunch_F",
  96.     "Box_IND_WpsLaunch_F",
  97.     "Box_Syndicate_WpsLaunch_F"
  98. ];
  99.  
  100. VZ_LOG_Container_6x3 = [
  101.     "B_supplyCrate_F",
  102.     "C_supplyCrate_F",
  103.     "C_T_supplyCrate_F",
  104.     "O_supplyCrate_F",
  105.     "I_supplyCrate_F",
  106.     "IG_supplyCrate_F",
  107.     "Box_NATO_WpsSpecial_F",
  108.     "Box_T_NATO_WpsSpecial_F",
  109.     "Box_East_WpsSpecial_F",
  110.     "Box_T_East_WpsSpecial_F",
  111.     "Box_IND_WpsSpecial_F",
  112.     "ACE_Box_Chemlights",
  113.     "rhssaf_virtual_crate"
  114. ];
  115.  
  116. VZ_LOG_Container_6x6 = [
  117.     "B_CargoNet_01_ammo_F",
  118.     "O_CargoNet_01_ammo_F",
  119.     "I_CargoNet_01_ammo_F",
  120.     "Box_NATO_AmmoVeh_F",
  121.     "Box_IND_AmmoVeh_F",
  122.     "Box_East_AmmoVeh_F",
  123.     "CargoNet_01_barrels_F",
  124.     "CargoNet_01_box_F",
  125.     "Land_PaperBox_closed_F",
  126.     "Land_PaperBox_open_empty_F",
  127.     "Land_PaperBox_open_full_F",
  128.     "Land_Pallet_MilBoxes_F",
  129.     "Land_CargoBox_V1_F",
  130.     "Land_WaterBarrel_F",
  131.     "Land_WoodenCrate_01_stack_x3_F",
  132.     "rhsusf_mags_crate",
  133.     "rhsusf_gear_crate",
  134.     "rhsusf_launcher_crate",
  135.     "rhsusf_spec_weapons_crate",
  136.     "rhsusf_weapon_crate",
  137.     "rhsusf_weapons_crate"
  138. ];
  139.  
  140. VZ_LOG_Container_9x3 = [
  141.     "rhs_weapons_crate_ak",
  142.     "rhs_launcher_crate",
  143.     "rhs_spec_weapons_crate",
  144.     "rhs_weapon_crate"
  145. ];
  146.  
  147. VZ_LOG_Container_6x18 = [
  148.     "B_Slingload_01_Ammo_F",
  149.     "B_Slingload_01_Cargo_F",
  150.     "B_Slingload_01_Fuel_F",
  151.     "B_Slingload_01_Medevac_F",
  152.     "B_Slingload_01_Repair_F"  
  153. ];
  154.  
  155. VZ_LOG_Check = { // For Diagnosing Purposes
  156.     cutText [format ["%1 is loaded %2, is selected %3, is attached %4, has cargo loaded %5", (typeOf _target), (_target getVariable ["isLoaded", false]), (_target getVariable ["isSelected", false]), (_target getVariable ["isAttached", false]), (_target getVariable ["hasCargoLoaded", false])], "PLAIN"];
  157. };
  158.  
  159. VZ_LOG_SelectCargo = { // Only Select the Cargo that is able to be loaded
  160.     _isSelected = _target getVariable ["isSelected", false];
  161.     _isAttached = _target getVariable ["isAttached", false];
  162.     _isLoaded = _target getVariable ["isLoaded", false];
  163.     if (_isAttached)    exitwith {
  164.         cutText [format ["%1 is already attached", (typeOf _Target)], "PLAIN"];
  165.     };
  166.     if (_isLoaded)      exitwith {
  167.         cutText [format ["%1 is already loaded", (typeOf _Target)], "PLAIN"];
  168.     };
  169.     if (_isSelected)    exitwith {
  170.         cutText [format ["%1 is already selected", (typeOf _Target)], "PLAIN"];
  171.     };
  172.     if (!_isSelected) then {
  173.         cutText [format ["select a vehicle to load %1 into...", (typeOf _Target)], "PLAIN"];
  174.         _target setVariable ["isSelected", true, true];
  175.     };
  176. };
  177.  
  178. VZ_LOG_LoadCargo = { // Actually load the damn thing in, but check if it is the one that you want to be loaded
  179.     _hasCargoLoaded = _target getVariable ["hasCargoLoaded", false];
  180.     if (_hasCargoLoaded) exitwith {
  181.         cutText [format ["%1 is full!", (typeOf _target)],"PLAIN"];
  182.     };
  183.     _NearestCargoList = (nearestObjects [_target, ["ReammoBox_F"], 10]);
  184.     _NearestCargoItem = (_NearestCargoList) Select 0; // Add the nearest object to define variable before forEach
  185.     if ((count _NearestCargoList) == 0) exitwith {
  186.         cutText [format ["There is nothing near to load"], "PLAIN"];
  187.     };
  188.     {
  189.         _isNearestSelected =    _x getVariable ["isSelected", false];
  190.         _isNearestAttached =    _x getVariable ["isAttached", false];
  191.         _isNearestLoaded =      _x getVariable ["isLoaded", false];
  192.         _NearestCargoItem =     _x;
  193.         if (_isNearestLoaded) exitwith {
  194.             systemchat format ["%1 is already loaded", (typeOf _NearestCargoItem)];
  195.         };
  196.         if (_isNearestAttached) exitwith {
  197.             systemchat format ["%1 is already attached", (typeOf _NearestCargoItem)];
  198.         };
  199.         if (_isNearestSelected) exitwith {
  200.             systemchat format ["%1 will be loaded", (typeOf _NearestCargoItem)];
  201.             _NearestCargoItem setVariable ["isAttached", true, true];
  202.             _NearestCargoItem setVariable ["isSelected", false, true];
  203.             _NearestCargoItem setVariable ["isLoaded", true, true];
  204.             _NearestCargoItem attachTo [_target, [0,-1,0]];
  205.             _target setVariable ["hasCargoLoaded", true, true];
  206.         };
  207.     } forEach _NearestCargoList;
  208.     _hasCargoLoaded = _target getVariable ["hasCargoLoaded", false];
  209.     _isNearestSelected = _NearestCargoItem getVariable ["isSelected", false]; // Just to throw an error if nothing was selected
  210.     if ((!_isNearestSelected) && !_hasCargoLoaded) exitwith {
  211.         cutText [format ["There was nothing selected"], "PLAIN"];
  212.     };
  213.     systemchat format ["Endresult: %1, %2, %3, %4, %5, %6", (typeOf _NearestCargoItem), _isSelected, _isAttached, _isLoaded, _hasCargoLoaded, (count _NearestCargoList)];
  214. };
  215.  
  216. VZ_LOG_UnloadCargo = { // Unload the Cargo and reset its state
  217.     _hasCargoLoaded = _target getVariable ["hasCargoLoaded", false];
  218.     if (!_hasCargoLoaded) exitwith {
  219.         cutText [format ["%1 has no cargo loaded!", (typeOf _target)], "PLAIN"];
  220.     };
  221.    
  222.     if (_hasCargoLoaded) then {
  223.         _unloadCargoDir = getDir _target;
  224.         _unloadCargoPos = _target getPos [-6, _unloadCargoDir];
  225.         {
  226.             detach _x;
  227.             _x setVelocity [0, 0, 0.2];
  228.             _x setPos _unloadCargoPos;
  229.             _x setVariable ["isSelected", false, true];
  230.             _x setVariable ["isAttached", false, true];
  231.             _x setVariable ["isLoaded", false, true];
  232.         } forEach attachedObjects _target; // Might be handy if more than one Item is attached
  233.         _target setVariable ["hasCargoLoaded", false, true];
  234.         _hasCargoLoaded = _target getVariable "hasCargoLoaded";
  235.         cutText [format ["%1 unloading cargo...", (typeOf _target)], "PLAIN"];
  236.     };
  237. };
  238.  
  239. _actionCargoCategory = ["VZ_Logistics", "Logistics", "", {}, {true}] call ACE_interact_menu_fnc_createAction; // Create Category
  240. _actionSelectCargo = ["VZ_SelectCargo", "Load into", "", {[_target] call VZ_LOG_SelectCargo;}, {true}] call ACE_interact_menu_fnc_createAction; // Create Select Cargo to Load Action
  241. _actionLoadCargo = ["VZ_LoadCargo", "Load Selected Cargo", "", {[_target] call VZ_LOG_LoadCargo;}, {true}] call ACE_interact_menu_fnc_createAction; // Create Load Cargo Action
  242. _actionUnloadCargo = ["VZ_UnloadCargo", "UnLoad Cargo", "", {[_target] call VZ_LOG_UnloadCargo;}, {true}] call ACE_interact_menu_fnc_createAction; // Create UnLoad Cargo Action
  243. _actionCargoCheck = ["VZ_CheckCargo", "Check Variables", "", {[_target] call VZ_LOG_Check;}, {true}] call ACE_interact_menu_fnc_createAction; // Create Check Variables
  244.  
  245. ["All", 0, ["ACE_MainActions"], _actionCargoCategory, true] call ACE_interact_menu_fnc_addActionToClass; // Add Category
  246. ["ReammoBox_F", 0, ["ACE_MainActions", "VZ_Logistics"], _actionSelectCargo, true] call ACE_interact_menu_fnc_addActionToClass; // Add Load Cargo Action to Supply Boxes
  247. ["Car", 0, ["ACE_MainActions", "VZ_Logistics"], _actionLoadCargo, true] call ACE_interact_menu_fnc_addActionToClass; // Add UnLoad Cargo Action to Vehicles
  248. ["Car", 0, ["ACE_MainActions", "VZ_Logistics"], _actionUnloadCargo, true] call ACE_interact_menu_fnc_addActionToClass; // Add UnLoad Cargo Action to Vehicles
  249. ["All", 0, ["ACE_MainActions", "VZ_Logistics"], _actionCargoCheck, true] call ACE_interact_menu_fnc_addActionToClass; // Add Check Variables
Advertisement
RAW Paste Data Copied
Advertisement