Merge pull request #4310 from acemod/voiperr-flashlight_housekeeping

Map + Flashlights Cleanup (merge conflicts + fixes)
This commit is contained in:
PabstMirror 2016-09-02 18:57:48 -05:00 committed by GitHub
commit 2b29dcadc3
20 changed files with 269 additions and 274 deletions

View File

@ -1,7 +0,0 @@
class CfgSounds {
class GVAR(flashlightClick) {
name = QGVAR(flashlightClick);
sound[] = {"\a3\sounds_f\weapons\Other\dry4.wss", 0.2, 2};
titles[] = {};
};
};

View File

@ -1,18 +1,7 @@
class CfgWeapons {
class ItemCore;
class ACE_ItemCore;
class InventoryItem_Base_F;
class InventoryFlashlightItem_Base_F;
class acc_flashlight: ItemCore {
class ItemInfo: InventoryFlashlightItem_Base_F {
class Flashlight {
ACE_Flashlight_Colour = "white";
ACE_Flashlight_Size = 2.75;
};
};
};
class ACE_Flashlight_MX991: ACE_ItemCore {
displayName = CSTRING(MX991_DisplayName);
@ -24,7 +13,9 @@ class CfgWeapons {
mass = 1;
class FlashLight {
ACE_Flashlight_Colour = "red";
ACE_Flashlight_Beam = QPATHTOF(UI\Flashlight_beam_red_ca.paa);
ACE_Flashlight_Size = 1.75;
ACE_Flashlight_Sound = 1;
};
};
};
@ -39,7 +30,9 @@ class CfgWeapons {
mass = 1;
class FlashLight {
ACE_Flashlight_Colour = "red";
ACE_Flashlight_Beam = QPATHTOF(UI\Flashlight_beam_red_ca.paa);
ACE_Flashlight_Size = 1.5;
ACE_Flashlight_Sound = 1;
};
};
};
@ -54,7 +47,9 @@ class CfgWeapons {
mass = 1;
class FlashLight {
ACE_Flashlight_Colour = "white";
ACE_Flashlight_Beam = QPATHTOF(UI\Flashlight_beam_white_ca.paa);
ACE_Flashlight_Size = 2.15;
ACE_Flashlight_Sound = 1;
};
};
};

View File

