mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
more common code cleanup
This commit is contained in:
parent
414151de38
commit
3037181fc2
@ -1,16 +1,18 @@
|
|||||||
// ACE - Common
|
// ACE - Common
|
||||||
|
|
||||||
// #define ENABLE_PERFORMANCE_COUNTERS
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
//IGNORE_PRIVATE_WARNING("_handleNetEvent", "_handleRequestAllSyncedEvents", "_handleRequestSyncedEvent", "_handleSyncedEvent");
|
// #define ENABLE_PERFORMANCE_COUNTERS
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
// PFHs
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
//Singe PFEH to handle execNextFrame and waitAndExec:
|
//Singe PFEH to handle execNextFrame and waitAndExec:
|
||||||
[{
|
[{
|
||||||
private ["_entry"];
|
private "_entry";
|
||||||
|
|
||||||
//Handle the waitAndExec array:
|
//Handle the waitAndExec array:
|
||||||
while {((count GVAR(waitAndExecArray)) > 0) && {((GVAR(waitAndExecArray) select 0) select 0) <= ACE_Time}} do {
|
while {!(GVAR(waitAndExecArray) isEqualTo []) && {GVAR(waitAndExecArray) select 0 select 0 <= ACE_Time}} do {
|
||||||
_entry = GVAR(waitAndExecArray) deleteAt 0;
|
_entry = GVAR(waitAndExecArray) deleteAt 0;
|
||||||
(_entry select 2) call (_entry select 1);
|
(_entry select 2) call (_entry select 1);
|
||||||
};
|
};
|
||||||
@ -18,7 +20,9 @@
|
|||||||
//Handle the execNextFrame array:
|
//Handle the execNextFrame array:
|
||||||
{
|
{
|
||||||
(_x select 0) call (_x select 1);
|
(_x select 0) call (_x select 1);
|
||||||
} forEach GVAR(nextFrameBufferA);
|
false
|
||||||
|
} count GVAR(nextFrameBufferA);
|
||||||
|
|
||||||
//Swap double-buffer:
|
//Swap double-buffer:
|
||||||
GVAR(nextFrameBufferA) = GVAR(nextFrameBufferB);
|
GVAR(nextFrameBufferA) = GVAR(nextFrameBufferB);
|
||||||
GVAR(nextFrameBufferB) = [];
|
GVAR(nextFrameBufferB) = [];
|
||||||
@ -26,39 +30,46 @@
|
|||||||
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
|
|
||||||
// Listens for global "SettingChanged" events, to update the force status locally
|
//////////////////////////////////////////////////
|
||||||
["SettingChanged", {
|
// Get Map Data
|
||||||
PARAMS_2(_name,_value);
|
//////////////////////////////////////////////////
|
||||||
if !(count _this > 2) exitWith {};
|
|
||||||
private ["_force", "_settingData"];
|
|
||||||
_force = _this select 2;
|
|
||||||
if (_force) then {
|
|
||||||
_settingData = [_name] call FUNC(getSettingData);
|
|
||||||
if (count _settingData == 0) exitWith {};
|
|
||||||
_settingData set [6,_force];
|
|
||||||
};
|
|
||||||
}] call FUNC(addEventhandler);
|
|
||||||
|
|
||||||
|
|
||||||
["HeadbugFixUsed", {
|
|
||||||
PARAMS_2(_profileName,_animation);
|
|
||||||
ACE_LOGINFO_2("Headbug Used: Name: %1, Animation: %2",_profileName,_animation);
|
|
||||||
}] call FUNC(addEventHandler);
|
|
||||||
|
|
||||||
|
|
||||||
//~~~~~Get Map Data~~~~~
|
|
||||||
//Find MGRS zone and 100km grid for current map
|
//Find MGRS zone and 100km grid for current map
|
||||||
[] call FUNC(getMGRSdata);
|
[] call FUNC(getMGRSdata);
|
||||||
//Prepare variables for FUNC(getMapGridFromPos)/FUNC(getMapPosFromGrid)
|
//Prepare variables for FUNC(getMapGridFromPos)/FUNC(getMapPosFromGrid)
|
||||||
[] call FUNC(getMapGridData);
|
[] call FUNC(getMapGridData);
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
// Eventhandlers
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
["fixCollision", DFUNC(fixCollision)] call FUNC(addEventhandler);
|
// Listens for global "SettingChanged" events, to update the force status locally
|
||||||
["fixFloating", DFUNC(fixFloating)] call FUNC(addEventhandler);
|
["SettingChanged", {
|
||||||
["fixPosition", DFUNC(fixPosition)] call FUNC(addEventhandler);
|
params ["_name", "_value", "_force"];
|
||||||
|
|
||||||
["unloadPersonEvent", DFUNC(unloadPersonLocal)] call FUNC(addEventhandler);
|
if (_force) then {
|
||||||
|
private "_settingData";
|
||||||
|
_settingData = [_name] call FUNC(getSettingData);
|
||||||
|
|
||||||
|
if (_settingData isEqualTo []) exitWith {};
|
||||||
|
|
||||||
|
_settingData set [6, _force];
|
||||||
|
};
|
||||||
|
}] call FUNC(addEventhandler);
|
||||||
|
|
||||||
|
|
||||||
|
// Event to log Fix Headbug output
|
||||||
|
["HeadbugFixUsed", {
|
||||||
|
params ["_profileName", "_animation"];
|
||||||
|
ACE_LOGINFO_2("Headbug Used: Name: %1, Animation: %2",_profileName,_animation);
|
||||||
|
}] call FUNC(addEventHandler);
|
||||||
|
|
||||||
|
["fixCollision", FUNC(fixCollision)] call FUNC(addEventhandler);
|
||||||
|
["fixFloating", FUNC(fixFloating)] call FUNC(addEventhandler);
|
||||||
|
["fixPosition", FUNC(fixPosition)] call FUNC(addEventhandler);
|
||||||
|
|
||||||
|
["unloadPersonEvent", FUNC(unloadPersonLocal)] call FUNC(addEventhandler);
|
||||||
|
|
||||||
["lockVehicle", {
|
["lockVehicle", {
|
||||||
_this setVariable [QGVAR(lockStatus), locked _this];
|
_this setVariable [QGVAR(lockStatus), locked _this];
|
||||||
@ -77,22 +88,10 @@ if (isServer) then {
|
|||||||
["hideObjectGlobal", {(_this select 0) hideObjectGlobal (_this select 1)}] call FUNC(addEventHandler);
|
["hideObjectGlobal", {(_this select 0) hideObjectGlobal (_this select 1)}] call FUNC(addEventHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
QGVAR(remoteFnc) addPublicVariableEventHandler {
|
|
||||||
(_this select 1) call FUNC(execRemoteFnc);
|
|
||||||
};
|
|
||||||
|
|
||||||
[missionNamespace] call FUNC(executePersistent);
|
//////////////////////////////////////////////////
|
||||||
|
// Set up remote execution
|
||||||
private ["_currentVersion", "_previousVersion"];
|
//////////////////////////////////////////////////
|
||||||
// check previous version number from profile
|
|
||||||
_currentVersion = getText (configFile >> "CfgPatches" >> QUOTE(ADDON) >> "version");
|
|
||||||
_previousVersion = profileNamespace getVariable ["ACE_VersionNumberString", ""];
|
|
||||||
|
|
||||||
if (_currentVersion != _previousVersion) then {
|
|
||||||
// do something
|
|
||||||
|
|
||||||
profileNamespace setVariable ["ACE_VersionNumberString", _currentVersion];
|
|
||||||
};
|
|
||||||
|
|
||||||
// ACE events
|
// ACE events
|
||||||
"ACEg" addPublicVariableEventHandler { _this call FUNC(_handleNetEvent); };
|
"ACEg" addPublicVariableEventHandler { _this call FUNC(_handleNetEvent); };
|
||||||
@ -100,7 +99,7 @@ if (_currentVersion != _previousVersion) then {
|
|||||||
|
|
||||||
// Synced ACE events
|
// Synced ACE events
|
||||||
// Handle JIP scenario
|
// Handle JIP scenario
|
||||||
if(!isServer) then {
|
if (!isServer) then {
|
||||||
["PlayerJip", {
|
["PlayerJip", {
|
||||||
ACE_LOGINFO("JIP event synchronization initialized");
|
ACE_LOGINFO("JIP event synchronization initialized");
|
||||||
["SEH_all", [player]] call FUNC(serverEvent);
|
["SEH_all", [player]] call FUNC(serverEvent);
|
||||||
@ -108,31 +107,72 @@ if(!isServer) then {
|
|||||||
} else {
|
} else {
|
||||||
["SEH_all", FUNC(_handleRequestAllSyncedEvents)] call FUNC(addEventHandler);
|
["SEH_all", FUNC(_handleRequestAllSyncedEvents)] call FUNC(addEventHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
["SEH", FUNC(_handleSyncedEvent)] call FUNC(addEventHandler);
|
["SEH", FUNC(_handleSyncedEvent)] call FUNC(addEventHandler);
|
||||||
["SEH_s", FUNC(_handleRequestSyncedEvent)] call FUNC(addEventHandler);
|
["SEH_s", FUNC(_handleRequestSyncedEvent)] call FUNC(addEventHandler);
|
||||||
|
|
||||||
if (isServer) then {
|
if (isServer) then {
|
||||||
[FUNC(syncedEventPFH), 0.5, []] call CBA_fnc_addPerFrameHandler;
|
[FUNC(syncedEventPFH), 0.5, []] call CBA_fnc_addPerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// @todo deprecated
|
||||||
|
QGVAR(remoteFnc) addPublicVariableEventHandler {
|
||||||
|
(_this select 1) call FUNC(execRemoteFnc);
|
||||||
|
};
|
||||||
|
|
||||||
|
// @todo figure out what this does.
|
||||||
|
[missionNamespace] call FUNC(executePersistent);
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
// Check files, previous installed version etc.
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
private ["_currentVersion", "_previousVersion"];
|
||||||
|
|
||||||
|
_currentVersion = getText (configFile >> "CfgPatches" >> QUOTE(ADDON) >> "version");
|
||||||
|
_previousVersion = profileNamespace getVariable ["ACE_VersionNumberString", ""];
|
||||||
|
|
||||||
|
// check previous version number from profile
|
||||||
|
if (_currentVersion != _previousVersion) then {
|
||||||
|
// do something
|
||||||
|
|
||||||
|
profileNamespace setVariable ["ACE_VersionNumberString", _currentVersion];
|
||||||
|
};
|
||||||
|
|
||||||
call FUNC(checkFiles);
|
call FUNC(checkFiles);
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
// Set up SettingsInitialized eventhandler
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
["SettingsInitialized", {
|
||||||
|
[
|
||||||
|
GVAR(checkPBOsAction),
|
||||||
|
GVAR(checkPBOsCheckAll),
|
||||||
|
call compile GVAR(checkPBOsWhitelist)
|
||||||
|
] call FUNC(checkPBOs)
|
||||||
|
}] call FUNC(addEventHandler);
|
||||||
|
|
||||||
// Create a pfh to wait until all postinits are ready and settings are initialized
|
// Create a pfh to wait until all postinits are ready and settings are initialized
|
||||||
[{
|
[{
|
||||||
PARAMS_1(_args);
|
params ["_args"];
|
||||||
EXPLODE_1_PVT(_args,_waitingMsgSent);
|
|
||||||
|
_args params ["_waitingMsgSent"];
|
||||||
|
|
||||||
// If post inits are not ready then wait
|
// If post inits are not ready then wait
|
||||||
if !(SLX_XEH_MACHINE select 8) exitWith {};
|
if !(SLX_XEH_MACHINE select 8) exitWith {};
|
||||||
|
|
||||||
// If settings are not initialized then wait
|
// If settings are not initialized then wait
|
||||||
if (isNil QGVAR(settings) || {(!isServer) && (isNil QEGVAR(modules,serverModulesRead))}) exitWith {
|
if (isNil QGVAR(settings) || {!isServer && isNil QEGVAR(modules,serverModulesRead)}) exitWith {
|
||||||
if (!_waitingMsgSent) then {
|
if !(_waitingMsgSent) then {
|
||||||
_args set [0, true];
|
_args set [0, true];
|
||||||
ACE_LOGINFO("Waiting on settings from server...");
|
ACE_LOGINFO("Waiting on settings from server...");
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||||
|
|
||||||
ACE_LOGINFO("Settings received from server.");
|
ACE_LOGINFO("Settings received from server.");
|
||||||
|
|
||||||
@ -152,36 +192,31 @@ call FUNC(checkFiles);
|
|||||||
|
|
||||||
//Set init finished and run all delayed functions:
|
//Set init finished and run all delayed functions:
|
||||||
GVAR(settingsInitFinished) = true;
|
GVAR(settingsInitFinished) = true;
|
||||||
diag_log text format ["[ACE] %1 delayed functions running", (count GVAR(runAtSettingsInitialized))];
|
ACE_LOGINFO_1(%1 delayed functions running.,count GVAR(runAtSettingsInitialized))
|
||||||
{
|
|
||||||
_x params ["_func", "_params"];
|
|
||||||
_params call _func;
|
|
||||||
} forEach GVAR(runAtSettingsInitialized);
|
|
||||||
GVAR(runAtSettingsInitialized) = nil; //cleanup
|
|
||||||
|
|
||||||
|
{
|
||||||
|
(_x select 1) call (_x select 0);
|
||||||
|
false
|
||||||
|
} count GVAR(runAtSettingsInitialized);
|
||||||
|
|
||||||
|
GVAR(runAtSettingsInitialized) = nil; //cleanup
|
||||||
}, 0, [false]] call CBA_fnc_addPerFrameHandler;
|
}, 0, [false]] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
|
|
||||||
["SettingsInitialized", {
|
/***************************************************************************/
|
||||||
[
|
/***************************************************************************/
|
||||||
GVAR(checkPBOsAction),
|
/** everything that only player controlled machines need, goes below this **/
|
||||||
GVAR(checkPBOsCheckAll),
|
/***************************************************************************/
|
||||||
call compile GVAR(checkPBOsWhitelist)
|
/***************************************************************************/
|
||||||
] call FUNC(checkPBOs)
|
|
||||||
}] call FUNC(addEventHandler);
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************/
|
|
||||||
/***************************************************************/
|
|
||||||
/***************************************************************/
|
|
||||||
/***************************************************************/
|
|
||||||
/***************************************************************/
|
|
||||||
|
|
||||||
// everything that only player controlled machines need, goes below this
|
|
||||||
if (!hasInterface) exitWith {};
|
if (!hasInterface) exitWith {};
|
||||||
|
|
||||||
call COMPILE_FILE(scripts\assignedItemFix);
|
//////////////////////////////////////////////////
|
||||||
call COMPILE_FILE(scripts\initScrollWheel);
|
// Set up mouse wheel eventhandler
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
call COMPILE_FILE(scripts\assignedItemFix);/////////////
|
||||||
|
call COMPILE_FILE(scripts\initScrollWheel);/////////////
|
||||||
|
|
||||||
DFUNC(mouseZHandler) = {
|
DFUNC(mouseZHandler) = {
|
||||||
waitUntil {!isNull (findDisplay 46)}; sleep 0.1;
|
waitUntil {!isNull (findDisplay 46)}; sleep 0.1;
|
||||||
@ -192,142 +227,175 @@ DFUNC(mouseZHandler) = {
|
|||||||
addMissionEventHandler ["Loaded", {[] spawn FUNC(mouseZHandler)}];
|
addMissionEventHandler ["Loaded", {[] spawn FUNC(mouseZHandler)}];
|
||||||
[] spawn FUNC(mouseZHandler);
|
[] spawn FUNC(mouseZHandler);
|
||||||
|
|
||||||
|
/*
|
||||||
|
call FUNC(assignedItemFix);
|
||||||
|
GVAR(ScrollWheelFrame) = diag_frameno;
|
||||||
|
|
||||||
|
addMissionEventHandler ["Loaded", {call FUNC(mouseZHandler)}];
|
||||||
|
call FUNC(mouseZHandler);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @todo remove?
|
||||||
enableCamShake true;
|
enableCamShake true;
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
// Eventhandler to set player names
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
// Set the name for the current player
|
// Set the name for the current player
|
||||||
["playerChanged", {
|
["playerChanged", {
|
||||||
EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer);
|
params ["_newPlayer","_oldPlayer"];
|
||||||
|
|
||||||
if (alive _newPlayer) then {
|
if (alive _newPlayer) then {
|
||||||
[_newPlayer] call FUNC(setName)
|
[_newPlayer] call FUNC(setName);
|
||||||
};
|
|
||||||
if (alive _oldPlayer) then {
|
|
||||||
[_oldPlayer] call FUNC(setName)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (alive _oldPlayer) then {
|
||||||
|
[_oldPlayer] call FUNC(setName);
|
||||||
|
};
|
||||||
}] call FUNC(addEventhandler);
|
}] call FUNC(addEventhandler);
|
||||||
|
|
||||||
GVAR(OldPlayerInventory) = [ACE_player] call FUNC(getAllGear);
|
|
||||||
GVAR(OldPlayerVisionMode) = currentVisionMode ACE_player;
|
//////////////////////////////////////////////////
|
||||||
GVAR(OldZeusDisplayIsOpen) = !(isNull findDisplay 312);
|
// Set up numerous eventhanders for player controlled units
|
||||||
GVAR(OldCameraView) = cameraView;
|
//////////////////////////////////////////////////
|
||||||
GVAR(OldPlayerVehicle) = vehicle ACE_player;
|
|
||||||
GVAR(OldPlayerTurret) = [ACE_player] call FUNC(getTurretIndex);
|
// default variables
|
||||||
GVAR(OldPlayerWeapon) = currentWeapon ACE_player;
|
GVAR(OldPlayerVehicle) = vehicle objNull;
|
||||||
|
GVAR(OldPlayerTurret) = [objNull] call FUNC(getTurretIndex);
|
||||||
|
GVAR(OldPlayerWeapon) = currentWeapon objNull;
|
||||||
|
GVAR(OldPlayerInventory) = [objNull] call FUNC(getAllGear);
|
||||||
|
GVAR(OldPlayerVisionMode) = currentVisionMode objNull;
|
||||||
|
GVAR(OldCameraView) = "";
|
||||||
GVAR(OldVisibleMap) = false;
|
GVAR(OldVisibleMap) = false;
|
||||||
|
GVAR(OldInventoryDisplayIsOpen) = nil; //@todo check this
|
||||||
|
GVAR(OldZeusDisplayIsOpen) = false;
|
||||||
|
GVAR(OldIsCamera) = false;
|
||||||
|
|
||||||
// PFH to raise varios events
|
// PFH to raise varios events
|
||||||
[{
|
[{
|
||||||
BEGIN_COUNTER(stateChecker);
|
BEGIN_COUNTER(stateChecker);
|
||||||
private ["_newCameraView", "_newInventoryDisplayIsOpen", "_newPlayerInventory", "_newPlayerTurret", "_newPlayerVehicle", "_newPlayerVisionMode", "_newPlayerWeapon", "_newZeusDisplayIsOpen", "_newVisibleMap"];
|
private "_data"; // reuse one variable to reduce number of variables that have to be set to private each frame
|
||||||
// "playerInventoryChanged" event
|
|
||||||
_newPlayerInventory = [ACE_player] call FUNC(getAllGear);
|
|
||||||
if !(_newPlayerInventory isEqualTo GVAR(OldPlayerInventory)) then {
|
|
||||||
// Raise ACE event locally
|
|
||||||
GVAR(OldPlayerInventory) = _newPlayerInventory;
|
|
||||||
["playerInventoryChanged", [ACE_player, _newPlayerInventory]] call FUNC(localEvent);
|
|
||||||
};
|
|
||||||
|
|
||||||
// "playerVisionModeChanged" event
|
|
||||||
_newPlayerVisionMode = currentVisionMode ACE_player;
|
|
||||||
if !(_newPlayerVisionMode isEqualTo GVAR(OldPlayerVisionMode)) then {
|
|
||||||
// Raise ACE event locally
|
|
||||||
GVAR(OldPlayerVisionMode) = _newPlayerVisionMode;
|
|
||||||
["playerVisionModeChanged", [ACE_player, _newPlayerVisionMode]] call FUNC(localEvent);
|
|
||||||
};
|
|
||||||
|
|
||||||
// "inventoryDisplayChanged" event
|
|
||||||
_newInventoryDisplayIsOpen = !(isNull findDisplay 602);
|
|
||||||
if !(_newInventoryDisplayIsOpen isEqualTo GVAR(OldInventoryDisplayIsOpen)) then {
|
|
||||||
// Raise ACE event locally
|
|
||||||
GVAR(OldInventoryDisplayIsOpen) = _newInventoryDisplayIsOpen;
|
|
||||||
["inventoryDisplayChanged", [ACE_player, _newInventoryDisplayIsOpen]] call FUNC(localEvent);
|
|
||||||
};
|
|
||||||
|
|
||||||
// "zeusDisplayChanged" event
|
|
||||||
_newZeusDisplayIsOpen = !(isNull findDisplay 312);
|
|
||||||
if !(_newZeusDisplayIsOpen isEqualTo GVAR(OldZeusDisplayIsOpen)) then {
|
|
||||||
// Raise ACE event locally
|
|
||||||
GVAR(OldZeusDisplayIsOpen) = _newZeusDisplayIsOpen;
|
|
||||||
["zeusDisplayChanged", [ACE_player, _newZeusDisplayIsOpen]] call FUNC(localEvent);
|
|
||||||
};
|
|
||||||
|
|
||||||
// "cameraViewChanged" event
|
|
||||||
_newCameraView = cameraView;
|
|
||||||
if !(_newCameraView isEqualTo GVAR(OldCameraView)) then {
|
|
||||||
// Raise ACE event locally
|
|
||||||
GVAR(OldCameraView) = _newCameraView;
|
|
||||||
["cameraViewChanged", [ACE_player, _newCameraView]] call FUNC(localEvent);
|
|
||||||
};
|
|
||||||
|
|
||||||
// "playerVehicleChanged" event
|
// "playerVehicleChanged" event
|
||||||
_newPlayerVehicle = vehicle ACE_player;
|
_data = vehicle ACE_player;
|
||||||
if !(_newPlayerVehicle isEqualTo GVAR(OldPlayerVehicle)) then {
|
if !(_data isEqualTo GVAR(OldPlayerVehicle)) then {
|
||||||
// Raise ACE event locally
|
// Raise ACE event locally
|
||||||
GVAR(OldPlayerVehicle) = _newPlayerVehicle;
|
GVAR(OldPlayerVehicle) = _data;
|
||||||
["playerVehicleChanged", [ACE_player, _newPlayerVehicle]] call FUNC(localEvent);
|
["playerVehicleChanged", [ACE_player, _data]] call FUNC(localEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
// "playerTurretChanged" event
|
// "playerTurretChanged" event
|
||||||
_newPlayerTurret = [ACE_player] call FUNC(getTurretIndex);
|
_data = [ACE_player] call FUNC(getTurretIndex);
|
||||||
if !(_newPlayerTurret isEqualTo GVAR(OldPlayerTurret)) then {
|
if !(_data isEqualTo GVAR(OldPlayerTurret)) then {
|
||||||
// Raise ACE event locally
|
// Raise ACE event locally
|
||||||
GVAR(OldPlayerTurret) = _newPlayerTurret;
|
GVAR(OldPlayerTurret) = _data;
|
||||||
["playerTurretChanged", [ACE_player, _newPlayerTurret]] call FUNC(localEvent);
|
["playerTurretChanged", [ACE_player, _data]] call FUNC(localEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
// "playerWeaponChanged" event
|
// "playerWeaponChanged" event
|
||||||
_newPlayerWeapon = currentWeapon ACE_player;
|
_data = currentWeapon ACE_player;
|
||||||
if (_newPlayerWeapon != GVAR(OldPlayerWeapon)) then {
|
if (_data != GVAR(OldPlayerWeapon)) then {
|
||||||
// Raise ACE event locally
|
// Raise ACE event locally
|
||||||
GVAR(OldPlayerWeapon) = _newPlayerWeapon;
|
GVAR(OldPlayerWeapon) = _data;
|
||||||
["playerWeaponChanged", [ACE_player, _newPlayerWeapon]] call FUNC(localEvent);
|
["playerWeaponChanged", [ACE_player, _data]] call FUNC(localEvent);
|
||||||
|
};
|
||||||
|
|
||||||
|
// "playerInventoryChanged" event
|
||||||
|
_data = [ACE_player] call FUNC(getAllGear);
|
||||||
|
if !(_data isEqualTo GVAR(OldPlayerInventory)) then {
|
||||||
|
// Raise ACE event locally
|
||||||
|
GVAR(OldPlayerInventory) = _data;
|
||||||
|
["playerInventoryChanged", [ACE_player, _data]] call FUNC(localEvent);
|
||||||
|
};
|
||||||
|
|
||||||
|
// "playerVisionModeChanged" event
|
||||||
|
_data = currentVisionMode ACE_player;
|
||||||
|
if !(_data isEqualTo GVAR(OldPlayerVisionMode)) then {
|
||||||
|
// Raise ACE event locally
|
||||||
|
GVAR(OldPlayerVisionMode) = _data;
|
||||||
|
["playerVisionModeChanged", [ACE_player, _data]] call FUNC(localEvent);
|
||||||
|
};
|
||||||
|
|
||||||
|
// "cameraViewChanged" event
|
||||||
|
_data = cameraView;
|
||||||
|
if !(_data isEqualTo GVAR(OldCameraView)) then {
|
||||||
|
// Raise ACE event locally
|
||||||
|
GVAR(OldCameraView) = _data;
|
||||||
|
["cameraViewChanged", [ACE_player, _data]] call FUNC(localEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
// "visibleMapChanged" event
|
// "visibleMapChanged" event
|
||||||
_newVisibleMap = visibleMap;
|
_data = visibleMap;
|
||||||
if (!_newVisibleMap isEqualTo GVAR(OldVisibleMap)) then {
|
if (!_data isEqualTo GVAR(OldVisibleMap)) then {
|
||||||
// Raise ACE event locally
|
// Raise ACE event locally
|
||||||
GVAR(OldVisibleMap) = _newVisibleMap;
|
GVAR(OldVisibleMap) = _data;
|
||||||
["visibleMapChanged", [ACE_player, _newVisibleMap]] call FUNC(localEvent);
|
["visibleMapChanged", [ACE_player, _data]] call FUNC(localEvent);
|
||||||
|
};
|
||||||
|
|
||||||
|
// "inventoryDisplayChanged" event
|
||||||
|
_data = !(isNull findDisplay 602);
|
||||||
|
if !(_data isEqualTo GVAR(OldInventoryDisplayIsOpen)) then {
|
||||||
|
// Raise ACE event locally
|
||||||
|
GVAR(OldInventoryDisplayIsOpen) = _data;
|
||||||
|
["inventoryDisplayChanged", [ACE_player, _data]] call FUNC(localEvent);
|
||||||
|
};
|
||||||
|
|
||||||
|
// "zeusDisplayChanged" event
|
||||||
|
_data = !(isNull findDisplay 312);
|
||||||
|
if !(_data isEqualTo GVAR(OldZeusDisplayIsOpen)) then {
|
||||||
|
// Raise ACE event locally
|
||||||
|
GVAR(OldZeusDisplayIsOpen) = _data;
|
||||||
|
["zeusDisplayChanged", [ACE_player, _data]] call FUNC(localEvent);
|
||||||
|
};
|
||||||
|
|
||||||
|
// "activeCameraChanged" event
|
||||||
|
_data = call FUNC(isfeatureCameraActive);
|
||||||
|
if !(_data isEqualTo GVAR(OldIsCamera)) then {
|
||||||
|
// Raise ACE event locally
|
||||||
|
GVAR(OldIsCamera) = _data;
|
||||||
|
["activeCameraChanged", [ACE_player, _data]] call FUNC(localEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
END_COUNTER(stateChecker);
|
END_COUNTER(stateChecker);
|
||||||
|
|
||||||
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
|
|
||||||
GVAR(OldIsCamera) = false;
|
//////////////////////////////////////////////////
|
||||||
|
// Eventhandlers for player controlled machines
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
[{
|
// @todo still needed?
|
||||||
|
[QGVAR(StateArrested), false, true, QUOTE(ADDON)] call FUNC(defineVariable);
|
||||||
// "activeCameraChanged" event
|
|
||||||
private ["_isCamera"];
|
|
||||||
_isCamera = call FUNC(isfeatureCameraActive);
|
|
||||||
if !(_isCamera isEqualTo GVAR(OldIsCamera)) then {
|
|
||||||
// Raise ACE event locally
|
|
||||||
GVAR(OldIsCamera) = _isCamera;
|
|
||||||
["activeCameraChanged", [ACE_player, _isCamera]] call FUNC(localEvent);
|
|
||||||
};
|
|
||||||
|
|
||||||
}, 1, []] call CBA_fnc_addPerFrameHandler; // feel free to decrease the sleep ACE_time if you need it.
|
|
||||||
|
|
||||||
|
|
||||||
[QGVAR(StateArrested),false,true,QUOTE(ADDON)] call FUNC(defineVariable);
|
|
||||||
|
|
||||||
["displayTextStructured", FUNC(displayTextStructured)] call FUNC(addEventhandler);
|
["displayTextStructured", FUNC(displayTextStructured)] call FUNC(addEventhandler);
|
||||||
["displayTextPicture", FUNC(displayTextPicture)] call FUNC(addEventhandler);
|
["displayTextPicture", FUNC(displayTextPicture)] call FUNC(addEventhandler);
|
||||||
["medical_onUnconscious", {if (local (_this select 0) && {!(_this select 1)}) then {[ _this select 0, false, QUOTE(FUNC(loadPerson)), west /* dummy side */] call FUNC(switchToGroupSide);};}] call FUNC(addEventhandler);
|
|
||||||
|
["medical_onUnconscious", {
|
||||||
|
params ["_unit", "_isUnconscious"];
|
||||||
|
|
||||||
|
if (local _unit && {!_isUnconscious}) then {
|
||||||
|
[_unit, false, QFUNC(loadPerson), west /* dummy side */] call FUNC(switchToGroupSide);
|
||||||
|
};
|
||||||
|
}] call FUNC(addEventhandler);
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
// Add various canInteractWith conditions
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
["notOnMap", {!visibleMap}] call FUNC(addCanInteractWithCondition);
|
["notOnMap", {!visibleMap}] call FUNC(addCanInteractWithCondition);
|
||||||
|
|
||||||
["isNotInside", {
|
["isNotInside", {
|
||||||
|
params ["_unit", "_target"];
|
||||||
|
|
||||||
// Players can always interact with himself if not boarded
|
// Players can always interact with himself if not boarded
|
||||||
vehicle (_this select 0) == (_this select 0) ||
|
vehicle _unit == _unit ||
|
||||||
// Players can always interact with his vehicle
|
// Players can always interact with his vehicle
|
||||||
{vehicle (_this select 0) == (_this select 1)} ||
|
{vehicle _unit == _target} ||
|
||||||
// Players can always interact with passengers of the same vehicle
|
// Players can always interact with passengers of the same vehicle
|
||||||
{!((_this select 0) isEqualTo (_this select 1)) && {vehicle (_this select 0) == vehicle (_this select 1)}}
|
{_unit != _target && {vehicle _unit == vehicle _target}}
|
||||||
}] call FUNC(addCanInteractWithCondition);
|
}] call FUNC(addCanInteractWithCondition);
|
||||||
|
|
||||||
// Lastly, do JIP events
|
// Lastly, do JIP events
|
||||||
@ -337,45 +405,47 @@ if (didJip) then {
|
|||||||
[{
|
[{
|
||||||
if((!(isNull player)) && GVAR(settingsInitFinished)) then {
|
if((!(isNull player)) && GVAR(settingsInitFinished)) then {
|
||||||
["PlayerJip", [player] ] call FUNC(localEvent);
|
["PlayerJip", [player] ] call FUNC(localEvent);
|
||||||
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
[(_this select 1)] call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
// CBA key input handling
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
//Device Handler:
|
//Device Handler:
|
||||||
GVAR(deviceKeyHandlingArray) = [];
|
GVAR(deviceKeyHandlingArray) = [];
|
||||||
GVAR(deviceKeyCurrentIndex) = -1;
|
GVAR(deviceKeyCurrentIndex) = -1;
|
||||||
|
|
||||||
// Register localizations for the Keybinding categories
|
// Register localizations for the Keybinding categories
|
||||||
["ACE3 Equipment", localize LSTRING(ACEKeybindCategoryEquipment)] call cba_fnc_registerKeybindModPrettyName;
|
["ACE3 Equipment", localize LSTRING(ACEKeybindCategoryEquipment)] call CBA_fnc_registerKeybindModPrettyName;
|
||||||
["ACE3 Common", localize LSTRING(ACEKeybindCategoryCommon)] call cba_fnc_registerKeybindModPrettyName;
|
["ACE3 Common", localize LSTRING(ACEKeybindCategoryCommon)] call CBA_fnc_registerKeybindModPrettyName;
|
||||||
["ACE3 Weapons", localize LSTRING(ACEKeybindCategoryWeapons)] call cba_fnc_registerKeybindModPrettyName;
|
["ACE3 Weapons", localize LSTRING(ACEKeybindCategoryWeapons)] call CBA_fnc_registerKeybindModPrettyName;
|
||||||
["ACE3 Movement", localize LSTRING(ACEKeybindCategoryMovement)] call cba_fnc_registerKeybindModPrettyName;
|
["ACE3 Movement", localize LSTRING(ACEKeybindCategoryMovement)] call CBA_fnc_registerKeybindModPrettyName;
|
||||||
["ACE3 Scope Adjustment", localize LSTRING(ACEKeybindCategoryScopeAdjustment)] call cba_fnc_registerKeybindModPrettyName;
|
["ACE3 Scope Adjustment", localize LSTRING(ACEKeybindCategoryScopeAdjustment)] call CBA_fnc_registerKeybindModPrettyName;
|
||||||
["ACE3 Vehicles", localize LSTRING(ACEKeybindCategoryVehicles)] call cba_fnc_registerKeybindModPrettyName;
|
["ACE3 Vehicles", localize LSTRING(ACEKeybindCategoryVehicles)] call CBA_fnc_registerKeybindModPrettyName;
|
||||||
|
|
||||||
["ACE3 Equipment", QGVAR(openDevice), (localize "STR_ACE_Common_toggleHandheldDevice"),
|
["ACE3 Equipment", QGVAR(openDevice), (localize "STR_ACE_Common_toggleHandheldDevice"), {
|
||||||
{
|
|
||||||
[] call FUNC(deviceKeyFindValidIndex);
|
[] call FUNC(deviceKeyFindValidIndex);
|
||||||
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
|
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
|
||||||
[] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 3);
|
[] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 3);
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
{false},
|
{false},
|
||||||
[0xC7, [false, false, false]], false] call cba_fnc_addKeybind; //Home Key
|
[0xC7, [false, false, false]], false] call CBA_fnc_addKeybind; //Home Key
|
||||||
|
|
||||||
["ACE3 Equipment", QGVAR(closeDevice), (localize "STR_ACE_Common_closeHandheldDevice"),
|
["ACE3 Equipment", QGVAR(closeDevice), (localize "STR_ACE_Common_closeHandheldDevice"), {
|
||||||
{
|
|
||||||
[] call FUNC(deviceKeyFindValidIndex);
|
[] call FUNC(deviceKeyFindValidIndex);
|
||||||
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
|
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
|
||||||
[] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 4);
|
[] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 4);
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
{false},
|
{false},
|
||||||
[0xC7, [false, true, false]], false] call cba_fnc_addKeybind; //CTRL + Home Key
|
[0xC7, [false, true, false]], false] call CBA_fnc_addKeybind; //CTRL + Home Key
|
||||||
|
|
||||||
["ACE3 Equipment", QGVAR(cycleDevice), (localize "STR_ACE_Common_cycleHandheldDevices"),
|
["ACE3 Equipment", QGVAR(cycleDevice), (localize "STR_ACE_Common_cycleHandheldDevices"), {
|
||||||
{
|
|
||||||
[1] call FUNC(deviceKeyFindValidIndex);
|
[1] call FUNC(deviceKeyFindValidIndex);
|
||||||
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
|
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
|
||||||
_displayName = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 0);
|
_displayName = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 0);
|
||||||
@ -384,6 +454,6 @@ GVAR(deviceKeyCurrentIndex) = -1;
|
|||||||
true
|
true
|
||||||
},
|
},
|
||||||
{false},
|
{false},
|
||||||
[0xC7, [true, false, false]], false] call cba_fnc_addKeybind; //SHIFT + Home Key
|
[0xC7, [true, false, false]], false] call CBA_fnc_addKeybind; //SHIFT + Home Key
|
||||||
|
|
||||||
GVAR(commonPostInited) = true;
|
GVAR(commonPostInited) = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user