2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2017-08-12 13:25:48 +00:00
|
|
|
/*
|
2023-08-17 10:02:17 +00:00
|
|
|
* Author: Nelson Duarte, AACO, kymckay
|
2017-08-12 13:25:48 +00:00
|
|
|
* Function used update the things to 3D draw
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Examples:
|
|
|
|
* [] call ace_spectator_fnc_ui_updateIconsToDraw
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
private _iconsToDraw = [];
|
|
|
|
private _entitiesToDraw = [];
|
|
|
|
|
2017-08-30 10:40:12 +00:00
|
|
|
// camToWorld is used instead of camera object to account for FPP
|
|
|
|
private _camPos = AGLToASL positionCameraToWorld [0,0,0];
|
2017-08-12 13:25:48 +00:00
|
|
|
{
|
|
|
|
private _vehicle = vehicle _x;
|
|
|
|
private _inVehicle = (_vehicle != _x);
|
2017-08-30 10:40:12 +00:00
|
|
|
private _distanceToCameraSqr = _camPos distanceSqr _x;
|
2017-08-12 13:25:48 +00:00
|
|
|
|
|
|
|
if (_distanceToCameraSqr <= DISTANCE_ICONS_SQR && { !_inVehicle || { _x == effectiveCommander _vehicle } }) then {
|
|
|
|
private _group = group _x;
|
2017-08-30 10:40:12 +00:00
|
|
|
private _isLeader = _x == leader _group;
|
|
|
|
private _groupColor = [side _group] call BIS_fnc_sideColor;
|
2017-08-12 13:25:48 +00:00
|
|
|
|
|
|
|
// Calculate distance fade
|
|
|
|
(_distanceToCameraSqr call {
|
|
|
|
if (_this <= 250000) exitWith { // 500^2
|
|
|
|
[1, 4, -2.5, 0.04]
|
|
|
|
};
|
|
|
|
if (_this <= 1000000) exitWith { // 1000^2
|
|
|
|
[0.75, 3.5, -2.2, 0.035]
|
|
|
|
};
|
|
|
|
if (_this <= 2250000) exitWith { // 1500^2
|
|
|
|
[0.5, 3, -1.9, 0.03]
|
|
|
|
};
|
|
|
|
if (_this <= 4000000) exitWith { // 2000^2
|
|
|
|
[0.3, 2.5, -1.6, 0.025]
|
|
|
|
};
|
|
|
|
if (_this <= 6250000) exitWith { // 2500^2
|
|
|
|
[0.2, 2, -1.3, 0.02]
|
|
|
|
};
|
|
|
|
[0.15, 1.5, -1, 0.015]
|
|
|
|
}) params ["_fadeByDistance", "_sizeByDistance", "_heightByDistance", "_fontSizeByDistance"];
|
|
|
|
|
|
|
|
// Apply color fade
|
|
|
|
_groupColor set [3, _fadeByDistance];
|
|
|
|
|
2017-08-30 10:40:12 +00:00
|
|
|
// Show unit name only if camera is near enough
|
|
|
|
if (_distanceToCameraSqr < DISTANCE_NAMES_SQR) then {
|
|
|
|
private _name = ([_x] call EFUNC(common,getName)) select [0, NAME_MAX_CHARACTERS];
|
|
|
|
if !(isPlayer _x) then { _name = format ["%1: %2", localize "str_player_ai", _name]; };
|
2017-08-12 13:25:48 +00:00
|
|
|
|
2017-08-30 10:40:12 +00:00
|
|
|
if (_inVehicle) then {
|
|
|
|
private _crewCount = (({alive _x} count (crew _vehicle)) - 1);
|
|
|
|
if (_crewCount > 0) then {
|
|
|
|
_name = format ["%1 (+%2)", _name, _crewCount];
|
|
|
|
};
|
2017-08-12 13:25:48 +00:00
|
|
|
};
|
|
|
|
|
2017-08-30 10:40:12 +00:00
|
|
|
// Draw unit name for effective commander or all units on foot
|
2017-08-12 13:25:48 +00:00
|
|
|
_iconsToDraw pushBack [_x, 2, [
|
|
|
|
"",
|
|
|
|
[1,1,1,1],
|
|
|
|
[0,0,0],
|
|
|
|
0,
|
|
|
|
_heightByDistance,
|
|
|
|
0,
|
|
|
|
_name,
|
|
|
|
2,
|
|
|
|
_fontSizeByDistance,
|
|
|
|
"PuristaMedium",
|
|
|
|
"center"
|
|
|
|
]];
|
|
|
|
} else {
|
2017-08-30 10:40:12 +00:00
|
|
|
// Draw group name for effective commander or leader on foot
|
|
|
|
if (_inVehicle || _isLeader) then {
|
2017-08-12 13:25:48 +00:00
|
|
|
_iconsToDraw pushBack [_x, 0, [
|
|
|
|
"",
|
|
|
|
[1,1,1,_fadeByDistance],
|
|
|
|
[0,0,0],
|
|
|
|
0,
|
|
|
|
_heightByDistance,
|
|
|
|
0,
|
2017-08-30 10:40:12 +00:00
|
|
|
groupID _group,
|
2017-08-12 13:25:48 +00:00
|
|
|
2,
|
|
|
|
_fontSizeByDistance,
|
|
|
|
"PuristaMedium",
|
|
|
|
"center"
|
|
|
|
]];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-08-30 10:40:12 +00:00
|
|
|
// Draw group icon for effective commander or leader on foot
|
|
|
|
if (_inVehicle || _isLeader) then {
|
2017-08-12 13:25:48 +00:00
|
|
|
_iconsToDraw pushBack [_x, 0, [
|
|
|
|
[_group, true] call FUNC(getGroupIcon),
|
|
|
|
_groupColor,
|
|
|
|
[0,0,0],
|
|
|
|
_sizeByDistance,
|
|
|
|
_sizeByDistance,
|
|
|
|
0,
|
|
|
|
"",
|
|
|
|
0,
|
|
|
|
0.035,
|
|
|
|
"PuristaMedium",
|
|
|
|
"center"
|
|
|
|
]];
|
|
|
|
};
|
|
|
|
|
2017-08-30 10:40:12 +00:00
|
|
|
// Draw unit icon for effective commander or all units on foot
|
2017-08-12 13:25:48 +00:00
|
|
|
_iconsToDraw pushBack [_x, 1, [
|
|
|
|
[ICON_UNIT, ICON_REVIVE] select (NEEDS_REVIVE(_x)),
|
|
|
|
_groupColor,
|
|
|
|
[0,0,0],
|
|
|
|
_sizeByDistance,
|
|
|
|
_sizeByDistance,
|
|
|
|
0,
|
|
|
|
"",
|
|
|
|
0,
|
|
|
|
0.035,
|
|
|
|
"PuristaMedium",
|
|
|
|
"center"
|
|
|
|
]];
|
|
|
|
|
2017-08-30 10:40:12 +00:00
|
|
|
// Track entities themselves for use with fired EH
|
|
|
|
_entitiesToDraw pushBack _vehicle;
|
2017-08-12 13:25:48 +00:00
|
|
|
|
2017-08-30 10:40:12 +00:00
|
|
|
// Add fired EH for drawing and icon highlighting
|
|
|
|
if (GETVAR(_vehicle,GVAR(firedEH),-1) == -1) then {
|
|
|
|
SETVAR(_vehicle,GVAR(firedEH),_vehicle addEventHandler [ARR_2("Fired",{_this call FUNC(handleFired)})]);
|
|
|
|
};
|
2017-08-12 13:25:48 +00:00
|
|
|
};
|
2018-01-06 00:30:15 +00:00
|
|
|
} forEach ([] call FUNC(getTargetEntities));
|
2017-08-12 13:25:48 +00:00
|
|
|
|
|
|
|
GVAR(iconsToDraw) = _iconsToDraw;
|
|
|
|
GVAR(entitiesToDraw) = _entitiesToDraw;
|