Guest User

Untitled

a guest
Jul 25th, 2025
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 1.84 KB | None | 0 0
  1. waituntil {alive player};
  2.  
  3. if (isNil "tort_debug") then {tort_debug = false};
  4. if (!isNil "hlp_shoot") then {
  5.    if (!scriptDone hlp_shoot) then {
  6.       terminate hlp_shoot;
  7.       waitUntil {scriptDone hlp_shoot};
  8.    };
  9. };
  10.  
  11. _scriptname = "hlp_shoot";
  12. if (tolower(str(_this#0)) find "false" >= 0) exitWith {tort_tasks = tort_tasks - [_scriptname]; systemchat "Random shooting terminated."};
  13. if (isnil "tort_tasks") then {tort_tasks = [_scriptname]} else {if !(_scriptname in tort_tasks) then {tort_tasks pushback _scriptname}};
  14.  
  15. hlp_shoot = _this spawn
  16. {
  17.    _minWait     = param [0,15];
  18.    _maxWait     = param [1,30];
  19.    _minDistance = param [2,50];
  20.    _maxDistance = param [3,700];
  21.    _maxShots    = param [4,3];
  22.    _probability = param [5,0.1];
  23.    sleep (40 + random _maxWait);
  24.  
  25.    while {true} do
  26.    {
  27.       sleep (_minWait + random (_maxWait - _minWait));
  28.       if (_probability > random 1) then
  29.       {
  30.          _nearUnits = allUnits select {((_x distance player) > _minDistance) && ((_x distance player) <= _maxDistance) && ((side _x) != CIVILIAN) && (vehicle _x == _x)};
  31.          if ((count _nearUnits) > 0) then
  32.          {
  33.             _i = 0; while {((random 1) > 0.75) && (_i < ((count _nearUnits) -1))} do {_i = _i + 1};
  34.             _unit = _nearUnits select _i;
  35.             _num = floor(1 + _maxShots * ((random 1)^1.4));
  36.             _unit disableAI "MOVE"; _unit disableAI "FSM"; _unit disableAI "AIMINGERROR";
  37.             _behaviour = behaviour _unit;
  38.             _unit setBehaviour "AWARE"; sleep 1;
  39.             for "_j" from 1 to _num do
  40.             {
  41.                _unit forceWeaponFire [currentMuzzle _unit, "Single"];
  42.                sleep (0.2 + random 1);
  43.             };
  44.             _unit enableAI "MOVE"; _unit enableAI "FSM"; _unit enableAI "AIMINGERROR"; _unit setBehaviour _behaviour;
  45.  
  46.          };
  47.       };
  48.    };
  49. };
Advertisement
Add Comment
Please, Sign In to add comment