mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Move draw to function (wip)
This commit is contained in:
parent
1a2a9dd584
commit
ae61dff44e
@ -19,22 +19,10 @@
|
||||
PARAMS_1(_unit);
|
||||
DEFAULT_PARAM(1,_target,objNull);
|
||||
|
||||
private ["_isAttached"];
|
||||
|
||||
if (isNull _target) then {
|
||||
_target = _unit getVariable [QGVAR(escortedUnit), objNull];
|
||||
};
|
||||
|
||||
if (isNull _target) exitWith {
|
||||
ERROR("Null Target (no ACE_escortedUnit)");
|
||||
false
|
||||
};
|
||||
if (isNull _target) exitWith {false};
|
||||
|
||||
_isAttached = _target in (attachedObjects _unit);
|
||||
|
||||
if (_isAttached && (!(_target getVariable [QGVAR(isHandcuffed), false]))) exitWith {
|
||||
ERROR("Attached But Not Captive");
|
||||
false
|
||||
};
|
||||
|
||||
_isAttached
|
||||
(_target in (attachedObjects _unit)) && {!(_target getVariable [QGVAR(isHandcuffed), false])}
|
||||
|
@ -27,69 +27,4 @@ if (!hasInterface) exitWith {};
|
||||
|
||||
|
||||
// Draw handle
|
||||
addMissionEventHandler ["Draw3D", {
|
||||
if (GVAR(showPlayerNames) == 0) exitWith {};
|
||||
|
||||
_player = ACE_player;
|
||||
|
||||
//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 "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 {
|
||||
_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 (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 "CAManBase"} && {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);
|
||||
};
|
||||
} else {
|
||||
_pos = positionCameraToWorld [0, 0, 0];
|
||||
_targets = _pos nearObjects ["CAManBase", GVAR(PlayerNamesViewDistance) + 5];
|
||||
|
||||
if (!surfaceIsWater _pos) then {
|
||||
_pos = ATLtoASL _pos;
|
||||
};
|
||||
_pos2 = positionCameraToWorld [0, 0, 1];
|
||||
if (!surfaceIsWater _pos2) then {
|
||||
_pos2 = ATLtoASL _pos2;
|
||||
};
|
||||
_vecy = _pos2 vectorDiff _pos;
|
||||
|
||||
{
|
||||
_target = _x;
|
||||
|
||||
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) == 3) then { //only on keypress
|
||||
_alpha = _alpha min (2 + (GVAR(ShowNamesTime) - time));
|
||||
};
|
||||
|
||||
[_player, _target, _alpha, _distance * 0.026] call FUNC(drawNameTagIcon);
|
||||
};
|
||||
} forEach _targets;
|
||||
};
|
||||
}];
|
||||
addMissionEventHandler ["Draw3D", {_this call FUNC(onDraw3d);}];
|
||||
|
@ -8,6 +8,7 @@ PREP(drawNameTagIcon);
|
||||
PREP(getVehicleData);
|
||||
PREP(initIsSpeaking);
|
||||
PREP(moduleNameTags);
|
||||
PREP(onDraw3d);
|
||||
PREP(onMouseZChanged);
|
||||
PREP(setText);
|
||||
|
||||
|
@ -53,10 +53,11 @@ class ACE_Settings {
|
||||
isClientSetable = 0;
|
||||
};
|
||||
class GVAR(showSoundWaves) {
|
||||
value = 0;
|
||||
typeName = "BOOL";
|
||||
value = 1;
|
||||
typeName = "SCALAR";
|
||||
isClientSetable = 1;
|
||||
displayName = "$STR_ACE_NameTags_ShowSoundWaves";
|
||||
values[] = {"Disabled", "Use Nametag settings", "Always Show All"};
|
||||
};
|
||||
class GVAR(PlayerNamesViewDistance) {
|
||||
value = 5;
|
||||
|
@ -25,7 +25,7 @@
|
||||
"\A3\Ui_f\data\GUI\Cfg\Ranks\colonel_gs.paa" \
|
||||
]
|
||||
|
||||
private ["_player", "_target", "_alpha", "_heightOffset", "_height", "_position", "_color", "_name", "_rank", "_size"];
|
||||
private ["_height", "_position", "_color", "_name", "_rank", "_size"];
|
||||
|
||||
PARAMS_4(_player,_target,_alpha,_heightOffset);
|
||||
|
||||
|
@ -45,7 +45,6 @@ case (isClass (configFile >> "cfgPatches" >> "acre_api")): {
|
||||
_newSetting = ([ACE_player] call ACRE_api_fnc_isBroadcasting) || {!(isNull findDisplay 55)};
|
||||
if (!(_oldSetting isEqualTo _newSetting)) then {
|
||||
ACE_player setVariable [QGVAR(isSpeaking), _newSetting, true];
|
||||
// ["IsTalking??", [ACE_player, _newSetting]] call localEvent //any use in ACE for a "speaking event"?
|
||||
};
|
||||
};
|
||||
};
|
||||
|
77
addons/nametags/functions/fnc_onDraw3d.sqf
Normal file
77
addons/nametags/functions/fnc_onDraw3d.sqf
Normal file
@ -0,0 +1,77 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
_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{};
|
||||
|
||||
|
||||
//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 "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 {
|
||||
_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);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
//"Only Cursor" mode, only show nametags for humans
|
||||
if (GVAR(showPlayerNames) in [2,4]) 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 {
|
||||
_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;
|
||||
};
|
||||
[_player, _target, _alpha, _distance * 0.026] call FUNC(drawNameTagIcon);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
if ((GVAR(showPlayerNames) in [1,3]) || {GVAR(showSoundWaves) == 2}) then {
|
||||
_pos = positionCameraToWorld [0, 0, 0];
|
||||
_targets = _pos nearObjects ["CAManBase", GVAR(PlayerNamesViewDistance) + 5];
|
||||
|
||||
if (!surfaceIsWater _pos) then {
|
||||
_pos = ATLtoASL _pos;
|
||||
};
|
||||
_pos2 = positionCameraToWorld [0, 0, 1];
|
||||
if (!surfaceIsWater _pos2) then {
|
||||
_pos2 = ATLtoASL _pos2;
|
||||
};
|
||||
_vecy = _pos2 vectorDiff _pos;
|
||||
|
||||
{
|
||||
_target = _x;
|
||||
|
||||
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) == 3) then { //only on keypress
|
||||
_alpha = _alpha min _onKeyPressAlphaMax;
|
||||
};
|
||||
|
||||
[_player, _target, _alpha, _distance * 0.026] call FUNC(drawNameTagIcon);
|
||||
};
|
||||
} forEach _targets;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user