Yeah it might be a good idea to get some sleep then. See ya later.
--edit--7:31
Ah I was hopeing I could still catch you but I guess you'll see this in six hours..
It worked!
here's what I used..
PHP Code:
// UNITS WILL DROP IF SHOT AT
// Original code idea by -Coulum-
// TPW 20120617
private ["_unit","_near","_bc","_shots","_id","_randid","_nearestenemy","_distoenemy","distoshooter"];
//Start hint
sleep 1;
hintsilent "TPW / -Coulum- suppress active";
//Main function
tpw_sup =
{
{
_unit = _x;
_nearestenemy = _unit findnearestenemy (getposatl _unit);
_distoenemy = _unit distance _nearestenemy;
if (_distoenemy > 25) then
{
_nextTime = _unit getVariable ["NextTime", -1];
if (_nextTime == -1) then
{
_unit setVariable ["NextTime", diag_tickTime];
_unit addeventhandler ["Fired",{shooter = (_this select 0)}];
};
if (diag_tickTime >= _nextTime) then {_unit setVariable ["Shots", 0]};
_bc = count ((getposatl _unit) nearobjects ["Bulletbase",10]);
_distoshooter = _unit distance shooter;
if ((_bc > 0) and _distoshooter >15)then
{
_unit setVariable ["NextTime", diag_tickTime + 3 + random 5];
_shots = _unit getVariable "Shots";
_unit setVariable ["Shots", _shots + _bc];
};
_shots = _unit getVariable "Shots";
if (_shots == 0) then {_unit setunitpos "auto"};
if (_shots > 0) then {_unit setunitpos "middle";};
if (_shots > 5) then {_unit setunitpos "down";};
};
} forEach allunits;
};
[tpw_sup,0.05] call cba_fnc_addPerFrameHandler;
Instead of using Nearbyunits I actually just measured the distance from the unit in question to the shooter. If the distance whas more than 15 metres apply suppression otherwise don't. Haven't tried it in a big fight yet but with just a few units it works fine. Great work Orcinus.
I have a feeling that the nearestobject method might be more efficient so I am going to try that as well.