Okay guys, this is what I got so far.
I placed one opfor unit down named "ai"
I placed 1 blufor player down.
I created the following eventhandler that is started in the "init.sqf"
PHP Code:
_fired = player addEventHandler ["fired", {_this execVM "suppression.sqf"}];
This means when I (the player) fires suppression.sqf (below) is run
PHP Code:
_ammo = _this select 4;
_round = nearestobject [player,_ammo];
while {(speed _round) > 0.1} do {
_dist = _round distance ai;
if (_dist < 10) then {
hint "ai is suppressed";
ai setunitpos "down";
_saveAccuracy = ai skill "aimingAccuracy";
_saveShake = ai skill "aimingshake";
ai setskill ["aimingAccuracy",0.01];
ai setskill ["aimingShake",0.01];
sleep 5;
ai setskill ["aimingAccuracy",_saveaccuracy];
ai setskill ["aimingShake",_saveshake];
ai setunitpos "auto";
};
};
This tracks the shot I have fired and determines if it has come close (10 "units") to the opfor named "ai". if so, it causes "ai" to go prone and have decreased accuracy for 5 seconds before he goes back to his normal stance and accuracy. All this works relatviely smoothly...
Now my newbie scripting questions are:
1. How do I make it so the fired eventhandler is not only created for "player", but also for every unit on the map (Besides manually naming all the ai and typing an eventhandler out for each of these names.)
2. Right now the script only tracks whether the round comes close to "ai". How do I make it so that the distances from the round to all units on the map is measured? (without naming ai1, ai2, ai3...etc. and having corresponding "_dist = _round distance ai;","_dist1 = _round distance ai1;","_dist2 = _round distance ai2;"... etc.)
If my questions aren't clear please let me now and I will try to explain what I mean better. Thanks for your help.
P.S.
from the little "test" I created above, things are looking quite promising in terms of gameplay improvements. If you keep up suppressive fire on "ai" he will go prone and you will sustain very little accurate fire from him. don't keep up the fire and he will start laying down accurate shots and suppressing/hitting you. If this stuff isn't ridiculously system intensive (which it very well may be) I think it will provide alot more depth to firefights.