2015-01-12 18:22:58 +00:00
// ACE - Common
2015-12-30 07:07:55 +00:00
// #define ENABLE_PERFORMANCE_COUNTERS
2016-01-13 00:18:12 +00:00
// #define DEBUG_MODE_FULL
2015-09-21 15:00:53 +00:00
#include "script_component.hpp"
2015-08-30 20:26:43 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Get Map Data
//////////////////////////////////////////////////
//Find MGRS zone and 100km grid for current map
[] call FUNC(getMGRSdata);
//Prepare variables for FUNC(getMapGridFromPos)/FUNC(getMapPosFromGrid)
[] call FUNC(getMapGridData);
//////////////////////////////////////////////////
// Eventhandlers
//////////////////////////////////////////////////
2016-01-13 00:18:12 +00:00
//Status Effect EHs:
2016-06-03 19:07:49 +00:00
[QGVAR(setStatusEffect), {_this call FUNC(statusEffect_set)}] call CBA_fnc_addEventHandler;
2016-01-13 00:18:12 +00:00
["forceWalk", false, ["ACE_SwitchUnits", "ACE_Attach", "ACE_dragging", "ACE_Explosives", "ACE_Ladder", "ACE_Sandbag", "ACE_refuel", "ACE_rearm", "ACE_dragging"]] call FUNC(statusEffect_addType);
2016-01-16 23:27:42 +00:00
["blockSprint", false, []] call FUNC(statusEffect_addType);
2016-06-03 18:57:21 +00:00
["setCaptive", true, [QEGVAR(captives,Handcuffed), QEGVAR(captives,Surrendered), "ace_unconscious"]] call FUNC(statusEffect_addType);
2016-01-13 00:18:12 +00:00
["blockDamage", false, ["fixCollision"]] call FUNC(statusEffect_addType);
2016-05-03 18:52:43 +00:00
["blockEngine", false, ["ACE_Refuel"]] call FUNC(statusEffect_addType);
2016-01-13 00:18:12 +00:00
2016-06-03 19:07:49 +00:00
[QGVAR(forceWalk), {
2016-01-13 00:18:12 +00:00
params ["_object", "_set"];
TRACE_2("forceWalk EH",_object,_set);
_object forceWalk (_set > 0);
2016-05-22 15:29:05 +00:00
}] call CBA_fnc_addEventHandler;
2016-06-03 19:07:49 +00:00
[QGVAR(blockSprint), { //Name reversed from `allowSprint` because we want NOR logic
2016-01-16 23:27:42 +00:00
params ["_object", "_set"];
TRACE_2("blockSprint EH",_object,_set);
_object allowSprint (_set == 0);
2016-05-22 15:29:05 +00:00
}] call CBA_fnc_addEventHandler;
2016-09-30 08:38:27 +00:00
[QGVAR(setAnimSpeedCoef), {
params ["_object", "_set"];
_object setAnimSpeedCoef _set;
}] call CBA_fnc_addEventHandler;
2016-06-03 19:07:49 +00:00
[QGVAR(setCaptive), {
2016-01-13 00:18:12 +00:00
params ["_object", "_set"];
2016-01-16 23:27:42 +00:00
TRACE_2("setCaptive EH",_object,_set);
2016-01-13 00:18:12 +00:00
_object setCaptive (_set > 0);
2016-05-22 15:29:05 +00:00
}] call CBA_fnc_addEventHandler;
2016-06-03 19:07:49 +00:00
[QGVAR(blockDamage), { //Name reversed from `allowDamage` because we want NOR logic
2016-01-13 00:18:12 +00:00
params ["_object", "_set"];
if ((_object isKindOf "CAManBase") && {(["ace_medical"] call FUNC(isModLoaded))}) then {
TRACE_2("blockDamage EH (using medical)",_object,_set);
_object setvariable [QEGVAR(medical,allowDamage), (_set == 0), true];
} else {
TRACE_2("blockDamage EH (using allowDamage)",_object,_set);
_object allowDamage (_set == 0);
};
2016-05-22 15:29:05 +00:00
}] call CBA_fnc_addEventHandler;
2016-06-03 19:07:49 +00:00
[QGVAR(blockEngine), {
2016-05-03 18:52:43 +00:00
params ["_vehicle", "_set"];
_vehicle setVariable [QGVAR(blockEngine), _set > 0, true];
_vehicle engineOn false;
2016-05-22 15:29:05 +00:00
}] call CBA_fnc_addEventHandler;
2016-01-13 00:18:12 +00:00
2015-12-18 17:08:10 +00:00
//Add a fix for BIS's zeus remoteControl module not reseting variables on DC when RC a unit
//This variable is used for isPlayer checks
if (isServer) then {
addMissionEventHandler ["HandleDisconnect", {
params ["_dcPlayer"];
private _zeusLogic = getAssignedCuratorLogic _dcPlayer;
if ((!isNil "_zeusLogic") && {!isNull _zeusLogic}) then {
{
if ((_x getvariable ["bis_fnc_moduleRemoteControl_owner", objnull]) isEqualTo _dcPlayer) exitWith {
2016-08-22 19:06:52 +00:00
INFO_3("[%1] DC - Was Zeus [%2] while controlling unit [%3] - manually clearing `bis_fnc_moduleRemoteControl_owner`", [_x] call FUNC(getName), _dcPlayer, _x);
2015-12-18 17:08:10 +00:00
_x setVariable ["bis_fnc_moduleRemoteControl_owner", nil, true];
};
2015-12-20 03:17:36 +00:00
nil
2015-12-18 17:08:10 +00:00
} count (curatorEditableObjects _zeusLogic);
};
}];
};
2015-02-03 04:45:04 +00:00
// Listens for global "SettingChanged" events, to update the force status locally
2016-06-04 10:12:56 +00:00
["ace_settingChanged", {
2015-09-21 15:00:53 +00:00
params ["_name", "_value", "_force"];
2015-02-03 04:45:04 +00:00
if (_force) then {
2015-12-14 12:17:48 +00:00
private _settingData = [_name] call FUNC(getSettingData);
2015-09-21 15:00:53 +00:00
if (_settingData isEqualTo []) exitWith {};
_settingData set [6, _force];
2015-02-03 04:45:04 +00:00
};
2016-05-22 15:29:05 +00:00
}] call CBA_fnc_addEventHandler;
2015-02-03 04:45:04 +00:00
2015-08-02 01:01:35 +00:00
2015-09-21 15:00:53 +00:00
// Event to log Fix Headbug output
2016-06-03 19:38:16 +00:00
[QGVAR(headbugFixUsed), {
2015-09-21 15:00:53 +00:00
params ["_profileName", "_animation"];
2016-08-22 19:06:52 +00:00
INFO_2("Headbug Used: Name: %1, Animation: %2",_profileName,_animation);
2016-05-22 15:29:05 +00:00
}] call CBA_fnc_addEventHandler;
2015-08-02 01:01:35 +00:00
2016-06-04 10:12:56 +00:00
[QGVAR(fixCollision), FUNC(fixCollision)] call CBA_fnc_addEventHandler;
[QGVAR(fixFloating), FUNC(fixFloating)] call CBA_fnc_addEventHandler;
[QGVAR(fixPosition), FUNC(fixPosition)] call CBA_fnc_addEventHandler;
2015-08-02 01:01:35 +00:00
2016-05-24 13:13:11 +00:00
["ace_loadPersonEvent", FUNC(loadPersonLocal)] call CBA_fnc_addEventHandler;
["ace_unloadPersonEvent", FUNC(unloadPersonLocal)] call CBA_fnc_addEventHandler;
2015-06-11 22:56:11 +00:00
2016-06-04 10:12:56 +00:00
[QGVAR(lockVehicle), {
2015-03-18 10:29:58 +00:00
_this setVariable [QGVAR(lockStatus), locked _this];
_this lock 2;
2016-05-22 15:29:05 +00:00
}] call CBA_fnc_addEventHandler;
2015-03-18 10:29:58 +00:00
2016-06-04 10:12:56 +00:00
[QGVAR(unlockVehicle), {
2015-03-18 10:29:58 +00:00
_this lock (_this getVariable [QGVAR(lockStatus), locked _this]);
2016-05-22 15:29:05 +00:00
}] call CBA_fnc_addEventHandler;
2016-06-04 10:12:56 +00:00
[QGVAR(setDir), {(_this select 0) setDir (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(setFuel), {(_this select 0) setFuel (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(engineOn), {(_this select 0) engineOn (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(setSpeaker), {(_this select 0) setSpeaker (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(selectLeader), {(_this select 0) selectLeader (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(setVelocity), {(_this select 0) setVelocity (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(playMove), {(_this select 0) playMove (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(playMoveNow), {(_this select 0) playMoveNow (_this select 1)}] call CBA_fnc_addEventHandler;
2016-07-12 14:16:01 +00:00
[QGVAR(playAction), {(_this select 0) playAction (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(playActionNow), {(_this select 0) playActionNow (_this select 1)}] call CBA_fnc_addEventHandler;
2016-06-04 10:12:56 +00:00
[QGVAR(switchMove), {(_this select 0) switchMove (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(setVectorDirAndUp), {(_this select 0) setVectorDirAndUp (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(setVanillaHitPointDamage), {(_this select 0) setHitPointDamage (_this select 1)}] call CBA_fnc_addEventHandler;
2015-03-24 18:07:39 +00:00
2016-05-21 17:59:44 +00:00
// Request framework
2016-06-03 00:29:30 +00:00
[QGVAR(requestCallback), FUNC(requestCallback)] call CBA_fnc_addEventHandler;
[QGVAR(receiveRequest), FUNC(receiveRequest)] call CBA_fnc_addEventHandler;
2016-05-21 17:59:44 +00:00
2016-06-03 00:29:30 +00:00
[QGVAR(systemChatGlobal), {systemChat _this}] call CBA_fnc_addEventHandler;
2016-05-21 17:59:44 +00:00
2015-07-03 01:14:58 +00:00
if (isServer) then {
2016-06-03 19:38:16 +00:00
[QGVAR(hideObjectGlobal), {(_this select 0) hideObjectGlobal (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(enableSimulationGlobal), {(_this select 0) enableSimulationGlobal (_this select 1)}] call CBA_fnc_addEventHandler;
2017-04-11 14:59:32 +00:00
[QGVAR(setShotParents), {(_this select 0) setShotParents [_this select 1, _this select 2]}] call CBA_fnc_addEventHandler;
2016-06-03 00:29:30 +00:00
["ace_setOwner", {(_this select 0) setOwner (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(serverLog), FUNC(serverLog)] call CBA_fnc_addEventHandler;
2015-07-03 01:14:58 +00:00
};
2015-01-11 16:42:31 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Set up remote execution
//////////////////////////////////////////////////
2015-01-11 16:42:31 +00:00
2015-04-18 02:26:27 +00:00
// Synced ACE events
// Handle JIP scenario
2015-09-21 15:00:53 +00:00
if (!isServer) then {
2016-06-03 19:38:16 +00:00
["ace_playerJIP", {
2016-08-22 19:06:52 +00:00
INFO("JIP event synchronization initialized");
2016-06-04 19:05:26 +00:00
["ACEa", [player]] call CBA_fnc_serverEvent;
2016-05-22 15:29:05 +00:00
}] call CBA_fnc_addEventHandler;
2015-04-18 02:26:27 +00:00
} else {
2016-06-04 19:05:26 +00:00
["ACEa", FUNC(_handleRequestAllSyncedEvents)] call CBA_fnc_addEventHandler;
2015-04-18 02:26:27 +00:00
};
2015-09-21 15:00:53 +00:00
2016-06-04 19:05:26 +00:00
["ACEe", FUNC(_handleSyncedEvent)] call CBA_fnc_addEventHandler;
["ACEs", FUNC(_handleRequestSyncedEvent)] call CBA_fnc_addEventHandler;
2015-09-21 15:00:53 +00:00
2015-08-06 05:28:43 +00:00
if (isServer) then {
[FUNC(syncedEventPFH), 0.5, []] call CBA_fnc_addPerFrameHandler;
};
2015-08-11 18:10:42 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Check files, previous installed version etc.
//////////////////////////////////////////////////
2015-12-14 12:17:48 +00:00
private _currentVersion = getText (configFile >> "CfgPatches" >> QUOTE(ADDON) >> "version");
private _previousVersion = profileNamespace getVariable ["ACE_VersionNumberString", ""];
2015-09-21 15:00:53 +00:00
// check previous version number from profile
if (_currentVersion != _previousVersion) then {
// do something
profileNamespace setVariable ["ACE_VersionNumberString", _currentVersion];
};
2015-05-09 11:25:19 +00:00
call FUNC(checkFiles);
2015-04-18 02:26:27 +00:00
2015-06-13 03:57:01 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
2016-06-03 00:59:18 +00:00
// Set up ace_settingsInitialized eventhandler
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
2016-06-03 00:59:18 +00:00
["ace_settingsInitialized", {
2015-09-21 15:00:53 +00:00
[
GVAR(checkPBOsAction),
GVAR(checkPBOsCheckAll),
2015-12-03 05:58:41 +00:00
GVAR(checkPBOsWhitelist)
2015-09-21 15:00:53 +00:00
] call FUNC(checkPBOs)
2016-05-22 15:29:05 +00:00
}] call CBA_fnc_addEventHandler;
2015-09-21 15:00:53 +00:00
2015-06-13 03:57:01 +00:00
// Create a pfh to wait until all postinits are ready and settings are initialized
[{
2015-09-21 15:00:53 +00:00
params ["_args"];
_args params ["_waitingMsgSent"];
2015-06-13 03:57:01 +00:00
// If post inits are not ready then wait
if !(SLX_XEH_MACHINE select 8) exitWith {};
// If settings are not initialized then wait
2015-09-21 15:00:53 +00:00
if (isNil QGVAR(settings) || {!isServer && isNil QEGVAR(modules,serverModulesRead)}) exitWith {
if !(_waitingMsgSent) then {
2015-06-13 03:57:01 +00:00
_args set [0, true];
2016-08-22 19:06:52 +00:00
INFO("Waiting on settings from server...");
2015-06-13 03:57:01 +00:00
};
};
2015-09-21 15:00:53 +00:00
[_this select 1] call CBA_fnc_removePerFrameHandler;
2015-06-13 03:57:01 +00:00
2016-08-22 19:06:52 +00:00
INFO("Settings received from server.");
2015-06-13 03:57:01 +00:00
2015-11-07 02:46:06 +00:00
if (isServer) then { //read settings from paramsArray
[] call FUNC(readSettingsFromParamsArray);
};
2015-06-13 03:57:01 +00:00
// Event so that ACE_Modules have their settings loaded:
2016-06-03 19:38:16 +00:00
[QGVAR(initSettingsFromModules), []] call CBA_fnc_localEvent;
2015-06-13 03:57:01 +00:00
2015-10-18 23:49:03 +00:00
if (isServer) then {
// Publish all settings data after all configs and modules are read
publicVariable QGVAR(settings);
};
2016-02-18 01:54:43 +00:00
2015-06-13 03:57:01 +00:00
// Load user settings from profile
if (hasInterface) then {
call FUNC(loadSettingsFromProfile);
call FUNC(loadSettingsLocalizedText);
};
2016-08-22 19:06:52 +00:00
INFO("Settings initialized.");
2015-06-13 03:57:01 +00:00
//Event that settings are safe to use:
2016-05-24 13:13:11 +00:00
["ace_settingsInitialized", []] call CBA_fnc_localEvent;
2015-06-13 03:57:01 +00:00
2015-09-03 04:58:24 +00:00
//Set init finished and run all delayed functions:
GVAR(settingsInitFinished) = true;
2016-08-22 19:06:52 +00:00
INFO_1("%1 delayed functions running.",count GVAR(runAtSettingsInitialized));
2015-09-21 15:00:53 +00:00
2015-09-03 04:58:24 +00:00
{
2015-09-21 15:00:53 +00:00
(_x select 1) call (_x select 0);
false
} count GVAR(runAtSettingsInitialized);
2015-09-03 05:16:48 +00:00
GVAR(runAtSettingsInitialized) = nil; //cleanup
2015-08-04 07:34:31 +00:00
}, 0, [false]] call CBA_fnc_addPerFrameHandler;
2015-06-13 03:57:01 +00:00
2015-09-21 15:00:53 +00:00
/***************************************************************************/
/***************************************************************************/
/** everything that only player controlled machines need, goes below this **/
/***************************************************************************/
/***************************************************************************/
2015-04-18 02:26:27 +00:00
2015-01-11 16:42:31 +00:00
if (!hasInterface) exitWith {};
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Set up mouse wheel eventhandler
//////////////////////////////////////////////////
call FUNC(assignedItemFix);
2015-09-21 16:37:19 +00:00
2015-09-21 15:00:53 +00:00
// @todo remove?
2015-01-11 16:42:31 +00:00
enableCamShake true;
2015-09-21 15:00:53 +00:00
2016-05-31 06:53:28 +00:00
//FUNC(showHud) needs to be refreshed if it was set during mission init
["ace_infoDisplayChanged", {
2016-07-30 10:28:06 +00:00
GVAR(showHudHash) params ["", "", "_masks"];
if !(_masks isEqualTo []) then {
2016-05-31 06:53:28 +00:00
[] call FUNC(showHud);
};
}] call CBA_fnc_addEventHandler;
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Eventhandler to set player names
//////////////////////////////////////////////////
2015-01-12 04:02:33 +00:00
// Set the name for the current player
2016-06-22 09:16:55 +00:00
["unit", {
2015-09-21 15:00:53 +00:00
params ["_newPlayer","_oldPlayer"];
2015-04-30 18:49:38 +00:00
2015-01-16 15:14:18 +00:00
if (alive _newPlayer) then {
2017-02-10 19:03:12 +00:00
[FUNC(setName), [_newPlayer]] call CBA_fnc_execNextFrame;
2015-01-12 21:34:01 +00:00
};
2015-09-21 15:00:53 +00:00
2015-01-16 15:14:18 +00:00
if (alive _oldPlayer) then {
2017-02-10 19:03:12 +00:00
[FUNC(setName), [_oldPlayer]] call CBA_fnc_execNextFrame;
2015-01-12 21:34:01 +00:00
};
2016-06-22 09:16:55 +00:00
}] call CBA_fnc_addPlayerEventHandler;
2015-01-13 23:27:42 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Set up numerous eventhanders for player controlled units
//////////////////////////////////////////////////
2017-04-11 15:06:29 +00:00
TRACE_1("adding unit playerEH to set ace_player",isNull cba_events_oldUnit);
2016-06-22 00:31:25 +00:00
["unit", {
ACE_player = (_this select 0);
2017-04-11 15:06:29 +00:00
}, true] call CBA_fnc_addPlayerEventHandler;
2016-06-22 00:31:25 +00:00
2015-09-21 15:00:53 +00:00
GVAR(OldIsCamera) = false;
2015-01-13 23:27:42 +00:00
2015-01-16 18:28:37 +00:00
[{
2015-08-30 20:26:43 +00:00
BEGIN_COUNTER(stateChecker);
2015-09-21 15:00:53 +00:00
// "activeCameraChanged" event
2016-06-22 08:46:04 +00:00
private _data = call FUNC(isfeatureCameraActive);
2015-09-21 15:00:53 +00:00
if !(_data isEqualTo GVAR(OldIsCamera)) then {
2015-08-11 18:10:42 +00:00
// Raise ACE event locally
2015-09-21 15:00:53 +00:00
GVAR(OldIsCamera) = _data;
2016-05-24 13:13:11 +00:00
["ace_activeCameraChanged", [ACE_player, _data]] call CBA_fnc_localEvent;
2015-08-11 18:10:42 +00:00
};
2015-08-26 13:20:11 +00:00
2015-08-30 20:26:43 +00:00
END_COUNTER(stateChecker);
2016-06-22 00:31:25 +00:00
}, 0.5, []] call CBA_fnc_addPerFrameHandler;
2015-04-18 20:06:42 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Eventhandlers for player controlled machines
//////////////////////////////////////////////////
2015-04-18 20:06:42 +00:00
2016-06-04 10:12:56 +00:00
[QGVAR(displayTextStructured), {_this call FUNC(displayTextStructured)}] call CBA_fnc_addEventHandler;
[QGVAR(displayTextPicture), {_this call FUNC(displayTextPicture)}] call CBA_fnc_addEventHandler;
2015-04-18 20:06:42 +00:00
2016-06-04 10:12:56 +00:00
["ace_unconscious", {
2015-09-21 15:00:53 +00:00
params ["_unit", "_isUnconscious"];
2015-04-18 20:06:42 +00:00
2015-09-21 15:00:53 +00:00
if (local _unit && {!_isUnconscious}) then {
[_unit, false, QFUNC(loadPerson), west /* dummy side */] call FUNC(switchToGroupSide);
};
2016-05-22 15:29:05 +00:00
}] call CBA_fnc_addEventHandler;
2015-04-18 20:06:42 +00:00
2016-05-24 13:13:11 +00:00
["ace_useItem", DFUNC(useItem)] call CBA_fnc_addEventHandler;
2016-02-18 01:54:43 +00:00
2015-01-28 20:38:04 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Add various canInteractWith conditions
//////////////////////////////////////////////////
2015-03-15 08:26:16 +00:00
2016-03-12 13:06:45 +00:00
["isNotDead", {
2016-07-07 07:10:14 +00:00
params ["_unit"];
2016-03-12 13:06:45 +00:00
alive _unit
}] call FUNC(addCanInteractWithCondition);
2015-03-15 15:12:37 +00:00
["notOnMap", {!visibleMap}] call FUNC(addCanInteractWithCondition);
2015-09-21 15:00:53 +00:00
2015-03-31 21:06:28 +00:00
["isNotInside", {
2015-09-21 15:00:53 +00:00
params ["_unit", "_target"];
2015-03-31 21:06:28 +00:00
// Players can always interact with himself if not boarded
2015-09-21 15:00:53 +00:00
vehicle _unit == _unit ||
2015-03-31 21:06:28 +00:00
// Players can always interact with his vehicle
2015-09-21 15:00:53 +00:00
{vehicle _unit == _target} ||
2015-03-31 21:06:28 +00:00
// Players can always interact with passengers of the same vehicle
2015-09-21 15:00:53 +00:00
{_unit != _target && {vehicle _unit == vehicle _target}}
2015-03-31 21:06:28 +00:00
}] call FUNC(addCanInteractWithCondition);
2015-04-17 23:44:53 +00:00
2015-12-30 07:48:43 +00:00
["isNotInZeus", {isNull curatorCamera}] call FUNC(addCanInteractWithCondition);
2016-07-07 13:47:37 +00:00
//////////////////////////////////////////////////
// Set up reload mutex
//////////////////////////////////////////////////
GVAR(isReloading) = false;
["keyDown", {
2016-07-07 14:35:07 +00:00
if ((_this select 1) in actionKeys "ReloadMagazine" && {alive ACE_player}) then {
2016-07-12 02:53:02 +00:00
//Ignore mounted (except ffv)
if (!(player call CBA_fnc_canUseWeapon)) exitWith {};
2016-07-07 13:47:37 +00:00
private _weapon = currentWeapon ACE_player;
if (_weapon != "") then {
private _gesture = getText (configfile >> "CfgWeapons" >> _weapon >> "reloadAction");
2016-07-12 02:53:02 +00:00
if (_gesture == "") exitWith {}; //Ignore weapons with no reload gesture (binoculars)
2016-07-07 13:47:37 +00:00
private _isLauncher = _weapon isKindOf ["Launcher", configFile >> "CfgWeapons"];
private _config = ["CfgGesturesMale", "CfgMovesMaleSdr"] select _isLauncher;
private _duration = getNumber (configfile >> _config >> "States" >> _gesture >> "speed");
if (_duration != 0) then {
_duration = if (_duration < 0) then { abs _duration } else { 1 / _duration };
} else {
_duration = 3;
};
TRACE_2("Reloading, blocking gestures",_weapon,_duration);
2016-07-08 13:12:47 +00:00
GVAR(reloadingETA) = CBA_missionTime + _duration;
if (!GVAR(isReloading)) then {
GVAR(isReloading) = true;
[{
CBA_missionTime > GVAR(reloadingETA)
},{
GVAR(isReloading) = false;
}] call CBA_fnc_waitUntilAndExecute;
};
2016-07-07 13:47:37 +00:00
};
};
false
}] call CBA_fnc_addDisplayHandler;
2015-09-21 16:37:19 +00:00
//////////////////////////////////////////////////
// Set up PlayerJIP eventhandler
//////////////////////////////////////////////////
2015-04-18 02:26:27 +00:00
// Lastly, do JIP events
2015-04-18 01:23:26 +00:00
// JIP Detection and event trigger. Run this at the very end, just in case anything uses it
2015-09-21 16:37:19 +00:00
// Note: usage of player is most likely on purpose
2015-08-27 03:39:27 +00:00
if (didJip) then {
2015-04-18 01:23:26 +00:00
// We are jipping! Get ready and wait, and throw the event
[{
2015-09-21 16:37:19 +00:00
if(!isNull player && GVAR(settingsInitFinished)) then {
2016-06-03 19:38:16 +00:00
["ace_playerJIP", [player]] call CBA_fnc_localEvent;
2015-09-21 16:37:19 +00:00
[_this select 1] call CBA_fnc_removePerFrameHandler;
2015-04-30 18:49:38 +00:00
};
2015-08-04 07:34:31 +00:00
}, 0, []] call CBA_fnc_addPerFrameHandler;
2015-04-18 01:23:26 +00:00
};
2015-05-10 19:59:53 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// CBA key input handling
//////////////////////////////////////////////////
2015-05-10 19:59:53 +00:00
//Device Handler:
GVAR(deviceKeyHandlingArray) = [];
GVAR(deviceKeyCurrentIndex) = -1;
2015-08-07 01:33:38 +00:00
// Register localizations for the Keybinding categories
2015-09-21 15:00:53 +00:00
["ACE3 Equipment", localize LSTRING(ACEKeybindCategoryEquipment)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Common", localize LSTRING(ACEKeybindCategoryCommon)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Weapons", localize LSTRING(ACEKeybindCategoryWeapons)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Movement", localize LSTRING(ACEKeybindCategoryMovement)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Scope Adjustment", localize LSTRING(ACEKeybindCategoryScopeAdjustment)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Vehicles", localize LSTRING(ACEKeybindCategoryVehicles)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Equipment", QGVAR(openDevice), (localize "STR_ACE_Common_toggleHandheldDevice"), {
2015-05-10 19:59:53 +00:00
[] call FUNC(deviceKeyFindValidIndex);
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
[] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 3);
2015-05-12 03:48:03 +00:00
true
2015-05-10 19:59:53 +00:00
},
{false},
2015-09-21 15:00:53 +00:00
[0xC7, [false, false, false]], false] call CBA_fnc_addKeybind; //Home Key
2015-05-10 19:59:53 +00:00
2015-09-21 15:00:53 +00:00
["ACE3 Equipment", QGVAR(closeDevice), (localize "STR_ACE_Common_closeHandheldDevice"), {
2015-05-10 19:59:53 +00:00
[] call FUNC(deviceKeyFindValidIndex);
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
[] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 4);
2015-05-12 03:48:03 +00:00
true
2015-05-10 19:59:53 +00:00
},
{false},
2015-09-21 15:00:53 +00:00
[0xC7, [false, true, false]], false] call CBA_fnc_addKeybind; //CTRL + Home Key
2015-05-10 19:59:53 +00:00
2015-09-21 15:00:53 +00:00
["ACE3 Equipment", QGVAR(cycleDevice), (localize "STR_ACE_Common_cycleHandheldDevices"), {
2015-05-10 19:59:53 +00:00
[1] call FUNC(deviceKeyFindValidIndex);
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
_displayName = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 0);
_iconImage = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 1);
[_displayName, _iconImage] call FUNC(displayTextPicture);
2015-05-12 03:48:03 +00:00
true
2015-05-10 19:59:53 +00:00
},
{false},
2015-09-21 15:00:53 +00:00
[0xC7, [true, false, false]], false] call CBA_fnc_addKeybind; //SHIFT + Home Key
2015-06-05 22:50:04 +00:00
2015-05-14 23:45:53 +00:00
GVAR(commonPostInited) = true;