Advertisement
papijuan23

initJammer2.sqf

Jun 17th, 2025 (edited)
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 4.87 KB | Gaming | 0 0
  1. private _jammerClassname = "Sania"; // Compatibilidad antigua
  2.  
  3. [] spawn {
  4.     private _jammerClassnames = ["Sania", "Sania_with_tripod_BLU", "Sania_with_tripod_RED"];
  5.     private _detectedJammers = [];
  6.  
  7.     while {true} do {
  8.         private _jammers = [];
  9.         {
  10.             _jammers = _jammers + allMissionObjects _x;
  11.         } forEach _jammerClassnames;
  12.  
  13.         {
  14.             if (!(_x in _detectedJammers)) then {
  15.                 _detectedJammers pushBack _x;
  16.             };
  17.         } forEach _jammers;
  18.  
  19.         {
  20.             private _isActive = _x getVariable ["DB_jammer_isActive", false];
  21.             private _wasActive = _x getVariable ["DB_jammer_lastActiveState", false];
  22.  
  23.             if (_isActive != _wasActive) then {
  24.                 _x setVariable ["DB_jammer_lastActiveState", _isActive];
  25.             };
  26.  
  27.             if (_isActive) then {
  28.                 _x setVariable ["isGPSJammer", true, true];
  29.                 _x setVariable ["jamRadius", 16000, true];
  30.                 _x setVariable ["jamSuccess", 1.0, true];
  31.  
  32.                 private _jammerPos = getPosATL _x;
  33.                 private _radius = _x getVariable ["jamRadius", 12000];
  34.                 private _chance = _x getVariable ["jamSuccess", 0.6];
  35.  
  36.                 private _projList = nearestObjects [_jammerPos, ["MissileBase", "BombCore", "SubmunitionBase"], _radius];
  37.  
  38.                 {
  39.                     private _proj = _x;
  40.                     private _projType = typeOf _proj;
  41.  
  42.                     if (!isNil "GPSJam_ValidBombs" && {_projType in GPSJam_ValidBombs}) then {
  43.                         if (isNil {_proj getVariable "gpsJammed"}) then {
  44.                             private _rand = random 1;
  45.                             if (_rand < _chance) then {
  46.                                 _proj setVariable ["gpsJammed", true, true];
  47.                                 _proj setVariable ["ITGT_TARGET", nil, true];
  48.                                 _proj setVariable ["FIR_ITGT_TARGET_POS", nil, true];
  49.                                 _proj setVariable ["FIR_GUIDANCE_ENABLED", false, true];
  50.  
  51.                                 // 🔊 BUSCAR ALTAVOZ Y SONAR SIRENA
  52.                                 private _nearbyLoudspeakers = nearestObjects [_jammerPos, ["Land_Loudspeakers_F"], 2000];
  53.                                 if (count _nearbyLoudspeakers > 0) then {
  54.                                     private _speaker = _nearbyLoudspeakers select 0;
  55.                                     [_speaker] remoteExec ["FR_fnc_playJammerSiren", 0];
  56.                                 };
  57.  
  58.                                 // Desviación de la bomba
  59.                                 [_proj, _jammerPos, _radius] spawn {
  60.                                     params ["_bomb", "_jammerPos", "_radius"];
  61.                                     while {!isNull _bomb} do {
  62.                                         private _pos = getPosATL _bomb;
  63.                                         private _dist = _pos distance _jammerPos;
  64.                                         private _alt = _pos select 2;
  65.  
  66.                                         if (_dist <= _radius && _alt <= 3000) then {
  67.                                             private _intensity = 1 - (_alt / 3000);
  68.                                             private _velX = (random 2 - 1) * _intensity;
  69.                                             private _velY = (random 2 - 1) * _intensity;
  70.                                             private _velZ = -40 * _intensity;
  71.  
  72.                                             private _forceX = ((random 100) - 50) * _intensity * 3;
  73.                                             private _forceY = ((random 100) - 50) * _intensity * 3;
  74.                                             private _forceZ = -300 * _intensity;
  75.  
  76.                                             _bomb setVelocity [_velX, _velY, _velZ];
  77.                                             _bomb setVectorDirAndUp [[_velX, _velY, -1], [0, 1, 0]];
  78.                                             _bomb addForce [[_forceX, _forceY, _forceZ], [0, 0, 0]];
  79.                                             _bomb setPosATL (_pos vectorAdd [_velX, _velY, -0.5 * _intensity]);
  80.  
  81.                                             _bomb setVariable ["ITGT_TARGET", nil, true];
  82.                                             _bomb setVariable ["FIR_ITGT_TARGET_POS", nil, true];
  83.                                             _bomb setVariable ["FIR_GUIDANCE_ENABLED", false, true];
  84.                                         };
  85.  
  86.                                         sleep 0.1;
  87.                                     };
  88.                                 };
  89.                             };
  90.                         };
  91.                     };
  92.                 } forEach _projList;
  93.             } else {
  94.                 _x setVariable ["isGPSJammer", false, true];
  95.             };
  96.         } forEach _jammers;
  97.  
  98.         sleep 1.2;
  99.     };
  100. };
  101.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement