diff --git a/Sources/epoch_code/compile/functions/EPOCH_fnc_addMagazineOverflow.sqf b/Sources/epoch_code/compile/functions/EPOCH_fnc_addMagazineOverflow.sqf new file mode 100644 index 00000000..524355f2 --- /dev/null +++ b/Sources/epoch_code/compile/functions/EPOCH_fnc_addMagazineOverflow.sqf @@ -0,0 +1,60 @@ +/* + Author: Aaron Clark - EpochMod.com + + Contributors: DirtySanchez + + Description: + Epoch add magazine with overflow toggle + + Licence: + Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike + + Github: + https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/functions/EPOCH_fnc_addMagazineOverflow.sqf + + Example: + [_mag,_magAmmo,true] call EPOCH_fnc_addMagazineOverflow; + + Parameter(s): + _this select 0: STRING - Magazine Class + _this select 1: NUMBER - (Optional) Ammo count + _this select 2: BOOLEAN - (Optional) drop to groundWeaponHolder + + Returns: + NUMBER 1: magazine was added to inventory + 2: not enough room in inventory + 3: magazine was dropped nearby + 0: failed +*/ +//[[[cog import generate_private_arrays ]]] +private ["_return","_nearByHolder","_wH","_wHPos"]; +//[[[end]]] +params [["_item","",[""]],["_count",1],["_canDrop",true]]; +_return = 0; +if (player canAdd _item) then { + player addMagazine [_item,_count]; + _return = 1; +} else { + _return = 3; + if(_canDrop)then{ + _wH = objNull; + if (isNil "_nearByHolder") then { + _nearByHolder = nearestObjects [player,["groundWeaponHolder"],3]; + }; + if (_nearByHolder isEqualTo []) then { + _wHPos = player modelToWorld [0,1,0]; + if (surfaceIsWater _wHPos) then { + _wHPos = ASLToATL _wHPos; + }; + _wH = createVehicle ["groundWeaponHolder",_wHPos, [], 0, "CAN_COLLIDE"]; + } else { + _wH = _nearByHolder select 0; + }; + if !(isNull _wh) then { + //_wh addItemCargoGlobal [_item,1]; + _wh addMagazineAmmoCargo [_item, 1, _count]; + }; + _return = 2; + }; +}; +_return diff --git a/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeCommanderAmmo.sqf b/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeCommanderAmmo.sqf index 8fe0f45d..0cebc4f8 100644 --- a/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeCommanderAmmo.sqf +++ b/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeCommanderAmmo.sqf @@ -33,7 +33,16 @@ if(_magAmmo isEqualTo 0)exitWith{ [format["The %1 does not have any ammo",_nameTurret],5] call Epoch_message; }; -[format["You have removed 1 can of %1 with %2 rounds",_magsTurret, _magAmmo],5] call Epoch_message; -player addMagazine [_magsTurret,_magAmmo]; +_return = [_magsTurret,_magAmmo] call EPOCH_fnc_addMagazineOverflow; +if(_return isEqualTo 0)exitWith{diag_log "[EpochDebug] removeCommanderAmmo _return epoch_equip failed"}; +if(_return isEqualTo 1)then{ + [format["You have removed 1 can of %1 with %2 rounds",_magsTurret, _magAmmo],5] call Epoch_message; +}; +if(_return isEqualTo 2)then{ + [format["You dropped 1 can of %1 with %2 rounds on the ground!",_magsTurret, _magAmmo],5] call Epoch_message; +}; +if(_return isEqualTo 3)then{ + [format["You dont have enough space for %1!",_magsTurret],5] call Epoch_message; +}; vehicle player removeMagazineTurret [_magsTurret,_turretPath]; reload vehicle player; \ No newline at end of file diff --git a/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeTurretAmmo.sqf b/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeTurretAmmo.sqf index f8883c25..5b78fdcd 100644 --- a/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeTurretAmmo.sqf +++ b/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeTurretAmmo.sqf @@ -24,7 +24,17 @@ if(_magsTurretDetails isEqualTo [])exitWith{ private _magsTurret = (_magsTurretDetails select 0) select 0; private _magAmmo = (_magsTurretDetails select 0) select 1; -[format["You have removed 1 can of %1 with %2 rounds",_magsTurret, _magAmmo],5] call Epoch_message; -player addMagazine [_magsTurret,_magAmmo]; + +_return = [_magsTurret,_magAmmo] call EPOCH_fnc_addMagazineOverflow; +if(_return isEqualTo 0)exitWith{diag_log "[EpochDebug] removeCommanderAmmo _return epoch_equip failed"}; +if(_return isEqualTo 1)then{ + [format["You have removed 1 can of %1 with %2 rounds",_magsTurret, _magAmmo],5] call Epoch_message; +}; +if(_return isEqualTo 2)then{ + [format["You dropped 1 can of %1 with %2 rounds on the ground!",_magsTurret, _magAmmo],5] call Epoch_message; +}; +if(_return isEqualTo 3)then{ + [format["You dont have enough space for %1!",_magsTurret],5] call Epoch_message; +}; vehicle player removeMagazineTurret [_magsTurret,_turretPath]; reload vehicle player; \ No newline at end of file diff --git a/Sources/epoch_config/Configs/CfgClientFunctions.hpp b/Sources/epoch_config/Configs/CfgClientFunctions.hpp index 786f23fc..d652ccd2 100644 --- a/Sources/epoch_config/Configs/CfgClientFunctions.hpp +++ b/Sources/epoch_config/Configs/CfgClientFunctions.hpp @@ -117,6 +117,7 @@ class CfgClientFunctions class fnc_isInsideBuilding {}; class fnc_findSafePos {}; class fnc_addItemOverflow {}; + class fnc_addMagazineOverflow {}; class itemData {}; class itemPicture {}; class itemDisplayName {};