mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #1302 from acemod/nameTagFixes
Nametags - Use EyePos of target / windows
This commit is contained in:
commit
9ed15d9702
@ -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"};
|
||||
};
|
||||
};
|
@ -16,24 +16,27 @@
|
||||
|
||||
#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 ACE_time if not visable
|
||||
if (_iconType == ICON_NONE) exitWith {}; //Don't waste ACE_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 Icon:
|
||||
_icon = "";
|
||||
_size = 0;
|
||||
if ((_iconType == ICON_NAME_SPEAK) || (_iconType == ICON_SPEAK)) then {
|
||||
_icon = QUOTE(PATHTOF(UI\soundwave)) + str (floor (random 10)) + ".paa";
|
||||
_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 = 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 {
|
||||
@ -42,41 +45,28 @@ _name = if (_iconType in [ICON_NAME, ICON_NAME_RANK, ICON_NAME_SPEAK]) then {
|
||||
""
|
||||
};
|
||||
|
||||
//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
|
||||
} 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;
|
||||
};
|
||||
};
|
||||
|
||||
//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)
|
||||
_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);
|
||||
};
|
||||
|
||||
_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"
|
||||
];
|
||||
|
@ -1,9 +1,12 @@
|
||||
#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", "_ambientBrightness", "_maxDistance"];
|
||||
|
||||
//don't show nametags in spectator
|
||||
if (!alive ACE_player) exitWith {};
|
||||
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) - ACE_time); //after release 1 second of full opacity, 1 second of fading to 0
|
||||
@ -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;
|
||||
@ -89,18 +90,14 @@ 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));
|
||||
|
||||
_alpha = ((1 - 0.2 * (_distance - GVAR(PlayerNamesViewDistance))) 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);
|
||||
};
|
||||
|
@ -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" \
|
||||
]
|
@ -216,5 +216,11 @@
|
||||
<English></English>
|
||||
<Polish>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.</Polish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_nametags_tagsize_name">
|
||||
<English>Nametags Size</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_nametags_tagsize_description">
|
||||
<English>Text and Icon Size Scaling</English>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user