_shooter = _this select 0
_projectile = nearestObject [vehicle(_shooter), _this select 4]
?(_shooter == player): goto exit
?((_this select 2) == "throw"): goto exit
_vel = velocity _projectile
_speed = speed _projectile
_disp = (_speed * (0.016 - (skill _shooter)/100) )
_dispX2 = _disp*2
_projectile SetVelocity [(_vel select 0) - _disp + Random(_dispX2),(_vel select 1) - _disp + Random(_dispX2),(_vel select 2) - _disp + Random(_dispX2)]
),(_vel select 2) - _disp + Random(_dispX2)]
Ok i used that as the script for the ai. And its set of by a anybody present once trigger that triggs this script:
_list = _this
_count = count _list
_i=0
#loop
(_list select _i) addEventHandler ["fired",{_this exec "fired.sqs"}]
_i = _i + 1
?(_i < _count ):goto"loop"
Thats for the ai.
Then i used this for the players units:
For the sniper i made a script called sniperdisp.sqs and its executed by this line in the units init field:
this addEventHandler ["fired",{_this exec "sniperdisp.sqs"}];
and the sniperdisp uses the same code as the fired script (ai disp) but with another setting for the disp.
Does this work?
Its seems wierd as sometimes i do have the disp but next time i preview the mish i dont and the ai seems to do the same. It always works on my test ai but not on the units in my mission area. The trigger is covering them all so thats not it.
What should i change.
And if anyone else have a better solution to add a global value to dispersion for the ai, a sniper player and one for the rest of the players ( i dont wanna go in and edit every darn weapon) please post how you would do this.
edit: the sniperdisp script dont have he player goto exit line, should i have a ai exit line though? (not player exit?)