Advertisement
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 _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;
- // The Box_IND_Support_F class crate doesn't support loading
- //_magicBox call A3A_Logistics_fnc_addLoadAction;
- //[_magicBox , "load"] remoteExec ["A3A_Logistics_fnc_addAction", 0, _magicBox];
- // This function is no longer exposed?
- //_magicBox call A3A_fnc_initMovableObject;
- };
- if(_magicBox == objNull or typeOf _magicBox == "") exitWith {
- systemChat "Loot box could not be created";
- };
- 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
Add Comment
Please, Sign In to add comment
Advertisement