Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- waituntil {alive player};
- if (isNil "tort_debug") then {tort_debug = false};
- if (!isNil "hlp_shoot") then {
- if (!scriptDone hlp_shoot) then {
- terminate hlp_shoot;
- waitUntil {scriptDone hlp_shoot};
- };
- };
- _scriptname = "hlp_shoot";
- if (tolower(str(_this#0)) find "false" >= 0) exitWith {tort_tasks = tort_tasks - [_scriptname]; systemchat "Random shooting terminated."};
- if (isnil "tort_tasks") then {tort_tasks = [_scriptname]} else {if !(_scriptname in tort_tasks) then {tort_tasks pushback _scriptname}};
- hlp_shoot = _this spawn
- {
- _minWait = param [0,15];
- _maxWait = param [1,30];
- _minDistance = param [2,50];
- _maxDistance = param [3,700];
- _maxShots = param [4,3];
- _probability = param [5,0.1];
- sleep (40 + random _maxWait);
- while {true} do
- {
- sleep (_minWait + random (_maxWait - _minWait));
- if (_probability > random 1) then
- {
- _nearUnits = allUnits select {((_x distance player) > _minDistance) && ((_x distance player) <= _maxDistance) && ((side _x) != CIVILIAN) && (vehicle _x == _x)};
- if ((count _nearUnits) > 0) then
- {
- _i = 0; while {((random 1) > 0.75) && (_i < ((count _nearUnits) -1))} do {_i = _i + 1};
- _unit = _nearUnits select _i;
- _num = floor(1 + _maxShots * ((random 1)^1.4));
- _unit disableAI "MOVE"; _unit disableAI "FSM"; _unit disableAI "AIMINGERROR";
- _behaviour = behaviour _unit;
- _unit setBehaviour "AWARE"; sleep 1;
- for "_j" from 1 to _num do
- {
- _unit forceWeaponFire [currentMuzzle _unit, "Single"];
- sleep (0.2 + random 1);
- };
- _unit enableAI "MOVE"; _unit enableAI "FSM"; _unit enableAI "AIMINGERROR"; _unit setBehaviour _behaviour;
- };
- };
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment