X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_mm%2Fmm_game.c;h=316c891edea811616016ef637d49bde1764c50ed;hb=3ca52442121dc311d2ead0dbf3b366ea367fcdeb;hp=a68a64b692193e54d820fcf94fb79805200877b7;hpb=7bedd910f0f469c78d51a0c90f679258d5b0ced7;p=rocksndiamonds.git diff --git a/src/game_mm/mm_game.c b/src/game_mm/mm_game.c index a68a64b6..316c891e 100644 --- a/src/game_mm/mm_game.c +++ b/src/game_mm/mm_game.c @@ -433,9 +433,9 @@ static void SetLaserColor(int brightness) pen_ray = GetPixelFromRGB(window, - (native_mm_level.laser_red ? color_max : color_up), - (native_mm_level.laser_green ? color_down : color_min), - (native_mm_level.laser_blue ? color_down : color_min)); + (game_mm.laser_red ? color_max : color_up), + (game_mm.laser_green ? color_down : color_min), + (game_mm.laser_blue ? color_down : color_min)); } static void InitMovDir_MM(int x, int y) @@ -538,6 +538,19 @@ static void InitField(int x, int y) laser.start_edge.x = x; laser.start_edge.y = y; laser.start_angle = get_element_angle(element); + + if (IS_MCDUFFIN(element)) + { + game_mm.laser_red = native_mm_level.mm_laser_red; + game_mm.laser_green = native_mm_level.mm_laser_green; + game_mm.laser_blue = native_mm_level.mm_laser_blue; + } + else + { + game_mm.laser_red = native_mm_level.df_laser_red; + game_mm.laser_green = native_mm_level.df_laser_green; + game_mm.laser_blue = native_mm_level.df_laser_blue; + } } break; @@ -627,6 +640,10 @@ void InitGameEngine_MM(void) game_mm.num_keys = 0; game_mm.ball_choice_pos = 0; + game_mm.laser_red = FALSE; + game_mm.laser_green = FALSE; + game_mm.laser_blue = TRUE; + game_mm.level_solved = FALSE; game_mm.game_over = FALSE; game_mm.game_over_cause = 0; @@ -916,29 +933,44 @@ static int ScanPixel(void) return hit_mask; } -void ScanLaser(void) +static void DeactivateLaserTargetElement(void) { - int element; - int end = 0, rf = laser.num_edges; - - // do not scan laser again after the game was lost for whatever reason - if (game_mm.game_over) - return; - if (laser.dest_element_last == EL_BOMB_ACTIVE || - laser.dest_element_last == EL_MINE_ACTIVE) + laser.dest_element_last == EL_MINE_ACTIVE || + laser.dest_element_last == EL_GRAY_BALL_OPENING) { int x = laser.dest_element_last_x; int y = laser.dest_element_last_y; int element = laser.dest_element_last; if (Tile[x][y] == element) - Tile[x][y] = (element == EL_BOMB_ACTIVE ? EL_BOMB : EL_MINE); + Tile[x][y] = (element == EL_BOMB_ACTIVE ? EL_BOMB : + element == EL_MINE_ACTIVE ? EL_MINE : EL_BALL_GRAY); + + if (Tile[x][y] == EL_BALL_GRAY) + MovDelay[x][y] = 0; laser.dest_element_last = EL_EMPTY; laser.dest_element_last_x = -1; laser.dest_element_last_y = -1; } +} + +void ScanLaser(void) +{ + int element = EL_EMPTY; + int last_element = EL_EMPTY; + int end = 0, rf = laser.num_edges; + + // do not scan laser again after the game was lost for whatever reason + if (game_mm.game_over) + return; + + // do not scan laser if fuse is off + if (laser.fuse_off) + return; + + DeactivateLaserTargetElement(); laser.overloaded = FALSE; laser.stops_inside_element = FALSE; @@ -1013,6 +1045,8 @@ void ScanLaser(void) hit_mask, LX, LY, ELX, ELY); #endif + last_element = element; + element = Tile[ELX][ELY]; laser.dest_element = element; @@ -1031,6 +1065,12 @@ void ScanLaser(void) ELX, ELY, element); #endif + // special case: leaving fixed MM steel grid (upwards) with non-90° angle + if (element == EL_EMPTY && + IS_GRID_STEEL(last_element) && + laser.current_angle % 4) // angle is not 90° + element = last_element; + if (element == EL_EMPTY) { if (!HitOnlyAnEdge(hit_mask)) @@ -1089,6 +1129,14 @@ void ScanLaser(void) if (rf) DrawLaser(rf - 1, DL_LASER_ENABLED); rf = laser.num_edges; + + if (!IS_DF_WALL_STEEL(element)) + { + // only used for scanning DF steel walls; reset for all other elements + last_LX = 0; + last_LY = 0; + last_hit_mask = 0; + } } #if 0 @@ -1315,6 +1363,13 @@ static void DrawLaserExt(int start_edge, int num_edges, int mode) void DrawLaser(int start_edge, int mode) { + // do not draw laser if fuse is off + if (laser.fuse_off && mode == DL_LASER_ENABLED) + return; + + if (mode == DL_LASER_DISABLED) + DeactivateLaserTargetElement(); + if (laser.num_edges - start_edge < 0) { Warn("DrawLaser: laser.num_edges - start_edge < 0"); @@ -1427,6 +1482,10 @@ boolean HitElement(int element, int hit_mask) // this is more precise: check if laser would go through the center if ((ELX * TILEX + 14 - LX) * YS != (ELY * TILEY + 14 - LY) * XS) { + // prevent cutting through laser emitter with laser beam + if (IS_LASER(element)) + return TRUE; + // skip the whole element before continuing the scan do { @@ -2403,7 +2462,8 @@ static void OpenSurpriseBall(int x, int y) if (!MovDelay[x][y]) { Tile[x][y] = Store[x][y]; - Store[x][y] = 0; + Store[x][y] = Store2[x][y] = 0; + DrawField_MM(x, y); ScanLaser(); @@ -3334,29 +3394,38 @@ static void GameActions_MM_Ext(void) if (element == EL_BALL_GRAY && CT > native_mm_level.time_ball) { - int last_anim_random_frame = gfx.anim_random_frame; - int element_pos; + if (!Store2[ELX][ELY]) // check if content element not yet determined + { + int last_anim_random_frame = gfx.anim_random_frame; + int element_pos; - if (native_mm_level.ball_choice_mode == ANIM_RANDOM) - gfx.anim_random_frame = RND(native_mm_level.num_ball_contents); + if (native_mm_level.ball_choice_mode == ANIM_RANDOM) + gfx.anim_random_frame = RND(native_mm_level.num_ball_contents); - element_pos = getAnimationFrame(native_mm_level.num_ball_contents, 1, - native_mm_level.ball_choice_mode, 0, - game_mm.ball_choice_pos); + element_pos = getAnimationFrame(native_mm_level.num_ball_contents, 1, + native_mm_level.ball_choice_mode, 0, + game_mm.ball_choice_pos); - if (native_mm_level.ball_choice_mode == ANIM_RANDOM) - gfx.anim_random_frame = last_anim_random_frame; + if (native_mm_level.ball_choice_mode == ANIM_RANDOM) + gfx.anim_random_frame = last_anim_random_frame; - game_mm.ball_choice_pos++; + game_mm.ball_choice_pos++; - int new_element = native_mm_level.ball_content[element_pos]; + int new_element = native_mm_level.ball_content[element_pos]; + + Store[ELX][ELY] = new_element + RND(get_num_elements(new_element)); + Store2[ELX][ELY] = TRUE; + } - Store[ELX][ELY] = new_element + RND(get_num_elements(new_element)); Tile[ELX][ELY] = EL_GRAY_BALL_OPENING; // !!! CHECK AGAIN: Laser on Polarizer !!! ScanLaser(); + laser.dest_element_last = Tile[ELX][ELY]; + laser.dest_element_last_x = ELX; + laser.dest_element_last_y = ELY; + return; #if 0