Handle 3 Soundwave options

This commit is contained in:
PabstMirror 2015-02-19 16:42:28 -06:00
parent ae61dff44e
commit 3ade628d87
4 changed files with 92 additions and 46 deletions

View File

@ -25,4 +25,4 @@ if (isNull _target) then {
if (isNull _target) exitWith {false};
(_target in (attachedObjects _unit)) && {!(_target getVariable [QGVAR(isHandcuffed), false])}
(_target in (attachedObjects _unit)) && {_target getVariable [QGVAR(isHandcuffed), false]}

View File

@ -4,9 +4,11 @@
* Draw the nametag and rank icon.
*
* Argument:
* 0: Unit (Array)
* 1: alpha (Number)
* 2: Height offset (Number)
* 0: Unit (Player) <OBJECT>
* 1: Target <OBJECT>
* 2: alpha (Number)
* 4: Height offset (Number)
* 5: Draw Type <NUMBER>
*
* Return value:
* None.
@ -23,30 +25,38 @@
"\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"];
PARAMS_4(_player,_target,_alpha,_heightOffset);
PARAMS_5(_player,_target,_alpha,_heightOffset,_iconType);
_name = [_target, true] call EFUNC(common,getName);
if (_alpha < 0) exitWith {}; //Don't waste time if not visable
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 (GVAR(showSoundWaves) && {(_target getVariable [QGVAR(isSpeaking), false]) && {(vehicle _target) == _target}}) then {
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 (GVAR(showPlayerRanks)) then {
if (_iconType == ICON_NAME_RANK) then {
_icon = TEXTURES_RANKS select ((["PRIVATE", "CORPORAL", "SERGEANT", "LIEUTENANT", "CAPTAIN", "MAJOR", "COLONEL"] find (rank _target)) + 1);
_size = 0.75;
};
};
if (_alpha < 0) exitWith {}; //Don't waste time if not visable
//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];
@ -55,19 +65,18 @@ if !(group _target == group _player) then {
};
_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,
_color,
_position,
_size,
_size,
0,
_name,
2,
0.033,
"PuristaMedium"
_icon,
_color,
_position,
_size,
_size,
0,
_name,
2,
0.033,
"PuristaMedium"
];

View File

