kerbo_

lootHoover.sqf

Apr 2nd, 2024 (edited)
3,152
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 6.21 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 _magicBoxClass = "Box_IND_Wps_F";
  10. private _magicBox = nearestObject [player, _magicBoxClass];  
  11. if(_magicBox == objNull or typeOf _magicBox == "") then {
  12.   // create empty crate  
  13.   _magicBox = createVehicle[_magicBoxClass, position player, [], 0, "NONE"];  
  14.   _magicBox allowDamage false;
  15.   clearWeaponCargoGlobal _magicBox;  
  16.   clearMagazineCargoGlobal _magicBox;
  17.   clearItemCargoGlobal _magicBox;
  18.   clearBackpackCargoGlobal _magicBox;
  19.   _magicBox call A3A_Logistics_fnc_addLoadAction;
  20.   _magicBox addAction [localize "STR_A3A_fn_base_flagaction_asset_move", A3A_fnc_carryItem, nil, 1.5, false, true, "", "!(call A3A_fnc_isCarrying)", 4];
  21. };
  22. private _targets = nearestObjects [getPosATL _magicBox, ["Man"], _maxDistance];  
  23. private _weaponHolders = nearestObjects [getPosATL _magicBox, ["WeaponHolder", "WeaponHolderSimulated", _lootCrateClass], _maxDistance];
  24. private _countBodies = 0;  
  25. private _countContainers = 0;  
  26.  
  27. private _lootWeapons = {  
  28. params ["_weaponItemsArray", "_container"];  
  29.  _container addWeaponWithAttachmentsCargoGlobal [_weaponItemsArray, 1];  
  30. };  
  31.  
  32. private _lootBodies = {  
  33. params ["_lootable", "_container"];  
  34.  
  35.  if (_lootable isKindOf "CAManBase") then  
  36.  {  
  37.   // Get HashMap of target loadout  
  38.   private _loadout = getUnitLoadout _lootable;  
  39.   _loadout = createHashMapFromArray [["primaryWeapon", _loadout select 0],  
  40.  ["secondaryWeapon", _loadout select 1],  
  41.  ["handgunWeapon", _loadout select 2],  
  42.  ["uniform", _loadout select 3],  
  43.  ["vest", _loadout select 4],  
  44.  ["backpack", _loadout select 5],  
  45.  ["helmet", _loadout select 6],  
  46.  ["faceWear", _loadout select 7],  
  47.  ["binoculars", _loadout select 8],  
  48.  ["items", _loadout select 9]];  
  49.   {  
  50.    // systemChat format ["Processing %1: %2", _x, _y];  
  51.    if (_y isNotEqualTo []) then  
  52.    {  
  53.  switch (_x) do  
  54.  {  
  55.   case "binoculars";  
  56.   case "primaryWeapon";  
  57.   case "secondaryWeapon";  
  58.   case "handgunWeapon":  
  59.   {  
  60.    [_y, _container] call _lootWeapons;  
  61.    _loadout set [_x, []];  
  62.   };  
  63.   // Break out items from these containers  
  64.   case "uniform";  
  65.   case "vest";  
  66.   case "backpack":  
  67.   {  
  68.    {  
  69.  switch (count _x) do  
  70.  {  
  71.   case 2:  
  72.   {  
  73.    _container addItemCargoGlobal _x;  
  74.   };  
  75.   case 3:  
  76.   {  
  77.    _container addMagazineAmmoCargo _x;  
  78.   };  
  79.   default  
  80.   {  
  81.   systemChat format ["ERROR: not sure how to handle %1", _x];  
  82.   };  
  83.  };  
  84.    } forEach (_y select 1);  
  85.    if (_x isEqualTo "vest") then  
  86.    {  
  87.  _container addItemCargoGlobal [_y select 0, 1];  
  88.    };  
  89.    if (_x isEqualTo "backpack") then  
  90.    {  
  91.  _container addBackpackCargoGlobal [_y select 0, 1];  
  92.    };  
  93.    if (_x isEqualTo "uniform") then  
  94.    {  
  95.  // Don't take the uniform  
  96.  // Keep your pants on, my guy  
  97.  _loadout set [_x, [_y select 0, []]];  
  98.    }  
  99.    else  
  100.    {  
  101.  _loadout set [_x, []];  
  102.    };  
  103.   };  
  104.   case "helmet":  
  105.   {  
  106.    _container addItemCargoGlobal [_y, 1];  
  107.    _loadout set [_x, ""];  
  108.   };  
  109.   case "faceWear":  
  110.   {  
  111.    // Do nothing, because we don't want to loot faceWear  
  112.   };  
  113.   case "items":  
  114.   {  
  115.    {  
  116.  if !(_x isEqualTo "") then  
  117.  {  
  118.   _container addItemCargoGlobal [_x, 1];  
  119.  };  
  120.    } forEach (_y);  
  121.    _loadout set [_x, ["", "", "", "", "", ""]];  
  122.   };  
  123.   default  
  124.   {  
  125.    // All the cases should be handled, but just in case  
  126.   systemChat format ["ERROR: Not sure how to handle %1", _x];  
  127.   };  
  128.  };  
  129.    }  
  130.    else  
  131.    {  
  132.  // Empty slot, so nothing to do here  
  133.    };  
  134.   } forEach _loadout;  
  135.  
  136.   // Push the fleeced loadout back to the unit  
  137.   // Has to be a Unit Loadout Array, yuck  
  138.   _loadout = [_loadout get "primaryWeapon",  
  139.   _loadout get "secondaryWeapon",  
  140.   _loadout get "handgunWeapon",  
  141.   _loadout get "uniform",  
  142.   _loadout get "vest",  
  143.   _loadout get "backpack",  
  144.   _loadout get "helmet",  
  145.   _loadout get "facewear",  
  146.   _loadout get "binoculars",  
  147.   _loadout get "items"];  
  148.   _lootable setUnitLoadout _loadout;  
  149.   private _looted = _lootable getVariable ["LootTaken", false];  
  150.   if(!_looted) then {  
  151.    _countBodies = _countBodies + 1;  
  152.    _lootable setVariable ["LootTaken", true, true];  
  153.    if(_placeFlag) then { createVehicle[_flagClass, position _lootable, [], 0, "NONE"]; };  
  154.   };  
  155.  } else {  
  156.   // Loot containers in container  
  157.   {  
  158.    private _subContainer = _x select 1;  
  159.    {  
  160.  [_x, _container] call _lootWeapons;  
  161.    } forEach weaponsItemsCargo _subContainer;  
  162.    {  
  163.  _container addItemCargoGlobal [_x, 1];  
  164.    } forEach itemCargo _subContainer;  
  165.    {  
  166.  _container addMagazineAmmoCargo [_x select 0, 1, _x select 1];  
  167.    } forEach magazinesAmmoCargo _subContainer;  
  168.   } forEach everyContainer _lootable;  
  169.   {  
  170.    [_x, _container] call _lootWeapons;  
  171.   } forEach weaponsItemsCargo _lootable;  
  172.   // Items include other containers like uniforms and vests  
  173.   {  
  174.    _container addItemCargoGlobal [_x, 1];  
  175.   } forEach itemCargo _lootable;  
  176.   // Backpacks aren't considered itemCargo; add them now  
  177.   {  
  178.    _container addBackpackCargoGlobal [_x, 1];  
  179.   } forEach backpackCargo _lootable;  
  180.   {  
  181.    _container addMagazineAmmoCargo [_x select 0, 1, _x select 1];  
  182.   } forEach magazinesAmmoCargo _lootable;  
  183.  
  184.   // Cleanse the fleeced container  
  185.   clearWeaponCargoGlobal _lootable;  
  186.   clearItemCargoGlobal _lootable;  
  187.   clearBackpackCargoGlobal _lootable;  
  188.   clearMagazineCargoGlobal _lootable;  
  189.  
  190.   private _looted = _lootable getVariable ["LootTaken", false];  
  191.   if(!_looted) then {  
  192.    _countContainers = _countContainers + 1;  
  193.    _lootable setVariable ["LootTaken", true, true];  
  194.   };  
  195.  };  
  196. };  
  197.  
  198. _targets = _targets select {!alive _x};  
  199. {[_x, _magicBox] call _lootBodies} forEach _targets;  
  200. {[_x, _magicBox] call _lootBodies} forEach _weaponHolders;  
  201. systemChat format ["Looted %1 bodies and %2 containers", _countBodies, _countContainers];  
  202. _countBodies + _countContainers;
Advertisement
Comments
  • deltafrost22
    1 year
    # 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_
      1 year
      # 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