Nametag changes

Adds user options for showing soundwaves and default nametag color
Before nametags would show effectiveCommander for cursorTarget vehicles,
moved this to a module option (default off).
This commit is contained in:
PabstMirror 2015-02-13 21:23:40 -06:00
parent dbd33d5230
commit ba2ee53804
7 changed files with 108 additions and 75 deletions

View File

@ -16,8 +16,7 @@ EXPLODE_1_PVT(_this,_optionEntry);
_fnc_getValueWithType = {
EXPLODE_2_PVT(_this,_optionEntry,_typeName);
_value = getNumber (_optionEntry >> "value");
_value = if (isNumber (_optionEntry >> "value")) then {getNumber (_optionEntry >> "value")} else {0}; //getNumber on an array throws a warning
TRACE_3("_fnc_getValueWithType:", configName _optionEntry, _typeName, _value);
if (_typeName == "BOOL") exitWith {
_value > 0

View File

@ -55,6 +55,15 @@ class CfgVehicles {
};
};
};
class showCursorTagForVehicles {
displayName = "Show for Vehicles";
description = "Show cursor NameTag for vehicle commander (only if client has name tags enabled)Default: No";
typeName = "BOOL";
class values {
class Yes {name = "Yes"; value = 1;};
class No {default = 1; name = "No"; value = 0;};
};
};
};
};
};

View File

