From 942066b04a0d58ddfa0ea70230445728c17eb78d Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 19 May 2015 00:09:49 -0500 Subject: [PATCH 1/4] Nametags - Use EyePos of target --- addons/nametags/functions/fnc_onDraw3d.sqf | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/nametags/functions/fnc_onDraw3d.sqf b/addons/nametags/functions/fnc_onDraw3d.sqf index 9efc70aeb9..efc555831d 100644 --- a/addons/nametags/functions/fnc_onDraw3d.sqf +++ b/addons/nametags/functions/fnc_onDraw3d.sqf @@ -1,9 +1,9 @@ #include "script_component.hpp" -private ["_onKeyPressAlphaMax", "_defaultIcon", "_distance", "_alpha", "_icon", "_targets", "_pos2", "_vecy", "_relPos", "_projDist", "_pos", "_target"]; +private ["_onKeyPressAlphaMax", "_defaultIcon", "_distance", "_alpha", "_icon", "_targets", "_pos2", "_vecy", "_relPos", "_projDist", "_pos", "_target", "_targetEyePosASL"]; //don't show nametags in spectator -if (!alive ACE_player) exitWith {}; +if ((isNull ACE_player) || {!alive ACE_player}) exitWith {}; _onKeyPressAlphaMax = if ((GVAR(showPlayerNames) in [3,4])) then { 2 + (GVAR(ShowNamesTime) - time); //after release 1 second of full opacity, 1 second of fading to 0 @@ -89,7 +89,9 @@ if (((GVAR(showPlayerNames) in [1,3]) && {_onKeyPressAlphaMax > 0}) || {GVAR(sho {GVAR(ShowNamesForAI) || {[_target] call EFUNC(common,isPlayer)}} && {!(_target getVariable ["ACE_hideName", false])}) then { - if (lineIntersects [_pos, (visiblePositionASL _target) vectorAdd [0,0,1], vehicle ACE_player, _target]) exitWith {}; // Check if there is line of sight + _targetEyePosASL = eyePos _target; + if (lineIntersects [_pos, _targetEyePosASL, ACE_player, _target]) exitWith {}; // Check if there is line of sight + _relPos = (visiblePositionASL _target) vectorDiff _pos; _distance = vectorMagnitude _relPos; _projDist = _relPos vectorDistance (_vecy vectorMultiply (_relPos vectorDotProduct _vecy)); From 6dc81796b5bc0ce6a4d88f4c2dac66ecb1a9ed64 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 19 May 2015 16:18:10 -0500 Subject: [PATCH 2/4] ambientBrightness effects tag distance --- addons/nametags/functions/fnc_onDraw3d.sqf | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/addons/nametags/functions/fnc_onDraw3d.sqf b/addons/nametags/functions/fnc_onDraw3d.sqf index efc555831d..6932788c2d 100644 --- a/addons/nametags/functions/fnc_onDraw3d.sqf +++ b/addons/nametags/functions/fnc_onDraw3d.sqf @@ -1,10 +1,13 @@ #include "script_component.hpp" -private ["_onKeyPressAlphaMax", "_defaultIcon", "_distance", "_alpha", "_icon", "_targets", "_pos2", "_vecy", "_relPos", "_projDist", "_pos", "_target", "_targetEyePosASL"]; +private ["_onKeyPressAlphaMax", "_defaultIcon", "_distance", "_alpha", "_icon", "_targets", "_pos2", "_vecy", "_relPos", "_projDist", "_pos", "_target", "_targetEyePosASL", "_ambientBrightness", "_maxDistance"]; //don't show nametags in spectator if ((isNull ACE_player) || {!alive ACE_player}) exitWith {}; +_ambientBrightness = ((([] call EFUNC(common,ambientBrightness)) + ([0, 0.4] select ((currentVisionMode ace_player) != 0))) min 1) max 0; +_maxDistance = _ambientBrightness * GVAR(PlayerNamesViewDistance); + _onKeyPressAlphaMax = if ((GVAR(showPlayerNames) in [3,4])) then { 2 + (GVAR(ShowNamesTime) - time); //after release 1 second of full opacity, 1 second of fading to 0 } else { @@ -29,8 +32,7 @@ if (GVAR(showCursorTagForVehicles) && {_onKeyPressAlphaMax > 0}) then { {GVAR(ShowNamesForAI) || {[_target] call EFUNC(common,isPlayer)}} && {!(_target getVariable ["ACE_hideName", false])}) then { _distance = ACE_player distance _target; - _alpha = ((1 - 0.2 * (_distance - GVAR(PlayerNamesViewDistance))) min 1) * GVAR(PlayerNamesMaxAlpha); - _alpha = _alpha min _onKeyPressAlphaMax; + _alpha = (((1 - 0.2 * (_distance - _maxDistance)) min 1) * GVAR(PlayerNamesMaxAlpha)) min _onKeyPressAlphaMax; [ACE_player, _target, _alpha, _distance * 0.026, _defaultIcon] call FUNC(drawNameTagIcon); }; }; @@ -46,8 +48,7 @@ if ((GVAR(showPlayerNames) in [2,4]) && {_onKeyPressAlphaMax > 0}) then { {GVAR(ShowNamesForAI) || {[_target] call EFUNC(common,isPlayer)}} && {!(_target getVariable ["ACE_hideName", false])}) then { _distance = ACE_player distance _target; - _alpha = ((1 - 0.2 * (_distance - GVAR(PlayerNamesViewDistance))) min 1) * GVAR(PlayerNamesMaxAlpha); - _alpha = _alpha min _onKeyPressAlphaMax; + _alpha = (((1 - 0.2 * (_distance - _maxDistance)) min 1) * GVAR(PlayerNamesMaxAlpha)) min _onKeyPressAlphaMax; _icon = ICON_NONE; if (GVAR(showSoundWaves) == 2) then { //icon will be drawn below, so only show name here _icon = if (([_target] call FUNC(isSpeaking)) && {(vehicle _target) == _target}) then {ICON_NAME} else {_defaultIcon}; @@ -61,7 +62,7 @@ if ((GVAR(showPlayerNames) in [2,4]) && {_onKeyPressAlphaMax > 0}) then { if (((GVAR(showPlayerNames) in [1,3]) && {_onKeyPressAlphaMax > 0}) || {GVAR(showSoundWaves) == 2}) then { _pos = positionCameraToWorld [0, 0, 0]; - _targets = _pos nearObjects ["CAManBase", GVAR(PlayerNamesViewDistance) + 5]; + _targets = _pos nearObjects ["CAManBase", _maxDistance + 5]; if (!surfaceIsWater _pos) then { _pos = ATLtoASL _pos; @@ -96,12 +97,12 @@ if (((GVAR(showPlayerNames) in [1,3]) && {_onKeyPressAlphaMax > 0}) || {GVAR(sho _distance = vectorMagnitude _relPos; _projDist = _relPos vectorDistance (_vecy vectorMultiply (_relPos vectorDotProduct _vecy)); - _alpha = ((1 - 0.2 * (_distance - GVAR(PlayerNamesViewDistance))) min (1 - 0.15 * (_projDist * 5 - _distance - 3)) min 1) * GVAR(PlayerNamesMaxAlpha); + _alpha = ((1 - 0.2 * (_distance - _maxDistance)) min (1 - 0.15 * (_projDist * 5 - _distance - 3)) min 1) * GVAR(PlayerNamesMaxAlpha); if ((GVAR(showSoundWaves) == 2) && {([_target] call FUNC(isSpeaking)) && {(vehicle _target) == _target}}) then { _alpha = 1; } else { - _alpha = _alpha min _onKeyPressAlphaMax; + _alpha = (_alpha min _onKeyPressAlphaMax); }; [ACE_player, _target, _alpha, _distance * 0.026, _icon] call FUNC(drawNameTagIcon); From ebeba23834965ced0a7009cc1cd4cf3e662689a6 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 19 May 2015 16:57:47 -0500 Subject: [PATCH 3/4] Nametag Size Option, selectionPosition for tag pos --- addons/nametags/ACE_Settings.hpp | 8 +++ .../functions/fnc_drawNameTagIcon.sqf | 50 ++++++++----------- addons/nametags/functions/fnc_onDraw3d.sqf | 8 +-- addons/nametags/script_component.hpp | 16 +++++- addons/nametags/stringtable.xml | 6 +++ 5 files changed, 49 insertions(+), 39 deletions(-) diff --git a/addons/nametags/ACE_Settings.hpp b/addons/nametags/ACE_Settings.hpp index a2c81e61b4..90d2b7d8c9 100644 --- a/addons/nametags/ACE_Settings.hpp +++ b/addons/nametags/ACE_Settings.hpp @@ -54,4 +54,12 @@ class ACE_Settings { typeName = "SCALAR"; isClientSettable = 0; }; + class GVAR(tagSize) { + value = 2; + typeName = "SCALAR"; + isClientSettable = 1; + displayName = "$STR_ACE_nametags_tagsize_name"; + description = "$STR_ACE_nametags_tagsize_description"; + values[] = {"$str_very_small", "$str_small", "$str_medium", "$str_large", "$str_very_large"}; + }; }; \ No newline at end of file diff --git a/addons/nametags/functions/fnc_drawNameTagIcon.sqf b/addons/nametags/functions/fnc_drawNameTagIcon.sqf index 6a7db7d5ac..9959fdca12 100644 --- a/addons/nametags/functions/fnc_drawNameTagIcon.sqf +++ b/addons/nametags/functions/fnc_drawNameTagIcon.sqf @@ -16,46 +16,35 @@ #include "script_component.hpp" -#define TEXTURES_RANKS [ \ - "", \ - "\A3\Ui_f\data\GUI\Cfg\Ranks\private_gs.paa", \ - "\A3\Ui_f\data\GUI\Cfg\Ranks\corporal_gs.paa", \ - "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa", \ - "\A3\Ui_f\data\GUI\Cfg\Ranks\lieutenant_gs.paa", \ - "\A3\Ui_f\data\GUI\Cfg\Ranks\captain_gs.paa", \ - "\A3\Ui_f\data\GUI\Cfg\Ranks\major_gs.paa", \ - "\A3\Ui_f\data\GUI\Cfg\Ranks\colonel_gs.paa" \ - ] - -private ["_height", "_position", "_color", "_name", "_rank", "_size", "_icon"]; - PARAMS_5(_player,_target,_alpha,_heightOffset,_iconType); -if (_alpha < 0) exitWith {}; //Don't waste time if not visable +private ["_position", "_color", "_name", "_rank", "_size", "_icon", "_scale"]; + if (_iconType == ICON_NONE) exitWith {}; //Don't waste time if not visable - -//Set Text: -_name = if (_iconType in [ICON_NAME, ICON_NAME_RANK, ICON_NAME_SPEAK]) then { - [_target, true] call EFUNC(common,getName) -} else { - "" -}; - //Set Icon: _icon = ""; _size = 0; if ((_iconType == ICON_NAME_SPEAK) || (_iconType == ICON_SPEAK)) then { _icon = QUOTE(PATHTOF(UI\soundwave)) + str (floor (random 10)) + ".paa"; - _size = 0.75; - _alpha = _alpha + 0.6;//Boost alpha when speaking + _size = 1; + _alpha = _alpha max 0.6;//Boost alpha when speaking } else { if (_iconType == ICON_NAME_RANK) then { _icon = TEXTURES_RANKS select ((["PRIVATE", "CORPORAL", "SERGEANT", "LIEUTENANT", "CAPTAIN", "MAJOR", "COLONEL"] find (rank _target)) + 1); - _size = 0.75; + _size = 1; }; }; +if (_alpha < 0) exitWith {}; //Don't waste time if not visable + +//Set Text: +_name = if (_iconType in [ICON_NAME, ICON_NAME_RANK, ICON_NAME_SPEAK]) then { + [_target, true] call EFUNC(common,getName) +} else { + "" +}; + //Set Color: if !(group _target == group _player) then { _color = +GVAR(defaultNametagColor); //Make a copy, then multiply both alpha values (allows client to decrease alpha in settings) @@ -64,19 +53,20 @@ if !(group _target == group _player) then { _color = [[1, 1, 1, _alpha], [1, 0, 0, _alpha], [0, 1, 0, _alpha], [0, 0, 1, _alpha], [1, 1, 0, _alpha]] select (["MAIN", "RED", "GREEN", "BLUE", "YELLOW"] find (if (_target == _player) then {0} else {assignedTeam _target})) max 0 }; -_height = [2, 1.5, 1, 1.5, 1] select (["STAND", "CROUCH", "PRONE", "UNDEFINED", ""] find (stance _target)); // Convert position to ASLW (expected by drawIcon3D) and add height offsets -_position = _target modelToWorldVisual [0, 0, (_height + _heightOffset)]; +_position = _target modelToWorldVisual ((_target selectionPosition "pilot") vectorAdd [0,0,(_heightOffset + .35)]); + +_scale = [0.333, 0.5, 0.666, 0.83333, 1] select GVAR(tagSize); drawIcon3D [ _icon, _color, _position, -_size, -_size, +(_size * _scale), +(_size * _scale), 0, _name, 2, -0.033, +(0.05 * _scale), "PuristaMedium" ]; diff --git a/addons/nametags/functions/fnc_onDraw3d.sqf b/addons/nametags/functions/fnc_onDraw3d.sqf index 6932788c2d..2e85d0112c 100644 --- a/addons/nametags/functions/fnc_onDraw3d.sqf +++ b/addons/nametags/functions/fnc_onDraw3d.sqf @@ -97,13 +97,7 @@ if (((GVAR(showPlayerNames) in [1,3]) && {_onKeyPressAlphaMax > 0}) || {GVAR(sho _distance = vectorMagnitude _relPos; _projDist = _relPos vectorDistance (_vecy vectorMultiply (_relPos vectorDotProduct _vecy)); - _alpha = ((1 - 0.2 * (_distance - _maxDistance)) min (1 - 0.15 * (_projDist * 5 - _distance - 3)) min 1) * GVAR(PlayerNamesMaxAlpha); - - if ((GVAR(showSoundWaves) == 2) && {([_target] call FUNC(isSpeaking)) && {(vehicle _target) == _target}}) then { - _alpha = 1; - } else { - _alpha = (_alpha min _onKeyPressAlphaMax); - }; + _alpha = (((1 - 0.2 * (_distance - _maxDistance)) min 1) * GVAR(PlayerNamesMaxAlpha)) min _onKeyPressAlphaMax; [ACE_player, _target, _alpha, _distance * 0.026, _icon] call FUNC(drawNameTagIcon); }; diff --git a/addons/nametags/script_component.hpp b/addons/nametags/script_component.hpp index e80768a723..da912b48c4 100644 --- a/addons/nametags/script_component.hpp +++ b/addons/nametags/script_component.hpp @@ -2,11 +2,11 @@ #include "\z\ace\addons\main\script_mod.hpp" #ifdef DEBUG_ENABLED_NAMETAGS - #define DEBUG_MODE_FULL +#define DEBUG_MODE_FULL #endif #ifdef DEBUG_SETTINGS_NAMETAGS - #define DEBUG_SETTINGS DEBUG_SETTINGS_NAMETAGS +#define DEBUG_SETTINGS DEBUG_SETTINGS_NAMETAGS #endif #include "\z\ace\addons\main\script_macros.hpp" @@ -16,3 +16,15 @@ #define ICON_NAME_RANK 2 #define ICON_NAME_SPEAK 3 #define ICON_SPEAK 4 + +//todo?: custom rank icons?? +#define TEXTURES_RANKS [ \ + "", \ + "\A3\Ui_f\data\GUI\Cfg\Ranks\private_gs.paa", \ + "\A3\Ui_f\data\GUI\Cfg\Ranks\corporal_gs.paa", \ + "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa", \ + "\A3\Ui_f\data\GUI\Cfg\Ranks\lieutenant_gs.paa", \ + "\A3\Ui_f\data\GUI\Cfg\Ranks\captain_gs.paa", \ + "\A3\Ui_f\data\GUI\Cfg\Ranks\major_gs.paa", \ + "\A3\Ui_f\data\GUI\Cfg\Ranks\colonel_gs.paa" \ + ] \ No newline at end of file diff --git a/addons/nametags/stringtable.xml b/addons/nametags/stringtable.xml index ef94140510..c74aaa5602 100644 --- a/addons/nametags/stringtable.xml +++ b/addons/nametags/stringtable.xml @@ -197,5 +197,11 @@ Opcja ta pozwala dostosować sposób wyświetlania efektu fal dźwiękowych nad głowami mówiących graczy, wyświetlanych po przytrzymaniu klawisza PTT. Opcja ta współpracuje z TFAR oraz ACRE2. + + Nametags Size + + + Text and Icon Size Scaling + From d410350a25f604719bbbf82d9158b5d91d17ec14 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 25 May 2015 14:01:59 -0500 Subject: [PATCH 4/4] Make code less smelly --- addons/nametags/functions/fnc_drawNameTagIcon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/nametags/functions/fnc_drawNameTagIcon.sqf b/addons/nametags/functions/fnc_drawNameTagIcon.sqf index 9959fdca12..1fdd703d62 100644 --- a/addons/nametags/functions/fnc_drawNameTagIcon.sqf +++ b/addons/nametags/functions/fnc_drawNameTagIcon.sqf @@ -50,7 +50,7 @@ if !(group _target == group _player) then { _color = +GVAR(defaultNametagColor); //Make a copy, then multiply both alpha values (allows client to decrease alpha in settings) _color set [3, (_color select 3) * _alpha]; } else { - _color = [[1, 1, 1, _alpha], [1, 0, 0, _alpha], [0, 1, 0, _alpha], [0, 0, 1, _alpha], [1, 1, 0, _alpha]] select (["MAIN", "RED", "GREEN", "BLUE", "YELLOW"] find (if (_target == _player) then {0} else {assignedTeam _target})) max 0 + _color = [[1, 1, 1, _alpha], [1, 0, 0, _alpha], [0, 1, 0, _alpha], [0, 0, 1, _alpha], [1, 1, 0, _alpha]] select ((["MAIN", "RED", "GREEN", "BLUE", "YELLOW"] find (assignedTeam _target)) max 0); }; // Convert position to ASLW (expected by drawIcon3D) and add height offsets