ACE3/addons/nightvision/functions/fnc_onFiredPlayer.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

62 lines
2.2 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: commy2, Dslyecxi, PabstMirror
* Change the blending when the player fires. Called from the unified fired EH only for the local player and his vehicle.
*
* Arguments:
* None. Parameters inherited from EFUNC(common,firedEH)
*
* Return Value:
* None
*
* Example:
* [clientFiredBIS-XEH] call ace_nightvision_fnc_onFiredPlayer
*
* Public: No
*/
//IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"];
TRACE_7("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile);
if ((!GVAR(running)) || {!GVAR(shutterEffects)} || {_weapon == "throw"} || {_weapon == "put"}) exitWith {};
private _visibleFireCoef = 1;
if (_unit == ace_player) then {
private _silencer = (_unit weaponAccessories _weapon) select 0;
if (_silencer != "") then {
_visibleFireCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "visibleFire");
TRACE_1("muzzle attachement",_visibleFireCoef);
};
};
private _visibleFire = getNumber (configFile >> "CfgAmmo" >> _ammo >> "visibleFire");
private _isTracer = call {
if (getNumber (configFile >> "CfgAmmo" >> _ammo >> "nvgOnly") > 0) exitWith {false};
private _indexShot = (_unit ammo _weapon) + 1;
private _lastRoundsTracer = getNumber (configFile >> "CfgMagazines" >> _magazine >> "lastRoundsTracer");
if (_indexShot <= _lastRoundsTracer) exitWith {true};
private _tracersEvery = getNumber (configFile >> "CfgMagazines" >> _magazine >> "tracersEvery");
if (_tracersEvery == 0) exitWith {false};
(_indexShot - _lastRoundsTracer) % _tracersEvery == 0
};
TRACE_3("",_ammo,_visibleFire,_isTracer);
if ( _isTracer) then {
_visibleFire = _visibleFire + 2;
};
_visibleFire = _visibleFireCoef * _visibleFire;
if (_ammo isKindOf "BulletBase") then {
_visibleFire = _visibleFire min 5; // Prevent every shot from triggering with HMG
};
TRACE_1("final", _visibleFire);
if (_visibleFire <= 1.5) exitWith {};
if ((random (linearConversion [1, 4, GVAR(nvgGeneration), 10, 20])) > _visibleFire) exitWith {};
QGVAR(cutoff) cutText ["", "BLACK", .1];
[{
QGVAR(cutoff) cutText ["", "PLAIN", 0];
}, [], 0.07] call CBA_fnc_waitAndExecute;