@ -5,44 +5,61 @@ _player = ACE_player;
//don't show nametags in spectator
if (!alive _player) exitWith {};
_onKeyPressAlphaMax = 2 + (GVAR(ShowNamesTime) - time); //after release 1 second of full opacity, 1 second of fading to 0
//If set to only show on keypress and nothing would be visable, exit
if ((GVAR(showPlayerNames) in [3,4]) && {GVAR(showSoundWaves) < 2} && {(2 + (GVAR(ShowNamesTime) - time)) < 0}) 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
} else {
1
};
_defaultIcon = if (GVAR(showPlayerRanks)) then {
ICON_NAME_RANK;
} else {
ICON_NAME;
};
//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 {
if (GVAR(showCursorTagForVehicles) && {_onKeyPressAlphaMax > 0}) then {
_target = cursorTarget;
if ((!(_target isKindOf "CAManBase")) && {!(_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 {
if ((!isNull _target) &&
{(side (group _target)) == (side (group _player))} &&
{_target != _player} &&
{GVAR(ShowNamesForAI) || {[_target] call EFUNC(common,isPlayer)}} &&
{!(_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 _onKeyPressAlphaMax;
};
[_player, _target, _alpha, _distance * 0.026] call FUNC(drawNameTagIcon);
_alpha = _alpha min _onKeyPressAlphaMax;
[_player, _target, _alpha, _distance * 0.026, _defaultIcon] call FUNC(drawNameTagIcon);
};
};
};
//"Only Cursor" mode, only show nametags for humans
if (GVAR(showPlayerNames) in [2,4]) then {
//"Only Cursor" mode, only show nametags for humans on cursorTarget
if ((GVAR(showPlayerNames) in [2,4]) && {_onKeyPressAlphaMax > 0}) then {
_target = cursorTarget;
if ((!isNull _target) && {_target isKindOf "CAManBase"} && {(side (group _target)) == (side (group _player))} && {_target != _player} && {isPlayer _target || {GVAR(ShowNamesForAI)}} && {!(_target getVariable ["ACE_hideName", false])}) then {
if ((!isNull _target) &&
{_target isKindOf "CAManBase"} &&
{(side (group _target)) == (side (group _player))} &&
{_target != _player} &&
{GVAR(ShowNamesForAI) || {[_target] call EFUNC(common,isPlayer)}} &&
{!(_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 _onKeyPressAlphaMax;
_alpha = _alpha min _onKeyPressAlphaMax;
_icon = ICON_NONE;
if (GVAR(showSoundWaves) == 2) then { //icon will be drawn below, so only show name here
_icon = if ((_target getVariable [QGVAR(isSpeaking), false]) && {(vehicle _target) == _target}) then {ICON_NAME} else {_defaultIcon};
} else {
_icon = if ((_target getVariable [QGVAR(isSpeaking), false]) && {(vehicle _target) == _target}) then {ICON_NAME_SPEAK} else {_defaultIcon};
};
[_player, _target, _alpha, _distance * 0.026] call FUNC(drawNameTagIcon);
[_player, _target, _alpha, _distance * 0.026, _icon] call FUNC(drawNameTagIcon);
};
};
if ((GVAR(showPlayerNames) in [1,3]) || {GVAR(showSoundWaves) == 2}) 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];
@ -58,7 +75,20 @@ if ((GVAR(showPlayerNames) in [1,3]) || {GVAR(showSoundWaves) == 2}) then {
{
_target = _x;
if ((!isNull _target) && {side group _target == playerSide} && {_target != _player} && {isPlayer _target || {GVAR(ShowNamesForAI)}} && {!(_target getVariable ["ACE_hideName", false])}) then {
_icon = ICON_NONE;
if ((GVAR(showPlayerNames) in [1,3]) && {_onKeyPressAlphaMax > 0}) then {
if ((_target getVariable [QGVAR(isSpeaking), false]) && {(vehicle _target) == _target}) then {_icon = ICON_NAME_SPEAK;} else {_icon = _defaultIcon};
} else {
//showSoundWaves must be 2, only draw speak icon
if ((_target getVariable [QGVAR(isSpeaking), false]) && {(vehicle _target) == _target}) then {_icon = ICON_SPEAK;};
};
if ((_icon != ICON_NONE) &&
{(side (group _target)) == (side (group _player))} &&
{_target != _player} &&
{GVAR(ShowNamesForAI) || {[_target] call EFUNC(common,isPlayer)}} &&
{!(_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;
@ -66,12 +96,13 @@ if ((GVAR(showPlayerNames) in [1,3]) || {GVAR(showSoundWaves) == 2}) then {
_alpha = ((1 - 0.2 * (_distance - GVAR(PlayerNamesViewDistance))) min (1 - 0.15 * (_projDist * 5 - _distance - 3)) min 1) * GVAR(PlayerNamesMaxAlpha);
if (GVAR(showPlayerNames) == 3) then { //only on keypress
if ((GVAR(showSoundWaves) == 2) && {(_target getVariable [QGVAR(isSpeaking), false]) && {(vehicle _target) == _target}}) then {
_alpha = 1;
} else {
_alpha = _alpha min _onKeyPressAlphaMax;
};
[_player, _target, _alpha, _distance * 0.026] call FUNC(drawNameTagIcon);
[_player, _target, _alpha, _distance * 0.026, _icon] call FUNC(drawNameTagIcon);
};
} forEach _targets;
};

View File

@ -9,4 +9,10 @@
#define DEBUG_SETTINGS DEBUG_SETTINGS_NAMETAGS
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#include "\z\ace\addons\main\script_macros.hpp"
#define ICON_NONE 0
#define ICON_NAME 1
#define ICON_NAME_RANK 2
#define ICON_NAME_SPEAK 3
#define ICON_SPEAK 4