2015-01-15 21:50:48 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-06-21 19:10:50 +00:00
|
|
|
// Exit on Headless as well
|
2015-08-11 17:49:39 +00:00
|
|
|
if (!hasInterface) exitWith {};
|
2015-06-21 19:10:50 +00:00
|
|
|
|
2015-03-14 19:58:05 +00:00
|
|
|
LOG(MSG_INIT);
|
2015-01-16 08:13:29 +00:00
|
|
|
|
2015-03-14 19:58:05 +00:00
|
|
|
// Calculate the maximum zoom allowed for this map
|
|
|
|
call FUNC(determineZoom);
|
2015-01-16 08:13:29 +00:00
|
|
|
|
2024-06-11 15:34:32 +00:00
|
|
|
GVAR(flashlights) = createHashMap;
|
2020-04-07 15:48:32 +00:00
|
|
|
|
2021-10-11 20:48:30 +00:00
|
|
|
["CBA_settingsInitialized", {
|
2015-09-29 16:36:30 +00:00
|
|
|
if (isMultiplayer && {GVAR(DefaultChannel) != -1}) then {
|
|
|
|
//Set the chat channel once the map has finished loading
|
|
|
|
[{
|
|
|
|
if ((isNull findDisplay 37) && {isNull findDisplay 52} && {isNull findDisplay 53} && {isNull findDisplay 12}) exitWith {};
|
|
|
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
|
|
|
|
|
|
|
setCurrentChannel GVAR(DefaultChannel);
|
|
|
|
if (currentChannel == GVAR(DefaultChannel)) then {
|
2024-02-05 17:04:24 +00:00
|
|
|
// INFO_1("Channel Set - %1",currentChannel);
|
2015-09-29 16:36:30 +00:00
|
|
|
} else {
|
2024-02-05 17:04:24 +00:00
|
|
|
ERROR_2("Failed To Set Channel %1 (is %2)",GVAR(DefaultChannel),currentChannel);
|
2015-09-29 16:36:30 +00:00
|
|
|
};
|
|
|
|
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
|
|
|
};
|
|
|
|
|
2015-08-11 17:49:39 +00:00
|
|
|
//illumination settings
|
|
|
|
if (GVAR(mapIllumination)) then {
|
2016-06-21 23:39:20 +00:00
|
|
|
["loadout", {
|
2016-06-18 00:18:06 +00:00
|
|
|
params ["_player", ""];
|
|
|
|
private _unitLight = _player getVariable [QGVAR(flashlight), ["", objNull]];
|
|
|
|
_unitLight params ["_flashlight", "_glow"];
|
2016-08-25 23:23:42 +00:00
|
|
|
if ((_flashlight != "") && {!(_flashlight in ([_player] call FUNC(getUnitFlashlights)))}) then {
|
|
|
|
// remove the current glow if the unit suddenly lost it's flashlight
|
2016-06-18 00:18:06 +00:00
|
|
|
if (!isNull _glow) then {
|
|
|
|
_glow = [_player, "", false] call FUNC(flashlightGlow);
|
|
|
|
};
|
|
|
|
_player setVariable [QGVAR(flashlight), ["", _glow], true];
|
2015-08-11 17:49:39 +00:00
|
|
|
};
|
2016-06-21 23:39:20 +00:00
|
|
|
}] call CBA_fnc_addPlayerEventHandler;
|
2015-08-11 17:49:39 +00:00
|
|
|
|
|
|
|
if (GVAR(mapGlow)) then {
|
2016-08-25 23:23:42 +00:00
|
|
|
["visibleMap", {
|
2015-08-11 17:49:39 +00:00
|
|
|
params ["_player", "_mapOn"];
|
2016-06-18 00:18:06 +00:00
|
|
|
private _unitLight = _player getVariable [QGVAR(flashlight), ["", objNull]];
|
|
|
|
_unitLight params ["_flashlight", "_glow"];
|
2015-08-11 17:49:39 +00:00
|
|
|
if (_mapOn) then {
|
2021-02-27 17:05:05 +00:00
|
|
|
if (_flashlight isNotEqualTo "" && {isNull _glow}) then {
|
2016-06-18 00:18:06 +00:00
|
|
|
[_player, _flashlight] call FUNC(flashlightGlow);
|
2018-10-25 16:39:27 +00:00
|
|
|
if ([_player, _flashlight] call FUNC(needPlaySound)) then {playSound QGVAR(flashlightClick)};
|
2015-08-11 17:49:39 +00:00
|
|
|
};
|
|
|
|
} else {
|
2016-06-18 00:18:06 +00:00
|
|
|
if (!isNull _glow) then {
|
|
|
|
[_player, ""] call FUNC(flashlightGlow);
|
2018-10-25 16:39:27 +00:00
|
|
|
if ([_player, _flashlight] call FUNC(needPlaySound)) then {playSound QGVAR(flashlightClick)};
|
2015-08-11 17:49:39 +00:00
|
|
|
};
|
|
|
|
};
|
2016-08-25 23:23:42 +00:00
|
|
|
}] call CBA_fnc_addPlayerEventHandler;
|
2015-08-11 17:49:39 +00:00
|
|
|
};
|
|
|
|
};
|
2016-05-22 15:29:05 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|
2015-09-01 23:59:07 +00:00
|
|
|
|
|
|
|
// hide clock on map if player has no watch
|
|
|
|
GVAR(hasWatch) = true;
|
|
|
|
|
2016-06-21 23:39:20 +00:00
|
|
|
["loadout", {
|
2017-04-11 15:06:29 +00:00
|
|
|
params ["_unit"];
|
|
|
|
if (isNull _unit) exitWith {
|
2015-09-01 23:59:07 +00:00
|
|
|
GVAR(hasWatch) = true;
|
|
|
|
};
|
2015-11-24 22:17:06 +00:00
|
|
|
GVAR(hasWatch) = false;
|
|
|
|
{
|
|
|
|
if (_x isKindOf ["ItemWatch", configFile >> "CfgWeapons"]) exitWith {GVAR(hasWatch) = true;};
|
2024-04-04 11:15:26 +00:00
|
|
|
} forEach (assignedItems _unit);
|
2017-04-11 15:06:29 +00:00
|
|
|
}, true] call CBA_fnc_addPlayerEventHandler;
|
2017-08-22 18:13:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Vehicle map lighting:
|
|
|
|
GVAR(vehicleLightCondition) = {true};
|
|
|
|
GVAR(vehicleExteriorTurrets) = [];
|
|
|
|
GVAR(vehicleLightColor) = [1,1,1,0];
|
|
|
|
|
|
|
|
["vehicle", {
|
|
|
|
params ["_unit", "_vehicle"];
|
|
|
|
if ((isNull _vehicle) || {_unit == _vehicle}) exitWith {};
|
2021-02-18 18:58:08 +00:00
|
|
|
private _cfg = configOf _vehicle;
|
2017-08-22 18:13:03 +00:00
|
|
|
GVAR(vehicleExteriorTurrets) = getArray (_cfg >> QGVAR(vehicleExteriorTurrets));
|
|
|
|
GVAR(vehicleLightColor) = [_cfg >> QGVAR(vehicleLightColor), "array", [1,1,1,0]] call CBA_fnc_getConfigEntry;
|
|
|
|
|
|
|
|
// Handle vehicles with toggleable interior lights:
|
|
|
|
private _vehicleLightCondition = getText (_cfg >> QGVAR(vehicleLightCondition));
|
|
|
|
if (_vehicleLightCondition == "") then {
|
2024-03-07 21:08:13 +00:00
|
|
|
private _userAction = toLowerANSI getText (_cfg >> "UserActions" >> "ToggleLight" >> "statement");
|
2021-10-12 08:31:46 +00:00
|
|
|
if (
|
|
|
|
false // isClass (_cfg >> "compartmentsLights")
|
|
|
|
|| {_userAction find "cabinlights_hide" > 0}
|
|
|
|
|| {_userAction find "cargolights_hide" > 0}
|
|
|
|
) then {
|
|
|
|
_vehicleLightCondition = "false";
|
2017-08-22 18:13:03 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
GVAR(vehicleLightCondition) = if (_vehicleLightCondition != "") then {
|
|
|
|
if (_vehicle isKindOf "Helicopter" || {_vehicle isKindOf "Plane"}) then {
|
|
|
|
compile format ["(driver _vehicle == _unit) || {gunner _vehicle == _unit} || {%1}", _vehicleLightCondition];
|
|
|
|
} else {
|
|
|
|
compile _vehicleLightCondition
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
switch (true) do {
|
|
|
|
case (_vehicle isKindOf "Tank");
|
2021-10-12 08:31:46 +00:00
|
|
|
case (_vehicle isKindOf "Wheeled_APC_F"): { {true} };
|
2019-04-25 18:27:53 +00:00
|
|
|
case (_vehicle isKindOf "ParachuteBase"): { {false} };
|
2017-08-22 18:13:03 +00:00
|
|
|
case (_vehicle isKindOf "Helicopter");
|
|
|
|
case (_vehicle isKindOf "Plane"): { {(driver _vehicle == _unit) || {gunner _vehicle == _unit}} };
|
|
|
|
default { {false} };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}, true] call CBA_fnc_addPlayerEventHandler;
|
2021-10-12 08:31:46 +00:00
|
|
|
|
|
|
|
// compartmentsLights work only when cameraView == "INTERNAL" so we switch it on map opening
|
|
|
|
["visibleMap", {
|
|
|
|
params ["_player", "_mapOn"];
|
|
|
|
if (_mapOn) then {
|
|
|
|
if (!isClass (configOf vehicle _player >> "compartmentsLights") || {cameraView == "INTERNAL"}) exitWith {};
|
|
|
|
GVAR(cameraViewLast) = cameraView;
|
|
|
|
vehicle _player switchCamera "INTERNAL";
|
|
|
|
} else {
|
|
|
|
if (isNil QGVAR(cameraViewLast)) exitWith {};
|
|
|
|
vehicle _player switchCamera GVAR(cameraViewLast);
|
|
|
|
GVAR(cameraViewLast) = nil;
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addPlayerEventHandler;
|