Definable classname for Spare Barrel (#4121)

* Added definable barrel classname through weapon config

* Improved condition for player carrying spare barrel
This commit is contained in:
Grey-Soldierman 2016-08-27 09:21:15 +01:00 committed by Glowbal
parent ac0c429a28
commit dae3d8d682
6 changed files with 71 additions and 6 deletions

View File

@ -15,7 +15,7 @@ class CfgVehicles {
};
class GVAR(SwapBarrel) {
displayName = CSTRING(SwapBarrel);
condition = QUOTE( GVAR(enabled) && {'ACE_SpareBarrel' in magazines _player} && {getNumber (configFile >> 'CfgWeapons' >> currentWeapon _player >> 'ACE_Overheating_allowSwapBarrel') == 1} );
condition = QUOTE( [ARR_2(_player, currentWeapon _player)] call FUNC(canSwapBarrel) );
statement = QUOTE( [ARR_3(_player, _player, currentWeapon _player)] call FUNC(swapBarrel); );
showDisabled = 0;
priority = 3;
@ -32,7 +32,7 @@ class CfgVehicles {
};
class GVAR(CheckTemperatureSpareBarrels) {
displayName = CSTRING(CheckTemperatureSpareBarrelsShort);
condition = QUOTE( GVAR(enabled) && {'ACE_SpareBarrel' in magazines _player});
condition = QUOTE((_player) call FUNC(canCheckSpareBarrelsTemperatures) );
exceptions[] = {"isNotInside", "isNotSitting"};
statement = QUOTE( [_player] call FUNC(checkSpareBarrelsTemperatures); );
showDisabled = 0;
@ -46,7 +46,7 @@ class CfgVehicles {
class ACE_Weapon {
class GVAR(SwapBarrel) {
displayName = CSTRING(SwapBarrel);
condition = QUOTE( GVAR(enabled) && {'ACE_SpareBarrel' in magazines _player} && {getNumber (configFile >> 'CfgWeapons' >> currentWeapon _target >> 'ACE_Overheating_allowSwapBarrel') == 1} );
condition = QUOTE( [ARR_2(_player, currentWeapon _target)] call FUNC(canSwapBarrel) );
statement = QUOTE([ARR_3(_player, _target, currentWeapon _target)] call FUNC(swapBarrelAssistant););
icon = QUOTE(PATHTOF(UI\spare_barrel_ca.paa));
};

View File

@ -1,6 +1,8 @@
PREP(calculateCooling);
PREP(canUnjam);
PREP(canSwapBarrel);
PREP(canCheckSpareBarrelsTemperatures);
PREP(checkSpareBarrelsTemperatures);
PREP(checkTemperature);
PREP(clearJam);

View File

@ -0,0 +1,25 @@
/*
* Author: Grey-Soldierman
* Return true if player can check temperatures of spare barrels
*
* Arguments:
* 0: Player <OBJECT>
*
* Return Value:
* Bool
*
* Public: No
*/
#include "script_component.hpp"
params["_unit"];
//Get the classname of the spare barrel for the weapon
private _weaponBarrelClass = getText (configFile >> 'CfgWeapons' >> currentWeapon _player >> QGVAR(barrelClassname));
//If the weapon has no defined classname then use the ACE one
if(_weaponBarrelClass == "") then {
_weaponBarrelClass = "ACE_SpareBarrel";
};
//Check if the player has the barrel and the weapon can have its barrel swapped
private _canCheckTemperature = GVAR(enabled) && {_weaponBarrelClass in magazines _player};
_canCheckTemperature;

View File

@ -0,0 +1,26 @@
/*
* Author: Grey-Soldierman
* Return true if player can swap barrel
*
* Arguments:
* 0: Player <OBJECT>
* 1: Weapon <STRING>
* Return Value:
* Bool
*
* Public: No
*/
#include "script_component.hpp"
params["_unit","_weapon"];
//Check if weapon can have its barrel swapped. If not exit out of function
if( !GVAR(enabled) && (getNumber (configFile >> 'CfgWeapons' >> _weapon >> QGVAR(allowSwapBarrel))) != 1) exitWith{false};
//Get the classname of the spare barrel for the weapon
private _weaponBarrelClass = getText (configFile >> 'CfgWeapons' >> _weapon >> QGVAR(barrelClassname));
//If the weapon has no defined classname then use the ACE one
if(_weaponBarrelClass == "") then {
_weaponBarrelClass = "ACE_SpareBarrel";
};
//If the player has the spare barrel then it can be swapped
(_weaponBarrelClass in magazines _unit)

View File

@ -20,9 +20,13 @@
params ["_assistant", "_gunner", "_weapon", "_weaponTemp", "_barrelMass"];
TRACE_5("loadCoolestSpareBarrel1",_assistant,_gunner,_weapon,_weaponTemp,_barrelMass);
private _weaponBarrelClass = getText (configFile >> 'CfgWeapons' >> _weapon >> QGVAR(barrelClassname));
//If the weapon has no defined classname then use the ACE one
if(_weaponBarrelClass == "") then {
_weaponBarrelClass = "ACE_SpareBarrel";
};
// Find all spare barrel the player has
private _allBarrels = [_assistant, "ACE_SpareBarrel"] call CBA_fnc_getMagazineIndex;
private _allBarrels = [_assistant, _weaponBarrelClass] call CBA_fnc_getMagazineIndex;
TRACE_1("_allBarrels",_allBarrels);
if ((count _allBarrels) < 1) exitWith {};

View File

@ -19,7 +19,15 @@ params ["_player","_unit"];
// Find all spare barrel the player has
TRACE_2("sendSpareBarrelsTemperatureHunt",_player,_unit);
private _allBarrels = [_unit, "ACE_SpareBarrel"] call CBA_fnc_getMagazineIndex;
//Get the weapon of the target unit
private _weapon = currentWeapon _player;
//Get the classname of the spare barrel of that weapon
private _weaponBarrelClass = getText (configFile >> 'CfgWeapons' >> _weapon >> QGVAR(barrelClassname));
//If the weapon has no defined classname then use the ACE one
if(_weaponBarrelClass == "") then {
_weaponBarrelClass = "ACE_SpareBarrel";
};
private _allBarrels = [_unit, _weaponBarrelClass] call CBA_fnc_getMagazineIndex;
TRACE_1("_allBarrels",_allBarrels);
if ((count _allBarrels) < 1) exitWith {};