2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2022-05-17 16:55:09 +00:00
|
|
|
/*
|
2023-04-30 21:03:35 +00:00
|
|
|
* Author: PabstMirror
|
|
|
|
* Gets viewports for a vehicle from config. Caches results to a setVar on the vic.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: vehicle <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* ARRAY
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [vehicle player] call ace_viewports_fnc_getViewports
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2022-05-17 16:55:09 +00:00
|
|
|
|
|
|
|
params ["_vehicle"];
|
|
|
|
|
|
|
|
private _viewports = _vehicle getVariable [QGVAR(viewports), nil];
|
|
|
|
|
|
|
|
if (isNil "_viewports") then {
|
|
|
|
_viewports = (configProperties [(configOf _vehicle) >> "ace_viewports", "isClass _x", true]) apply {
|
|
|
|
// name [STRING] is just used for debug
|
|
|
|
private _name = configName _x;
|
|
|
|
// type [STRING] - Optional
|
|
|
|
private _type = getText (_x >> "type");
|
|
|
|
// camLocation [ARRAY or STRING] - Required
|
|
|
|
private _camLocation = if (isArray (_x >> "camLocation")) then {
|
|
|
|
getArray (_x >> "camLocation") // modelOffset
|
|
|
|
} else {
|
|
|
|
getText (_x >> "camLocation") // memPoint
|
|
|
|
};
|
|
|
|
// camAttach [ARRAY or NUMBER] - Required
|
|
|
|
private _camAttach = if (isArray (_x >> "camAttach")) then {
|
|
|
|
getArray (_x >> "camAttach") // turret
|
|
|
|
} else {
|
|
|
|
getNumber (_x >> "camAttach") // angle
|
|
|
|
};
|
|
|
|
// screenLocation [ARRAY or STRING] - Optional (will be converted to ARRAY here!)
|
|
|
|
private _screenLocation = if (isArray (_x >> "screenLocation")) then {
|
|
|
|
getArray (_x >> "screenLocation") // modelOffset
|
|
|
|
} else {
|
|
|
|
getText (_x >> "screenLocation") // memPoint
|
|
|
|
};
|
|
|
|
if (_screenLocation isEqualType "") then {
|
|
|
|
// screens should be on the hull (IE non-animated) so we can do all the mem-point calculations here
|
|
|
|
if (_screenLocation == "") exitWith { // use generic periscope drop height from cam
|
2023-04-30 21:03:35 +00:00
|
|
|
private _camLocArray = if (_camLocation isEqualType []) then {
|
2022-05-17 16:55:09 +00:00
|
|
|
_camLocation
|
|
|
|
} else {
|
|
|
|
_vehicle selectionPosition [_camLocation, "Memory"];
|
|
|
|
};
|
2023-04-30 21:03:35 +00:00
|
|
|
_screenLocation =_camLocArray vectorAdd [0,0,-0.175]
|
2022-05-17 16:55:09 +00:00
|
|
|
};
|
|
|
|
_screenLocation = _vehicle selectionPosition [_screenLocation, "Memory"];
|
|
|
|
};
|
|
|
|
// maxDistance [NUMBER] - Optional
|
|
|
|
private _maxDistance = getNumber (_x >> "maxDistance");
|
|
|
|
if (_maxDistance == 0) then {
|
|
|
|
_maxDistance = 0.8;
|
|
|
|
};
|
|
|
|
// compartments [ARRAY] - Optional
|
|
|
|
private _compartments = (getArray (_x >> "compartments")) apply {toLower _x};
|
|
|
|
// roles [ARRAY] - Optional
|
|
|
|
private _roles = (getArray (_x >> "roles")) apply {toLower _x};
|
|
|
|
|
|
|
|
[_name, _type, _camLocation, _camAttach, _screenLocation, _maxDistance, _compartments, _roles]
|
|
|
|
};
|
|
|
|
TRACE_3("getViewports",_vehicle,typeOf _vehicle,count _viewports);
|
|
|
|
_vehicle setVariable [QGVAR(viewports), _viewports];
|
|
|
|
};
|
|
|
|
|
|
|
|
_viewports
|