X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_mm%2Fmm_game.c;h=de372a864479b3d1c9c072f3db57f32e5e7f06e9;hb=a3195af55b8970b94334efa3d1383ad5e6ee0c17;hp=cda5e6aee9db15eba2061ac419ba873fe2125ae9;hpb=c602135de533bbffabc4e284156b79fe156e884c;p=rocksndiamonds.git diff --git a/src/game_mm/mm_game.c b/src/game_mm/mm_game.c index cda5e6ae..de372a86 100644 --- a/src/game_mm/mm_game.c +++ b/src/game_mm/mm_game.c @@ -1049,24 +1049,51 @@ static void ScanLaser(void) break; } - if (hit_mask == (HIT_MASK_TOPRIGHT | HIT_MASK_BOTTOMLEFT)) - { - /* we have hit the top-right and bottom-left element -- - choose the bottom-left one */ - /* !!! THIS CAN BE DONE MORE INTELLIGENTLY, FOR EXAMPLE, IF ONE - ELEMENT WAS STEEL AND THE OTHER ONE WAS ICE => ALWAYS CHOOSE - THE ICE AND MELT IT AWAY INSTEAD OF OVERLOADING LASER !!! */ - ELX = (LX - 2) / TILEX; - ELY = (LY + 2) / TILEY; - } + // check if laser scan has hit two diagonally adjacent element corners + boolean diag_1 = ((hit_mask & HIT_MASK_DIAGONAL_1) == HIT_MASK_DIAGONAL_1); + boolean diag_2 = ((hit_mask & HIT_MASK_DIAGONAL_2) == HIT_MASK_DIAGONAL_2); - if (hit_mask == (HIT_MASK_TOPLEFT | HIT_MASK_BOTTOMRIGHT)) + // check if laser scan has crossed element boundaries (not just mini tiles) + boolean cross_x = (LX / TILEX != (LX + 2) / TILEX); + boolean cross_y = (LY / TILEY != (LY + 2) / TILEY); + + // handle special case of laser hitting two diagonally adjacent elements + // (with or without a third corner element behind these two elements) + if ((diag_1 || diag_2) && cross_x && cross_y) { - /* we have hit the top-left and bottom-right element -- - choose the top-left one */ - // !!! SEE ABOVE !!! - ELX = (LX - 2) / TILEX; - ELY = (LY - 2) / TILEY; + // compare the two diagonally adjacent elements + int xoffset = 2; + int yoffset = 2 * (diag_1 ? -1 : +1); + int elx1 = (LX - xoffset) / TILEX; + int ely1 = (LY + yoffset) / TILEY; + int elx2 = (LX + xoffset) / TILEX; + int ely2 = (LY - yoffset) / TILEY; + int e1 = Tile[elx1][ely1]; + int e2 = Tile[elx2][ely2]; + boolean use_element_1 = FALSE; + + if (IS_WALL_ICE(e1) || IS_WALL_ICE(e2)) + { + if (IS_WALL_ICE(e1) && IS_WALL_ICE(e2)) + use_element_1 = (RND(2) ? TRUE : FALSE); + else if (IS_WALL_ICE(e1)) + use_element_1 = TRUE; + } + else if (IS_WALL_AMOEBA(e1) || IS_WALL_AMOEBA(e2)) + { + // if both tiles match, we can just select the first one + if (IS_WALL_AMOEBA(e1)) + use_element_1 = TRUE; + } + else if (IS_ABSORBING_BLOCK(e1) || IS_ABSORBING_BLOCK(e2)) + { + // if both tiles match, we can just select the first one + if (IS_ABSORBING_BLOCK(e1)) + use_element_1 = TRUE; + } + + ELX = (use_element_1 ? elx1 : elx2); + ELY = (use_element_1 ? ely1 : ely2); } #if 0 @@ -2405,10 +2432,18 @@ static boolean HitAbsorbingWalls(int element, int hit_mask) if (IS_WALL_ICE(element)) { + int lx = LX + XS; + int ly = LY + YS; int mask; - mask = (LX + XS) / MINI_TILEX - ELX * 2 + 1; // Quadrant (horizontal) - mask <<= (((LY + YS) / MINI_TILEY - ELY * 2) > 0) * 2; // || (vertical) + // check if laser hit adjacent edges of two diagonal tiles + if (ELX != lx / TILEX) + lx = LX - XS; + if (ELY != ly / TILEY) + ly = LY - YS; + + mask = lx / MINI_TILEX - ELX * 2 + 1; // Quadrant (horizontal) + mask <<= ((ly / MINI_TILEY - ELY * 2) > 0 ? 2 : 0); // || (vertical) // check if laser hits wall with an angle of 90° if (IS_90_ANGLE(laser.current_angle)) @@ -2727,12 +2762,14 @@ static void Explode_MM(int x, int y, int phase, int mode) Tile[x][y] = center_element; } - Store[x][y] = EL_EMPTY; + if (center_element != EL_GRAY_BALL_ACTIVE) + Store[x][y] = EL_EMPTY; Store2[x][y] = center_element; Tile[x][y] = EL_EXPLODING_OPAQUE; GfxElement[x][y] = (center_element == EL_BOMB_ACTIVE ? EL_BOMB : + center_element == EL_GRAY_BALL_ACTIVE ? EL_GRAY_BALL : IS_MCDUFFIN(center_element) ? EL_MCDUFFIN : center_element); @@ -2783,6 +2820,9 @@ static void Explode_MM(int x, int y, int phase, int mode) InitField(x, y, FALSE); DrawField_MM(x, y); + + if (center_element == EL_GRAY_BALL_ACTIVE) + ScanLaser_FromLastMirror(); } else if (!(phase % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) { @@ -3497,9 +3537,12 @@ static void GameActions_MM_Ext(void) Store2[ELX][ELY] = TRUE; } - Tile[ELX][ELY] = EL_GRAY_BALL_OPENING; + if (native_mm_level.explode_ball) + Bang_MM(ELX, ELY); + else + Tile[ELX][ELY] = EL_GRAY_BALL_OPENING; - laser.dest_element_last = Tile[ELX][ELY]; + laser.dest_element = laser.dest_element_last = Tile[ELX][ELY]; return; }