ACE3/addons/optics/functions/fnc_handleFired.sqf
Dedmen Miller e2ac18a05d [WIP] Fix script errors reporting wrong line numbers (#6407)
* advanced_ballistics

* advanced_fatigue

* advanced_throwing

* ai

* aircraft

* arsenal

* atragmx

* attach

* backpacks

* ballistics

* captives

* cargo

* chemlights

* common

* concertina_wire

* cookoff

* dagr

* disarming

* disposable

* dogtags

* dragging

* explosives

* fastroping

* fcs

* finger

* frag

* gestures

* gforces

* goggles

* grenades

* gunbag

* hearing

* hitreactions

* huntir

* interact_menu

* interaction

* inventory

* kestrel4500

* laser

* laserpointer

* logistics_uavbattery

* logistics_wirecutter

* magazinerepack

* map

* map_gestures

* maptools

* markers

* medical

* medical_ai

* medical_blood

* medical_menu

* microdagr

* minedetector

* missileguidance

* missionmodules

* mk6mortar

* modules

* movement

* nametags

* nightvision

* nlaw

* optics

* optionsmenu

* overheating

* overpressure

* parachute

* pylons

* quickmount

* rangecard

* rearm

* recoil

* refuel

* reload

* reloadlaunchers

* repair

* respawn

* safemode

* sandbag

* scopes

* slideshow

* spectator

* spottingscope

* switchunits

* tacticalladder

* tagging

* trenches

* tripod

* ui

* vector

* vehiclelock

* vehicles

* viewdistance

* weaponselect

* weather

* winddeflection

* yardage450

* zeus

* arsenal defines.hpp

* optionals

* DEBUG_MODE_FULL 1

* DEBUG_MODE_FULL 2

* Manual fixes

* Add SQF Validator check for #include after block comment

* explosives fnc_openTimerUI

* fix uniqueItems
2018-09-17 14:19:29 -05:00

105 lines
3.4 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: Taosenai
* Adapted By: KoffeinFlummi, commy2
*
* Animates the scope when firing. Called from the unified fired EH only for the local player.
*
* Arguments:
* None. Parameters inherited from EFUNC(common,firedEH)
*
* Return Value:
* None
*
* Example:
* call ace_optics_fnc_handleFired
*
* Public: No
*/
// IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"];
TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile, _vehicle, _gunner, _turret);
disableSerialization;
// Check if compatible scope is used
private _display = uiNamespace getVariable [QGVAR(RscWeaponInfo2D), displayNull];
if (isNull _display) exitWith {};
// Reduce the reticle movement as the player drops into lower, supported stances.
private _recoilCoef = switch (true) do {
case (isWeaponDeployed _unit): {0.1};
case (isWeaponRested _unit): {0.4};
default {1};
};
// Constants which determine how the scope recoils
private _recoilScope = _recoilCoef * linearConversion [0, 1, random 1, SCOPE_RECOIL_MIN, SCOPE_RECOIL_MAX, false];
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];
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];
// Create and commit recoil effect
private _sizeX = (0.75 + _recoilScope) / (getResolution select 5);
private _sizeY = _sizeX * (4 / 3);
private _positionReticle = [
safezoneX + 0.5 * safezoneW - 0.5 * (_sizeX + _reticleShiftX),
safezoneY + 0.5 * safezoneH - 0.5 * (_sizeY + _reticleShiftY),
_sizeX,
_sizeY
];
(_display displayCtrl 1713001) ctrlSetPosition _positionReticle;
(_display displayCtrl 1713002) ctrlSetPosition _positionReticle;
private _positionBody = [
safezoneX + 0.5 * safezoneW - 0.5 * (2 * _sizeX + _scopeShiftX),
safezoneY + 0.5 * safezoneH - 0.5 * (2 * _sizeY + _scopeShiftY),
2 * _sizeX,
2 * _sizeY
];
(_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
_sizeX = 0.75 / (getResolution select 5);
_sizeY = _sizeX * (4 / 3);
_positionReticle = [
safezoneX + 0.5 * safezoneW - 0.5 * _sizeX,
safezoneY + 0.5 * safezoneH - 0.5 * _sizeY,
_sizeX,
_sizeY
];
(_display displayCtrl 1713001) ctrlSetPosition _positionReticle;
(_display displayCtrl 1713002) ctrlSetPosition _positionReticle;
_positionBody = [
safezoneX + 0.5 * safezoneW - 0.5 * 2 * _sizeX,
safezoneY + 0.5 * safezoneH - 0.5 * 2 * _sizeY,
2 * _sizeX,
2 * _sizeY
];
(_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;