mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Add "check temperature" and "swap barrel" actions for AARs
This commit is contained in:
parent
6cf9787fd1
commit
ae8cbb4834
@ -4,7 +4,7 @@ class CfgVehicles {
|
||||
class CAManBase: Man {
|
||||
class ACE_SelfActions {
|
||||
class ACE_Equipment {
|
||||
class ACE_UnJam {
|
||||
class GVAR(UnJam) {
|
||||
displayName = CSTRING(UnjamWeapon);
|
||||
condition = QUOTE( [_player] call FUNC(canUnjam) );
|
||||
exceptions[] = {"isNotInside", "isNotSitting"};
|
||||
@ -13,7 +13,7 @@ class CfgVehicles {
|
||||
priority = 4;
|
||||
icon = QUOTE(PATHTOF(UI\unjam_ca.paa));
|
||||
};
|
||||
class ACE_SwapBarrel {
|
||||
class GVAR(SwapBarrel) {
|
||||
displayName = CSTRING(SwapBarrel);
|
||||
condition = QUOTE( 'ACE_SpareBarrel' in magazines _player && {getNumber (configFile >> 'CfgWeapons' >> currentWeapon _player >> 'ACE_Overheating_allowSwapBarrel') == 1} );
|
||||
statement = QUOTE( [ARR_2(_player, currentWeapon _player)] call FUNC(swapBarrel); );
|
||||
@ -21,16 +21,16 @@ class CfgVehicles {
|
||||
priority = 3;
|
||||
icon = QUOTE(PATHTOF(UI\spare_barrel_ca.paa));
|
||||
};
|
||||
class ACE_CheckTemperature {
|
||||
class GVAR(CheckTemperature) {
|
||||
displayName = CSTRING(CheckTemperatureShort);
|
||||
condition = "switch (currentWeapon _player) do {case (''): {false}; case (primaryWeapon _player); case (secondaryWeapon _player); case (handgunWeapon _player): {true}; default {false}}";
|
||||
condition = "switch (currentWeapon _player) do {case (''): {false}; case (primaryWeapon _player); case (handgunWeapon _player): {true}; default {false}}";
|
||||
exceptions[] = {"isNotInside", "isNotSitting"};
|
||||
statement = QUOTE( [ARR_2(_player, currentWeapon _player)] call FUNC(CheckTemperature); );
|
||||
statement = QUOTE( [ARR_3(_player, _player, currentWeapon _player)] call FUNC(checkTemperature); );
|
||||
showDisabled = 0;
|
||||
priority = 2.9;
|
||||
icon = QUOTE(PATHTOF(UI\temp_ca.paa));
|
||||
};
|
||||
class ACE_CheckTemperatureSpareBarrels {
|
||||
class GVAR(CheckTemperatureSpareBarrels) {
|
||||
displayName = CSTRING(CheckTemperatureSpareBarrelsShort);
|
||||
condition = QUOTE( 'ACE_SpareBarrel' in magazines _player);
|
||||
exceptions[] = {"isNotInside", "isNotSitting"};
|
||||
@ -41,6 +41,24 @@ class CfgVehicles {
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class ACE_Actions {
|
||||
class ACE_Weapon {
|
||||
class GVAR(SwapBarrel) {
|
||||
displayName = CSTRING(SwapBarrel);
|
||||
condition = QUOTE( 'ACE_SpareBarrel' in magazines _player && {getNumber (configFile >> 'CfgWeapons' >> currentWeapon _target >> 'ACE_Overheating_allowSwapBarrel') == 1} );
|
||||
statement = QUOTE([ARR_3(_player, _target, currentWeapon _target)] call FUNC(swapBarrelAssistant););
|
||||
icon = QUOTE(PATHTOF(UI\spare_barrel_ca.paa));
|
||||
};
|
||||
class GVAR(CheckTemperature) {
|
||||
displayName = CSTRING(CheckTemperatureShort);
|
||||
condition = "switch (currentWeapon _target) do {case (''): {false}; case (primaryWeapon _target); case (handgunWeapon _target): {true}; default {false}}";
|
||||
exceptions[] = {"isNotInside", "isNotSitting"};
|
||||
statement = QUOTE( [ARR_3(_player, _target, currentWeapon _target)] call FUNC(checkTemperature); );
|
||||
icon = QUOTE(PATHTOF(UI\temp_ca.paa));
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class ReammoBox_F;
|
||||
|
@ -13,6 +13,7 @@ PREP(loadCoolestSpareBarrel);
|
||||
PREP(overheat);
|
||||
PREP(sendSpareBarrelsTemperaturesHint);
|
||||
PREP(swapBarrel);
|
||||
PREP(swapBarrelAssistant);
|
||||
PREP(swapBarrelCallback);
|
||||
PREP(updateSpareBarrelsTemperaturesThread);
|
||||
PREP(updateTemperature);
|
||||
|
@ -56,7 +56,7 @@ GVAR(cacheSilencerData) = call CBA_fnc_createNamespace;
|
||||
};
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
|
||||
// Install event handlers to display temp when a barrel was swapped
|
||||
["barrelSwapped", {
|
||||
_this call FUNC(displayTemperature);
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
// Install event handler to display temp when a barrel was swapped
|
||||
["showWeaponTemperature", DFUNC(displayTemperature)] call EFUNC(common,addEventHandler);
|
||||
// Install event handler to initiate an assisted barrel swap
|
||||
["initiateSwapBarrelAssisted", DFUNC(swapBarrel)] call EFUNC(common,addEventHandler);
|
||||
|
@ -3,8 +3,9 @@
|
||||
* Make the player check the temperature of his weapon
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Player <OBJECT>
|
||||
* 1: Weapon <STRING>
|
||||
* 0: Unit checking <OBJECT>
|
||||
* 1: Unit that has the weapon <OBJECT>
|
||||
* 2: Weapon <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -16,17 +17,18 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_player", "_weapon"];
|
||||
TRACE_2("params",_player,_weapon);
|
||||
params ["_assistant", "_gunner", "_weapon"];
|
||||
TRACE_3("params",_assistant,_gunner,_weapon);
|
||||
|
||||
// Play animation and report temperature
|
||||
private _action = getText (configFile >> "CfgWeapons" >> _weapon >> "ACE_checkTemperatureAction");
|
||||
|
||||
if (_action == "") then {
|
||||
_action = "Gear";
|
||||
private _action = "PutDown";
|
||||
if (_assistant isEqualTo _gunner) then {
|
||||
_action = getText (configFile >> "CfgWeapons" >> _weapon >> "ACE_checkTemperatureAction");
|
||||
if (_action == "") then {
|
||||
_action = "Gear";
|
||||
};
|
||||
};
|
||||
|
||||
_player playActionNow _action;
|
||||
_assistant playActionNow _action;
|
||||
|
||||
// Waits a sec before displaying the temperature
|
||||
[FUNC(displayTemperature), [_player, _weapon], 1.0] call EFUNC(common,waitAndExecute);
|
||||
[FUNC(displayTemperature), [_gunner, _weapon], 1.0] call EFUNC(common,waitAndExecute);
|
||||
|
@ -4,10 +4,11 @@
|
||||
* coolest on the unit weapon. Runs on the server.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Weapon <STRING>
|
||||
* 2: Weapon temp before switching <NUMBER>
|
||||
* 3: Mass of the removed barrel <NUMBER>
|
||||
* 0: Unit that has the spare barrels <OBJECT>
|
||||
* 1: Unit that has the weapon <OBJECT>
|
||||
* 2: Weapon <STRING>
|
||||
* 3: Weapon temp before switching <NUMBER>
|
||||
* 4: Mass of the removed barrel <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
@ -17,11 +18,11 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_weapon", "_weaponTemp", "_barrelMass"];
|
||||
TRACE_4("loadCoolestSpareBarrel1",_unit,_weapon,_weaponTemp,_barrelMass);
|
||||
params ["_assistant", "_gunner", "_weapon", "_weaponTemp", "_barrelMass"];
|
||||
TRACE_5("loadCoolestSpareBarrel1",_assistant,_gunner,_weapon,_weaponTemp,_barrelMass);
|
||||
|
||||
// Find all spare barrel the player has
|
||||
private _allBarrels = [_unit, "ACE_SpareBarrel"] call CBA_fnc_getMagazineIndex;
|
||||
private _allBarrels = [_assistant, "ACE_SpareBarrel"] call CBA_fnc_getMagazineIndex;
|
||||
TRACE_1("_allBarrels",_allBarrels);
|
||||
if ((count _allBarrels) < 1) exitWith {};
|
||||
|
||||
@ -43,10 +44,10 @@ TRACE_3("loadCoolestSpareBarrel5",_coolestTemp,_coolestMag,_weaponTemp);
|
||||
|
||||
// The new weapon temperature is similar to the coolest barrel
|
||||
// Publish the new temperature value
|
||||
_unit setVariable [format [QGVAR(%1_temp), _weapon], _coolestTemp, true];
|
||||
_gunner setVariable [format [QGVAR(%1_temp), _weapon], _coolestTemp, true];
|
||||
|
||||
// Heat up the coolest barrel to the former weapon temperature
|
||||
[GVAR(storedSpareBarrels), _coolestMag, [_weaponTemp, ACE_Time, _barrelMass]] call CBA_fnc_hashSet;
|
||||
|
||||
// Send an event so the local machine can show the hint
|
||||
["barrelSwapped", _unit, [_unit, _weapon]] call EFUNC(common,objectEvent);
|
||||
// Send an event so the machines of the assistant and gunner can show the hint
|
||||
["showWeaponTemperature", [_assistant, _gunner], [_gunner, _weapon]] call EFUNC(common,targetEvent);
|
||||
|
@ -3,29 +3,35 @@
|
||||
* Make a unit start swapping it's barrel
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Weapon <STRING>
|
||||
* 0: Unit initiating the action <OBJECT>
|
||||
* 1: Unit that has the weapon <OBJECT>
|
||||
* 2: Weapon <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player, currentWeapon player] call ace_overheating_fnc_swapBarrel
|
||||
* [cursorTarget, player, currentWeapon player] call ace_overheating_fnc_swapBarrel
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_player", "_weapon"];
|
||||
TRACE_2("params",_player,_weapon);
|
||||
params ["_assistant", "_gunner", "_weapon"];
|
||||
TRACE_3("params",_assistant,_gunner,_weapon);
|
||||
|
||||
// Make the standing player kneel down
|
||||
if (stance _player != "PRONE") then {
|
||||
[_player, "amovpknlmstpsraswrfldnon", 1] call EFUNC(common,doAnimation);
|
||||
if (stance _gunner != "PRONE") then {
|
||||
[_gunner, "amovpknlmstpsraswrfldnon", 1] call EFUNC(common,doAnimation);
|
||||
};
|
||||
|
||||
// Barrel dismount gesture
|
||||
_player playActionNow QGVAR(GestureDismountMuzzle);
|
||||
_gunner playActionNow QGVAR(GestureDismountMuzzle);
|
||||
playSound "ACE_BarrelSwap";
|
||||
|
||||
[5, [_player, _weapon], {(_this select 0) call FUNC(swapBarrelCallback)}, {}, (localize LSTRING(SwappingBarrel))] call EFUNC(common,progressBar);
|
||||
private _duration = 3.0;
|
||||
if (_assistant isEqualTo _gunner) then {
|
||||
_duration = 5.0;
|
||||
};
|
||||
|
||||
[_duration, [_assistant,_gunner,_weapon], {(_this select 0) call FUNC(swapBarrelCallback)}, {}, (localize LSTRING(SwappingBarrel))] call EFUNC(common,progressBar);
|
||||
|
33
addons/overheating/functions/fnc_swapBarrelAssistant.sqf
Normal file
33
addons/overheating/functions/fnc_swapBarrelAssistant.sqf
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Author: esteldunedain, Commy2
|
||||
* Make a unit start swapping the barrel of another unit
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit initiating the action <OBJECT>
|
||||
* 1: Unit that has the weapon <OBJECT>
|
||||
* 2: Weapon <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player, cursorTarget, currentWeapon cursorTarget] call ace_overheating_fnc_swapBarrelAssistant
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_assistant", "_gunner", "_weapon"];
|
||||
TRACE_3("params",_assistant,_gunner,_weapon);
|
||||
|
||||
// Make the standing player kneel down
|
||||
if (stance _assistant != "PRONE") then {
|
||||
[_assistant, "amovpknlmstpsraswrfldnon", 1] call EFUNC(common,doAnimation);
|
||||
};
|
||||
|
||||
// Barrel dismount gesture
|
||||
playSound "ACE_BarrelSwap";
|
||||
|
||||
[3, [_assistant, _gunner, _weapon], {}, {}, (localize LSTRING(SwappingBarrel))] call EFUNC(common,progressBar);
|
||||
|
||||
["initiateSwapBarrelAssisted", _gunner, [_assistant, _gunner, _weapon]] call EFUNC(common,objectEvent);
|
@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Author: Commy2
|
||||
* Author: Commy2, esteldunedain
|
||||
* Swap barrel callback
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Weapon <STRING>
|
||||
* 0: Unit initiating the action <OBJECT>
|
||||
* 1: Unit that has the weapon <OBJECT>
|
||||
* 2: Weapon <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
@ -17,21 +18,23 @@
|
||||
#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_player", "_weapon"];
|
||||
TRACE_2("params",_player,_weapon);
|
||||
params ["_assistant", "_gunner", "_weapon"];
|
||||
TRACE_3("params",_assistant,_gunner,_weapon);
|
||||
|
||||
// Barrel mount gesture
|
||||
_player playAction QGVAR(GestureMountMuzzle);
|
||||
playSound "ACE_BarrelSwap";
|
||||
if (_assistant isEqualTo _gunner) then {
|
||||
// Barrel mount gesture
|
||||
_gunner playAction QGVAR(GestureMountMuzzle);
|
||||
playSound "ACE_BarrelSwap";
|
||||
};
|
||||
|
||||
private _temp = _player getVariable [format [QGVAR(%1_temp), _weapon], 0];
|
||||
private _temp = _gunner getVariable [format [QGVAR(%1_temp), _weapon], 0];
|
||||
private _barrelMass = 0.50 * (getNumber (configFile >> "CfgWeapons" >> _weapon >> "WeaponSlotsInfo" >> "mass") / 22.0) max 1.0;
|
||||
|
||||
// Instruct the server to load the coolest spare barrel into the weapon and
|
||||
// store the removed barrel with the former weapon temperature. The server
|
||||
// also updates the current weapon temperature to match that of the new
|
||||
// loaded barrel.
|
||||
["spareBarrelsLoadCoolest", [_player, _weapon, _temp, _barrelMass]] call EFUNC(common,serverEvent);
|
||||
["spareBarrelsLoadCoolest", [_assistant, _gunner, _weapon, _temp, _barrelMass]] call EFUNC(common,serverEvent);
|
||||
|
||||
// Store the update time
|
||||
_player setVariable [format [QGVAR(%1_time), _weapon], ACE_time];
|
||||
_gunner setVariable [format [QGVAR(%1_time), _weapon], ACE_time];
|
||||
|
Loading…
Reference in New Issue
Block a user