mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Map - Use getLightingAt
(more light sources illuminate map) (#8343)
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
parent
f7b07c362d
commit
65b9cf3754
@ -94,9 +94,12 @@ GVAR(vehicleLightColor) = [1,1,1,0];
|
||||
private _vehicleLightCondition = getText (_cfg >> QGVAR(vehicleLightCondition));
|
||||
if (_vehicleLightCondition == "") then {
|
||||
private _userAction = toLower getText (_cfg >> "UserActions" >> "ToggleLight" >> "statement");
|
||||
switch (true) do {
|
||||
case ((_userAction find "cabinlights_hide") > 0): {_vehicleLightCondition = "(_vehicle animationSourcePhase 'cabinlights_hide') == 1";};
|
||||
case ((_userAction find "cargolights_hide") > 0): {_vehicleLightCondition = "(_vehicle animationSourcePhase 'cargolights_hide') == 1";};
|
||||
if (
|
||||
false // isClass (_cfg >> "compartmentsLights")
|
||||
|| {_userAction find "cabinlights_hide" > 0}
|
||||
|| {_userAction find "cargolights_hide" > 0}
|
||||
) then {
|
||||
_vehicleLightCondition = "false";
|
||||
};
|
||||
};
|
||||
|
||||
@ -109,7 +112,7 @@ GVAR(vehicleLightColor) = [1,1,1,0];
|
||||
} else {
|
||||
switch (true) do {
|
||||
case (_vehicle isKindOf "Tank");
|
||||
case (_vehicle isKindOf "Wheeled_APC"): { {true} };
|
||||
case (_vehicle isKindOf "Wheeled_APC_F"): { {true} };
|
||||
case (_vehicle isKindOf "ParachuteBase"): { {false} };
|
||||
case (_vehicle isKindOf "Helicopter");
|
||||
case (_vehicle isKindOf "Plane"): { {(driver _vehicle == _unit) || {gunner _vehicle == _unit}} };
|
||||
@ -117,3 +120,17 @@ GVAR(vehicleLightColor) = [1,1,1,0];
|
||||
};
|
||||
};
|
||||
}, true] call CBA_fnc_addPlayerEventHandler;
|
||||
|
||||
// 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;
|
||||
|
@ -18,35 +18,15 @@
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
// Blend two colors
|
||||
private _fnc_blendColor = {
|
||||
params ["_c1", "_c2", "_alpha"];
|
||||
[(_c1 select 0) * (1 - _alpha) + (_c2 select 0) * _alpha,
|
||||
(_c1 select 1) * (1 - _alpha) + (_c2 select 1) * _alpha,
|
||||
(_c1 select 2) * (1 - _alpha) + (_c2 select 2) * _alpha,
|
||||
(_c1 select 3) * (1 - _alpha) + (_c2 select 3) * _alpha]
|
||||
};
|
||||
|
||||
// Ambient light tint depending on time of day
|
||||
private _lightTint = call {
|
||||
if (sunOrMoon == 1.0) exitWith {[0.5,0.5,0.5,1]};
|
||||
if (sunOrMoon > 0.80) exitWith {[[1.0 - overcast,0.2,0,1], [1,1,1,1], (sunOrMoon - 0.8) / 0.2] call _fnc_blendColor};
|
||||
if (sunOrMoon > 0.50) exitWith {[[0,0,0.1,1], [1.0 - overcast,0.2,0,1], (sunOrMoon - 0.5) / 0.3] call _fnc_blendColor};
|
||||
if (sunOrMoon <= 0.5) exitWith {[0,0,0.1,1]};
|
||||
[0,0,0,0]
|
||||
};
|
||||
|
||||
private _lightLevel = 0.04 + (0.96 * call EFUNC(common,ambientBrightness));
|
||||
|
||||
// Do not obscure the map if the ambient light level is above 0.95
|
||||
if (_lightLevel > 0.95) exitWith {
|
||||
[false, [1,1,1,0]]
|
||||
};
|
||||
|
||||
private _vehicle = vehicle _unit;
|
||||
|
||||
// Do not obscure the map if the player is on a enclosed vehicle (assume internal illumination)
|
||||
if ((_vehicle != _unit) && {(!isTurnedOut _unit)} && GVAR(vehicleLightCondition) && {!((_unit call CBA_fnc_turretPath) in GVAR(vehicleExteriorTurrets))}) exitWith {
|
||||
if (
|
||||
_vehicle != _unit
|
||||
&& {!isTurnedOut _unit}
|
||||
&& GVAR(vehicleLightCondition)
|
||||
&& {!((_unit call CBA_fnc_turretPath) in GVAR(vehicleExteriorTurrets))}
|
||||
) exitWith {
|
||||
TRACE_1("Player in a enclosed vehicle",GVAR(vehicleLightColor));
|
||||
[GVAR(vehicleLightColor) isNotEqualTo [1,1,1,0], GVAR(vehicleLightColor)]
|
||||
};
|
||||
@ -54,46 +34,29 @@ if ((_vehicle != _unit) && {(!isTurnedOut _unit)} && GVAR(vehicleLightCondition)
|
||||
// Player is not in a vehicle
|
||||
TRACE_1("Player is on foot or in an open vehicle","");
|
||||
|
||||
// Check if player is near a campfires, streetlamps, units with flashlights, vehicles with lights on, etc. - 40m
|
||||
getLightingAt _unit params ["_ambientLightColor", "_ambientLightBrightness", "_dynamicLightColor", "_dynamicLightBrightness"];
|
||||
|
||||
private _brightness = _ambientLightBrightness + _dynamicLightBrightness;
|
||||
if (_brightness > 3000) exitWith {[false, [1,1,1,0]]};
|
||||
|
||||
private _alfa = switch (true) do {
|
||||
case (_brightness <= 0.2): { 1 };
|
||||
case (_brightness <= 2): { linearConversion [0.2, 2, _brightness, 1, 0.86] };
|
||||
case (_brightness <= 10): { linearConversion [2, 10, _brightness, 0.86, 0.6] };
|
||||
case (_brightness <= 100): { linearConversion [10, 100, _brightness, 0.6, 0.3] };
|
||||
case (_brightness <= 200): { linearConversion [100, 200, _brightness, 0.3, 0.14] };
|
||||
default { linearConversion [200, 3000, _brightness, 0.14, 0] };
|
||||
};
|
||||
|
||||
private _finalLightColor = [];
|
||||
{
|
||||
_lightLevel = _lightLevel max ([_unit, _x] call EFUNC(common,lightIntensityFromObject));
|
||||
} forEach nearestObjects [_unit, ["All"], 40];
|
||||
|
||||
// @todo: Illumination flares (timed)
|
||||
|
||||
// Using chemlights
|
||||
private _nearObjects = (_unit nearObjects ["Chemlight_base", 4]) select {alive _x};
|
||||
|
||||
if (_nearObjects isNotEqualTo []) then {
|
||||
private _nearestlight = _nearObjects select 0;
|
||||
private _lightLevelTemp = (1 - ((((_unit distance _nearestlight) - 2) / 2) max 0)) * 0.4;
|
||||
if (_lightLevelTemp > _lightLevel) then {
|
||||
private _flareTint = getArray (configFile >> "CfgLights" >> (getText (configFile >> (getText (configFile >> "CfgAmmo" >> typeOf _nearestlight >> "EffectsSmoke")) >> "Light1" >> "type")) >> "color");
|
||||
_lightTint = [_lightTint, _flareTint, (_lightLevelTemp - _lightLevel) / (1 - _lightLevel)] call _fnc_blendColor;
|
||||
_lightLevel = _lightLevelTemp;
|
||||
TRACE_1("player near chemlight","");
|
||||
};
|
||||
private _finalColor = (_ambientLightBrightness * _x + _dynamicLightBrightness * (_dynamicLightColor select _forEachIndex)) / _brightness;
|
||||
if (_alfa > 0.5) then {
|
||||
_finalColor = _finalColor * (1 - _alfa) / 3;
|
||||
};
|
||||
_finalLightColor pushBack _finalColor;
|
||||
} forEach _ambientLightColor;
|
||||
|
||||
// Do not obscure the map if the ambient light level is above 0.95
|
||||
if (_lightLevel > 0.95) exitWith {
|
||||
[false, [1,1,1,0]]
|
||||
};
|
||||
_finalLightColor pushBack _alfa;
|
||||
|
||||
// Calculate resulting map color from tint and light level
|
||||
private _halfLight = _lightLevel / 0.5;
|
||||
|
||||
private _finalLevel = if (_lightLevel < 0.5) then {
|
||||
[(_lightTint select 0) * _halfLight,
|
||||
(_lightTint select 1) * _halfLight,
|
||||
(_lightTint select 2) * _halfLight,
|
||||
(_lightTint select 3) * (1 - _lightLevel)]
|
||||
} else {
|
||||
_halfLight = (_lightLevel - 0.5) / 0.5;
|
||||
[(_lightTint select 0) * (1 - _halfLight) + _halfLight,
|
||||
(_lightTint select 1) * (1 - _halfLight) + _halfLight,
|
||||
(_lightTint select 2) * (1 - _halfLight) + _halfLight,
|
||||
(_lightTint select 3) * (1 - _lightLevel)]
|
||||
};
|
||||
|
||||
[true, _finalLevel]
|
||||
[true, _finalLightColor]
|
||||
|
@ -41,12 +41,15 @@ _lightLevel params ["_r", "_g", "_b", "_a"];
|
||||
private _colourAlpha = (_r + _g + _b) min _a;
|
||||
private _shadeAlpha = _a;
|
||||
|
||||
private _colourList = [_r, _g, _b];
|
||||
_colourList sort false;
|
||||
private _maxColour = _colourList select 0;
|
||||
private _maxColour = selectMax [_r, _g, _b];
|
||||
private _ambientColor = if (_maxColour == 0) then {
|
||||
[1, 1, 1, _colourAlpha];
|
||||
} else {
|
||||
[_r / _maxColour, _g / _maxColour, _b / _maxColour, _colourAlpha];
|
||||
};
|
||||
|
||||
//ambient colour fill
|
||||
_mapCtrl drawIcon ["#(rgb,8,8,3)color(1,1,1,1)", [_r / _maxColour, _g / _maxColour, _b / _maxColour, _colourAlpha], _mapCentre, _screenSize, _screenSize, 0, "", 0];
|
||||
_mapCtrl drawIcon ["#(rgb,8,8,3)color(1,1,1,1)", _ambientColor, _mapCentre, _screenSize, _screenSize, 0, "", 0];
|
||||
|
||||
if (_flashlight == "") then {
|
||||
//ambient shade fill
|
||||
|
@ -4,13 +4,13 @@
|
||||
* On map draw, updates the effects
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
* 0: Map control <CONTROL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* call ACE_map_fnc_updateMapEffects
|
||||
* _mapControl call ACE_map_fnc_updateMapEffects
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user