Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // get all the lootz and put it in a crate
- // For use with Antistasi when you just can't be bothered
- // Twitter: @Kerbo_
- private _maxDistance = 20000;
- private _flagClass = "FlagMarker_01_F";
- private _placeFlag = false;
- private _lootCrateClass = "Box_IND_Wps_F";
- private _magicBoxClass = "Box_IND_Support_F";
- // private _magicBoxClass = "Box_IND_Wps_F";
- private _magicBox = nearestObject [player, _magicBoxClass];
- if (_magicBox == objNull or typeOf _magicBox == "") then {
- // create empty crate
- _magicBox = createVehicle[_magicBoxClass, position player, [], 0, "NONE"];
- _magicBox allowDamage false;
- clearWeaponCargoGlobal _magicBox;
- clearMagazineCargoGlobal _magicBox;
- clearItemCargoGlobal _magicBox;
- clearBackpackCargoGlobal _magicBox;
- _magicBox call A3A_Logistics_fnc_addLoadAction;
- _magicBox addAction [localize "STR_A3A_fn_base_flagaction_asset_move", A3A_fnc_carryItem, nil, 1.5, false, true, "", "!(call A3A_fnc_isCarrying)", 4];
- };
- private _targets = nearestObjects [getPosATL _magicBox, ["Man"], _maxDistance];
- private _weaponHolders = nearestObjects [getPosATL _magicBox, ["WeaponHolder", "WeaponHolderSimulated", _lootCrateClass], _maxDistance];
- private _countBodies = 0;
- private _countContainers = 0;
- private _lootWeapons = {
- params ["_weaponItemsArray", "_container"];
- _container addWeaponWithAttachmentsCargoGlobal [_weaponItemsArray, 1];
- };
- private _lootBodies = {
- params ["_lootable", "_container"];
- if (_lootable isKindOf "CAManBase") then {
- // get HashMap of target loadout
- private _loadout = getUnitLoadout _lootable;
- _loadout = createHashMapFromArray [["primaryWeapon", _loadout select 0],
- ["secondaryWeapon", _loadout select 1],
- ["handgunWeapon", _loadout select 2],
- ["uniform", _loadout select 3],
- ["vest", _loadout select 4],
- ["backpack", _loadout select 5],
- ["helmet", _loadout select 6],
- ["faceWear", _loadout select 7],
- ["binoculars", _loadout select 8],
- ["items", _loadout select 9]];
- {
- // systemChat format ["Processing %1: %2", _x, _y];
- if (_y isNotEqualTo []) then {
- switch (_x) do
- {
- case "binoculars";
- case "primaryWeapon";
- case "secondaryWeapon";
- case "handgunWeapon":
- {
- [_y, _container] call _lootWeapons;
- _loadout set [_x, []];
- };
- // break out items from these containers
- case "uniform";
- case "vest";
- case "backpack":
- {
- {
- switch (count _x) do
- {
- case 2:
- {
- _container addItemCargoGlobal _x;
- };
- case 3:
- {
- _container addMagazineAmmoCargo _x;
- };
- default
- {
- systemChat format ["ERROR: not sure how to handle %1", _x];
- };
- };
- } forEach (_y select 1);
- if (_x isEqualTo "vest") then {
- _container addItemCargoGlobal [_y select 0, 1];
- };
- if (_x isEqualTo "backpack") then {
- _container addBackpackCargoGlobal [_y select 0, 1];
- };
- if (_x isEqualTo "uniform") then {
- // Don't take the uniform
- // Keep your pants on, my guy
- _loadout set [_x, [_y select 0, []]];
- } else {
- _loadout set [_x, []];
- };
- };
- case "helmet":
- {
- _container addItemCargoGlobal [_y, 1];
- _loadout set [_x, ""];
- };
- case "faceWear":
- {
- // Do nothing, because we don't want to loot faceWear
- };
- case "items":
- {
- {
- if !(_x isEqualTo "") then
- {
- _container addItemCargoGlobal [_x, 1];
- };
- } forEach (_y);
- _loadout set [_x, ["", "", "", "", "", ""]];
- };
- default
- {
- // All the cases should be handled, but just in case
- systemChat format ["ERROR: Not sure how to handle %1", _x];
- };
- };
- } else {
- // Empty slot, so nothing to do here
- };
- } forEach _loadout;
- // Push the fleeced loadout back to the unit
- // Has to be a Unit Loadout Array, yuck
- _loadout = [_loadout get "primaryWeapon",
- _loadout get "secondaryWeapon",
- _loadout get "handgunWeapon",
- _loadout get "uniform",
- _loadout get "vest",
- _loadout get "backpack",
- _loadout get "helmet",
- _loadout get "facewear",
- _loadout get "binoculars",
- _loadout get "items"];
- _lootable setUnitLoadout _loadout;
- private _looted = _lootable getVariable ["LootTaken", false];
- if (!_looted) then {
- _countBodies = _countBodies + 1;
- _lootable setVariable ["LootTaken", true, true];
- if (_placeFlag) then {
- createVehicle[_flagClass, position _lootable, [], 0, "NONE"];
- };
- };
- } else {
- // Loot containers in container
- {
- private _subContainer = _x select 1;
- {
- [_x, _container] call _lootWeapons;
- } forEach weaponsItemsCargo _subContainer;
- {
- _container addItemCargoGlobal [_x, 1];
- } forEach itemCargo _subContainer;
- {
- _container addMagazineAmmoCargo [_x select 0, 1, _x select 1];
- } forEach magazinesAmmoCargo _subContainer;
- } forEach everyContainer _lootable;
- {
- [_x, _container] call _lootWeapons;
- } forEach weaponsItemsCargo _lootable;
- // items include other containers like uniforms and vests
- {
- _container addItemCargoGlobal [_x, 1];
- } forEach itemCargo _lootable;
- // Backpacks aren't considered itemCargo; add them now
- {
- _container addBackpackCargoGlobal [_x, 1];
- } forEach backpackCargo _lootable;
- {
- _container addMagazineAmmoCargo [_x select 0, 1, _x select 1];
- } forEach magazinesAmmoCargo _lootable;
- // Cleanse the fleeced container
- clearWeaponCargoGlobal _lootable;
- clearItemCargoGlobal _lootable;
- clearBackpackCargoGlobal _lootable;
- clearMagazineCargoGlobal _lootable;
- private _looted = _lootable getVariable ["LootTaken", false];
- if (!_looted) then {
- _countContainers = _countContainers + 1;
- _lootable setVariable ["LootTaken", true, true];
- };
- };
- };
- _targets = _targets select {
- !alive _x
- };
- {
- [_x, _magicBox] call _lootBodies
- } forEach _targets;
- {
- [_x, _magicBox] call _lootBodies
- } forEach _weaponHolders;
- systemChat format ["Looted %1 bodies and %2 containers", _countBodies, _countContainers];
- _countBodies + _countContainers;
Advertisement
Comments
-
- 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?
-
- 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
-
- Hey,
- So I have been playing around with this script and have noticed that if you run the hoover, then run it again, it just deletes everything from the first collection? I am certain that the last time I used it, it grabbed everything from the first box and didn't just delete it?
- It seems to be grabbing the same box (if it can find it near the player?) so I am guessing it is clearing that box of its contents before the find loot part actually runs? Is there anyway to make it spawn and fill a new one each time? That way it would grab out of the first loot hoover box and put it in the second.
- Also if you're interested:
- // WORLD WIDE LOOT HOOVER:
- // Tweaked by: SabreCodes
- // Twitter: @Kerbo_
- private _maxDistance = 20000;
- private _flagClass = "FlagMarker_01_F";
- private _placeFlag = false;
- private _lootCrateClass = "Box_IND_Wps_F";
- // private _magicBoxClass = "Box_IND_Support_F";
- private _magicBoxClass = "Box_IND_Wps_F";
- private _magicBox = nearestObject [player, _magicBoxClass];
- if (_magicBox == objNull or typeOf _magicBox == "") then {
- // create empty crate
- _magicBox call A3A_fnc_initObject;
- _magicBox call A3a_fnc_;
- _magicBox = createVehicle[_magicBoxClass, position player, [], 0, "NONE"];
- _magicBox allowDamage false;
- clearWeaponCargoGlobal _magicBox;
- clearMagazineCargoGlobal _magicBox;
- clearItemCargoGlobal _magicBox;
- clearBackpackCargoGlobal _magicBox;
- };
- Small change I made that makes it the normal Antistasi Loot Crate (Weapons box) with the same, carry, load loot to crate, load loot to vehicle, and load into vehicle. So you can use it to quickly gather all of the loot (I play solo so major time-saver!) but still have a box to potentially loose transporting it home!
-
- Hello,
- I don't see that behavior on my end using the script as is. In the edit you show you're using the same class for the hoover as the loot boxes. That will cause the behavior you're seeing. The main loop will treat the created hoover box as just another loot box. I specifically use another class for the hoover box so it doesn't get collected.
- -Kerbo
Add Comment
Please, Sign In to add comment