Update of missile-code

This commit is contained in:
Nikolai V. Chr 2022-01-04 03:42:37 +01:00
parent ac519b3e89
commit 1b1504a4b1
3 changed files with 16 additions and 12 deletions

View File

@ -1600,6 +1600,7 @@ var AIM = {
me.sun_enabled = TRUE; me.sun_enabled = TRUE;
me.sun = geo.Coord.new(); me.sun = geo.Coord.new();
me.sun.set_xyz(me.ac_init.x()+sun_x*2000000, me.ac_init.y()+sun_y*2000000, me.ac_init.z()+sun_z*2000000);#heat seeking missiles don't fly far, so setting it 2000Km away is fine. me.sun.set_xyz(me.ac_init.x()+sun_x*2000000, me.ac_init.y()+sun_y*2000000, me.ac_init.z()+sun_z*2000000);#heat seeking missiles don't fly far, so setting it 2000Km away is fine.
me.sun.alt();# TODO: once fixed in FG this line is no longer needed.
} else { } else {
# old FG versions does not supply location of sun. So this feature gets disabled. # old FG versions does not supply location of sun. So this feature gets disabled.
me.sun_enabled = FALSE; me.sun_enabled = FALSE;
@ -3581,8 +3582,8 @@ var AIM = {
me.raw_steer_signal_head = me.curr_deviation_h; me.raw_steer_signal_head = me.curr_deviation_h;
if (me.cruise_or_loft == FALSE) { if (me.cruise_or_loft == FALSE) {
me.raw_steer_signal_elev = me.curr_deviation_e; me.raw_steer_signal_elev = me.curr_deviation_e;
me.attitudePN = math.atan2(-(me.speed_down_fps+g_fps * me.dt), me.speed_horizontal_fps ) * R2D; me.attitudePN = (math.atan2(-(me.speed_down_fps+g_fps * me.dt), me.speed_horizontal_fps ) - math.atan2(-me.speed_down_fps, me.speed_horizontal_fps )) * R2D;
me.gravComp = me.pitch - me.attitudePN; me.gravComp = - me.attitudePN;
#printf("Gravity compensation %0.2f degs", me.gravComp); #printf("Gravity compensation %0.2f degs", me.gravComp);
me.raw_steer_signal_elev += me.gravComp; me.raw_steer_signal_elev += me.gravComp;
} }
@ -3733,8 +3734,8 @@ var AIM = {
} }
if (me.fixed_aim != nil and me.life_time < me.fixed_aim_time) { if (me.fixed_aim != nil and me.life_time < me.fixed_aim_time) {
me.raw_steer_signal_elev = me.curr_deviation_e+me.fixed_aim; me.raw_steer_signal_elev = me.curr_deviation_e+me.fixed_aim;
me.attitudePN = math.atan2(-(me.speed_down_fps+g_fps * me.dt), me.speed_horizontal_fps ) * R2D; me.attitudePN = (math.atan2(-(me.speed_down_fps+g_fps * me.dt), me.speed_horizontal_fps ) - math.atan2(-me.speed_down_fps, me.speed_horizontal_fps )) * R2D;
me.gravComp = me.pitch - me.attitudePN; me.gravComp = - me.attitudePN;
#printf("Gravity compensation %0.2f degs", me.gravComp); #printf("Gravity compensation %0.2f degs", me.gravComp);
me.raw_steer_signal_elev += me.gravComp; me.raw_steer_signal_elev += me.gravComp;
} else { } else {
@ -3792,8 +3793,8 @@ var AIM = {
} }
# now compensate for the predicted gravity drop of attitude: # now compensate for the predicted gravity drop of attitude:
me.attitudePN = math.atan2(-(me.speed_down_fps+g_fps * me.dt), me.speed_horizontal_fps ) * R2D; me.attitudePN = (math.atan2(-(me.speed_down_fps+g_fps * me.dt), me.speed_horizontal_fps ) - math.atan2(-me.speed_down_fps, me.speed_horizontal_fps )) * R2D;
me.gravComp = me.pitch - me.attitudePN; me.gravComp = -me.attitudePN;
#printf("Gravity compensation %0.2f degs", me.gravComp); #printf("Gravity compensation %0.2f degs", me.gravComp);
me.raw_steer_signal_elev += me.gravComp; me.raw_steer_signal_elev += me.gravComp;
@ -3964,6 +3965,7 @@ var AIM = {
me.crc_closestRange = me.myMath.magnitudeVector(me.myMath.minus(targetCoord, missileCoord)); me.crc_closestRange = me.myMath.magnitudeVector(me.myMath.minus(targetCoord, missileCoord));
me.crc_missileCoord = geo.Coord.new(); me.crc_missileCoord = geo.Coord.new();
me.crc_missileCoord.set_xyz(missileCoord[0], missileCoord[1], missileCoord[2]); me.crc_missileCoord.set_xyz(missileCoord[0], missileCoord[1], missileCoord[2]);
me.crc_missileCoord.alt();# TODO: once fixed in FG this line is no longer needed.
}, },
log: func (str) { log: func (str) {

View File

@ -1600,6 +1600,7 @@ var AIM = {
me.sun_enabled = TRUE; me.sun_enabled = TRUE;
me.sun = geo.Coord.new(); me.sun = geo.Coord.new();
me.sun.set_xyz(me.ac_init.x()+sun_x*2000000, me.ac_init.y()+sun_y*2000000, me.ac_init.z()+sun_z*2000000);#heat seeking missiles don't fly far, so setting it 2000Km away is fine. me.sun.set_xyz(me.ac_init.x()+sun_x*2000000, me.ac_init.y()+sun_y*2000000, me.ac_init.z()+sun_z*2000000);#heat seeking missiles don't fly far, so setting it 2000Km away is fine.
me.sun.alt();# TODO: once fixed in FG this line is no longer needed.
} else { } else {
# old FG versions does not supply location of sun. So this feature gets disabled. # old FG versions does not supply location of sun. So this feature gets disabled.
me.sun_enabled = FALSE; me.sun_enabled = FALSE;
@ -3581,8 +3582,8 @@ var AIM = {
me.raw_steer_signal_head = me.curr_deviation_h; me.raw_steer_signal_head = me.curr_deviation_h;
if (me.cruise_or_loft == FALSE) { if (me.cruise_or_loft == FALSE) {
me.raw_steer_signal_elev = me.curr_deviation_e; me.raw_steer_signal_elev = me.curr_deviation_e;
me.attitudePN = math.atan2(-(me.speed_down_fps+g_fps * me.dt), me.speed_horizontal_fps ) * R2D; me.attitudePN = (math.atan2(-(me.speed_down_fps+g_fps * me.dt), me.speed_horizontal_fps ) - math.atan2(-me.speed_down_fps, me.speed_horizontal_fps )) * R2D;
me.gravComp = me.pitch - me.attitudePN; me.gravComp = - me.attitudePN;
#printf("Gravity compensation %0.2f degs", me.gravComp); #printf("Gravity compensation %0.2f degs", me.gravComp);
me.raw_steer_signal_elev += me.gravComp; me.raw_steer_signal_elev += me.gravComp;
} }
@ -3733,8 +3734,8 @@ var AIM = {
} }
if (me.fixed_aim != nil and me.life_time < me.fixed_aim_time) { if (me.fixed_aim != nil and me.life_time < me.fixed_aim_time) {
me.raw_steer_signal_elev = me.curr_deviation_e+me.fixed_aim; me.raw_steer_signal_elev = me.curr_deviation_e+me.fixed_aim;
me.attitudePN = math.atan2(-(me.speed_down_fps+g_fps * me.dt), me.speed_horizontal_fps ) * R2D; me.attitudePN = (math.atan2(-(me.speed_down_fps+g_fps * me.dt), me.speed_horizontal_fps ) - math.atan2(-me.speed_down_fps, me.speed_horizontal_fps )) * R2D;
me.gravComp = me.pitch - me.attitudePN; me.gravComp = - me.attitudePN;
#printf("Gravity compensation %0.2f degs", me.gravComp); #printf("Gravity compensation %0.2f degs", me.gravComp);
me.raw_steer_signal_elev += me.gravComp; me.raw_steer_signal_elev += me.gravComp;
} else { } else {
@ -3792,8 +3793,8 @@ var AIM = {
} }
# now compensate for the predicted gravity drop of attitude: # now compensate for the predicted gravity drop of attitude:
me.attitudePN = math.atan2(-(me.speed_down_fps+g_fps * me.dt), me.speed_horizontal_fps ) * R2D; me.attitudePN = (math.atan2(-(me.speed_down_fps+g_fps * me.dt), me.speed_horizontal_fps ) - math.atan2(-me.speed_down_fps, me.speed_horizontal_fps )) * R2D;
me.gravComp = me.pitch - me.attitudePN; me.gravComp = -me.attitudePN;
#printf("Gravity compensation %0.2f degs", me.gravComp); #printf("Gravity compensation %0.2f degs", me.gravComp);
me.raw_steer_signal_elev += me.gravComp; me.raw_steer_signal_elev += me.gravComp;
@ -3964,6 +3965,7 @@ var AIM = {
me.crc_closestRange = me.myMath.magnitudeVector(me.myMath.minus(targetCoord, missileCoord)); me.crc_closestRange = me.myMath.magnitudeVector(me.myMath.minus(targetCoord, missileCoord));
me.crc_missileCoord = geo.Coord.new(); me.crc_missileCoord = geo.Coord.new();
me.crc_missileCoord.set_xyz(missileCoord[0], missileCoord[1], missileCoord[2]); me.crc_missileCoord.set_xyz(missileCoord[0], missileCoord[1], missileCoord[2]);
me.crc_missileCoord.alt();# TODO: once fixed in FG this line is no longer needed.
}, },
log: func (str) { log: func (str) {

BIN
S-75/Sounds/launch.wav Normal file

Binary file not shown.