From 122cb8b96c542e795df8a9a5a3221d707c1a694e Mon Sep 17 00:00:00 2001 From: "DESKTOP-UH65DCE\\MusTanG" Date: Sat, 23 Sep 2017 20:58:48 -0500 Subject: [PATCH 1/6] Gunner and Driver Turrets Reload and remove mags from gunner and driver turrets. Will expand for more slots --- .../EPOCH_vehicle_checkTurretAmmo.sqf | 39 +++++++++++++++++++ .../EPOCH_vehicle_removeTurretAmmo.sqf | 30 ++++++++++++++ .../CfgActionMenu/CfgActionMenu_core.hpp | 16 ++++++++ .../CfgActionMenu/CfgActionMenu_self.hpp | 28 +++++++++++++ .../Configs/CfgClientFunctions.hpp | 2 + 5 files changed, 115 insertions(+) create mode 100644 Sources/epoch_code/compile/vehicles/EPOCH_vehicle_checkTurretAmmo.sqf create mode 100644 Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeTurretAmmo.sqf 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_removeTurretAmmo.sqf b/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeTurretAmmo.sqf new file mode 100644 index 00000000..f8883c25 --- /dev/null +++ b/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeTurretAmmo.sqf @@ -0,0 +1,30 @@ +/* + + 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; +[format["You have removed 1 can of %1 with %2 rounds",_magsTurret, _magAmmo],5] call Epoch_message; +player addMagazine [_magsTurret,_magAmmo]; +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..e5154f9a 100644 --- a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_core.hpp +++ b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_core.hpp @@ -32,6 +32,22 @@ 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_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}"; }; class self diff --git a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp index 6197635c..04609651 100644 --- a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp +++ b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp @@ -163,3 +163,31 @@ 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{''}"; +}; \ No newline at end of file diff --git a/Sources/epoch_config/Configs/CfgClientFunctions.hpp b/Sources/epoch_config/Configs/CfgClientFunctions.hpp index 1d4cdaab..0293173b 100644 --- a/Sources/epoch_config/Configs/CfgClientFunctions.hpp +++ b/Sources/epoch_config/Configs/CfgClientFunctions.hpp @@ -157,6 +157,8 @@ class CfgClientFunctions class client_upgradeVehicleCheck {}; class client_VehicleMaintananceCheck {}; class client_VehicleMaintananceDo {}; + class vehicle_checkTurretAmmo {}; + class vehicle_removeTurretAmmo {}; }; class missions { From 19b5a0621514bb5d9d8237b8cff41c9bf6f7cfbf Mon Sep 17 00:00:00 2001 From: "DESKTOP-UH65DCE\\MusTanG" Date: Sat, 23 Sep 2017 22:29:45 -0500 Subject: [PATCH 2/6] Commander Reload and Remove Turret Mags --- .../EPOCH_vehicle_removeCommanderAmmo.sqf | 39 +++++++++++++++++++ .../CfgActionMenu/CfgActionMenu_core.hpp | 2 + .../CfgActionMenu/CfgActionMenu_self.hpp | 14 +++++++ .../Configs/CfgClientFunctions.hpp | 1 + 4 files changed, 56 insertions(+) create mode 100644 Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeCommanderAmmo.sqf 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..8fe0f45d --- /dev/null +++ b/Sources/epoch_code/compile/vehicles/EPOCH_vehicle_removeCommanderAmmo.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_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; +}; + +[format["You have removed 1 can of %1 with %2 rounds",_magsTurret, _magAmmo],5] call Epoch_message; +player addMagazine [_magsTurret,_magAmmo]; +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 e5154f9a..06146273 100644 --- a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_core.hpp +++ b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_core.hpp @@ -35,6 +35,7 @@ class CfgActionMenu 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']"; @@ -48,6 +49,7 @@ class CfgActionMenu 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 04609651..d1931546 100644 --- a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp +++ b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp @@ -190,4 +190,18 @@ class veh_driverRemoveAmmo 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_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{''}"; }; \ No newline at end of file diff --git a/Sources/epoch_config/Configs/CfgClientFunctions.hpp b/Sources/epoch_config/Configs/CfgClientFunctions.hpp index 0293173b..786f23fc 100644 --- a/Sources/epoch_config/Configs/CfgClientFunctions.hpp +++ b/Sources/epoch_config/Configs/CfgClientFunctions.hpp @@ -159,6 +159,7 @@ class CfgClientFunctions class client_VehicleMaintananceDo {}; class vehicle_checkTurretAmmo {}; class vehicle_removeTurretAmmo {}; + class vehicle_removeCommanderAmmo {}; }; class missions { From f6c706379d2cf1d3db938b28de68a3525a29d1d3 Mon Sep 17 00:00:00 2001 From: "DESKTOP-UH65DCE\\MusTanG" Date: Sat, 23 Sep 2017 22:58:57 -0500 Subject: [PATCH 3/6] increase driver and commander selections add driver select 1 and 2 add commander select 1 --- .../CfgActionMenu/CfgActionMenu_self.hpp | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp index d1931546..0c3b9913 100644 --- a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp +++ b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp @@ -191,6 +191,34 @@ class veh_driverRemoveAmmo 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 && (count dyna_driverTurret > 1))then{!((dyna_driverTurret select 1) in dyna_blockTurrets)}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 = "dyna_isDriving && (count dyna_driverTurret > 1) && !(dyna_driverTurretMags isEqualTo [])"; + 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 && (count dyna_driverTurret > 2))then{!((dyna_driverTurret select 1) in dyna_blockTurrets)}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 = "dyna_isDriving && (count dyna_driverTurret > 2) && !(dyna_driverTurretMags isEqualTo [])"; + 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}"; @@ -204,4 +232,18 @@ class veh_commanderRemoveAmmo 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 && (count dyna_weaponsTurret > 1))then{!((dyna_weaponsTurret select 1) in dyna_blockTurrets)}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 = "dyna_isCommanding && (count dyna_weaponsTurret > 1) && !(dyna_weaponsTurretMags isEqualTo [])"; + 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 From bf004a92d845687fe143e495703a6442090faf8c Mon Sep 17 00:00:00 2001 From: "DESKTOP-UH65DCE\\MusTanG" Date: Sat, 23 Sep 2017 23:07:09 -0500 Subject: [PATCH 4/6] corrections --- .../Configs/CfgActionMenu/CfgActionMenu_self.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp index 0c3b9913..4a308d81 100644 --- a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp +++ b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp @@ -193,28 +193,28 @@ class veh_driverRemoveAmmo }; class veh_driverRearm1 { - condition = "if(dyna_isDriving && (count dyna_driverTurret > 1))then{!((dyna_driverTurret select 1) in dyna_blockTurrets)}else{false}"; + 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 = "dyna_isDriving && (count dyna_driverTurret > 1) && !(dyna_driverTurretMags isEqualTo [])"; + 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 && (count dyna_driverTurret > 2))then{!((dyna_driverTurret select 1) in dyna_blockTurrets)}else{false}"; + 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 = "dyna_isDriving && (count dyna_driverTurret > 2) && !(dyna_driverTurretMags isEqualTo [])"; + 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{''}"; @@ -235,14 +235,14 @@ class veh_commanderRemoveAmmo }; class veh_commanderRearm1 { - condition = "if(dyna_isCommanding && (count dyna_weaponsTurret > 1))then{!((dyna_weaponsTurret select 1) in dyna_blockTurrets)}else{false}"; + 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 = "dyna_isCommanding && (count dyna_weaponsTurret > 1) && !(dyna_weaponsTurretMags isEqualTo [])"; + 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{''}"; From 22ef7c1c2c7bdae34ac32dd098dd3319209c0f8f Mon Sep 17 00:00:00 2001 From: "DESKTOP-UH65DCE\\MusTanG" Date: Sun, 24 Sep 2017 01:37:34 -0500 Subject: [PATCH 5/6] battleye filters for veh reload and remove mag --- Server_Install_Pack/sc/battleye/scripts.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From 3b11fc7f75b9dd94db54a2760b91086f1a8188ed Mon Sep 17 00:00:00 2001 From: "DESKTOP-UH65DCE\\MusTanG" Date: Sun, 24 Sep 2017 04:46:20 -0500 Subject: [PATCH 6/6] Inventory space checks --- .../EPOCH_fnc_addMagazineOverflow.sqf | 60 +++++++++++++++++++ .../EPOCH_vehicle_removeCommanderAmmo.sqf | 13 +++- .../EPOCH_vehicle_removeTurretAmmo.sqf | 14 ++++- .../Configs/CfgClientFunctions.hpp | 1 + 4 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 Sources/epoch_code/compile/functions/EPOCH_fnc_addMagazineOverflow.sqf 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 {};