2015-04-04 04:19:19 +00:00
|
|
|
/*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Author: Taosenai
|
2015-04-04 04:19:19 +00:00
|
|
|
* Adapted By: KoffeinFlummi, commy2
|
|
|
|
*
|
2016-02-06 20:50:35 +00:00
|
|
|
* Animates the scope when firing. Called from the unified fired EH only for the local player.
|
2015-04-04 04:19:19 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2016-02-06 20:50:35 +00:00
|
|
|
* None. Parameters inherited from EFUNC(common,firedEH)
|
2015-04-04 04:19:19 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* call ace_optics_fnc_handleFired
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-04-04 04:19:19 +00:00
|
|
|
*/
|
2017-06-08 13:31:51 +00:00
|
|
|
|
2015-04-04 04:19:19 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2017-08-29 22:47:01 +00:00
|
|
|
// IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"];
|
2016-02-06 20:50:35 +00:00
|
|
|
TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile, _vehicle, _gunner, _turret);
|
2015-04-04 04:19:19 +00:00
|
|
|
|
2016-08-22 13:09:08 +00:00
|
|
|
disableSerialization;
|
|
|
|
|
2017-08-29 22:47:01 +00:00
|
|
|
// Check if compatible scope is used
|
2016-06-12 04:08:55 +00:00
|
|
|
private _display = uiNamespace getVariable [QGVAR(RscWeaponInfo2D), displayNull];
|
2015-04-04 04:19:19 +00:00
|
|
|
|
|
|
|
if (isNull _display) exitWith {};
|
|
|
|
|
|
|
|
// Reduce the reticle movement as the player drops into lower, supported stances.
|
2016-09-04 14:44:22 +00:00
|
|
|
private _recoilCoef = switch (true) do {
|
2015-04-04 04:19:19 +00:00
|
|
|
case (isWeaponDeployed _unit): {0.1};
|
|
|
|
case (isWeaponRested _unit): {0.4};
|
|
|
|
default {1};
|
|
|
|
};
|
|
|
|
|
|
|
|
// Constants which determine how the scope recoils
|
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _recoilScope = _recoilCoef * linearConversion [0, 1, random 1, SCOPE_RECOIL_MIN, SCOPE_RECOIL_MAX, false];
|
2015-04-04 04:19:19 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _reticleShiftX = _recoilCoef * linearConversion [0, 1, random 1, RETICLE_SHIFT_X_MIN, RETICLE_SHIFT_X_MAX, false];
|
|
|
|
private _reticleShiftY = _recoilCoef * linearConversion [0, 1, random 1, RETICLE_SHIFT_Y_MIN, RETICLE_SHIFT_Y_MAX, false];
|
2015-04-04 04:19:19 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _scopeShiftX = _recoilCoef * linearConversion [0, 1, random 1, SCOPE_SHIFT_X_MIN, SCOPE_SHIFT_X_MAX, false];
|
|
|
|
private _scopeShiftY = _recoilCoef * linearConversion [0, 1, random 1, SCOPE_SHIFT_Y_MIN, SCOPE_SHIFT_Y_MAX, false];
|
2015-04-04 04:19:19 +00:00
|
|
|
|
|
|
|
// Create and commit recoil effect
|
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _sizeX = (0.75 + _recoilScope) / (getResolution select 5);
|
|
|
|
private _sizeY = _sizeX * (4 / 3);
|
2015-04-04 04:19:19 +00:00
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _positionReticle = [
|
2017-08-29 22:47:01 +00:00
|
|
|
safezoneX + 0.5 * safezoneW - 0.5 * (_sizeX + _reticleShiftX),
|
|
|
|
safezoneY + 0.5 * safezoneH - 0.5 * (_sizeY + _reticleShiftY),
|
2015-04-04 04:19:19 +00:00
|
|
|
_sizeX,
|
|
|
|
_sizeY
|
|
|
|
];
|
|
|
|
|
|
|
|
(_display displayCtrl 1713001) ctrlSetPosition _positionReticle;
|
|
|
|
(_display displayCtrl 1713002) ctrlSetPosition _positionReticle;
|
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _positionBody = [
|
2017-08-29 22:47:01 +00:00
|
|
|
safezoneX + 0.5 * safezoneW - 0.5 * (2 * _sizeX + _scopeShiftX),
|
|
|
|
safezoneY + 0.5 * safezoneH - 0.5 * (2 * _sizeY + _scopeShiftY),
|
2016-09-04 14:44:22 +00:00
|
|
|
2 * _sizeX,
|
|
|
|
2 * _sizeY
|
2015-04-04 04:19:19 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
(_display displayCtrl 1713005) ctrlSetPosition _positionBody;
|
|
|
|
(_display displayCtrl 1713006) ctrlSetPosition _positionBody;
|
|
|
|
|
|
|
|
(_display displayCtrl 1713001) ctrlCommit 0;
|
|
|
|
(_display displayCtrl 1713002) ctrlCommit 0;
|
|
|
|
(_display displayCtrl 1713005) ctrlCommit 0;
|
|
|
|
(_display displayCtrl 1713006) ctrlCommit 0;
|
|
|
|
|
|
|
|
// Bring them all back
|
2017-08-29 22:47:01 +00:00
|
|
|
_sizeX = 0.75 / (getResolution select 5);
|
|
|
|
_sizeY = _sizeX * (4 / 3);
|
2015-04-04 04:19:19 +00:00
|
|
|
|
|
|
|
_positionReticle = [
|
2016-09-04 14:44:22 +00:00
|
|
|
safezoneX + 0.5 * safezoneW - 0.5 * _sizeX,
|
|
|
|
safezoneY + 0.5 * safezoneH - 0.5 * _sizeY,
|
2015-04-04 04:19:19 +00:00
|
|
|
_sizeX,
|
|
|
|
_sizeY
|
|
|
|
];
|
|
|
|
|
|
|
|
(_display displayCtrl 1713001) ctrlSetPosition _positionReticle;
|
|
|
|
(_display displayCtrl 1713002) ctrlSetPosition _positionReticle;
|
|
|
|
|
|
|
|
_positionBody = [
|
2016-09-04 14:44:22 +00:00
|
|
|
safezoneX + 0.5 * safezoneW - 0.5 * 2 * _sizeX,
|
|
|
|
safezoneY + 0.5 * safezoneH - 0.5 * 2 * _sizeY,
|
|
|
|
2 * _sizeX,
|
|
|
|
2 * _sizeY
|
2015-04-04 04:19:19 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
(_display displayCtrl 1713005) ctrlSetPosition _positionBody;
|
|
|
|
(_display displayCtrl 1713006) ctrlSetPosition _positionBody;
|
|
|
|
|
|
|
|
(_display displayCtrl 1713001) ctrlCommit RECENTER_TIME;
|
|
|
|
(_display displayCtrl 1713002) ctrlCommit RECENTER_TIME;
|
|
|
|
(_display displayCtrl 1713005) ctrlCommit RECENTER_TIME;
|
|
|
|
(_display displayCtrl 1713006) ctrlCommit RECENTER_TIME;
|