Post by Sa8Gecko on Mar 21, 2007 9:29:39 GMT -5
As you probably know, the tow which comes with version 1.00 to 1.05 of Armed Assault cannot be guided by hand. Here's a simple script, still written in OFP way as it's only a test, to 'adjust' the thing:
First thing to do is to place in the 'Initialization:' field of the unit (I just tested for the HMMWV TOW vehicle) this line:
and then save the mission in the mission editor and in the same folder place the script, saved under the name of 'fired.sqs': you should be good to go.
Please note: since the BIS TOW missile was too fast, the script provides to adjust it to the correct (almost) speed as in real life. For this reason max range is also reduced (as in real life) to 3600 meters. Don't lock the target you mean to attack, otherwise the missile will automatically steer to it (of course). For lack of time the turn rate of the missile is not controlled in any way. A further version will check for this too. I've not tested it with AI as gunners, as probably it won't work correctly. If positive feedback is encountered, we may consider releasing a simple addon (tow humvee), using the actual BIS model, but with scoped optics and of course this manual guidance script. So please check this out and report back your impressions.
_missile=nearestObject[_this select 0,_this select 1]
if(typeOf(_missile) != "M_TOW_AT")then{exit}
_shooter= vehicle (_this select 0)
;player globalchat format["%1",[_missile,_shooter]]
_speed=5
_mis2Time=_time-.001
_M_bnt=1.5
_M_exh=2100
_M_mas=22.5
_M_mtr=90
_M_frC=".9+exp(-300/(_speed))"
_M_kgs=2.15
_M_Int=0
_M_fm=19.275
#loop
_dir =_shooter weapondirection "TOWLAUNCHERSINGLE"
_d = 50 + (_missile distance _shooter)
_sPos = getposASL _shooter
_vel= velocity _missile
_frC=call compile _M_frC
if(_frC<0)then{_frC=0;};
if(_time<_M_bnT)then{_M_Int=_M_Int+((_time-_mis2Time)*_M_kgs);_speed=_speed+(((_M_exh*_M_kgs)/(_M_mas-_M_Int))-_speed *((_frC*_M_kgs+_frC*(_M_mas-_M_Int))/((_M_mas-_M_Int)^2)))*(_time-_mis2Time);comment{player globalchat format["%1",[_speed]]};}else{_speed=_speed-_speed*(_frC/_M_Fm)*(_time-_mis2Time);comment{player globalchat format["%1",[_time,_missile distance _shooter,_speed]]};};
_mPos = getposASL _missile
_tpos = [(_sPos select 0)+_d*(_dir select 0),(_sPos select 1)+_d*(_dir select 1),(_sPos select 2)+_d*(_dir select 2)+2]
_vecInt= sqrt( ((_tpos select 0)-(_mpos select 0))^2+((_tpos select 1)-(_mpos select 1))^2+((_tpos select 2)-(_mpos select 2))^2)
_dir2 = [((_tpos select 0)-(_mpos select 0))/_vecInt,((_tpos select 1)-(_mpos select 1))/_vecInt,((_tpos select 2)-(_mpos select 2))/_vecInt]
_missile setvelocity [_speed*(_dir2 select 0),_speed*(_dir2 select 1),_speed*(_dir2 select 2)]
_mis2Time=_time
~.025
if(!alive _missile)then{exit}
;player globalchat format["%1",[_time,_missile distance _shooter,_speed,_frC]]
goto "loop"
First thing to do is to place in the 'Initialization:' field of the unit (I just tested for the HMMWV TOW vehicle) this line:
this addEventHandler ["fired",{[_this select 0,_this select 4] exec "fired.sqs"}]
and then save the mission in the mission editor and in the same folder place the script, saved under the name of 'fired.sqs': you should be good to go.
Please note: since the BIS TOW missile was too fast, the script provides to adjust it to the correct (almost) speed as in real life. For this reason max range is also reduced (as in real life) to 3600 meters. Don't lock the target you mean to attack, otherwise the missile will automatically steer to it (of course). For lack of time the turn rate of the missile is not controlled in any way. A further version will check for this too. I've not tested it with AI as gunners, as probably it won't work correctly. If positive feedback is encountered, we may consider releasing a simple addon (tow humvee), using the actual BIS model, but with scoped optics and of course this manual guidance script. So please check this out and report back your impressions.