Bring component up-to-date, cleanup

This commit is contained in:
johnb432 2024-08-30 15:51:28 +02:00
parent b1e518e1a2
commit c7b82a51f3
21 changed files with 58 additions and 75 deletions

View File

@ -1,6 +1,6 @@
#include "script_component.hpp"
if (hasInterface) then {
if (hasInterface) then {
#include "initKeybinds.inc.sqf"
// add camera interactions
@ -14,14 +14,13 @@ if (hasInterface) then {
params ["_target", "_player", "_params"];
private _camera = _player getVariable [QGVAR(missileCamera), objNull];
private _projectile = _camera getVariable [QGVAR(missile), objNull];
!([] call FUNC(camera_userInCamera)) && { !(_camera isEqualTo objNull); } && { !(_projectile isEqualTo objNull) }
!([] call FUNC(camera_userInCamera)) && { !isNull _camera } && { !isNull _projectile }
}/*, {
params ["_target", "_player", "_params"];
// insert children
}*/] call EFUNC(interact_menu,createAction);
["CAManBase", 1, ["ACE_SelfActions"], _switchToCameraAction, true] call EFUNC(interact_menu,addActionToClass);
GVAR(activeCamera) = objNull;
GVAR(projectileHashMap) = createHashMap; // used in the seeker to get the namespace for the associated projectile
};

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Decreases zoom of current camera
@ -31,4 +31,3 @@ if (_increase) then {
};
};
[_cameraNamespace, _zoomIndex] call FUNC(camera_setZoom);

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Cycles camera thermal mode (if avaliable)
@ -23,7 +23,7 @@ private _tiArray = _cameraNamespace getVariable [QGVAR(thermalTypes), []];
if ((count _tiArray) == 0) exitWith {};
if ((_tiIndex + 1) >= count _tiArray) then {
_tiIndex = 0;
} else {
} else {
_tiIndex = _tiIndex + 1;
};

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Destroys camera attaches to projectile
@ -18,10 +18,10 @@
params ["_cameraNamespace"];
private _userInThisCamera = [_cameraNamespace] call FUNC(camera_userInCamera);
private _userCamera = ACE_PLAYER getVariable [QGVAR(missileCamera), objNull];
private _userCamera = ACE_player getVariable [QGVAR(missileCamera), objNull];
if (_userInThisCamera || { _userCamera isEqualTo _cameraNamespace }) then {
ACE_PLAYER setVariable [QGVAR(missileCamera), objNull];
ACE_player setVariable [QGVAR(missileCamera), objNull];
};
[_cameraNamespace] call FUNC(camera_switchAway);
@ -35,4 +35,3 @@ private _camera = _cameraNamespace getVariable QGVAR(camera);
camDestroy _camera;
_cameraNamespace call CBA_fnc_deleteNamespace;

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Updates camera with inputs
@ -43,7 +43,7 @@ switch (_key) do {
};
_return = true;
}; //Up
case CAMERA_KEY_LEFT: {
if (_down) then {
_lookInput set [2, 1];
@ -52,7 +52,7 @@ switch (_key) do {
};
_return = true;
}; //Left
case CAMERA_KEY_RIGHT: {
if (_down) then {
_lookInput set [3, 1];
@ -61,7 +61,7 @@ switch (_key) do {
};
_return = true;
}; //Right
case CAMERA_KEY_DOWN: {
if (_down) then {
_lookInput set [1, 1];

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Initializes camera for player to view missile from its nose
@ -18,9 +18,9 @@
params ["_projectile", "_cameraArray", "_shooter", "_switchOnFireInit"];
_cameraArray params ["_enabled", "_fovLevels", "_initialFOV", "_thermalTypes", "_initialThermalType", "_switchOnFire", "_lerpFOV", "_fovChangeTime", "", "_gimbalData", "_reticleData", "_designating"];
_gimbalData params ["_hasGimbal", "_maxGimbalX", "_maxGimbalY", "_gimbalSpeedX", "_gimbalSpeedY", "_initGimbalAngleX", "_initGimbalAngleY", "_gimbalZoomSpeedModifiers"];
if !(_enabled) exitWith {};
private _activeCameraNamespace = [] call CBA_fnc_createNamespace;
_activeCameraNamespace setVariable [QGVAR(fovLevels), _fovLevels];
_activeCameraNamespace setVariable [QGVAR(thermalTypes), _thermalTypes];
@ -83,4 +83,3 @@ if (_switchOnFire && _switchOnFireInit) then {
};
_activeCameraNamespace

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Cycles camera thermal mode (if avaliable)

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Decreases zoom of current camera
@ -22,4 +22,3 @@ _cameraNamespace setVariable [QGVAR(targetFOV), _zoomArray select _zoomIndex];
_cameraNamespace setVariable [QGVAR(fovChanged), true];
_cameraNamespace setVariable [QGVAR(fovChangedTime), CBA_missionTime];
_cameraNamespace setVariable [QGVAR(startingFov), _cameraNamespace getVariable QGVAR(currentFOV)];

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Switches away from the currently controlled camera
@ -24,4 +24,3 @@ _camera cameraEffect ["terminate", "back"];
GVAR(activeCamera) = objNull;
QGVAR(camera_hud) cutText ["", "PLAIN"];

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Switches to the currently controlled camera
@ -50,4 +50,3 @@ _cameraNamespace setVariable [QGVAR(reticleLeft), (uiNameSpace getVariable _uiNa
_cameraNamespace setVariable [QGVAR(reticleRight), (uiNameSpace getVariable _uiNamespaceDialogVariable) displayCtrl _rightGate];
_cameraNamespace setVariable [QGVAR(reticleTop), (uiNameSpace getVariable _uiNamespaceDialogVariable) displayCtrl _topGate];
_cameraNamespace setVariable [QGVAR(reticleBottom), (uiNameSpace getVariable _uiNamespaceDialogVariable) displayCtrl _bottomGate];

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Updates camera to be on a fixed point
@ -20,7 +20,7 @@ _cameraArray params ["_hasCamera", "", "", "", "", "", "", "", "_viewData", "_gi
_viewData params ["_lookDir", "_groundPos", "_pointPos", "_movingCameraX", "_movingCameraY"];
_gimbalData params ["_hasGimbal", "_maxGimbalX", "_maxGimbalY", "_gimbalSpeedX", "_gimbalSpeedY", "", "", "_gimbalZoomSpeedModifiers", "_stabilizeWhenMoving", "_designateWhenStationary", "_trackLockedPosition"];
if (!_hasCamera || { _cameraNamespace isEqualTo objNull }) exitWith {};
if (!_hasCamera || { isNull _cameraNamespace }) exitWith {};
if ([_cameraNamespace] call FUNC(camera_userInCamera)) then {
cameraEffectEnableHUD true;
@ -51,20 +51,20 @@ if (_fovChanged) then {
private _fovChangeStart = _cameraNamespace getVariable [QGVAR(fovChangedTime), 0];
private _startingFOV = _cameraNamespace getVariable [QGVAR(startingFov), 1];
private _fovChangeTime = _cameraNamespace getVariable [QGVAR(fovChangeTime), 0];
private _setFOV = _targetFOV;
if (_lerpFovEnabled) then {
_setFOV = linearConversion [0, _fovChangeTime, CBA_missionTime - _fovChangeStart, _startingFOV, _targetFOV, true];
} else {
_fovChanged = false;
};
// if the FOV is near enough to the target FOV stop the lerp
if (abs(_setFOV - _targetFOV) == 0 || ((CBA_missionTime - _fovChangeStart) > _fovChangeTime + 2)) then {
_setFOV = _targetFOV;
_fovChanged = false;
};
_camera camSetFOV _setFOV;
_cameraNamespace setVariable [QGVAR(fovChanged), _fovChanged];
_cameraNamespace setVariable [QGVAR(currentFOV), _setFOV];
@ -84,7 +84,7 @@ if (_hasGimbal) then {
private _lastGroundPos = _cameraNamespace getVariable [QGVAR(lastMovedGroundPos), [0, 0, 0]];
if !((_movingCameraX || _movingCameraY) || true) then {
if !((_movingCameraX || _movingCameraY) || true) then {
// If we designate a target set the current tracking point to the current ground point to avoid unwanted behavior from static cameras
if (_designating && !_designatedLastFrame) then {
_designatedLastFrame = true;
@ -107,7 +107,7 @@ if (_hasGimbal) then {
_expectedPos = _directionToGround vectorMultiply GIMBAL_LOGIC_OFFSET;
};
} else {
} else {
private _speedModifier = 1;
if (_gimbalZoomSpeedModifiers isNotEqualTo []) then {
_speedModifier = (_gimbalZoomSpeedModifiers select (_cameraNamespace getVariable [QGVAR(currentZoomIndex), 0]));
@ -238,5 +238,3 @@ _cameraArray set [8, _viewData];
_camera camCommit 0;
[_cameraNamespace, _cameraArray] call FUNC(camera_updateTargetingGate);

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Switches away from the currently controlled camera
@ -21,7 +21,7 @@ _viewData params ["_lookDir", "_groundPos", "_pointPos", "_movingCameraX", "_mov
_gimbalData params ["_hasGimbal", "_maxGimbalX", "_maxGimbalY", "_gimbalSpeedX", "_gimbalSpeedY", "", "", "_gimbalZoomSpeedModifiers"];
_reticleData params ["", "", "", "", "", "", "", "", "", "_reticleMovesWithTrack"];
if !(([_cameraNamespace] call FUNC(camera_userInCamera))) exitWith {};
if !([_cameraNamespace] call FUNC(camera_userInCamera)) exitWith {};
private _seekerTargetPos = _cameraNamespace getVariable [QGVAR(seekerTargetPos), [0, 0, 0]];
private _seekerTargetInfo = _cameraNamespace getVariable [QGVAR(seekerTargetInfo), [false, [0, 0], [0, 0]]];
@ -45,7 +45,7 @@ if (_seekerTargetPos isEqualTo [0, 0, 0]) then {
{
_x ctrlShow false;
} forEach (_cameraNamespace getVariable QGVAR(disappearOnLock));
if (_reticleMovesWithTrack) then {
_seekerPositionScreen = worldToScreen ASLtoAGL _seekerTargetPos;
if (_seekerPositionScreen isEqualTo []) then {
@ -66,7 +66,7 @@ if (_locked) then {
_seekerTargetInfo params ["_lockedObject", "_boundsTL", "_boundsBR"];
if (_lockedObject) then {
private _missile = _cameraNamespace getVariable QGVAR(missile);
private _avgDistance = (_boundsTL#1 + _boundsBR#1) / 2;
private _topCenter = [((_boundsTL#0) + (_boundsBR#0)) / 2, _avgDistance, _boundsBR#2];
@ -80,21 +80,21 @@ if (_locked) then {
_ctrlPos set [1, 0.5];
};
(_cameraNamespace getVariable QGVAR(reticleLeft)) ctrlSetPosition [(_ctrlPos#0 - _seekerPositionScreen#0) - 0.5, (_ctrlPos#1 - _seekerPositionScreen#1) - 0.5];
_ctrlPos = worldToScreen (_missile modelToWorldVisual _rightCenter);
if (_ctrlPos isEqualTo []) then {
_ctrlPos set [0, 0.5];
_ctrlPos set [1, 0.5];
};
(_cameraNamespace getVariable QGVAR(reticleRight)) ctrlSetPosition [(_ctrlPos#0 - _seekerPositionScreen#0) - 0.5, (_ctrlPos#1 - _seekerPositionScreen#1) - 0.5];
_ctrlPos = worldToScreen (_missile modelToWorldVisual _topCenter);
if (_ctrlPos isEqualTo []) then {
_ctrlPos set [0, 0.5];
_ctrlPos set [1, 0.5];
};
(_cameraNamespace getVariable QGVAR(reticleTop)) ctrlSetPosition [(_ctrlPos#0 - _seekerPositionScreen#0) - 0.5, (_ctrlPos#1 - _seekerPositionScreen#1) - 0.5];
_ctrlPos = worldToScreen (_missile modelToWorldVisual _bottomCenter);
if (_ctrlPos isEqualTo []) then {
_ctrlPos set [0, 0.5];

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Switches away from the currently controlled camera
@ -19,5 +19,4 @@ params [["_cameraNamespace", objNull]];
if (isNil QGVAR(activeCamera)) exitWith { false };
(GVAR(activeCamera) isNotEqualTo objNull) && { (_cameraNamespace isEqualTo objNull) || (_cameraNamespace isEqualTo GVAR(activeCamera)) };
(!isNull GVAR(activeCamera)) && { isNull _cameraNamespace || (_cameraNamespace isEqualTo GVAR(activeCamera)) };

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Return the position of a potential EO target via a "edge detection" algorithm. Compares object bounding boxes to see what we are most likely hitting
@ -65,7 +65,7 @@ if (_nearObjects isNotEqualTo []) then {
// I want to prefer the designated position on the object moreso than the bounds of the object
private _averagePosition = _seekerTargetPos vectorMultiply SEEKER_BIAS;
private _averagePositionCounter = SEEKER_BIAS;
private _bestScore = 0;
private _bestObject = objNull;
@ -122,4 +122,3 @@ if (_nearObjects isNotEqualTo []) then {
};
_seekerTargetPos

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Handle key presses
@ -17,7 +17,7 @@
*/
params ["_key", "_down"];
if ((currentWeapon ACE_PLAYER) != QGVAR(launcher)) exitWith {};
if ((currentWeapon ACE_player) != QGVAR(launcher)) exitWith {};
if (_key == SPIKE_KEY_DESIGNATE) then {
if (cameraView == "GUNNER") then {

View File

@ -1,9 +1,8 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Handles the map helper's draw event
* Resets arguments if not run recently
* And starts a watchdog to detect when weapon display unloaded
* Resets arguments if not run recently and starts a watchdog to detect when weapon display unloaded
*
* Arguments:
* None
@ -21,7 +20,7 @@
private _currentShooter = if (ACE_player call CBA_fnc_canUseWeapon) then {ACE_player} else {vehicle ACE_player};
if (isNil QGVAR(arguments)) then {
TRACE_1("Starting optic draw", _this);
TRACE_1("Starting optic draw",_this);
// reset shooter var:
_currentShooter setVariable ["ace_missileguidance_target", nil, false];
@ -64,7 +63,7 @@ if (cameraView isEqualTo "GUNNER") then {
} else {
if (_targetPosition isEqualTo [0, 0, 0]) then {
__SPIKE_RETICLE ctrlSetPosition [0, 0];
(__SPIKE_DISPLAY displayCtrl 243101) ctrlShow false;
(__SPIKE_DISPLAY displayCtrl 243201) ctrlShow false;
(__SPIKE_DISPLAY displayCtrl 243301) ctrlShow false;
@ -98,4 +97,3 @@ if (cameraView isEqualTo "GUNNER") then {
__SPIKE_RETICLE ctrlShow false;
(__SPIKE_DISPLAY displayCtrl 241000) ctrlShow false;
};

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Condition to switch to next navigation profile
@ -19,4 +19,3 @@ _stateParams params ["", "", "", "","_navigationParams"];
_navigationParams params ["_state"];
_state isEqualTo STAGE_TERMINAL

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Sets up a top-attack profile. If we don't have a target: coast
@ -113,4 +113,3 @@ drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,0,1], (ASLt
#endif
_projectile vectorModelToWorldVisual _cmdAccel

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Initialises SPIKE camera
@ -22,21 +22,21 @@ private _missileGuidanceConfig = (configOf _projectile) >> "ace_missileguidance"
// Setup camera array
private _cameraConfig = _missileGuidanceConfig >> "camera";
private _cameraArray = [false];
if (!(_cameraConfig isEqualTo configNull) && { (getNumber (_cameraConfig >> "enabled")) == 1 }) then {
if (!isNull _cameraConfig && { (getNumber (_cameraConfig >> "enabled")) == 1 }) then {
_cameraArray set [0, true];
_cameraArray set [1, getArray (_cameraConfig >> "fovLevels")];
_cameraArray set [2, getNumber (_cameraConfig >> "initialFOV")];
_cameraArray set [3, getArray (_cameraConfig >> "enabledThermalTypes")];
_cameraArray set [4, getText (_cameraConfig >> "initialThermalType")];
_cameraArray set [5, (getNumber (_cameraConfig >> "switchOnFire")) == 1];
_cameraArray set [6, getNumber (_cameraConfig >> "lerpFOV")];
_cameraArray set [7, getNumber (_cameraConfig >> "fovChangeTime")];
_cameraArray set [8, [[0, 0, 0], [0, 0, 0], [0, 0, 0], false, false]]; // camera view data. [look direction, ground pos, point pos, moving camera x, moving camera y]
_cameraArray set [9, [
getNumber (_cameraConfig >> "gimbal" >> "enabled") == 1,
getNumber (_cameraConfig >> "gimbal" >> "gimbalAngleX"),
@ -50,7 +50,7 @@ if (!(_cameraConfig isEqualTo configNull) && { (getNumber (_cameraConfig >> "ena
getNumber (_cameraConfig >> "gimbal" >> "designateWhenStationary") == 1,
getNumber (_cameraConfig >> "gimbal" >> "trackLockedPosition") == 1
]];
_cameraArray set [10, [
getText (_cameraConfig >> "reticle" >> "titleRsc"),
getNumber (_cameraConfig >> "reticle" >> "centerReticle"),
@ -63,13 +63,13 @@ if (!(_cameraConfig isEqualTo configNull) && { (getNumber (_cameraConfig >> "ena
getText (_cameraConfig >> "reticle" >> "uiNamespaceDialogVariable"),
getNumber (_cameraConfig >> "reticle" >> "reticleMovesWithTrack") == 1
]];
_cameraArray set [11, (getNumber (_cameraConfig >> "alwaysDesignate")) == 1];
_cameraArray set [12, (getNumber (_cameraConfig >> "canStopDesignating")) == 1];
};
private _preTarget = +(ACE_PLAYER getVariable [QGVAR(target), [0, 0, 0]]);
ACE_PLAYER setVariable [QGVAR(target), [0, 0, 0]];
private _preTarget = +(ACE_player getVariable [QGVAR(target), [0, 0, 0]]);
ACE_player setVariable [QGVAR(target), [0, 0, 0]];
private _camera = [_projectile, _cameraArray, _shooter, _preTarget isEqualTo [0, 0, 0]] call FUNC(camera_init);
GVAR(projectileHashMap) set [hashValue _projectile, [_camera, _preTarget]];
[{

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
#include "..\script_component.hpp"
/*
* Author: Dani (TCVM)
* Seeker Type: Spike Optical
@ -74,4 +74,3 @@ _seekerStateParams set [0, _lastPositions];
_seekerStateParams set [2, _velocity];
_seekerTargetPos

View File

@ -1 +0,0 @@
#include "\z\ace\addons\spike\script_component.hpp"