Difference between revisions of "VN ms fnc tracker onPlayerFired"

From Savage Game Design Wiki
Jump to navigation Jump to search
m (Text replacement - "[[vn_" to "[[VN_")
(Page filling)
 
Line 1: Line 1:
[[Category:TODO]]
 
 
{{Function
 
{{Function
  
Line 12: Line 11:
 
|g1= tracker
 
|g1= tracker
  
|d= <pre>/*
+
|d= Handles fired event to notify patrolling units etc. Uses [[VN_ms_fnc_tracker_receiveNoise]].
    Author: Wyqer, veteran29
 
    Date: 2019-07-14
 
  
    Description:
+
|s= firedEhParameters call [[VN_ms_fnc_tracker_onPlayerFired]]
        Handles fired event to notify patrolling units etc.
 
  
    Parameter(s):
+
|p1n= firedEhParameters
        AS PER "FIRED" EH, see:
+
|p1t= array
        https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Fired
+
|p1d= see {{Biki|Arma 3: Event Handlers#Fired|"Fired" Event Handler}}
 
 
    Returns:
 
        NOTHING
 
*/
 
params [
 
    "_unit",
 
    "_weapon",
 
    "_muzzle",
 
    "",
 
    "_ammo",
 
    "",
 
    "_projectile"
 
];
 
 
 
// TODO
 
if (_weapon == "throw") exitWith {
 
    #ifdef VN_DEBUG
 
    systemChat "TODO Tracker grenade handler";
 
    #endif
 
};
 
 
 
private _shotTimeout = _unit getVariable ["vn_tracker_shotTimeout", 0];
 
if (diag_tickTime < _shotTimeout) exitWith {};
 
// do not allow to trigger this too frequently, might need tweaking
 
_unit setVariable ["vn_tracker_shotTimeout", diag_tickTime + 20];
 
 
 
private _muzzleAttachement = _unit weaponAccessories _muzzle param [0, ""];
 
// get ammo audible distance
 
private _audibleFire = vn_ms_tracker_audibleFireCache getVariable (_muzzleAttachement+_ammo);
 
 
 
if (isNil "_audibleFire") then {
 
    private _audibleFireAmmo = getNumber (configFile >> "CfgAmmo" >> _ammo >> "audibleFire");
 
    private _audibleFireMuzzle = getNumber (configFile >> "CfgWeapons" >> _muzzleAttachement >> "ItemInfo" >> "AmmoCoef" >> "audibleFire");
 
    // If there is no entry for this muzzle / there is no attachment assume default coef of 1
 
    if (_audibleFireMuzzle == 0) then {_audibleFireMuzzle = 1};
 
 
 
    _audibleFire = _audibleFireAmmo * _audibleFireMuzzle;
 
    vn_ms_tracker_audibleFireCache setVariable [(_muzzleAttachement+_ammo), _audibleFire];
 
};
 
 
 
// difficulty coeficient with default in case our scripts are used outside of campaign
 
private _difficultyCoef = 1 + (missionNamespace getVariable ["vn_difficulty", 1]);
 
// audible distance after applying all coeficients
 
private _audibleSoundDist = _audibleFire * _difficultyCoef * VN_MS_AUDIBLE_FIRE_COEF;
 
 
 
#ifdef VN_DEBUG
 
    systemChat format ["Gunshot dist - %1: %2, %3", (_ammo+_muzzleAttachement), _audibleFire, _audibleSoundDist];
 
#endif
 
 
 
// broadcast the noise to server
 
if (isMultiplayer) then {
 
</pre><small>''(Placeholder description extracted from the function header by '''LM_exportFunctionsToWiki.sqf''')''</small>
 
 
 
|s= [] call [[VN_ms_fnc_tracker_onPlayerFired]]
 
 
 
|p1n=
 
|p1t=
 
|p1d=
 
 
|p1v=
 
|p1v=
  
Line 90: Line 28:
 
|r1d=
 
|r1d=
  
|x1= <code>-</code>
+
|x1= <code>player addEventHandler ["Fired", { _this spawn [[VN_ms_fnc_tracker_onPlayerFired]]; }];</code>
 
}}
 
}}

Latest revision as of 15:49, 26 February 2021

← back to Functions Introduced in S.O.G. Prairie Fire v1.00
by Wyqer, veteran29
Argument(s): n/a
Effect(s): unknown

Description

Handles fired event to notify patrolling units etc. Uses VN_ms_fnc_tracker_receiveNoise.

Syntax

Syntax
firedEhParameters call VN_ms_fnc_tracker_onPlayerFired
Parameters
firedEhParameters: Array - see "Fired" Event Handler
Return value
Nothing

Examples

Example 1
player addEventHandler ["Fired", { _this spawn VN_ms_fnc_tracker_onPlayerFired; }];