2015-12-15 07:09:26 +00:00
|
|
|
// by esteldunedain
|
2015-01-18 20:08:56 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2021-08-23 17:43:05 +00:00
|
|
|
// Spare barrel item to magazine
|
|
|
|
["ACE_SpareBarrel_Item", "ACE_SpareBarrel"] call EFUNC(common,registerItemReplacement);
|
|
|
|
|
2016-05-04 19:59:04 +00:00
|
|
|
if (hasInterface) then {
|
|
|
|
// Add keybinds
|
2016-07-13 09:00:31 +00:00
|
|
|
["ACE3 Weapons", QGVAR(unjamWeapon), localize LSTRING(UnjamWeapon), {
|
2016-05-04 19:59:04 +00:00
|
|
|
// Conditions: canInteract
|
|
|
|
if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
|
|
|
// Conditions: specific
|
2016-02-27 04:46:27 +00:00
|
|
|
|
2016-05-04 19:59:04 +00:00
|
|
|
if !(GVAR(enabled) && {[ACE_player] call FUNC(canUnjam)}) exitWith {false};
|
2016-02-27 03:29:30 +00:00
|
|
|
|
2016-05-04 19:59:04 +00:00
|
|
|
// Statement
|
|
|
|
[ACE_player, currentMuzzle ACE_player, false] call FUNC(clearJam);
|
|
|
|
true
|
2016-07-13 09:00:31 +00:00
|
|
|
}, {false}, [19, [true, false, false]], false] call CBA_fnc_addKeybind; //SHIFT + R Key
|
2015-02-14 19:22:02 +00:00
|
|
|
};
|
|
|
|
|
2021-10-11 20:48:30 +00:00
|
|
|
["CBA_settingsInitialized", {
|
2024-02-05 17:04:24 +00:00
|
|
|
TRACE_1("SettingsInitialized eh",GVAR(enabled));
|
2016-05-04 19:59:04 +00:00
|
|
|
if (!GVAR(enabled)) exitWith {};
|
2015-02-14 19:22:02 +00:00
|
|
|
|
2016-05-04 19:59:04 +00:00
|
|
|
if (isServer) then {
|
|
|
|
GVAR(pseudoRandomList) = [];
|
|
|
|
// Construct a list of pseudo random 2D vectors
|
|
|
|
for "_i" from 0 to 30 do {
|
|
|
|
GVAR(pseudoRandomList) pushBack [-1 + random 2, -1 + random 2];
|
|
|
|
};
|
|
|
|
publicVariable QGVAR(pseudoRandomList);
|
2015-01-18 20:08:56 +00:00
|
|
|
|
2016-05-04 19:59:04 +00:00
|
|
|
// Keep track of the temperature of stored spare barrels
|
2021-10-10 16:55:14 +00:00
|
|
|
GVAR(storedSpareBarrels) = createHashMap;
|
2015-12-27 01:56:40 +00:00
|
|
|
|
2016-05-04 19:59:04 +00:00
|
|
|
// Install event handlers for spare barrels
|
2024-03-28 18:57:23 +00:00
|
|
|
[QGVAR(sendSpareBarrelTemperatureHint), LINKFUNC(sendSpareBarrelsTemperaturesHint)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(loadCoolestSpareBarrel), LINKFUNC(loadCoolestSpareBarrel)] call CBA_fnc_addEventHandler;
|
2016-02-20 23:19:56 +00:00
|
|
|
|
2016-05-04 19:59:04 +00:00
|
|
|
// Schedule cool down calculation of stored spare barrels
|
|
|
|
[] call FUNC(updateSpareBarrelsTemperaturesThread);
|
|
|
|
};
|
2015-01-18 20:08:56 +00:00
|
|
|
|
2016-05-04 19:59:04 +00:00
|
|
|
if !(hasInterface) exitWith {};
|
2016-01-19 20:04:51 +00:00
|
|
|
|
2021-11-08 18:06:31 +00:00
|
|
|
GVAR(cacheWeaponData) = createHashMap;
|
|
|
|
GVAR(cacheAmmoData) = createHashMap;
|
|
|
|
GVAR(cacheSilencerData) = createHashMap;
|
2016-01-19 20:04:51 +00:00
|
|
|
|
2021-10-14 15:47:52 +00:00
|
|
|
//Add Take EH if required
|
|
|
|
if (GVAR(unJamOnReload) || {GVAR(cookoffCoef) > 0}) then {
|
2024-03-28 18:57:23 +00:00
|
|
|
["CAManBase", "Take", LINKFUNC(handleTakeEH)] call CBA_fnc_addClassEventHandler;
|
2021-10-14 15:47:52 +00:00
|
|
|
};
|
2016-02-06 20:59:54 +00:00
|
|
|
|
|
|
|
// Register fire event handler
|
2024-03-28 18:57:23 +00:00
|
|
|
["ace_firedPlayer", LINKFUNC(firedEH)] call CBA_fnc_addEventHandler;
|
2016-02-06 20:59:54 +00:00
|
|
|
// Only add eh to non local players if dispersion is enabled
|
2021-10-14 15:47:52 +00:00
|
|
|
if (GVAR(overheatingDispersion) || {GVAR(showParticleEffectsForEveryone)}) then {
|
2024-03-28 18:57:23 +00:00
|
|
|
["ace_firedPlayerNonLocal", LINKFUNC(firedEH)] call CBA_fnc_addEventHandler;
|
2016-02-06 20:59:54 +00:00
|
|
|
};
|
2016-03-01 22:27:39 +00:00
|
|
|
|
2016-05-04 19:59:04 +00:00
|
|
|
// Schedule cool down calculation of player weapons at (infrequent) regular intervals
|
|
|
|
[] call FUNC(updateTemperatureThread);
|
2016-06-24 13:45:13 +00:00
|
|
|
|
2021-10-14 15:47:52 +00:00
|
|
|
//Add event handlers and start ammo heating loop for cookoff
|
|
|
|
if (GVAR(cookoffCoef) > 0) then {
|
|
|
|
[] call FUNC(updateAmmoTemperatureThread);
|
|
|
|
|
|
|
|
// Reset ammo temperature on reload, unless the reload is a second muzzle.
|
|
|
|
["CAManBase", "Reloaded", {
|
|
|
|
params ["_unit", "_weapon", "_muzzle"];
|
|
|
|
if (_muzzle == _weapon) then {
|
|
|
|
_unit setVariable [format [QGVAR(%1_ammoTemp), _weapon], 0];
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addClassEventHandler;
|
|
|
|
};
|
|
|
|
|
2021-11-08 18:06:31 +00:00
|
|
|
// Reset all weapon heat to ambient on death to prevent cookoffs when a unit respawns.
|
|
|
|
["CAManBase", "Killed", {
|
|
|
|
params ["_unit"];
|
|
|
|
{
|
|
|
|
_unit setVariable [_x, ambientTemperature select 0];
|
|
|
|
} forEach (_unit getVariable [QGVAR(trackedWeapons), []]);
|
|
|
|
_unit setVariable [QGVAR(trackedWeapons), []];
|
|
|
|
}] call CBA_fnc_addClassEventHandler;
|
|
|
|
|
2016-05-04 19:59:04 +00:00
|
|
|
// Install event handler to display temp when a barrel was swapped
|
2024-03-28 18:57:23 +00:00
|
|
|
[QGVAR(showWeaponTemperature), LINKFUNC(displayTemperature)] call CBA_fnc_addEventHandler;
|
2021-11-08 18:06:31 +00:00
|
|
|
|
2016-05-04 19:59:04 +00:00
|
|
|
// Install event handler to initiate an assisted barrel swap
|
2024-03-28 18:57:23 +00:00
|
|
|
[QGVAR(initiateSwapBarrelAssisted), LINKFUNC(swapBarrel)] call CBA_fnc_addEventHandler;
|
2016-05-04 19:59:04 +00:00
|
|
|
|
2021-10-14 15:47:52 +00:00
|
|
|
// Add an action to allow hot weapons to be cooled off in AceX Field Rations water sources
|
2022-01-30 17:56:20 +00:00
|
|
|
if (["acex_field_rations"] call EFUNC(common,isModLoaded)) then {
|
2021-10-14 15:47:52 +00:00
|
|
|
[
|
2021-10-17 22:00:16 +00:00
|
|
|
{EXGVAR(field_rations,enabled) || CBA_missionTime > 1},
|
2021-10-14 15:47:52 +00:00
|
|
|
{
|
2021-10-17 22:00:16 +00:00
|
|
|
if (!EXGVAR(field_rations,enabled)) exitWith {};
|
2021-10-14 15:47:52 +00:00
|
|
|
|
2021-10-18 02:45:01 +00:00
|
|
|
private _coolWeaponWithWaterSourceAction = [
|
2021-10-14 15:47:52 +00:00
|
|
|
QGVAR(CoolWeaponWithWaterSource),
|
|
|
|
LLSTRING(CoolWeaponWithWaterSource),
|
2021-10-17 22:00:16 +00:00
|
|
|
QPATHTOEF(field_rations,ui\icon_water_tap.paa),
|
2021-10-14 15:47:52 +00:00
|
|
|
{
|
2021-10-18 02:45:01 +00:00
|
|
|
private _waterSource = _target getVariable [QEGVAR(field_rations,waterSource), objNull];
|
2021-10-14 15:47:52 +00:00
|
|
|
[_player, _waterSource] call FUNC(coolWeaponWithWaterSource);
|
|
|
|
},
|
|
|
|
{
|
2021-10-18 02:45:01 +00:00
|
|
|
private _waterSource = _target getVariable [QEGVAR(field_rations,waterSource), objNull];
|
|
|
|
[_player, _waterSource] call EFUNC(field_rations,canDrinkFromSource);
|
2021-10-14 15:47:52 +00:00
|
|
|
}
|
|
|
|
] call EFUNC(interact_menu,createAction);
|
|
|
|
|
2021-10-18 02:45:01 +00:00
|
|
|
[QEGVAR(field_rations,helper), 0, [QEGVAR(field_rations,waterSource)], _coolWeaponWithWaterSourceAction] call EFUNC(interact_menu,addActionToClass);
|
2021-10-14 15:47:52 +00:00
|
|
|
},
|
|
|
|
[]
|
|
|
|
] call CBA_fnc_waitUntilAndExecute;
|
|
|
|
};
|
2016-05-22 15:29:05 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|