@ -17,4 +17,3 @@ class CfgPatches {
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"
#include "CfgSounds.hpp"

View File

@ -1,39 +1,34 @@
class CfgAmmo {
class Chemlight_base;
class Grenade;
class ACE_FlashlightProxy_White: Chemlight_base {
model = "\A3\Weapons_f\empty";
class ACE_FlashlightProxy_White: Grenade {
effectsSmoke = "ACE_FlashlightEffect_White";
explosionTime = 0.01;
grenadeBurningSound[] = {};
grenadeFireSound[] = {};
hit = 0;
model = "\A3\Weapons_f\empty.p3d";
simulation = "shotSmokeX";
smokeColor[] = {1,1,1,1};
timeToLive = 1e10;
soundImpactHard1[] = {"",1,1};
soundImpactHard2[] = {"",1,1};
soundImpactHard3[] = {"",1,1};
soundImpactHard4[] = {"",1,1};
soundImpactHard5[] = {"",1,1};
soundImpactHard6[] = {"",1,1};
soundImpactHard7[] = {"",1,1};
soundImpactIron1[] = {"",1,1};
soundImpactIron2[] = {"",1,1};
soundImpactIron3[] = {"",1,1};
soundImpactIron4[] = {"",1,1};
soundImpactIron5[] = {"",1,1};
soundImpactSoft1[] = {"",1,1};
soundImpactSoft2[] = {"",1,1};
soundImpactSoft3[] = {"",1,1};
soundImpactSoft4[] = {"",1,1};
soundImpactSoft5[] = {"",1,1};
soundImpactSoft6[] = {"",1,1};
soundImpactSoft7[] = {"",1,1};
soundImpactWater1[] = {"",1,1};
soundImpactWater2[] = {"",1,1};
soundImpactWater3[] = {"",1,1};
soundImpactWoodExt1[] = {"",1,1};
soundImpactWoodExt2[] = {"",1,1};
soundImpactWoodExt3[] = {"",1,1};
soundImpactWoodExt4[] = {"",1,1};
impactArmor[] = {};
impactConcrete[] = {};
impactDefault[] = {};
impactGlass[] = {};
impactGlassArmored[] = {};
impactGroundHard[] = {};
impactGroundSoft[] = {};
impactIron[] = {};
impactMan[] = {};
impactMetal[] = {};
impactMetalPlate[] = {};
impactMetalPlastic[] = {};
impactRubber[] = {};
impactTyre[] = {};
impactWater[] = {};
impactWood[] = {};
};
class ACE_FlashlightProxy_Red: ACE_FlashlightProxy_White {
@ -51,4 +46,8 @@ class CfgAmmo {
class ACE_FlashlightProxy_Yellow: ACE_FlashlightProxy_White {
effectsSmoke = "ACE_FlashlightEffect_Yellow";
};
class ACE_FlashlightProxy_Orange: ACE_FlashlightProxy_White {
effectsSmoke = "ACE_FlashlightEffect_Orange";
};
};

View File

@ -7,12 +7,13 @@ class Extended_PreStart_EventHandlers {
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit) );
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
clientInit = QUOTE(call COMPILE_FILE(XEH_postInitClient) );
clientInit = QUOTE(call COMPILE_FILE(XEH_postInitClient));
serverInit = QUOTE(call COMPILE_FILE(XEH_postInitServer));
};
};

16
addons/map/CfgWeapons.hpp Normal file
View File

@ -0,0 +1,16 @@
class CfgWeapons {
class ItemCore;
class InventoryFlashlightItem_Base_F;
class acc_flashlight: ItemCore {
class ItemInfo: InventoryFlashlightItem_Base_F {
class FlashLight {
ACE_Flashlight_Colour = "white";
ACE_Flashlight_Beam = QPATHTOF(UI\Flashlight_beam_white_ca.paa);
ACE_Flashlight_Size = 2.75;
ACE_Flashlight_Sound = 1;
};
};
};
};

View File

@ -33,4 +33,11 @@ class ACE_FlashlightEffect_Yellow {
simulation = "light";
type = "ACE_FlashlightLight_Yellow";
};
};
class ACE_FlashlightEffect_Orange {
class Light1 {
simulation = "light";
type = "ACE_FlashlightLight_Orange";
};
};

Binary file not shown.

View File

