Gunner and Driver Turrets

Reload and remove mags from gunner and driver turrets.
Will expand for more slots
This commit is contained in:
DESKTOP-UH65DCE\MusTanG 2017-09-23 20:58:48 -05:00
parent 359efd8d68
commit 122cb8b96c
5 changed files with 115 additions and 0 deletions

View File

@ -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;
};

View File

@ -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;

View File

@ -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

View File

@ -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{''}";
};

View File

@ -157,6 +157,8 @@ class CfgClientFunctions
class client_upgradeVehicleCheck {};
class client_VehicleMaintananceCheck {};
class client_VehicleMaintananceDo {};
class vehicle_checkTurretAmmo {};
class vehicle_removeTurretAmmo {};
};
class missions
{