2015-01-12 18:22:58 +00:00
|
|
|
// ACE - Common
|
2015-01-12 04:02:33 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-02-03 00:14:16 +00:00
|
|
|
// Load settings from profile
|
2015-02-08 21:29:49 +00:00
|
|
|
if (hasInterface) then {
|
|
|
|
call FUNC(loadSettingsFromProfile);
|
|
|
|
};
|
2015-02-03 00:14:16 +00:00
|
|
|
|
2015-02-03 04:45:04 +00:00
|
|
|
// Listens for global "SettingChanged" events, to update the force status locally
|
|
|
|
["SettingChanged", {
|
|
|
|
|
|
|
|
PARAMS_2(_name,_value);
|
|
|
|
if !(count _this > 2) exitWith {};
|
|
|
|
|
|
|
|
_force = _this select 2;
|
|
|
|
if (_force) then {
|
|
|
|
_settingData = [_name] call FUNC(getSettingData);
|
2015-02-03 05:37:13 +00:00
|
|
|
if (count _settingData == 0) exitWith {};
|
2015-02-03 04:45:04 +00:00
|
|
|
_settingData set [6,_force];
|
|
|
|
};
|
|
|
|
}] call FUNC(addEventhandler);
|
|
|
|
|
2015-03-18 00:36:56 +00:00
|
|
|
["fixCollision", DFUNC(fixCollision)] call FUNC(addEventhandler);
|
|
|
|
["fixFloating", DFUNC(fixFloating)] call FUNC(addEventhandler);
|
|
|
|
["fixPosition", DFUNC(fixPosition)] call FUNC(addEventhandler);
|
2015-03-16 18:25:29 +00:00
|
|
|
|
2015-03-18 10:29:58 +00:00
|
|
|
["lockVehicle", {
|
|
|
|
_this setVariable [QGVAR(lockStatus), locked _this];
|
|
|
|
_this lock 2;
|
|
|
|
}] call FUNC(addEventhandler);
|
|
|
|
|
|
|
|
["unlockVehicle", {
|
|
|
|
_this lock (_this getVariable [QGVAR(lockStatus), locked _this]);
|
|
|
|
}] call FUNC(addEventhandler);
|
|
|
|
|
2015-01-19 16:47:52 +00:00
|
|
|
// hack to get PFH to work in briefing
|
|
|
|
[QGVAR(onBriefingPFH), "onEachFrame", {
|
|
|
|
if (time > 0) exitWith {
|
2015-01-24 18:32:06 +00:00
|
|
|
[QGVAR(onBriefingPFH), "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
|
2015-01-19 16:47:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
call cba_common_fnc_onFrame;
|
|
|
|
}] call BIS_fnc_addStackedEventHandler;
|
|
|
|
/////
|
|
|
|
|
2015-01-11 18:20:14 +00:00
|
|
|
QGVAR(remoteFnc) addPublicVariableEventHandler {
|
2015-01-12 21:34:01 +00:00
|
|
|
(_this select 1) call FUNC(execRemoteFnc);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
2015-01-11 18:20:14 +00:00
|
|
|
[missionNamespace] call FUNC(executePersistent);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
// check previous version number from profile
|
2015-01-17 11:35:59 +00:00
|
|
|
_currentVersion = getText (configFile >> "CfgPatches" >> QUOTE(ADDON) >> "version");
|
2015-01-12 04:02:33 +00:00
|
|
|
_previousVersion = profileNamespace getVariable ["ACE_VersionNumberString", ""];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
if (_currentVersion != _previousVersion) then {
|
2015-01-12 21:34:01 +00:00
|
|
|
// do something
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-01-12 21:34:01 +00:00
|
|
|
profileNamespace setVariable ["ACE_VersionNumberString", _currentVersion];
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
2015-01-12 13:12:50 +00:00
|
|
|
0 spawn COMPILE_FILE(scripts\Version\checkVersionNumber);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-01-17 01:12:37 +00:00
|
|
|
"ACEg" addPublicVariableEventHandler { _this call FUNC(_handleNetEvent); };
|
|
|
|
"ACEc" addPublicVariableEventHandler { _this call FUNC(_handleNetEvent); };
|
2015-01-13 23:27:42 +00:00
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
// everything that only player controlled machines need, goes below this
|
|
|
|
if (!hasInterface) exitWith {};
|
|
|
|
|
2015-01-12 13:12:50 +00:00
|
|
|
call COMPILE_FILE(scripts\assignedItemFix);
|
2015-01-24 18:32:06 +00:00
|
|
|
call COMPILE_FILE(scripts\initScrollWheel);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
0 spawn {
|
2015-01-12 21:34:01 +00:00
|
|
|
while {true} do {
|
|
|
|
waitUntil {!isNull (findDisplay 46)}; sleep 0.1;
|
|
|
|
findDisplay 46 displayAddEventHandler ["MouseZChanged", QUOTE( _this call GVAR(onScrollWheel) )];
|
|
|
|
[false] call FUNC(disableUserInput);
|
|
|
|
waitUntil {isNull (findDisplay 46)};
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
enableCamShake true;
|
|
|
|
|
2015-01-12 04:02:33 +00:00
|
|
|
// Set the name for the current player
|
2015-01-16 15:14:18 +00:00
|
|
|
["playerChanged", {
|
|
|
|
EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer);
|
|
|
|
|
|
|
|
if (alive _newPlayer) then {
|
|
|
|
[_newPlayer] call FUNC(setName)
|
2015-01-12 21:34:01 +00:00
|
|
|
};
|
2015-01-16 15:14:18 +00:00
|
|
|
if (alive _oldPlayer) then {
|
|
|
|
[_oldPlayer] call FUNC(setName)
|
2015-01-12 21:34:01 +00:00
|
|
|
};
|
2015-01-16 23:21:47 +00:00
|
|
|
|
2015-01-16 15:14:18 +00:00
|
|
|
}] call FUNC(addEventhandler);
|
2015-01-13 23:27:42 +00:00
|
|
|
|
2015-02-10 04:22:10 +00:00
|
|
|
GVAR(OldPlayerInventory) = [ACE_player] call FUNC(getAllGear);
|
2015-01-16 18:39:19 +00:00
|
|
|
GVAR(OldPlayerVisionMode) = currentVisionMode ACE_player;
|
2015-01-16 18:39:38 +00:00
|
|
|
GVAR(OldZeusDisplayIsOpen) = !(isNull findDisplay 312);
|
2015-01-16 20:16:42 +00:00
|
|
|
GVAR(OldCameraView) = cameraView;
|
|
|
|
GVAR(OldPlayerVehicle) = vehicle ACE_player;
|
|
|
|
GVAR(OldPlayerTurret) = [ACE_player] call FUNC(getTurretIndex);
|
2015-03-18 14:42:33 +00:00
|
|
|
GVAR(OldPlayerWeapon) = currentWeapon ACE_player;
|
2015-01-13 23:27:42 +00:00
|
|
|
|
2015-01-16 18:39:19 +00:00
|
|
|
// PFH to raise varios events
|
2015-01-16 18:28:37 +00:00
|
|
|
[{
|
2015-01-16 18:39:38 +00:00
|
|
|
|
2015-01-16 18:39:19 +00:00
|
|
|
// "playerInventoryChanged" event
|
2015-02-10 04:22:10 +00:00
|
|
|
_newPlayerInventory = [ACE_player] call FUNC(getAllGear);
|
2015-01-16 19:30:48 +00:00
|
|
|
if !(_newPlayerInventory isEqualTo GVAR(OldPlayerInventory)) then {
|
2015-01-16 18:39:19 +00:00
|
|
|
// Raise ACE event locally
|
2015-01-16 18:28:37 +00:00
|
|
|
GVAR(OldPlayerInventory) = _newPlayerInventory;
|
|
|
|
["playerInventoryChanged", [ACE_player, _newPlayerInventory]] call FUNC(localEvent);
|
|
|
|
};
|
2015-01-16 18:39:19 +00:00
|
|
|
|
|
|
|
// "playerVisionModeChanged" event
|
2015-01-16 19:30:48 +00:00
|
|
|
_newPlayerVisionMode = currentVisionMode ACE_player;
|
|
|
|
if !(_newPlayerVisionMode isEqualTo GVAR(OldPlayerVisionMode)) then {
|
2015-01-16 18:39:19 +00:00
|
|
|
// Raise ACE event locally
|
|
|
|
GVAR(OldPlayerVisionMode) = _newPlayerVisionMode;
|
|
|
|
["playerVisionModeChanged", [ACE_player, _newPlayerVisionMode]] call FUNC(localEvent);
|
|
|
|
};
|
|
|
|
|
2015-01-18 05:45:28 +00:00
|
|
|
// "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);
|
|
|
|
};
|
|
|
|
|
2015-01-16 18:39:38 +00:00
|
|
|
// "zeusDisplayChanged" event
|
|
|
|
_newZeusDisplayIsOpen = !(isNull findDisplay 312);
|
2015-01-16 19:30:48 +00:00
|
|
|
if !(_newZeusDisplayIsOpen isEqualTo GVAR(OldZeusDisplayIsOpen)) then {
|
2015-01-16 18:39:38 +00:00
|
|
|
// Raise ACE event locally
|
|
|
|
GVAR(OldZeusDisplayIsOpen) = _newZeusDisplayIsOpen;
|
|
|
|
["zeusDisplayChanged", [ACE_player, _newZeusDisplayIsOpen]] call FUNC(localEvent);
|
|
|
|
};
|
2015-01-16 18:39:19 +00:00
|
|
|
|
2015-01-16 20:16:42 +00:00
|
|
|
// "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
|
|
|
|
_newPlayerVehicle = vehicle ACE_player;
|
|
|
|
if !(_newPlayerVehicle isEqualTo GVAR(OldPlayerVehicle)) then {
|
|
|
|
// Raise ACE event locally
|
|
|
|
GVAR(OldPlayerVehicle) = _newPlayerVehicle;
|
|
|
|
["playerVehicleChanged", [ACE_player, _newPlayerVehicle]] call FUNC(localEvent);
|
|
|
|
};
|
|
|
|
|
|
|
|
// "playerTurretChanged" event
|
|
|
|
[ACE_player] call FUNC(getTurretIndex);
|
|
|
|
if !(_newPlayerTurret isEqualTo GVAR(OldPlayerTurret)) then {
|
|
|
|
// Raise ACE event locally
|
|
|
|
GVAR(OldPlayerTurret) = _newPlayerTurret;
|
|
|
|
["playerTurretChanged", [ACE_player, _newPlayerTurret]] call FUNC(localEvent);
|
|
|
|
};
|
|
|
|
|
2015-03-18 14:42:33 +00:00
|
|
|
// "playerWeaponChanged" event
|
|
|
|
_newPlayerWeapon = currentWeapon ACE_player;
|
|
|
|
if (_newPlayerWeapon != GVAR(OldPlayerWeapon)) then {
|
|
|
|
// Raise ACE event locally
|
|
|
|
GVAR(OldPlayerWeapon) = _newPlayerWeapon;
|
|
|
|
["playerWeaponChanged", [ACE_player, _newPlayerWeapon]] call FUNC(localEvent);
|
|
|
|
};
|
|
|
|
|
2015-01-16 18:28:37 +00:00
|
|
|
}, 0, []] call cba_fnc_addPerFrameHandler;
|
2015-01-16 23:21:47 +00:00
|
|
|
|
|
|
|
[QGVAR(StateArrested),false,true,QUOTE(ADDON)] call FUNC(defineVariable);
|
2015-01-28 20:38:04 +00:00
|
|
|
|
|
|
|
["VehicleSetFuel", {
|
|
|
|
PARAMS_2(_vehicle,_fuelLevel);
|
|
|
|
_vehicle setFuel _fuelLevel;
|
|
|
|
}] call FUNC(addEventhandler);
|
2015-02-24 17:10:40 +00:00
|
|
|
|
|
|
|
["displayTextStructured", FUNC(displayTextStructured)] call FUNC(addEventhandler);
|
|
|
|
["displayTextPicture", FUNC(displayTextPicture)] call FUNC(addEventhandler);
|
2015-03-15 08:26:16 +00:00
|
|
|
|
2015-03-15 15:12:37 +00:00
|
|
|
["notOnMap", {!visibleMap}] call FUNC(addCanInteractWithCondition);
|