added following diagonal side of a slope corner for MM engine
authorHolger Schemel <info@artsoft.org>
Fri, 19 May 2023 14:05:08 +0000 (16:05 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 19 May 2023 14:05:08 +0000 (16:05 +0200)
src/game_mm/mm_game.c

index d66dbc846aa9d6fb7f6d7f52b1466c9df59de6bf..b258e374b7f0bbeb868be9b873e831e331394af0 100644 (file)
@@ -1702,7 +1702,26 @@ static boolean HitElement(int element, int hit_mask)
        hit_mask == HIT_MASK_TOP ||
        hit_mask == HIT_MASK_BOTTOM)
     {
-      return HitReflectingWalls(element, hit_mask);
+      boolean hit_slope_corner_in_laser_direction =
+       ((hit_mask == HIT_MASK_LEFT   && (element == EL_DF_SLOPE_01 ||
+                                         element == EL_DF_SLOPE_02)) ||
+        (hit_mask == HIT_MASK_RIGHT  && (element == EL_DF_SLOPE_00 ||
+                                         element == EL_DF_SLOPE_03)) ||
+        (hit_mask == HIT_MASK_TOP    && (element == EL_DF_SLOPE_02 ||
+                                         element == EL_DF_SLOPE_03)) ||
+        (hit_mask == HIT_MASK_BOTTOM && (element == EL_DF_SLOPE_00 ||
+                                         element == EL_DF_SLOPE_01)));
+
+      boolean hit_slope_corner_in_laser_direction_double_checked =
+       (cross_x && cross_y &&
+        laser.current_angle == mirrored_angle &&
+        hit_slope_corner_in_laser_direction);
+
+      // check special case of laser hitting the corner of a slope and another
+      // element (either wall or another slope), following the diagonal side
+      // of the slope which has the same angle as the direction of the laser
+      if (!hit_slope_corner_in_laser_direction_double_checked)
+       return HitReflectingWalls(element, hit_mask);
     }
 
     // check if an edge was hit while crossing element borders