Post by Sa8Gecko on Feb 19, 2005 10:35:58 GMT -5
Some new functions, that you can find in the latest release:
PSY_MCAR_angleOT.sqf
called by: guidMis_10.sqs
; Returns the 2D angle to steer the missile with to reach the
; target and the time this calculation has been done (for future
; usage) and a number used to know how hard the missile
; has turned
;
; Usage:
; [object,object,time,number] call PSY_MCAR_angleOT
;
; returns:
; [number,time,number]
; this routine is similar to the one (written inside a script)
; used in the script which guides the normal tow2a missile
private ["_ms","_tg","_dM","_alpha","_beta","_nD","_mT","_angle","_cf","_tR"];
_ms = _this select 0;
_tg = _this select 1;
_mT = _this select 2;
_tR = _this select 3;
_alpha = position _ms;
_beta = position _tg;
_cf = 0;
if (alive _ms) then {
_dM = direction _ms;
_nD = ((_beta select 0)-(_alpha select 0)) atan2 ((_beta select 1)-(_alpha select 1));
if( _nDr< 0) then { _nD = _nD +360;};
if( abs(_nD - _dM) > 180 && _nD < _dM) then { _nD = _nD + 360;};
if( abs(_nD - _dM) > 180 && _nD > _dM) then { _dM = _dM + 360;};
if( abs(_nD - _dM) > (_tR * (_time - _mT))) then {
_nD = _dM + (((_nD - _dM)/abs(_nD - _dM))*(_tR * (_time - _mT)));
};
_angle = _nD - _dM;
_cf = abs(_angle / (_tR * (_time - _mT)) );
} else {
_angle = 0;
};
[_angle,_time,_cf]
PSY_MCAR_delta2.sqf
called by: guidMis_16.sqs
; This function serves to detonate the proximity fuse of the
; SA-8's missile. First it checks if the target is inside the
; missile's warhead range: if it is, it checks if the missile is
; already leaving it behind, in which case the proximity fuse
; has to be detonated, and the function exits. If not it checks
; if the missile is approaching the target from its front side,
; in which case the warhead is detonated anyway.
; This kind of proximity fuse allows the missile, if it's approaching
; the target from behind it or from the sides, to go for a
; direct hit.
;
; Usage:
; [object,object,3Darray,number] call PSY_MCAR_delta2
; returns:
; a number
; (0 to let the missile go for a direct hit, 1 if the missile is
; already past the target but inside the warhead range,
; 2 if the missile is approaching from the front)
private ["_ms","_tg","_vN","_rs","_dt","_vT","_vM","_delta"];
_ms = _this select 0;
_tg = _this select 1;
_vM = _this select 2;
_dt = (_ms distance _tg);
if (_dt < (_this select 3)) then
{
_vN = _vM call PSY_MCAR_vnorm;
_vT = (velocity _tg) call PSY_MCAR_vnorm;
_rs = sqrt( ((position _ms select 0)+ (_vN select 0) - (position _tg select 0))^2 + ((position _ms select 1)+ (_vN select 1) - (position _tg select 1))^2 + ((position _ms select 2)+ (_vN select 2) - (_ms call PSY_MCAR_calcH) - (position _tg select 2) + (_tg call PSY_MCAR_calcH))^2);
if (_dt < _rs) then {_delta = 1}
else
{
if (sqrt( ((_vN select 0)-(_vT select 0))^2 + ((_vN select 1)-(_vT select 1))^2 + ((_vN select 2)-(_vT select 2))^2 )>1.7 ) then {_delta = 2}
else {_delta = 0};
};
}
else {_delta = 0};
_delta
PSY_MCAR_angleOT.sqf
called by: guidMis_10.sqs
; Returns the 2D angle to steer the missile with to reach the
; target and the time this calculation has been done (for future
; usage) and a number used to know how hard the missile
; has turned
;
; Usage:
; [object,object,time,number] call PSY_MCAR_angleOT
;
; returns:
; [number,time,number]
; this routine is similar to the one (written inside a script)
; used in the script which guides the normal tow2a missile
private ["_ms","_tg","_dM","_alpha","_beta","_nD","_mT","_angle","_cf","_tR"];
_ms = _this select 0;
_tg = _this select 1;
_mT = _this select 2;
_tR = _this select 3;
_alpha = position _ms;
_beta = position _tg;
_cf = 0;
if (alive _ms) then {
_dM = direction _ms;
_nD = ((_beta select 0)-(_alpha select 0)) atan2 ((_beta select 1)-(_alpha select 1));
if( _nDr< 0) then { _nD = _nD +360;};
if( abs(_nD - _dM) > 180 && _nD < _dM) then { _nD = _nD + 360;};
if( abs(_nD - _dM) > 180 && _nD > _dM) then { _dM = _dM + 360;};
if( abs(_nD - _dM) > (_tR * (_time - _mT))) then {
_nD = _dM + (((_nD - _dM)/abs(_nD - _dM))*(_tR * (_time - _mT)));
};
_angle = _nD - _dM;
_cf = abs(_angle / (_tR * (_time - _mT)) );
} else {
_angle = 0;
};
[_angle,_time,_cf]
PSY_MCAR_delta2.sqf
called by: guidMis_16.sqs
; This function serves to detonate the proximity fuse of the
; SA-8's missile. First it checks if the target is inside the
; missile's warhead range: if it is, it checks if the missile is
; already leaving it behind, in which case the proximity fuse
; has to be detonated, and the function exits. If not it checks
; if the missile is approaching the target from its front side,
; in which case the warhead is detonated anyway.
; This kind of proximity fuse allows the missile, if it's approaching
; the target from behind it or from the sides, to go for a
; direct hit.
;
; Usage:
; [object,object,3Darray,number] call PSY_MCAR_delta2
; returns:
; a number
; (0 to let the missile go for a direct hit, 1 if the missile is
; already past the target but inside the warhead range,
; 2 if the missile is approaching from the front)
private ["_ms","_tg","_vN","_rs","_dt","_vT","_vM","_delta"];
_ms = _this select 0;
_tg = _this select 1;
_vM = _this select 2;
_dt = (_ms distance _tg);
if (_dt < (_this select 3)) then
{
_vN = _vM call PSY_MCAR_vnorm;
_vT = (velocity _tg) call PSY_MCAR_vnorm;
_rs = sqrt( ((position _ms select 0)+ (_vN select 0) - (position _tg select 0))^2 + ((position _ms select 1)+ (_vN select 1) - (position _tg select 1))^2 + ((position _ms select 2)+ (_vN select 2) - (_ms call PSY_MCAR_calcH) - (position _tg select 2) + (_tg call PSY_MCAR_calcH))^2);
if (_dt < _rs) then {_delta = 1}
else
{
if (sqrt( ((_vN select 0)-(_vT select 0))^2 + ((_vN select 1)-(_vT select 1))^2 + ((_vN select 2)-(_vT select 2))^2 )>1.7 ) then {_delta = 2}
else {_delta = 0};
};
}
else {_delta = 0};
_delta