2015-02-18 04:07:29 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Change the blending when the player fires??
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: unit - Object the event handler is assigned to <OBJECT>
|
|
|
|
* 1: weapon - Fired weapon <STRING>
|
|
|
|
* 2: muzzle - Muzzle that was used <STRING>
|
|
|
|
* 3: mode - Current mode of the fired weapon <STRING>
|
|
|
|
* 4: ammo - Ammo used <STRING>
|
|
|
|
* 5: magazine - magazine name which was used <STRING>
|
|
|
|
* 6: projectile - Object of the projectile that was shot <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Nothing
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [clientFiredBIS-XEH] call ace_nightvision_fnc_blending
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-12 22:08:37 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
private ["_vehicle", "_weapon", "_ammo", "_magazine", "_player"];
|
|
|
|
|
|
|
|
_vehicle = _this select 0;
|
|
|
|
_weapon = _this select 1;
|
|
|
|
_ammo = _this select 4;
|
|
|
|
_magazine = _this select 5;
|
|
|
|
|
|
|
|
_player = ACE_player;
|
2015-02-18 04:24:37 +00:00
|
|
|
//If our vehicle didn't shoot, or we're not in NVG mode, exit
|
2015-02-18 04:07:29 +00:00
|
|
|
if ((_vehicle != (vehicle _player)) || {(currentVisionMode _player) != 1}) exitWith {};
|
2015-02-18 04:24:37 +00:00
|
|
|
//If we are mounted, and it wasn't our weapon system that fired, exit
|
2015-01-12 22:08:37 +00:00
|
|
|
if (_player != _vehicle && {!(_weapon in (_vehicle weaponsTurret ([_player] call EFUNC(common,getTurretIndex))))}) exitWith {};
|
|
|
|
|
|
|
|
private ["_silencer", "_visibleFireCoef", "_visibleFireTimeCoef", "_visibleFire", "_visibleFireTime", "_nvgBrightnessCoef", "_fnc_isTracer", "_darkness"];
|
|
|
|
|
|
|
|
_silencer = switch (_weapon) do {
|
2015-02-18 04:07:29 +00:00
|
|
|
case (primaryWeapon _player) : {primaryWeaponItems _player select 0};
|
|
|
|
case (secondaryWeapon _player) : {secondaryWeaponItems _player select 0};
|
|
|
|
case (handgunWeapon _player) : {handgunItems _player select 0};
|
|
|
|
default {""};
|
2015-01-12 22:08:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_visibleFireCoef = 1;
|
|
|
|
_visibleFireTimeCoef = 1;
|
|
|
|
if (_silencer != "") then {
|
2015-02-18 04:07:29 +00:00
|
|
|
_visibleFireCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "visibleFire");
|
|
|
|
_visibleFireTimeCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "visibleFireTime");
|
2015-01-12 22:08:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_visibleFire = getNumber (configFile >> "CfgAmmo" >> _ammo >> "visibleFire");
|
|
|
|
_visibleFireTime = getNumber (configFile >> "CfgAmmo" >> _ammo >> "visibleFireTime");
|
|
|
|
|
2015-01-16 04:43:54 +00:00
|
|
|
_nvgBrightnessCoef = 1 + (_player getVariable [QGVAR(NVGBrightness), 0]) / 4;
|
2015-01-12 22:08:37 +00:00
|
|
|
|
|
|
|
_fnc_isTracer = {
|
2015-02-18 04:07:29 +00:00
|
|
|
private ["_indexShot", "_lastRoundsTracer", "_tracersEvery"];
|
2015-01-12 22:08:37 +00:00
|
|
|
|
2015-02-18 04:07:29 +00:00
|
|
|
if (getNumber (configFile >> "CfgAmmo" >> _ammo >> "nvgOnly") > 0) exitWith {false};
|
2015-01-12 22:08:37 +00:00
|
|
|
|
2015-02-18 04:07:29 +00:00
|
|
|
_indexShot = (_player ammo _weapon) + 1;
|
2015-01-12 22:08:37 +00:00
|
|
|
|
2015-02-18 04:07:29 +00:00
|
|
|
_lastRoundsTracer = getNumber (configFile >> "CfgMagazines" >> _magazine >> "lastRoundsTracer");
|
|
|
|
if (_indexShot <= _lastRoundsTracer) exitWith {true};
|
2015-01-12 22:08:37 +00:00
|
|
|
|
2015-02-18 04:07:29 +00:00
|
|
|
_tracersEvery = getNumber (configFile >> "CfgMagazines" >> _magazine >> "tracersEvery");
|
|
|
|
if (_tracersEvery == 0) exitWith {false};
|
2015-01-12 22:08:37 +00:00
|
|
|
|
2015-02-18 04:07:29 +00:00
|
|
|
(_indexShot - _lastRoundsTracer) % _tracersEvery == 0
|
2015-01-12 22:08:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (call _fnc_isTracer) then {
|
2015-02-18 04:07:29 +00:00
|
|
|
_visibleFire = _visibleFire + 2;
|
|
|
|
_visibleFireTime = _visibleFireTime + 2;
|
2015-01-12 22:08:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_darkness = 1 - (call EFUNC(common,ambientBrightness));
|
|
|
|
|
|
|
|
_visibleFire = _darkness * _visibleFireCoef * _visibleFire * _nvgBrightnessCoef / 10 min 1;
|
|
|
|
_visibleFireTime = _darkness * _visibleFireTimeCoef * _visibleFireTime * _nvgBrightnessCoef / 10 min 0.5;
|
|
|
|
|
2015-01-12 22:53:19 +00:00
|
|
|
// ["NightVision", [_visibleFire, _visibleFireTime], {format ["visibleFire: %1 - visibleFireTime: %2", _this select 0, _this select 1]}] call AGM_Debug_fnc_log; //todo
|
2015-01-12 22:08:37 +00:00
|
|
|
|
|
|
|
GVAR(ppEffectMuzzleFlash) ppEffectAdjust [1, 1, _visibleFire, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]];
|
|
|
|
GVAR(ppEffectMuzzleFlash) ppEffectCommit 0;
|
|
|
|
|
|
|
|
GVAR(ppEffectMuzzleFlash) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]];
|
|
|
|
GVAR(ppEffectMuzzleFlash) ppEffectCommit _visibleFireTime;
|