ACE3/addons/viewports/functions/fnc_getViewports.sqf
Grim e06c6f7835
General - Replace toLower with toLowerANSI where applicable (#9790)
* General - Replace toLower with toLowerANSI where applicable

* whoops

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Update addons/repair/functions/fnc_setHitPointDamage.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Update addons/repair/dev/draw_showRepairInfo.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Update addons/tagging/XEH_preStart.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Update addons/vehicle_damage/functions/fnc_handleCookoff.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Update addons/tagging/XEH_preStart.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* comparment -> compartment

* Update fnc_showHud.sqf

* Update fnc_registerObjects.sqf

* Update addons/common/functions/fnc_cbaSettings_settingChanged.sqf

---------

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
2024-03-07 22:08:13 +01:00

75 lines
2.8 KiB
Plaintext

#include "..\script_component.hpp"
/*
* 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
*/
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
private _camLocArray = if (_camLocation isEqualType []) then {
_camLocation
} else {
_vehicle selectionPosition [_camLocation, "Memory"];
};
_screenLocation =_camLocArray vectorAdd [0,0,-0.175]
};
_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 {toLowerANSI _x};
// roles [ARRAY] - Optional
private _roles = (getArray (_x >> "roles")) apply {toLowerANSI _x};
[_name, _type, _camLocation, _camAttach, _screenLocation, _maxDistance, _compartments, _roles]
};
TRACE_3("getViewports",_vehicle,typeOf _vehicle,count _viewports);
_vehicle setVariable [QGVAR(viewports), _viewports];
};
_viewports