mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
e06c6f7835
* 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>
78 lines
2.5 KiB
Plaintext
78 lines
2.5 KiB
Plaintext
#include "..\script_component.hpp"
|
|
/*
|
|
* Author: PabstMirror
|
|
* Runs each frame while inside of a vehicle with viewports
|
|
*
|
|
* Arguments:
|
|
* 0: PFEH Args <ARRAY>
|
|
* 0: Player <OBJECT>
|
|
* 1: Vehicle <OBJECT>
|
|
* 2: Viewport configuration <ARRAY>
|
|
* 3: Viewport index shown (-1 for none) <NUMBER>
|
|
* 4: Last visionmode <NUMBER>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [] call ace_viewports_fnc_eachFrame
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_args", "_pfID"];
|
|
_args params ["_player", "_vehicle", "_viewports", "_shownIndex", "_lastVisionMode"];
|
|
|
|
private _newIndex = -1;
|
|
if (cba_events_control) then {
|
|
if (cameraView != "INTERNAL") exitWith {};
|
|
if (isTurnedOut _player) exitWith {};
|
|
if (!([_player, _vehicle, []] call EFUNC(common,canInteractWith))) exitWith {};
|
|
|
|
BEGIN_COUNTER(newIndex);
|
|
if ((_shownIndex > -1) && {currentVisionMode _player != _lastVisionMode}) then {
|
|
// Vision Mode Changed - Force stop cam and restart
|
|
call FUNC(viewCleanup);
|
|
_shownIndex = -1;
|
|
};
|
|
|
|
([_player] call FUNC(getSeatInfo)) params ["_role", "", "", "_compartment"];
|
|
|
|
private _newIndexAngle = 45; // Controls the max angle
|
|
private _eyesPosASL = AGLtoASL (positionCameraToWorld [0, 0, 0]);
|
|
private _eyesDir = (AGLtoASL (positionCameraToWorld [0, 0, 1])) vectorDiff _eyesPosASL;
|
|
{
|
|
_x params ["", "", "_camLocation", "", "_screenLocation", "_maxDistance", "_compartments", "_roles"];
|
|
|
|
private _viewASL = AGLtoASL (_vehicle modelToWorldVisual _screenLocation);
|
|
private _viewDiff = _viewASL vectorDiff _eyesPosASL;
|
|
private _viewAngle = acos (_viewDiff vectorCos _eyesDir);
|
|
#ifdef DEBUG_MODE_FULL
|
|
systemChat format ["%1: %2 @ %3",_forEachIndex,round _viewAngle, vectorMagnitude _viewDiff];
|
|
#endif
|
|
if (
|
|
(_viewAngle < _newIndexAngle)
|
|
&& {(_compartments isEqualTo []) || {(toLowerANSI _compartment) in _compartments}}
|
|
&& {(_roles isEqualTo []) || {(toLowerANSI _role) in _roles}}
|
|
&& {(vectorMagnitude _viewDiff) < _maxDistance}
|
|
) then {
|
|
_newIndex = _forEachIndex;
|
|
_newIndexAngle = _viewAngle;
|
|
};
|
|
} forEach _viewports;
|
|
END_COUNTER(newIndex);
|
|
};
|
|
|
|
if (_shownIndex == _newIndex) exitWith {}; // No-change - fast exit
|
|
|
|
if (_shownIndex > -1) then {
|
|
call FUNC(viewCleanup);
|
|
};
|
|
|
|
if (_newIndex > -1) then {
|
|
[_vehicle, _viewports # _newIndex, currentVisionMode _player] call FUNC(viewCreate);
|
|
_args set [4, currentVisionMode _player];
|
|
};
|
|
|
|
_args set [3, _newIndex];
|