@ -31,15 +31,32 @@ addMissionEventHandler ["Draw3D", {
if (GVAR(showPlayerNames) == 0) exitWith {};
_player = ACE_player;
if (GVAR(showPlayerNames) in [2,4]) then { //only on cursor
_target = cursorTarget;
_target = if (_target in allUnitsUAV) then {objNull} else {effectiveCommander _target};
if (!isNull _target && {side group _target == playerSide} && {_target != _player} && {isPlayer _target || {GVAR(ShowNamesForAI)}} && {!(_target getVariable ["ACE_hideName", false])}) then {
//When cursorTarget is on a vehicle show the nametag for the commander.
//If set to "Only On Keypress" settings, fade just like main tags
if (GVAR(showCursorTagForVehicles)) then {
_target = cursorTarget;
if ((!(_target isKindOf "Man")) && {!(_target in allUnitsUAV)}) then {
_target = effectiveCommander _target;
if ((!isNull _target) && {side group _target == playerSide} && {_target != _player} && {isPlayer _target || {GVAR(ShowNamesForAI)}} && {!(_target getVariable ["ACE_hideName", false])}) then {
_distance = _player distance _target;
_alpha = ((1 - 0.2 * (_distance - GVAR(PlayerNamesViewDistance))) min 1) * GVAR(PlayerNamesMaxAlpha);
if ((GVAR(showPlayerNames) in [3,4])) then { //only on keypress
_alpha = _alpha min (1 - (time - GVAR(ShowNamesTime) - 1));
_alpha = _alpha min (2 + (GVAR(ShowNamesTime) - time));
};
[_player, _target, _alpha, _distance * 0.026] call FUNC(drawNameTagIcon);
};
};
};
if (GVAR(showPlayerNames) in [2,4]) then {
//"Only Cursor" mode, only show nametags for humans
_target = cursorTarget;
if ((!isNull _target) && {_target isKindOf "Man"} && {side group _target == playerSide} && {_target != _player} && {isPlayer _target || {GVAR(ShowNamesForAI)}} && {!(_target getVariable ["ACE_hideName", false])}) then {
_distance = _player distance _target;
_alpha = ((1 - 0.2 * (_distance - GVAR(PlayerNamesViewDistance))) min 1) * GVAR(PlayerNamesMaxAlpha);
if ((GVAR(showPlayerNames) == 4)) then { //only on keypress
_alpha = _alpha min (2 + (GVAR(ShowNamesTime) - time));
};
[_player, _target, _alpha, _distance * 0.026] call FUNC(drawNameTagIcon);
};
@ -57,25 +74,20 @@ addMissionEventHandler ["Draw3D", {
_vecy = _pos2 vectorDiff _pos;
{
_target = if (_x in allUnitsUAV) then {objNull} else {effectiveCommander _x};
_target = _x;
if (!isNull _target && {side group _target == playerSide} && {_target != _player} && {isPlayer _target || {GVAR(ShowNamesForAI)}} && {!(_target getVariable ["ACE_hideName", false])}) then {
if ((!isNull _target) && {side group _target == playerSide} && {_target != _player} && {isPlayer _target || {GVAR(ShowNamesForAI)}} && {!(_target getVariable ["ACE_hideName", false])}) then {
if (lineIntersects [_pos, (visiblePositionASL _target) vectorAdd [0,0,1], vehicle _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(showPlayerNames) in [3,4])) then { //only on keypress
_alpha = _alpha min (1 - (time - GVAR(ShowNamesTime) - 1));
if (GVAR(showPlayerNames) == 3) then { //only on keypress
_alpha = _alpha min (2 + (GVAR(ShowNamesTime) - time));
};
// Check if there is line of sight
if (_alpha > 0) then {
if (lineIntersects [_pos, (visiblePositionASL _target) vectorAdd [0,0,1], vehicle _player, _target]) then {
_alpha = 0;
};
};
[_player, _target, _alpha, _distance * 0.026] call FUNC(drawNameTagIcon);
};
} forEach _targets;

View File

@ -16,6 +16,12 @@ class CfgPatches {
#include "CfgVehicles.hpp"
class ACE_Settings {
class GVAR(defaultNametagColor) {
value[] = {0.77, 0.51, 0.08, 1};
typeName = "COLOR";
isClientSetable = 1;
displayName = "$STR_ACE_NameTags_DefaultNametagColor";
};
class GVAR(showPlayerNames) {
value = 1;
typeName = "SCALAR";
@ -41,6 +47,11 @@ class ACE_Settings {
isClientSetable = 1;
displayName = "$STR_ACE_NameTags_ShowNamesForAI";
};
class GVAR(showCursorTagForVehicles) {
value = 0;
typeName = "BOOL";
isClientSetable = 0;
};
class GVAR(showSoundWaves) {
value = 0;
typeName = "BOOL";

View File

@ -27,39 +27,37 @@
private ["_player", "_target", "_alpha", "_heightOffset", "_height", "_position", "_color", "_name", "_rank", "_size"];
_player = _this select 0;
_target = _this select 1;
_alpha = _this select 2;
_heightOffset = _this select 3;
_height = [2, 1.5, 1, 1.5, 1] select (["STAND", "CROUCH", "PRONE", "UNDEFINED", ""] find stance _target);
_position = visiblePositionASL _target;
// Convert position to ASLW (expected by drawIcon3D) and add height offsets
_position set [2, ((_target modelToWorld [0,0,0]) select 2) + _height + _heightOffset];
_color = if !(group _target == group _player) then {
[0.77, 0.51, 0.08, _alpha]
} else {
[[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
};
PARAMS_4(_player,_target,_alpha,_heightOffset);
_name = [_target, true] call EFUNC(common,getName);
_icon = "";
_size = 0;
if (GVAR(showSoundWaves) && {_target getVariable [QGVAR(isSpeaking), false]}) then {
_icon = QUOTE(PATHTOF(UI\soundwave));
_icon = _icon + str (floor (random 10)) + ".paa"; //random
// _icon = _icon + str (diag_frameno % 10) + ".paa"; //play in order??
_size = 2;
if (GVAR(showSoundWaves) && {(_target getVariable [QGVAR(isSpeaking), false]) && {(vehicle _target) == _target}}) then {
_icon = QUOTE(PATHTOF(UI\soundwave)) + str (floor (random 10)) + ".paa";
_size = 0.75;
_alpha = _alpha + 0.6;//Boost alpha when speaking
} else {
if (GVAR(showPlayerRanks)) then {
_icon = TEXTURES_RANKS select ((["PRIVATE", "CORPORAL", "SERGEANT", "LIEUTENANT", "CAPTAIN", "MAJOR", "COLONEL"] find (rank _target)) + 1);
_size = 1;
_size = 0.75;
};
};
if (_alpha < 0) exitWith {}; //Don't waste time if not visable
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
};
_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)];
drawIcon3D [
_icon,

View File

@ -25,5 +25,6 @@ GVAR(Module) = true;
[_logic, QGVAR(PlayerNamesViewDistance), "PlayerNamesViewDistance" ] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(ShowNamesForAI), "ShowNamesForAI" ] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(showVehicleCrewInfo), "showVehicleCrewInfo" ] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(showCursorTagForVehicles), "showCursorTagForVehicles" ] call EFUNC(common,readSettingFromModule);
diag_log text "[ACE]: NameTags Module Initialized.";

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Edited with tabler - 2015-02-12 -->
<!-- Edited with tabler - 2015-02-13 -->
<Project name="ACE">
<Package name="NameTags">
<Key ID="STR_ACE_NameTags_ShowNames">
@ -70,9 +70,12 @@
<English>Show name tags for AI units</English>
</Key>
<Key ID="STR_ACE_NameTags_ShowSoundWaves">
<English>Show SoundWaves when speaking</English>
<German>Zeigen Schallwelle im Gespräch</German>
<Spanish>Mostrar onda sonora cuando se habla</Spanish>
<English>Show SoundWaves (requires player names)</English>
<German>Zeigen Schallwelle (benötigt spielernamen)</German>
<Spanish>Mostrar onda sonora (requiere Mostrar nombres de jugadores)</Spanish>
</Key>
<Key ID="STR_ACE_NameTags_DefaultNametagColor">
<English>Default Nametag Color (Non Group Members)</English>
</Key>
</Package>
</Project>