diff --git a/Server_Install_Pack/sc/battleye/scripts.txt b/Server_Install_Pack/sc/battleye/scripts.txt index d83e9baa..b11114fa 100644 --- a/Server_Install_Pack/sc/battleye/scripts.txt +++ b/Server_Install_Pack/sc/battleye/scripts.txt @@ -16,7 +16,7 @@ 5 allowDamage !="_unit allowDamage false;" !="_unit allowDamage true;" !="player allowDamage true;" !="vehicle player allowDamage true;" !="player allowDamage false;" !="_target allowDamage true;" !="_cargo allowDamage false;" 5 addWeaponCargo !="_acceptHolder addWeaponCargo [_wWeapon, 1] ;" !="CBA_fnc_addWeaponCargo" !="\\fnc_addWeaponCargo" !="\"addWeaponCargo" !="cba_fAddWeaponCargo" 5 onMapSingleClick !="onMapSingleClick '';" !="\"onmapsingleclick\"" -5 addMagazine !"addMagazineCargo" !="player addMagazine [_item, _magazineSizeMax];" !="player addMagazine [_item, floor (_magazineSize % _magazineSizeMax)];" !="player addMagazine[_x select 0, _x select 1];" !="player addMagazine \"sledge_swing\";" !="player addMagazine \"Hatchet_swing\";" !="player addMagazine \"stick_swing\";" !="_wh addMagazineAmmoCargo[_item, 1, _count];" !="CBA_fnc_addMagazine" !="\\fnc_addMagazine" !="\"addMagazine" +5 addMagazine !"addMagazineCargo" !="player addMagazine [_item, _magazineSizeMax];" !="player addMagazine [_item, floor (_magazineSize % _magazineSizeMax)];" !="player addMagazine[_x select 0, _x select 1];" !="player addMagazine \"sledge_swing\";" !="player addMagazine \"Hatchet_swing\";" !="player addMagazine \"stick_swing\";" !="_wh addMagazineAmmoCargo[_item, 1, _count];" !="CBA_fnc_addMagazine" !="\\fnc_addMagazine" !="\"addMagazine" !="vehicle player addMagazineTurret" !="player addMagazine [_magsTurret,_magAmmo]" 5 addMagazineCargo !="_dogHolder addMagazineCargo [\"RabbitCarcass_EPOCH\", 1]" !="_dogHolder addMagazineCargo [\"Pelt_EPOCH\", 1]" !="_dogHolder addMagazineCargo [\"Venom_EPOCH\", 1]" !="_dogHolder addMagazineCargo [\"SnakeCarcass_EPOCH\", 1]" !="_dogHolder addMagazineCargo [\"ChickenCarcass_EPOCH\", 1]" !="_acceptHolder addMagazineCargo [_wAmmo, 1] ;" !="CBA_fnc_addMagazineCargo" !="\\fnc_addMagazineCargo" !="\"addMagazineCargo" !="cba_fAddMagazineCargo" 5 addItem !="{player addItemToVest _x} forEach _vestItems;" !="player addItem _item;" !="_plyr addItemToVest _missionItem;" !="axeVIP addItemToVest _item;" !="_plyr addItemToVest _missionItem;" !="EPOCH_fnc_addItemOverflow" !="CBA_fnc_addItem" !="\\fnc_addItem" !="\"addItem" !="fnc_addItemCargo" !="wH = _nearByHolder select 0;\n};\nif !(isNull _wh) then {\n_wh addItemCargoGlobal [_item,1];\n};\n};\n};\n\n_fnc_findItemInContainers = " 5 addBackPack !="fnc_addBackpackCargo" 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_checkTurretAmmo.sqf b/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_checkTurretAmmo.sqf new file mode 100644 index 00000000..27aa764d --- /dev/null +++ b/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_checkTurretAmmo.sqf @@ -0,0 +1,39 @@ +/* + Author: DirtySanchez - ported from DonkeyPunch eXpoch http://DonkeyPunch.INFO + + Contributors: + + 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/vehicles/EPOCH_vehicle_checkTurretAmmo.sqf +*/ +params["_weaponTurret", "_turretPath"]; + +if(isNil {_weaponTurret})exitWith{diag_log "[EpochDebug] checkTurretAmmo _weaponTurret was nil"}; + +if(isNil {_turretPath})exitWith{diag_log "[EpochDebug] checkTurretAmmo _turretPath was nil"}; + +private _ammoCount = 0; +private _ammoTurret = getArray(configFile >> "CfgWeapons" >> _weaponTurret >> "magazines"); +private _items = magazines player; +private _availAmmo = _items arrayIntersect _ammoTurret; +if (count _availAmmo == 0) then +{ + [format["You need a can of %1 or any of its variants",_ammoTurret select 0],5] call Epoch_message; +} +else +{ + private _ammo = _availAmmo select 0; + private _magazinesAmmoFull = magazinesAmmoFull player; + { + if((_x select 0) isEqualTo _ammo) then { + _ammoCount = _x select 1; + _magazinesAmmoFull = []; + }; + }forEach _magazinesAmmoFull; + [format["You have added 1 can of %1 with %2 rounds",_ammo,_ammoCount],5] call Epoch_message; + vehicle player addMagazineTurret [_ammo,_turretPath,_ammoCount]; + player removeMagazine _ammo; +}; \ No newline at end of file diff --git a/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeCommanderAmmo.sqf b/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeCommanderAmmo.sqf new file mode 100644 index 00000000..0cebc4f8 --- /dev/null +++ b/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeCommanderAmmo.sqf @@ -0,0 +1,48 @@ +/* + + Author: DirtySanchez - ported from DonkeyPunch eXpoch http://DonkeyPunch.INFO + + Contributors: + + 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/vehicles/EPOCH_vehicle_removeCommanderAmmo.sqf +*/ +params["_weaponTurret", "_turretPath"]; + +if(isNil {_weaponTurret})exitWith{diag_log "[EpochDebug] removeCommanderAmmo _weaponTurret was nil"}; + +if(isNil {_turretPath})exitWith{diag_log "[EpochDebug] removeCommanderAmmo _turretPath was nil"}; + +private _magAmmo = 0; +private _magsTurret = ""; +private _ammoTurret = getArray(configFile >> "CfgWeapons" >> _weaponTurret >> "magazines"); +private _magsAllTurrets = magazinesAllTurrets vehicle player; +{ + if(_x select 0 in _ammoTurret)then{ + _magsTurret = _x select 0; + _magAmmo = _x select 2; + _magsAllTurrets = []; + }; +}forEach _magsAllTurrets; + +if(_magAmmo isEqualTo 0)exitWith{ + private _nameTurret = getText(configFile >> "CfgWeapons" >> _weaponTurret >> "displayName"); + [format["The %1 does not have any ammo",_nameTurret],5] call Epoch_message; +}; + +_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 new file mode 100644 index 00000000..5b78fdcd --- /dev/null +++ b/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeTurretAmmo.sqf @@ -0,0 +1,40 @@ +/* + + Author: DirtySanchez - ported from DonkeyPunch eXpoch http://DonkeyPunch.INFO + + Contributors: + + 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/vehicles/EPOCH_vehicle_removeTurretAmmo.sqf +*/ +params["_weaponTurret", "_turretPath"]; + +if(isNil {_weaponTurret})exitWith{diag_log "[EpochDebug] removeTurretAmmo _weaponTurret was nil"}; + +if(isNil {_turretPath})exitWith{diag_log "[EpochDebug] removeTurretAmmo _turretPath was nil"}; + +private _magsTurretDetails = magazinesAmmo vehicle player; +if(_magsTurretDetails isEqualTo [])exitWith{ + private _nameTurret = getText(configFile >> "CfgWeapons" >> _weaponTurret >> "displayName"); + [format["The %1 does not have any ammo",_nameTurret],5] call Epoch_message; +}; + +private _magsTurret = (_magsTurretDetails select 0) select 0; +private _magAmmo = (_magsTurretDetails select 0) select 1; + +_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/CfgActionMenu/CfgActionMenu_core.hpp b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_core.hpp index 44ea4652..06146273 100644 --- a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_core.hpp +++ b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_core.hpp @@ -32,6 +32,24 @@ class CfgActionMenu dyna_canAcceptTrade = "if (!(isNull EPOCH_pendingP2ptradeTarget) && alive EPOCH_pendingP2ptradeTarget) then {((EPOCH_pendingP2ptradeTarget isKindOf 'Man') && (dyna_cursorTarget isEqualTo EPOCH_pendingP2ptradeTarget))} else {false}"; dyna_locked = "locked dyna_cursorTarget in [2,3]"; dyna_lockedInVehicle = "locked vehicle player in [2,3]"; + + dyna_inDriver = "driver vehicle player == player"; + dyna_inTurret = "gunner vehicle player == player"; + dyna_inCommander = "player isEqualTo commander objectParent player"; + dyna_vehicleRoleEmpty = "((assignedVehicleRole player) isEqualTo [])"; + + dyna_blockTurrets = "['Horn', 'MiniCarHorn', 'SportCarHorn', 'TruckHorn2', 'TruckHorn', 'BikeHorn', 'CarHorn', 'TruckHorn3']"; + + dyna_weaponsTurret = "if!(dyna_vehicleRoleEmpty)then{(vehicle player) weaponsTurret ((assignedVehicleRole player) select 1)}else{nil}"; + dyna_weaponsTurretPath = "if(!isNil {dyna_weaponsTurret})then{((assignedVehicleRole player) select 1)}else{nil}"; + dyna_weaponsTurretMags = "if(!isNil {dyna_weaponsTurret})then{vehicle player magazinesTurret dyna_weaponsTurretPath}else{[]}"; + + dyna_driverTurret = "if(dyna_inDriver)then{vehicle player weaponsTurret[-1]}else{nil}"; + dyna_driverTurretMags = "if(!isNil {dyna_driverTurret})then{vehicle player magazinesTurret[-1]}else{[]}"; + + dyna_isGunning = "if(dyna_inVehicle && dyna_inTurret && !dyna_inDriver)then{(!isNil {dyna_weaponsTurret})}else{false}"; + dyna_isDriving = "if(dyna_inVehicle && dyna_inDriver)then{(!isNil {dyna_driverTurret})}else{false}"; + dyna_isCommanding = "if(dyna_inVehicle && dyna_inCommander)then{(!isNil {dyna_weaponsTurret})}else{false}"; }; class self diff --git a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp index 6197635c..4a308d81 100644 --- a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp +++ b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp @@ -163,3 +163,87 @@ class ServicePoint tooltipcode = "Ignatz_Rearm2 select 0"; }; }; +class veh_gunnerRearm +{ + condition = "if(dyna_isGunning)then{!((dyna_weaponsTurret select 0) in dyna_blockTurrets)}else{false}"; + action = "[dyna_weaponsTurret select 0, dyna_weaponsTurretPath] call EPOCH_vehicle_checkTurretAmmo"; + icon = "x\addons\a3_epoch_code\Data\UI\buttons\Rearm.paa"; + tooltipcode = "if(!isNil {dyna_weaponsTurret})then{format['Add Mag to %1',getText(configFile >> 'CfgWeapons' >> dyna_weaponsTurret select 0 >> 'displayName')]}else{''}"; +}; +class veh_gunnerRemoveAmmo +{ + condition = "dyna_isGunning && !(dyna_weaponsTurretMags isEqualTo [])"; + action = "[dyna_weaponsTurret select 0, dyna_weaponsTurretPath] call EPOCH_vehicle_removeTurretAmmo"; + icon = "x\addons\a3_epoch_code\Data\UI\buttons\RemoveMag.paa"; + tooltipcode = "if(!isNil {dyna_weaponsTurret})then{format['Remove Mag from %1',getText(configFile >> 'CfgWeapons' >> dyna_weaponsTurret select 0 >> 'displayName')]}else{''}"; +}; +class veh_driverRearm +{ + condition = "if(dyna_isDriving)then{!((dyna_driverTurret select 0) in dyna_blockTurrets)}else{false}"; + action = "[dyna_driverTurret select 0, [-1]] call EPOCH_vehicle_checkTurretAmmo"; + icon = "x\addons\a3_epoch_code\Data\UI\buttons\Rearm.paa"; + tooltipcode = "if(!isNil {dyna_driverTurret})then{format['Add Mag to %1',getText(configFile >> 'CfgWeapons' >> dyna_driverTurret select 0 >> 'displayName')]}else{''}"; +}; +class veh_driverRemoveAmmo +{ + condition = "dyna_isDriving && !(dyna_driverTurretMags isEqualTo [])"; + action = "[dyna_driverTurret select 0, [-1]] call EPOCH_vehicle_removeTurretAmmo"; + icon = "x\addons\a3_epoch_code\Data\UI\buttons\RemoveMag.paa"; + tooltipcode = "if!(dyna_driverTurretMags isEqualTo [])then{format['Remove Mag of %1',dyna_driverTurretMags select 0]}else{''}"; +}; +class veh_driverRearm1 +{ + condition = "if(dyna_isDriving)then{!((dyna_driverTurret select 1) in dyna_blockTurrets) && (count dyna_driverTurret > 1)}else{false}"; + action = "[dyna_driverTurret select 1, [-1]] call EPOCH_vehicle_checkTurretAmmo"; + icon = "x\addons\a3_epoch_code\Data\UI\buttons\Rearm.paa"; + tooltipcode = "if(!isNil {dyna_driverTurret})then{format['Add Mag to %1',getText(configFile >> 'CfgWeapons' >> dyna_driverTurret select 1 >> 'displayName')]}else{''}"; +}; +class veh_driverRemoveAmmo1 +{ + condition = "if(dyna_isDriving)then{(count dyna_driverTurret > 1) && !(dyna_driverTurretMags isEqualTo [])}else{false}"; + action = "[dyna_driverTurret select 1, [-1]] call EPOCH_vehicle_removeTurretAmmo"; + icon = "x\addons\a3_epoch_code\Data\UI\buttons\RemoveMag.paa"; + tooltipcode = "if!(dyna_driverTurretMags isEqualTo [])then{format['Remove Mag of %1',dyna_driverTurretMags select 1]}else{''}"; +}; +class veh_driverRearm2 +{ + condition = "if(dyna_isDriving)then{!((dyna_driverTurret select 1) in dyna_blockTurrets) && (count dyna_driverTurret > 2)}else{false}"; + action = "[dyna_driverTurret select 2, [-1]] call EPOCH_vehicle_checkTurretAmmo"; + icon = "x\addons\a3_epoch_code\Data\UI\buttons\Rearm.paa"; + tooltipcode = "if(!isNil {dyna_driverTurret})then{format['Add Mag to %1',getText(configFile >> 'CfgWeapons' >> dyna_driverTurret select 2 >> 'displayName')]}else{''}"; +}; +class veh_driverRemoveAmmo2 +{ + condition = "if(dyna_isDriving)then{(count dyna_driverTurret > 2) && !(dyna_driverTurretMags isEqualTo [])}else{false}"; + action = "[dyna_driverTurret select 2, [-1]] call EPOCH_vehicle_removeTurretAmmo"; + icon = "x\addons\a3_epoch_code\Data\UI\buttons\RemoveMag.paa"; + tooltipcode = "if!(dyna_driverTurretMags isEqualTo [])then{format['Remove Mag of %1',dyna_driverTurretMags select 2]}else{''}"; +}; +class veh_commanderRearm +{ + condition = "if(dyna_isCommanding)then{!((dyna_weaponsTurret select 0) in dyna_blockTurrets)}else{false}"; + action = "[dyna_weaponsTurret select 0, dyna_weaponsTurretPath] call EPOCH_vehicle_checkTurretAmmo"; + icon = "x\addons\a3_epoch_code\Data\UI\buttons\Rearm.paa"; + tooltipcode = "if(!isNil {dyna_weaponsTurret})then{format['Add Mag to %1',getText(configFile >> 'CfgWeapons' >> dyna_weaponsTurret select 0 >> 'displayName')]}else{''}"; +}; +class veh_commanderRemoveAmmo +{ + condition = "dyna_isCommanding && !(dyna_weaponsTurretMags isEqualTo [])"; + action = "[dyna_weaponsTurret select 0, dyna_weaponsTurretPath] call EPOCH_vehicle_removeCommanderAmmo"; + icon = "x\addons\a3_epoch_code\Data\UI\buttons\RemoveMag.paa"; + tooltipcode = "if(!isNil {dyna_weaponsTurret})then{format['Remove Mag from %1',getText(configFile >> 'CfgWeapons' >> dyna_weaponsTurret select 0 >> 'displayName')]}else{''}"; +}; +class veh_commanderRearm1 +{ + condition = "if(dyna_isCommanding)then{!((dyna_weaponsTurret select 1) in dyna_blockTurrets) && (count dyna_weaponsTurret > 1)}else{false}"; + action = "[dyna_weaponsTurret select 1, dyna_weaponsTurretPath] call EPOCH_vehicle_checkTurretAmmo"; + icon = "x\addons\a3_epoch_code\Data\UI\buttons\Rearm.paa"; + tooltipcode = "if(!isNil {dyna_weaponsTurret})then{format['Add Mag to %1',getText(configFile >> 'CfgWeapons' >> dyna_weaponsTurret select 1 >> 'displayName')]}else{''}"; +}; +class veh_commanderRemoveAmmo1 +{ + condition = "if(dyna_isCommanding)then{(count dyna_weaponsTurret > 1) && !(dyna_weaponsTurretMags isEqualTo [])}else{false}"; + action = "[dyna_weaponsTurret select 1, dyna_weaponsTurretPath] call EPOCH_vehicle_removeCommanderAmmo"; + icon = "x\addons\a3_epoch_code\Data\UI\buttons\RemoveMag.paa"; + tooltipcode = "if(!isNil {dyna_weaponsTurret})then{format['Remove Mag from %1',getText(configFile >> 'CfgWeapons' >> dyna_weaponsTurret select 1 >> 'displayName')]}else{''}"; +}; \ No newline at end of file diff --git a/Sources/epoch_config/Configs/CfgClientFunctions.hpp b/Sources/epoch_config/Configs/CfgClientFunctions.hpp index 1d4cdaab..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 {}; @@ -157,6 +158,9 @@ class CfgClientFunctions class client_upgradeVehicleCheck {}; class client_VehicleMaintananceCheck {}; class client_VehicleMaintananceDo {}; + class vehicle_checkTurretAmmo {}; + class vehicle_removeTurretAmmo {}; + class vehicle_removeCommanderAmmo {}; }; class missions {