Post by Sa8Gecko on Dec 9, 2004 14:33:58 GMT -5
This is a modified (almost completely different) version of the
script Rastavovich wrote for VIT BMP-3 Arena.
The Arena is a countermeasure system mounted on some
last generation russian tanks and apcs that should intercept
incoming missiles.
The Rastavovich original intercepts all incoming locked-on
missiles, but misses unguided rockets.
This one no. It could even intercept tank shells if fired at less
than 850m/s. I had to choose so high a speed cause
the Hellfires from AH-64 fly at more than 2700 km/h.
For this set of scripts to work you must:
create a init.sqs file with this line:
then place the following files in your mission directory:
VIT_arena.sqs
intercept.sqf
deleteme.sqs:
See intructions on top of VIT_arena.sqs.
It's full of globalchats cause are useful to track down data.
Remove them if they annoy you. This is a version I wrote
more than a year ago and never finished cause I started
working on MCAR. I modified it today, making it more
efficient. It's not finished yet, but fell free to modify it and use in your
mission. Ask me for help if needed, and eventual bugs.
If you plan to use it in your missions or addons, no need
to credit me. Only DON'T state the script is a fruit of your
own work when infact it's a fruit of MY own work.
Down there is the old, fully commented, version. Look at
it as reference. This ones intercepts only BIS missiles and
rockets, though.
script Rastavovich wrote for VIT BMP-3 Arena.
The Arena is a countermeasure system mounted on some
last generation russian tanks and apcs that should intercept
incoming missiles.
The Rastavovich original intercepts all incoming locked-on
missiles, but misses unguided rockets.
This one no. It could even intercept tank shells if fired at less
than 850m/s. I had to choose so high a speed cause
the Hellfires from AH-64 fly at more than 2700 km/h.
For this set of scripts to work you must:
create a init.sqs file with this line:
intercept = preprocessFile "intercept.sqf"
then place the following files in your mission directory:
VIT_arena.sqs
; usage: put this line in init field of each Arena units:
;
; [this] exec "VIT_arena.sqs"
_tank = _this select 0
_misArray =[]
_sectors = 8
_anglesect = 360 / _sectors
_hits = 3
_arena = (_hits ^ _sectors) -1
_i = 0
#check
? damage _tank > .95: exit
_pos = position _tank
#loop
_missile = NearestObject [(_pos select 0)+30*sin(_i),(_pos select 1)+30*cos(_i),5]
? (speed _missile)!=0:player globalchat format ["%1",speed _missile]
? (abs(speed _missile)> 300) && (abs(speed _missile)< 3000) && (!(_missile in _misArray)): goto "missile"
_i = _i + 23
? _i < 360: goto "loop"
_i =_i -360
@(true)
goto "check"
#missile
;@ (_tank distance _missile < 25 ||!alive _missile)
_misArray = _misArray +[_missile];_arena = [_missile,_tank,_arena,_anglesect,_hits] call intercept
hint "missile acquired"
goto "check"
intercept.sqf
private ["_dir","_tank","_missile","_arena","_mem","_angleapp","_anglesect","_hits","_check","_dist","_xone","_zmiss","_sectorapp","_vmissvert","_ttog","_vhoriz","_dummy"];
_missile = _this select 0;
_tank = _this select 1;
_arena =_this select 2;
_anglesect = _this select 3;
_hits = _this select 4;
_dir = ((getpos _tank select 0) - (getpos _missile select 0)) atan2 ((getpos _tank select 1) - (getpos _missile select 1));
if (_dir < 0) then {_dir = _dir + 360};
player globalchat format ["dir %1, mis %2 tank %3,dist %4", _dir,direction _missile, direction _tank,_missile distance _tank];
if (abs (_dir - (direction _missile)) < 155 && (alive _missile)) then {
if ( abs (sin (_dir - (direction _missile)) * (_missile distance _tank))< 3.5) then {
player globalchat format ["horiz angle %1",abs (sin (_dir - (direction _missile)) * (_missile distance _tank))];
_angleapp =(direction _missile - direction _tank);
if (_angleapp < 0) then {_angleapp = _angleapp + 360};
player globalchat format ["angle %1",_angleapp];
_sectorapp = (_angleapp / _anglesect) - ((_angleapp / _anglesect) mod 1);
_check = (_arena / (_hits ^ _sectorapp)) - ((_arena / (_hits ^ _sectorapp)) mod 1);
_mem = _check mod _hits;
player globalchat format ["sector %1, _mem %2",_sectorapp,_mem];
if (_mem != 0 ) then {
_dist = _tank distance _missile;
_xone = sqrt (((getpos _tank select 0) - (getpos _missile select 0))^2 + ((getpos _tank select 1) - (getpos _missile select 1))^2);
_zmiss = _dist * cos (asin (_xone / _dist)) ;
_vmissvert = (velocity _missile select 2);
if (_vmissvert == 0) then { _vmissvert = 0.01};
_ttog = _zmiss / ( - _vmissvert);
_vhoriz = sqrt ((velocity _missile select 0)^2 + (velocity _missile select 1)^2);
if ( (((_ttog * _vhoriz) > (_xone - 15)) || ((_ttog * _vhoriz) < (_xone +15))) ) then {
_dummy = "RKT_detonator" camcreate position _missile;
_dummy exec "deleteme.sqs";
_arena = _arena - (_hits ^ _sectorapp);
player globalchat format ["%1,%2,%3",typeOf _dummy,_arena,_missile distance _tank];
};
};
};
};
_arena
deleteme.sqs:
~.5
deletevehicle _this
exit
See intructions on top of VIT_arena.sqs.
It's full of globalchats cause are useful to track down data.
Remove them if they annoy you. This is a version I wrote
more than a year ago and never finished cause I started
working on MCAR. I modified it today, making it more
efficient. It's not finished yet, but fell free to modify it and use in your
mission. Ask me for help if needed, and eventual bugs.
If you plan to use it in your missions or addons, no need
to credit me. Only DON'T state the script is a fruit of your
own work when infact it's a fruit of MY own work.
Down there is the old, fully commented, version. Look at
it as reference. This ones intercepts only BIS missiles and
rockets, though.