Advertisement
kerbo_

lootHoover.sqf

Apr 2nd, 2024 (edited)
1,666
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 6.57 KB | None | 0 0
  1. // Get all the lootz and put it in a crate  
  2. // For use with Antistasi when you just can't be bothered  
  3. // Twitter: @Kerbo_  
  4. private _maxDistance = 20000;  
  5. private _flagClass = "FlagMarker_01_F";  
  6. private _placeFlag = false;  
  7. private _lootCrateClass = "Box_IND_Wps_F";  
  8. private _magicBoxClass = "Box_IND_Support_F";  
  9. private _magicBox = nearestObject [player, _magicBoxClass];  
  10. if(_magicBox == objNull or typeOf _magicBox == "") then {  
  11.   // create empty crate  
  12.   _magicBox = createVehicle[_magicBoxClass, position player, [], 0, "NONE"];  
  13.   _magicBox allowDamage false;  
  14.   clearWeaponCargoGlobal _magicBox;  
  15.   clearMagazineCargoGlobal _magicBox;  
  16.   clearItemCargoGlobal _magicBox;  
  17.   clearBackpackCargoGlobal _magicBox;
  18.   // The Box_IND_Support_F class crate doesn't support loading
  19.   //_magicBox call A3A_Logistics_fnc_addLoadAction;
  20.   //[_magicBox , "load"] remoteExec ["A3A_Logistics_fnc_addAction", 0, _magicBox];
  21.  
  22.   // This function is no longer exposed?
  23.   //_magicBox call A3A_fnc_initMovableObject;
  24. };
  25. if(_magicBox == objNull or typeOf _magicBox == "") exitWith {
  26.   systemChat "Loot box could not be created";
  27. };
  28.  
  29. private _targets = nearestObjects [getPosATL _magicBox, ["Man"], _maxDistance];  
  30. private _weaponHolders = nearestObjects [getPosATL _magicBox, ["WeaponHolder", "WeaponHolderSimulated", _lootCrateClass], _maxDistance];  
  31. private _countBodies = 0;  
  32. private _countContainers = 0;  
  33.    
  34. private _lootWeapons = {  
  35. params ["_weaponItemsArray", "_container"];  
  36.  _container addWeaponWithAttachmentsCargoGlobal [_weaponItemsArray, 1];  
  37. };  
  38.    
  39. private _lootBodies = {  
  40. params ["_lootable", "_container"];  
  41.    
  42.  if (_lootable isKindOf "CAManBase") then  
  43.  {  
  44.   // Get HashMap of target loadout  
  45.   private _loadout = getUnitLoadout _lootable;  
  46.   _loadout = createHashMapFromArray [["primaryWeapon", _loadout select 0],  
  47.  ["secondaryWeapon", _loadout select 1],  
  48.  ["handgunWeapon", _loadout select 2],  
  49.  ["uniform", _loadout select 3],  
  50.  ["vest", _loadout select 4],  
  51.  ["backpack", _loadout select 5],  
  52.  ["helmet", _loadout select 6],  
  53.  ["faceWear", _loadout select 7],  
  54.  ["binoculars", _loadout select 8],  
  55.  ["items", _loadout select 9]];  
  56.   {  
  57.    // systemChat format ["Processing %1: %2", _x, _y];  
  58.    if (_y isNotEqualTo []) then  
  59.    {  
  60.  switch (_x) do  
  61.  {  
  62.   case "binoculars";  
  63.   case "primaryWeapon";  
  64.   case "secondaryWeapon";  
  65.   case "handgunWeapon":  
  66.   {  
  67.    [_y, _container] call _lootWeapons;  
  68.    _loadout set [_x, []];  
  69.   };  
  70.   // Break out items from these containers  
  71.   case "uniform";  
  72.   case "vest";  
  73.   case "backpack":  
  74.   {  
  75.    {  
  76.  switch (count _x) do  
  77.  {  
  78.   case 2:  
  79.   {  
  80.    _container addItemCargoGlobal _x;  
  81.   };  
  82.   case 3:  
  83.   {  
  84.    _container addMagazineAmmoCargo _x;  
  85.   };  
  86.   default  
  87.   {  
  88.   systemChat format ["ERROR: not sure how to handle %1", _x];  
  89.   };  
  90.  };  
  91.    } forEach (_y select 1);  
  92.    if (_x isEqualTo "vest") then  
  93.    {  
  94.  _container addItemCargoGlobal [_y select 0, 1];  
  95.    };  
  96.    if (_x isEqualTo "backpack") then  
  97.    {  
  98.  _container addBackpackCargoGlobal [_y select 0, 1];  
  99.    };  
  100.    if (_x isEqualTo "uniform") then  
  101.    {  
  102.  // Don't take the uniform  
  103.  // Keep your pants on, my guy  
  104.  _loadout set [_x, [_y select 0, []]];  
  105.    }  
  106.    else  
  107.    {  
  108.  _loadout set [_x, []];  
  109.    };  
  110.   };  
  111.   case "helmet":  
  112.   {  
  113.    _container addItemCargoGlobal [_y, 1];  
  114.    _loadout set [_x, ""];  
  115.   };  
  116.   case "faceWear":  
  117.   {  
  118.    // Do nothing, because we don't want to loot faceWear  
  119.   };  
  120.   case "items":  
  121.   {  
  122.    {  
  123.  if !(_x isEqualTo "") then  
  124.  {  
  125.   _container addItemCargoGlobal [_x, 1];  
  126.  };  
  127.    } forEach (_y);  
  128.    _loadout set [_x, ["", "", "", "", "", ""]];  
  129.   };  
  130.   default  
  131.   {  
  132.    // All the cases should be handled, but just in case  
  133.   systemChat format ["ERROR: Not sure how to handle %1", _x];  
  134.   };  
  135.  };  
  136.    }  
  137.    else  
  138.    {  
  139.  // Empty slot, so nothing to do here  
  140.    };  
  141.   } forEach _loadout;  
  142.    
  143.   // Push the fleeced loadout back to the unit  
  144.   // Has to be a Unit Loadout Array, yuck  
  145.   _loadout = [_loadout get "primaryWeapon",  
  146.   _loadout get "secondaryWeapon",  
  147.   _loadout get "handgunWeapon",  
  148.   _loadout get "uniform",  
  149.   _loadout get "vest",  
  150.   _loadout get "backpack",  
  151.   _loadout get "helmet",  
  152.   _loadout get "facewear",  
  153.   _loadout get "binoculars",  
  154.   _loadout get "items"];  
  155.   _lootable setUnitLoadout _loadout;  
  156.   private _looted = _lootable getVariable ["LootTaken", false];  
  157.   if(!_looted) then {  
  158.    _countBodies = _countBodies + 1;  
  159.    _lootable setVariable ["LootTaken", true, true];  
  160.    if(_placeFlag) then { createVehicle[_flagClass, position _lootable, [], 0, "NONE"]; };  
  161.   };  
  162.  } else {  
  163.   // Loot containers in container  
  164.   {  
  165.    private _subContainer = _x select 1;  
  166.    {  
  167.  [_x, _container] call _lootWeapons;  
  168.    } forEach weaponsItemsCargo _subContainer;  
  169.    {  
  170.  _container addItemCargoGlobal [_x, 1];  
  171.    } forEach itemCargo _subContainer;  
  172.    {  
  173.  _container addMagazineAmmoCargo [_x select 0, 1, _x select 1];  
  174.    } forEach magazinesAmmoCargo _subContainer;  
  175.   } forEach everyContainer _lootable;  
  176.   {  
  177.    [_x, _container] call _lootWeapons;  
  178.   } forEach weaponsItemsCargo _lootable;  
  179.   // Items include other containers like uniforms and vests  
  180.   {  
  181.    _container addItemCargoGlobal [_x, 1];  
  182.   } forEach itemCargo _lootable;  
  183.   // Backpacks aren't considered itemCargo; add them now  
  184.   {  
  185.    _container addBackpackCargoGlobal [_x, 1];  
  186.   } forEach backpackCargo _lootable;  
  187.   {  
  188.    _container addMagazineAmmoCargo [_x select 0, 1, _x select 1];  
  189.   } forEach magazinesAmmoCargo _lootable;  
  190.    
  191.   // Cleanse the fleeced container  
  192.   clearWeaponCargoGlobal _lootable;  
  193.   clearItemCargoGlobal _lootable;  
  194.   clearBackpackCargoGlobal _lootable;  
  195.   clearMagazineCargoGlobal _lootable;  
  196.    
  197.   private _looted = _lootable getVariable ["LootTaken", false];  
  198.   if(!_looted) then {  
  199.    _countContainers = _countContainers + 1;  
  200.    _lootable setVariable ["LootTaken", true, true];  
  201.   };  
  202.  };  
  203. };  
  204.    
  205. _targets = _targets select {!alive _x};  
  206. {[_x, _magicBox] call _lootBodies} forEach _targets;  
  207. {[_x, _magicBox] call _lootBodies} forEach _weaponHolders;  
  208. systemChat format ["Looted %1 bodies and %2 containers", _countBodies, _countContainers];  
  209. _countBodies + _countContainers;
Advertisement
Comments
  • deltafrost22
    224 days
    # text 0.19 KB | 0 0
    1. Pardon my ignorance, but how do I go about implementing this into my Antistasi gameplay? Do I just type it into the debug menu or do I need to create the sqf file and drop it in a folder somewhere?
    • kerbo_
      224 days
      # text 0.22 KB | 1 0
      1. Yes, you would paste it into the debug console like any other code you want to run. I use this mod which gives more options for editing, saving, running code: https://steamcommunity.com/sharedfiles/filedetails/?id=2369477168
Add Comment
Please, Sign In to add comment
Advertisement