@ -1,23 +1,5 @@
#include "script_component.hpp"
//Delete map glow lights from disconnecting players #2810
if (isServer) then {
addMissionEventHandler ["HandleDisconnect",{
params ["_disconnectedPlayer"];
if ((!GVAR(mapGlow)) || {isNull _disconnectedPlayer}) exitWith {};
{
if (_x isKindOf "ACE_FlashlightProxy_White") then {
// ACE_LOGINFO_2("Deleting leftover light [%1:%2] from DC player [%3]", _x, typeOf _x, _disconnectedPlayer);
detach _x;
deleteVehicle _x;
};
} forEach attachedObjects _disconnectedPlayer;
nil
}];
};
// Exit on Headless as well
if (!hasInterface) exitWith {};
@ -39,12 +21,11 @@ call FUNC(determineZoom);
//Allow panning the lastStillPosition while mapShake is active
GVAR(rightMouseButtonLastPos) = [];
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", {[] call FUNC(updateMapEffects);}];
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", {_this call FUNC(updateMapEffects)}];
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseMoving", {
if (GVAR(isShaking) && {(count GVAR(rightMouseButtonLastPos)) == 2}) then {
private["_lastPos", "_newPos"];
_lastPos = (_this select 0) ctrlMapScreenToWorld GVAR(rightMouseButtonLastPos);
_newPos = (_this select 0) ctrlMapScreenToWorld (_this select [1,2]);
private _lastPos = (_this select 0) ctrlMapScreenToWorld GVAR(rightMouseButtonLastPos);
private _newPos = (_this select 0) ctrlMapScreenToWorld (_this select [1,2]);
GVAR(lastStillPosition) set [0, (GVAR(lastStillPosition) select 0) + (_lastPos select 0) - (_newPos select 0)];
GVAR(lastStillPosition) set [1, (GVAR(lastStillPosition) select 1) + (_lastPos select 1) - (_newPos select 1)];
GVAR(rightMouseButtonLastPos) = _this select [1,2];
@ -97,35 +78,33 @@ call FUNC(determineZoom);
//illumination settings
if (GVAR(mapIllumination)) then {
GVAR(flashlightInUse) = "";
GVAR(glow) = objNull;
["loadout", {
private _flashlights = [ACE_player] call FUNC(getUnitFlashlights);
if ((GVAR(flashlightInUse) != "") && !(GVAR(flashlightInUse) in _flashlights)) then {
GVAR(flashlightInUse) = "";
params ["_player", ""];
private _unitLight = _player getVariable [QGVAR(flashlight), ["", objNull]];
_unitLight params ["_flashlight", "_glow"];
if ((_flashlight != "") && {!(_flashlight in ([_player] call FUNC(getUnitFlashlights)))}) then {
// remove the current glow if the unit suddenly lost it's flashlight
if (!isNull _glow) then {
_glow = [_player, "", false] call FUNC(flashlightGlow);
};
_player setVariable [QGVAR(flashlight), ["", _glow], true];
};
}] call CBA_fnc_addPlayerEventHandler;
if (GVAR(mapGlow)) then {
["visibleMap", {
params ["_player", "_mapOn"];
private _unitLight = _player getVariable [QGVAR(flashlight), ["", objNull]];
_unitLight params ["_flashlight", "_glow"];
private _flashlightOn = !(_flashlight isEqualTo "");
if (_mapOn) then {
if (!alive _player && !isNull GVAR(glow)) then {
GVAR(flashlightInUse) = "";
};
if (GVAR(flashlightInUse) != "") then {
if (isNull GVAR(glow)) then {
[GVAR(flashlightInUse)] call FUNC(flashlightGlow);
};
} else {
if (!isNull GVAR(glow)) then {
[""] call FUNC(flashlightGlow);
};
if (_flashlightOn && {isNull _glow}) then {
[_player, _flashlight] call FUNC(flashlightGlow);
playSound QGVAR(flashlightClick);
};
} else {
if (!isNull GVAR(glow)) then {
[""] call FUNC(flashlightGlow);
if (!isNull _glow) then {
[_player, ""] call FUNC(flashlightGlow);
};
};
}] call CBA_fnc_addPlayerEventHandler;

View File

@ -0,0 +1,16 @@
#include "script_component.hpp"
// Delete map glow lights from disconnecting players, #2810
addMissionEventHandler ["HandleDisconnect",{
params ["_disconnectedPlayer"];
if (!GVAR(mapGlow)) exitWith {};
private _unitLight = _disconnectedPlayer getVariable [QGVAR(flashlight), ["", objNull]];
_unitLight params ["", "_glow"];
if ((!isNull _disconnectedPlayer) && {!isNull _glow}) then {
detach _glow;
deleteVehicle _glow;
};
nil
}];

View File

@ -29,6 +29,7 @@ class RscEdit;
#include "CfgEventHandlers.hpp"
#include "CfgMarkers.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"
#include "CfgAmmo.hpp"
#include "CfgSounds.hpp"
#include "CfgLights.hpp"

View File

@ -2,8 +2,6 @@
#include "script_component.hpp"
// BEGIN_COUNTER(blueForceTrackingUpdate);
private ["_groupsToDrawMarkers", "_playersToDrawMarkers", "_playerSide", "_anyPlayers", "_colour", "_marker"];
// Delete last set of markers (always)
{
deleteMarkerLocal _x;
@ -13,8 +11,8 @@ GVAR(BFT_markers) = [];
if (GVAR(BFT_Enabled) and {(!isNil "ACE_player") and {alive ACE_player}}) then {
_groupsToDrawMarkers = [];
_playerSide = call EFUNC(common,playerSide);
private _groupsToDrawMarkers = [];
private _playerSide = call EFUNC(common,playerSide);
_groupsToDrawMarkers = allGroups select {side _x == _playerSide};
@ -27,7 +25,7 @@ if (GVAR(BFT_Enabled) and {(!isNil "ACE_player") and {alive ACE_player}}) then {
};
if (GVAR(BFT_ShowPlayerNames)) then {
_playersToDrawMarkers = allPlayers select {side _x == _playerSide && {!(_x getVariable [QGVAR(hideBlueForceMarker), false])}};
private _playersToDrawMarkers = allPlayers select {side _x == _playerSide && {!(_x getVariable [QGVAR(hideBlueForceMarker), false])}};
{
private _markerType = [_x] call EFUNC(common,getMarkerType);

View File

@ -20,27 +20,27 @@
params ["", "_player"];
private["_action", "_actions", "_cfg", "_displayName", "_flashlights", "_icon", "_statement"];
_actions = [];
_flashlights = [_player] call FUNC(getUnitFlashlights);
private _actions = [];
private _flashlightItems = [_player] call FUNC(getUnitFlashlights);
private _unitLight = _player getVariable [QGVAR(flashlight), ["", objNull]];
_unitLight params ["_flashlight", ""];
//add all carried flashlight menus and on/off submenu actions
{
_cfg = (configFile >> "CfgWeapons" >> _x);
_displayName = getText (_cfg >> "displayName");
_icon = getText (_cfg >> "picture");
private _cfg = (configFile >> "CfgWeapons" >> _x);
private _displayName = getText (_cfg >> "displayName");
private _icon = getText (_cfg >> "picture");
_statement = if (GVAR(flashlightInUse) == _x) then {
private _statement = if (_flashlight == _x) then {
_displayName = format [localize LSTRING(turnLightOff), _displayName];
{[""] call FUNC(switchFlashlight)}
{[_player, ""] call FUNC(switchFlashlight)}
} else {
_displayName = format [localize LSTRING(turnLightOn), _displayName];
{[_this select 2] call FUNC(switchFlashlight)}
{[_player, _this select 2] call FUNC(switchFlashlight)}
};
_action = [_x, _displayName, _icon, _statement, {true}, {}, _x] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _player];
} forEach _flashlights;
} forEach _flashlightItems;
_actions

View File

@ -1,83 +1,50 @@
/*
* Author: Rocko and esteldunedain
* Calculates the current map illumination for a given unit
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* 0: Does the map needs shading? <BOOL>
* 1: Color of the overlay <ARRAY>
*
* Public: No
*/
* Author: Rocko and esteldunedain
* Calculates the current map illumination for a given unit
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* 0: Does the map needs shading? <BOOL>
* 1: Color of the overlay <ARRAY>
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
private ["_fnc_blendColor", "_lightTint", "_fnc_calcColor", "_l", "_lightLevel", "_vehicle", "_isEnclosed", "_nearObjects", "_light", "_ll", "_flashlight", "_flareTint"];
// Blend two colors
_fnc_blendColor = {
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]
(_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
_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] };
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]
};
// Calculates overlay color from tint and light level
_fnc_calcColor = {
params ["_c1", "_lightLevel"];
if (_lightLevel < 0.5) then {
_l = _lightLevel / 0.5;
[(_c1 select 0) * _l,
(_c1 select 1) * _l,
(_c1 select 2) * _l,
(_c1 select 3) * (1 - _lightLevel)]
} else {
_l = (_lightLevel - 0.5) / 0.5;
[(_c1 select 0) * (1 - _l) + _l,
(_c1 select 1) * (1 - _l) + _l,
(_c1 select 2) * (1 - _l) + _l,
(_c1 select 3) * (1 - _lightLevel)]
};
};
_lightLevel = 0.04 + (0.96 * call EFUNC(common,ambientBrightness));
/*
// check if player has NVG enabled
if (currentVisionMode _unit == 1) exitWith {
// stick to nvg color
[true, [154/255,253/255,177/255,0.5]]
};
*/
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, [0.5,0.5,0.5,0]]
[false, [1,1,1,0]]
};
_vehicle = vehicle _unit;
private _vehicle = vehicle _unit;
// Do not obscure the map if the player is on a enclosed vehicle (assume internal illumination)
if (_vehicle != _unit) then {
// Player is in a vehicle
if (!isTurnedOut _unit && { _vehicle isKindOf "Tank" || { ( _vehicle isKindOf "Helicopter" || _vehicle isKindOf "Plane" ) && { (driver _vehicle) == _unit || { (gunner _vehicle) == _unit } } } || {_vehicle isKindOf "Wheeled_APC"}}) then {
_isEnclosed = true;
};
};
if (_isEnclosed) exitWith {
if ((_vehicle != _unit) && {!isTurnedOut _unit && {_vehicle isKindOf "Tank" || {(_vehicle isKindOf "Helicopter" || _vehicle isKindOf "Plane") && {driver _vehicle == _unit || {gunner _vehicle == _unit}}} || {_vehicle isKindOf "Wheeled_APC"}}}) exitWith {
TRACE_1("Player in a enclosed vehicle","");
[false, [1,1,1,0]]
};
@ -93,29 +60,38 @@ TRACE_1("Player is on foot or in an open vehicle","");
// @todo: Illumination flares (timed)
// Using chemlights
_nearObjects = (_unit nearObjects ["SmokeShell", 4]) select {alive _x && {toLower typeOf _x in ["chemlight_red", "chemlight_green", "chemlight_blue", "chemlight_yellow"]}};
private _nearObjects = (_unit nearObjects ["Chemlight_base", 4]) select {alive _x};
if (count (_nearObjects) > 0) then {
_light = _nearObjects select 0;
_ll = (1 - ((((_unit distance _light) - 2)/2) max 0)) * 0.4;
if (_ll > _lightLevel) then {
_flareTint = switch (toLower typeOf _light) do {
case "chemlight_red" : {[1,0,0,1]};
case "chemlight_green" : {[0,1,0,1]};
case "chemlight_blue" : {[0,0,1,1]};
case "chemlight_yellow" : {[1,1,0,1]};
};
_lightTint = [_lightTint, _flareTint, (_ll - _lightLevel)/(1 - _lightLevel)] call _fnc_blendColor;
_lightLevel = _ll;
if !(_nearObjects isEqualTo []) 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","");
};
};
// Do not obscure the map if the ambient light level is above 0.95
if (_lightLevel > 0.95) exitWith {
[false, [0.5,0.5,0.5,0]]
[false, [1,1,1,0]]
};
// Calculate resulting map color
[true, [_lightTint, _lightLevel] call _fnc_calcColor]
// 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]

View File

@ -12,15 +12,14 @@
*/
#include "script_component.hpp"
private ["_grids", "_fourSize", "_sixSize", "_continue", "_size", "_i"];
_grids = (configFile >> "CfgWorlds" >> worldName >> "Grid");
_fourSize = -1;
_sixSize = -1;
private _grids = (configFile >> "CfgWorlds" >> worldName >> "Grid");
private _fourSize = -1;
private _sixSize = -1;
for "_i" from 1 to 10 do {
_continue = false;
private _continue = false;
if (isClass(_grids >> format["Zoom%1", _i])) then {
_continue = true;
_size = getText(_grids >> format["Zoom%1", _i] >> "formatX");
private _size = getText(_grids >> format["Zoom%1", _i] >> "formatX");
if ((count toArray(_size)) == 2) then {
_fourSize = getNumber(_grids >> format["Zoom%1", _i] >> "zoomMax");
};

View File

@ -3,37 +3,44 @@
* Add or remove global flashlight glow for when player is looking at map.
*
* Arguments:
* 0: Flashlight classname ("" for off) <STRING>
* 0: Unit <OBJECT>
* 1: Flashlight classname ("" for off) <STRING>
* 2: Set the PVAR? <BOOL> (default: true)
*
* Return Value:
* None
* Glow object <OBJECT>
*
* Example:
* ["ACE_Flashlight_MX991"] call ace_map_fnc_flashlightGlow;
* [ACE_player, "ACE_Flashlight_MX991"] call ace_map_fnc_flashlightGlow;
*
* Public: No
*/
#include "script_component.hpp"
private ["_light", "_color", "_class"];
params ["_flashlight"];
params ["_unit", "_flashlightType", ["_set", true]];
_light = GVAR(glow);
if (!isNull _light) then {
detach _light;
deleteVehicle _light;
private _unitLight = _unit getVariable [QGVAR(flashlight), ["", objNull]];
_unitLight params ["_flashlight", "_glow"];
if (!isNull _glow) then {
detach _glow;
deleteVehicle _glow;
};
if (_flashlight != "") then {
_color = getText (configFile >> "CfgWeapons" >> _flashlight >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Colour");
if !(_color in ["white", "red", "green", "blue", "yellow"]) then {_color = "white"};
_class = format["ACE_FlashlightProxy_%1", _color];
if !(_flashlightType isEqualTo "") then {
private _color = getText (configFile >> "CfgWeapons" >> _flashlightType >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Colour");
if !(_color in ["white", "red", "green", "blue", "yellow", "orange"]) then {_color = "white"};
private _class = format ["ACE_FlashlightProxy_%1", _color];
_light = _class createVehicle [0,0,0];
_light attachTo [ACE_player, [0,0.1,-0.05], "neck"];
_glow = _class createVehicle [0,0,0];
_glow attachTo [_unit, [0,0.1,-0.05], "neck"];
} else {
_light = objNull;
_glow = objNull;
};
GVAR(glow) = _light;
if (_set) then {
_unit setVariable [QGVAR(flashlight), [_flashlight, _glow], true];
};
_glow

View File

@ -21,8 +21,8 @@ params ["_unit"];
private _flashlights = [];
{
if ((isText (configFile >> "CfgWeapons" >> _x >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Colour")) && !(_x in _flashlights)) then {
_flashlights pushBack _x;
if (isText (configFile >> "CfgWeapons" >> _x >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Colour")) then {
_flashlights pushBackUnique _x;
};
} forEach (items _unit);

View File

@ -1,48 +1,47 @@
/*
* Author: voiper
* Draw nearby lighting and sexy flashlight beams on main map.
*
* Arguments:
* 0: Map control <CONTROL>
* 1: Map zoom level <NUMBER>
* 2: Current map centre <ARRAY>
* 3: Light level from ace_map_fnc_determineMapLight <ARRAY>
*
* Return Value:
* None
*
* Public: No
*/
* Author: voiper
* Draw nearby lighting and sexy flashlight beams on main map.
*
* Arguments:
* 0: Map control <CONTROL>
* 1: Map zoom level <NUMBER>
* 2: Current map centre <ARRAY>
* 3: Light level from ace_map_fnc_determineMapLight <ARRAY>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
private ["_hmd", "_flashlight", "_screenSize", "_realViewPortY", "_realViewPortX", "_fillTex", "_colourAlpha", "_shadeAlpha", "_colourList", "_maxColour"];
params ["_mapCtrl", "_mapScale", "_mapCentre", "_lightLevel"];
_hmd = hmd ACE_player;
_flashlight = GVAR(flashlightInUse);
private _unitLight = ACE_player getVariable [QGVAR(flashlight), ["", objNull]];
_unitLight params ["_flashlight", ""];
//map width (on screen) in pixels
_screenSize = 640 * safeZoneWAbs;
private _screenSize = 640 * safeZoneWAbs;
//resolution params (every frame in case resolution change)
getResolution params ["_resX", "_resY", "_viewPortX", "_viewPortY", "", "_uiScale"];
//engine rounds the viewport ratios, when they should be fractions; this can cause problems
_realViewPortY = _resY * _uiScale;
_realViewPortX = _realViewPortY * 4/3;
private _realViewPortY = _resY * _uiScale;
private _realViewPortX = _realViewPortY * 4/3;
//textures
_fillTex = "#(rgb,8,8,3)color(0,0,0,1)";
private _fillTex = "#(rgb,8,8,3)color(0,0,0,1)";
//colour/alpha
_lightLevel params ["_r", "_g", "_b", "_a"];
_colourAlpha = (_r + _g + _b) min _a;
_shadeAlpha = _a;
private _colourAlpha = (_r + _g + _b) min _a;
private _shadeAlpha = _a;
_colourList = [_r, _g, _b];
private _colourList = [_r, _g, _b];
_colourList sort false;
_maxColour = _colourList select 0;
private _maxColour = _colourList select 0;
//ambient colour fill
_mapCtrl drawIcon [format["#(rgb,8,8,3)color(%1,%2,%3,1)", _r / _maxColour, _g / _maxColour, _b / _maxColour], [1,1,1,_colourAlpha], _mapCentre, _screenSize, _screenSize, 0, "", 0];
@ -51,22 +50,19 @@ if (_flashlight == "") then {
//ambient shade fill
_mapCtrl drawIcon [_fillTex, [1,1,1,_shadeAlpha], _mapCentre, _screenSize, _screenSize, 0, "", 0];
} else {
private ["_mousePos", "_colour", "_size", "_flashTex", "_beamSize", "_viewPortRatioFixY", "_offsetX", "_offsetYDown", "_offsetYUp"];
//mouse pos
_mousePos = GVAR(mousePos);
private _mousePos = GVAR(mousePos);
//flashlight settings
_colour = getText (configFile >> "CfgWeapons" >> _flashlight >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Colour");
if !(_colour in ["white", "red", "green", "blue", "yellow"]) then {_colour = "white"};
_size = getNumber (configFile >> "CfgWeapons" >> _flashlight >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Size");
_flashTex = format[QUOTE(PATHTOF_SYS(ace,flashlights,UI\Flashlight_Beam_%1_ca.paa)), _colour];
_beamSize = (safeZoneW/safeZoneWAbs) * _screenSize / _size;
private _cfg = (configFile >> "CfgWeapons" >> _flashlight >> "ItemInfo" >> "FlashLight");
private _size = getNumber (_cfg >> "ACE_Flashlight_Size");
private _flashTex = getText (_cfg >> "ACE_Flashlight_Beam");
private _beamSize = (safeZoneW/safeZoneWAbs) * _screenSize / _size;
//after 5x zoom, it's simulated to be fixed (it actually gets bigger relative to zoom)
if (_mapScale < 0.2) then {_beamSize = _beamSize / (_mapScale * (1 / 0.2))};
//assign corrective ratio to fix sub-pixel gaps/overlaps (symptom of viewport * X/Y resolution rounding)
_viewPortRatioFixY = if (_realViewPortY != _viewPortY) then {
private _viewPortRatioFixY = if (_realViewPortY != _viewPortY) then {
_realViewPortX / (_realViewPortY / _viewPortY * _viewPortX)
} else {
if (_realViewPortX != _viewPortX) then {
@ -77,10 +73,10 @@ if (_flashlight == "") then {
};
//offset the elements
_offsetX = _mapScale * GVAR(worldSize) * (_screenSize * 2 + _beamSize);
_offsetYDown = _mapScale * GVAR(worldSize) * (_screenSize + _beamSize) * _viewPortRatioFixY;
private _offsetX = _mapScale * GVAR(worldSize) * (_screenSize * 2 + _beamSize);
private _offsetYDown = _mapScale * GVAR(worldSize) * (_screenSize + _beamSize) * _viewPortRatioFixY;
//up is bigger because of a potential exploit
_offsetYUp = _mapScale * GVAR(worldSize) * (_screenSize * 4 + _beamSize) * _viewPortRatioFixY;
private _offsetYUp = _mapScale * GVAR(worldSize) * (_screenSize * 4 + _beamSize) * _viewPortRatioFixY;
//draw the matrix /whoa
_mapCtrl drawIcon [_flashTex, [1,1,1,_shadeAlpha], _mousePos, _beamSize, _beamSize, 0, "", 0]; //centre beam

View File

@ -1,25 +1,39 @@
/*
* Author: voioper
* Switch flashlight.
* Switch flashlight on/off.
*
* Arguments:
* 0: Flashlight classname ("" for off) <STRING>
* 0: Unit <OBJECT>
* 1: New flashlight classname ("" for off) <STRING>
*
* Return Value:
* None
*
* Example:
* ["ACE_Flashlight_MX991"] call ace_map_fnc_switchFlashlight;
* [ACE_player, "ACE_Flashlight_MX991"] call ace_map_fnc_switchFlashlight;
*
* Public: No
*/
#include "script_component.hpp"
params ["_flashlight"];
params ["_unit", "_newFlashlight"];
private _unitLight = _unit getVariable [QGVAR(flashlight), ["", objNull]];
_unitLight params ["_flashlight", "_glow"];
GVAR(flashlightInUse) = _flashlight;
if (GVAR(mapGlow)) then {
[GVAR(flashlightInUse)] call FUNC(flashlightGlow);
// we don't want to set the PVAR twice in a row, so tell this func not to set it
_glow = [_unit, _newFlashlight, false] call FUNC(flashlightGlow);
};
playSound QGVAR(flashlightClick);
private _config = (configFile >> "CfgWeapons");
if (
(getNumber (_config >> _newFlashlight >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Sound") > 0) ||
{getNumber (_config >> _flashlight >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Sound") > 0}
) then {
playSound QGVAR(flashlightClick);
};
_unit setVariable [QGVAR(flashlight), [_newFlashlight, _glow], true];

View File

@ -1,25 +1,25 @@
/*
* Author: Rocko and esteldunedain
* On map draw, updates the effects
*
* Arguments:
* None
*
* Return Value:
* None
*
* Public: No
*/
* Author: Rocko and esteldunedain
* On map draw, updates the effects
*
* Arguments:
* None
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
private ["_mapCtrl", "_mapScale", "_mapCentre", "_light"];
_mapCtrl = findDisplay 12 displayCtrl 51;
_mapScale = ctrlMapScale _mapCtrl;
_mapCentre = _mapCtrl ctrlMapScreenToWorld [0.5, 0.5];
params ["_mapCtrl"];
private _mapScale = ctrlMapScale _mapCtrl;
private _mapCentre = _mapCtrl ctrlMapScreenToWorld [0.5, 0.5];
if (GVAR(mapIllumination)) then {
//get nearby lighting
_light = [[ACE_player], FUNC(determineMapLight), missionNamespace, QGVAR(mapLight), 0.1] call EFUNC(common,cachedCall);
private _light = [[ACE_player], FUNC(determineMapLight), missionNamespace, QGVAR(mapLight), 0.1] call EFUNC(common,cachedCall);
_light params ["_applyLighting", "_lightLevel"];
@ -29,10 +29,9 @@ if (GVAR(mapIllumination)) then {
};
if (GVAR(mapShake)) then {
private ["_speed","_amplitude", "_time", "_shakePos"];
// Only shake map while moving on foot
_speed = 0;
private _speed = 0;
if (vehicle ACE_player == ACE_player) then {
_speed = vectorMagnitude (velocity ACE_player);
};
@ -41,10 +40,10 @@ if (GVAR(mapShake)) then {
if (_speed > 0.1) then {
if (ctrlMapAnimDone _mapCtrl) then {
_amplitude = (_speed - 0.1) / 5 * (1000 * _mapScale);
_time = 0.1;
private _amplitude = (_speed - 0.1) / 5 * (1000 * _mapScale);
private _time = 0.1;
_shakePos = [(GVAR(lastStillPosition) select 0) + sin((CBA_missionTime + _time - GVAR(lastStillTime))*100) * _amplitude * 0.25,
private _shakePos = [(GVAR(lastStillPosition) select 0) + sin((CBA_missionTime + _time - GVAR(lastStillTime))*100) * _amplitude * 0.25,
(GVAR(lastStillPosition) select 1) + sin((CBA_missionTime + _time - GVAR(lastStillTime))*260) * _amplitude];
_mapCtrl ctrlMapAnimAdd [_time, _mapScale, _shakePos];