nuxil 2 Posted March 19, 2007 hi.. im trying to make a Anti air craft script.. wher a unit simulates a sam site or other kind of aa vehicles.. i use a stryker for my aa vehicle.. it shoots out a missile "M_Ch29_AT" and should tryes to track the target, which is air type. however,, i cant adjust the vectorUp.. guess my skriping skill isnt good enought yet,, so i have to use sevelocity instead.. which looks weird.. cos the missil is going in a kind of ossilation state.. _-_-_-_ :P <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> sleep 1; //need the mission to compleate the load.. sleep (1+(random 3)); _AAvehicle = (_this select 0); _i=0; for [{_i=0},{_i<1},{_i=_i}] do { WestTriggerOne = createTrigger ["EmptyDetector", position _AAvehicle]; WestTriggerOne setTriggerActivation ["EAST", "PRESENT", true]; WestTriggerOne setTriggerType "NONE"; WestTriggerOne setTriggerArea [2500, 2500, 30, false ]; sleep 2; //get a list of enemy units inside the trigger. _whohere = list WestTriggerOne; _nr=count (_whohere); _a=0; for [{_a=0},{_a<_nr},{_a=_a+1}] do { //make the trigger big.. //? WestTriggerOne setTriggerArea [2500, 2500, 0, false ]; _unit = _whohere select _a; _nameAA= name _AAvehicle; _HELI=30; _PLAIN=90; _Value=0; _locktime=0; _Eclass=typeof _unit; _Ename= name _unit; _Ehight = getpos _unit select 2; _b=0; if ((_Eclass == "Su34") || (_Eclass == "Su34B")) then { _Value=_PLAIN; _locktime=3; } else { _Value=_HELI; _locktime=2; }; // end class if ((side _unit != side _AAvehicle) && (_unit iskindOf "AIR") && (_Ehight > _Value) && (_Ehight < 800) && ((getdammage _unit) <0.8)) then { _lockon=format["West: %1 locking on\nEast: %2,",_nameAA , _Ename]; hint format["%1", _lockon]; sleep (_locktime); hint ""; //check the hight again,,, we want to be able to avoid the AA vehicle.. if ( _Ehight < _Value ) then { _b=1; }; _missil = "M_Ch29_AT" createVehicle [0,0,0]; _missil setpos [(getpos _AAvehicle select 0),(getpos _AAvehicle select 1),(getpos _AAvehicle select 2)+ 3.5]; // need the missile to launch verticaly.. _missil setvectorUp [0,1,-1]; //_missil setvelocity [0,0,50]; //_missil setvectordir [1,0,0]; sleep 1; while {(alive _missil) && (_b == 0)} do { // "n e s w" hight so on.. _targetpos = getpos _unit; _tx = _targetpos select 0; _ty = _targetpos select 1; _tz = _targetpos select 2; _missilpos = getpos _missil; _mx = _missilpos select 0; _my = _missilpos select 1; _mz = _missilpos select 2; // missil direction _heading = getdir _missil; // Trigometri _hypotenus = [_mx,_my,0] distance [_tx,_ty,0]; // position of the target, and calculate new heading,, divide into 4 sectors. if ((_mx < _tx) && (_my < _ty)) then { _hoskatet = [_mx,_my,0] distance [_tx,_my,0]; _motkatet = [_tx,_my,0] distance [_tx,_ty,0]; _tanvink=( _motkatet / _hoskatet ); _reelvink = atan _tanvink; _nyheading = 90 - _reelvink; _missil setdir _nyheading; }; if ((_mx < _tx) && (_my > _ty)) then { _hoskatet = [_mx,_my,0] distance [_tx,_my,0]; _motkatet = [_tx,_my,0] distance [_tx,_ty,0]; _tanvink=( _motkatet / _hoskatet ); _reelvink = atan _tanvink; _vx = 90 + _reelvink; _nyheading = _vx; _missil setdir _vx; }; if ((_mx > _tx) && (_my > _ty)) then { _hoskatet = [_mx,_my,0] distance [_mx,_ty,0]; _motkatet = [_mx,_ty,0] distance [_tx,_ty,0]; _tanvink=( _motkatet / _hoskatet ); _reelvink = atan _tanvink; _nyheading = 180 + _reelvink; _missil setdir _nyheading; }; if ((_mx > _tx) && (_my < _ty)) then { _hoskatet = [_mx,_my,0] distance [_tx,_my,0]; _motkatet = [_tx,_my,0] distance [_tx,_ty,0]; _tanvink=( _motkatet / _hoskatet ); _reelvink = atan _tanvink; _nyheading = 270 + _reelvink; _missil setdir _nyheading; }; // check the hight for the missile and compared to the target. if (_mz > _tz) then { _vel = velocity _missil; _dir = direction _missil; _speed = 5; // move missile down.. ( think its better with setvectrorUp.. but dont know howto do it,, _missil setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+(cos _dir*_speed),-350]; }; if (_mz < _tz) then { _vel = velocity _missil; _dir = direction _missil; _speed = 5; // move missile up.. ( think its better with setvectrorUp.. but dont know howto do it,, _missil setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+(cos _dir*_speed),350]; }; sleep 0.001; }; //end the while hint ""; // resize the trigger after the shots WestTriggerOne setTriggerArea [5, 5, 30, false ]; }; // end if iskindOf "AIR" //check the status of the unit we just shot at.. if (getdammage _unit < 0.8) then {_a=_a; _b = 0;} else {_a=_nr; hint ""; }; }; // end 2nd loop //check if ower unit is dead.. and end the loop if aavehicle is dead. if (( _AAvehicle in _AAvehicle ) && (getdammage _AAvehicle < 0.7)) then {_i=_i;} else {_i=1;}; }; // end 1st loop to test the script just do var=[this] execvm "script.sqf" can anyone help? i know ther are variables uses over again with diff name :\ it nees a bit of cleaning up.. anyone Share this post Link to post Share on other sites