Advertisement
Guest User

Untitled

a guest
Mar 30th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.00 KB | None | 0 0
  1. private ["_projectile","_unit","_ammo"];
  2.  
  3. //[unit, weapon, muzzle, mode, ammo, magazine, projectile]
  4. _unit = _this select 0;
  5. //_weapon = _this select 1;
  6. _ammo = _this select 4;
  7. _projectile = _this select 6;
  8.  
  9. //Alert Nearby
  10. _audible = getNumber (configFile >> "CfgAmmo" >> _ammo >> "audibleFire");
  11. _caliber = getNumber (configFile >> "CfgAmmo" >> _ammo >> "caliber");
  12. _distance = round(_audible * 10 * _caliber);
  13. _origdist = _distance;
  14.  
  15. // Modified for sound dampening if raining (based upon intensity) by ^bdc
  16. if (dayz_PlayerFiredSoundRealism_RainSoundDampening) then {
  17.     _CorrectionFactor = 0;
  18.     _RainAmt = drn_var_DynamicWeather_Rain; // referenced from \z\addons\dayz_code\system\DynamicWeatherEffects.sqf
  19.     if ((_distance > 0) and (_RainAmt > 0)) then {
  20.         if (_RainAmt > 0.72) then { // very heavy rain
  21.             _CorrectionFactor = dayz_PlayerFiredSoundRealism_VeryHeavyRainMagnitude; };  // 40%
  22.         if (_RainAmt > 0.53) then { // heavy rain
  23.             _CorrectionFactor = dayz_PlayerFiredSoundRealism_HeavyRainMagnitude; };  // 55%
  24.         if (_RainAmt > 0.25) then { // medium rain
  25.             _CorrectionFactor = dayz_PlayerFiredSoundRealism_ModerateRainMagnitude; };  // 70%
  26.         if (_RainAmt < 0.25) then { // light rain
  27.             _CorrectionFactor = dayz_PlayerFiredSoundRealism_ModerateRainMagnitude; };  // 85%
  28.         _distance = (_distance * _CorrectionFactor);
  29.     };
  30. };
  31.    
  32. if (dayz_PlayerFiredSoundRealism_Enabled) then { // init.sqf
  33.     _distance = (_distance * dayz_PlayerFiredSoundRealism_Magnitude);
  34.     if (_distance >= dayz_PlayerFiredSoundRealism_MaximumDisAudialRange) then {
  35.         _distance = dayz_PlayerFiredSoundRealism_MaximumDisAudialRange;
  36.     };
  37. };
  38.  
  39. dayz_disAudial = _distance;
  40. dayz_firedCooldown = time;
  41.  
  42. if (dayz_PlayerFiredSoundRealism_Logging) then {
  43.     diag_log format["Player_Fired.SQF: Diagnostic: OriginalDistance %1 RainCorrectionFactor %2 TotalDistance %3 SoundRealismMagnitude %4",_origdist,_CorrectionFactor,dayz_disAudial,dayz_PlayerFiredSoundRealism_Magnitude];
  44. };
  45.  
  46. // added for debug - ^bdc
  47. //cutText [format["Player fired - ammo %1 audible %2 caliber %3 distance %4 RainAmt %5",_ammo,_audible,_caliber,_distance,_RainAmt], "PLAIN DOWN"];
  48.  
  49. if (_ammo isKindOf "Melee") exitWith {
  50.     _unit playActionNow "GestureSwing";
  51. };
  52.  
  53. if ((_ammo isKindOf "SmokeShell") or (_ammo isKindOf "GrenadeHandTimedWest") or (_ammo isKindOf "G_40mm_HE")) then {
  54.     if (_ammo isKindOf "G_40mm_HE") then { dayz_disAudial = 30 };
  55.  
  56.     [_unit,_ammo] spawn {
  57.         private ["_pos","_group","_localtargets","_remotetargets"];
  58.         _unit = _this select 0;
  59.         _ammo = _this select 1;
  60.  
  61.         _projectile = nearestObject [_unit, _ammo];
  62.         _pos = getPosATL _projectile;
  63.  
  64.         if (_ammo isKindOf "SmokeShell") then {
  65.             while { ((getPosATL _projectile) select 2) >= 1 } do {
  66.                 _pos = getPosATL _projectile;
  67.                 sleep 0.01;
  68.             };
  69.  
  70.             _listTalk = _pos nearEntities ["zZombie_Base",50];
  71.  
  72.             {
  73.                 _group = group _x;
  74.                 if (isNull group _x) then {
  75.                     _group = _x;
  76.                 };
  77.                 _isLocal = (local _x);
  78.                 _x reveal [_projectile,4];
  79.                 _localtargets = _group getVariable ["localtargets",[]];
  80.                 _remotetargets = _group getVariable ["remotetargets",[]];
  81.                 _targets = _localtargets + _remotetargets;
  82.                 if (!(_projectile in _targets)) then {
  83.                     switch (_isLocal) do {
  84.                         case false: {
  85.                             _remotetargets set [count _remotetargets,_projectile];
  86.                             _x setVariable ["remotetargets",_remotetargets,true];
  87.                         };
  88.                         case true: {
  89.                             _localtargets set [count _localtargets,_projectile];
  90.                             _x setVariable ["localtargets",_localtargets,false];
  91.                         };
  92.                     };
  93.                 };
  94.             } forEach _listTalk;
  95.            
  96.         } else {
  97.             while { alive _projectile } do {
  98.                 _pos = getPosATL _projectile;
  99.                 sleep 0.01;
  100.             };
  101.  
  102.             _listTalk = _pos nearEntities ["zZombie_Base",50];
  103.  
  104.             {
  105.                 _x setVariable ["myDest",_pos]; // removed networked var.  targets should be enough
  106.             } forEach _listTalk;
  107.         };
  108.     };
  109. } else {
  110.     [_unit,_distance,true,(getPosATL player)] call player_alertZombies;
  111.  
  112.     /*
  113.     _combattimeout = player getVariable["combattimeout",0];
  114.     if (_combattimeout > 0) then {
  115.         _timeleft = _combattimeout - time;
  116.         if (_timeleft > 0) then {
  117.            // [getPosATL player] call combat_spawnZombies;
  118.         } else {
  119.         };
  120.     } else {
  121.     };
  122.     */
  123.  
  124.     //Check if need to place arrow
  125.     if (_ammo isKindOf "Bolt") then {
  126.         [_this] spawn player_crossbowBolt;
  127.     };
  128.     if (_ammo isKindOf "GrenadeHand") then {
  129.  
  130.         if (_ammo isKindOf "ThrownObjects") then {
  131.             [_this] spawn player_throwObject;
  132.         };
  133.         if (_ammo isKindOf "RoadFlare") then {
  134.             //hint str(_ammo);
  135.             _projectile = nearestObject [_unit, "RoadFlare"];
  136.             [_projectile,0] spawn object_roadFlare;
  137.             PVDZ_obj_RoadFlare = [_projectile,0];
  138.             publicVariable "PVDZ_obj_RoadFlare";
  139.             [_this] spawn player_throwObject;
  140.         };
  141.         if (_ammo isKindOf "ChemLight") then {
  142.             _projectile = nearestObject [_unit, "ChemLight"];
  143.             [_projectile,1] spawn object_roadFlare;
  144.             PVDZ_obj_RoadFlare = [_projectile,1];
  145.             publicVariable "PVDZ_obj_RoadFlare";
  146.             [_this] spawn player_throwObject;
  147.         };
  148.     };
  149. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement