{ "df_mirror_fixed_16.ypos", "10" },
{ "df_mirror_fixed_16.frames", "1" },
+ { "df_slope_1", "RocksDF.png" },
+ { "df_slope_1.xpos", "0" },
+ { "df_slope_1.ypos", "11" },
+ { "df_slope_1.frames", "1" },
+ { "df_slope_2", "RocksDF.png" },
+ { "df_slope_2.xpos", "1" },
+ { "df_slope_2.ypos", "11" },
+ { "df_slope_2.frames", "1" },
+ { "df_slope_3", "RocksDF.png" },
+ { "df_slope_3.xpos", "2" },
+ { "df_slope_3.ypos", "11" },
+ { "df_slope_3.frames", "1" },
+ { "df_slope_4", "RocksDF.png" },
+ { "df_slope_4.xpos", "3" },
+ { "df_slope_4.ypos", "11" },
+ { "df_slope_4.frames", "1" },
+
// (these are only defined as elements to support ".PANEL" definitions)
{ "graphic_1", UNDEFINED_FILENAME },
{ "graphic_2", UNDEFINED_FILENAME },
#define MM_MASK_GRID_2 5
#define MM_MASK_GRID_3 6
#define MM_MASK_GRID_4 7
-#define MM_MASK_RECTANGLE 8
-#define MM_MASK_CIRCLE 9
+#define MM_MASK_SLOPE_1 8
+#define MM_MASK_SLOPE_2 9
+#define MM_MASK_SLOPE_3 10
+#define MM_MASK_SLOPE_4 11
+#define MM_MASK_RECTANGLE 12
+#define MM_MASK_CIRCLE 13
-#define NUM_MM_MASKS 10
+#define NUM_MM_MASKS 14
// element masks for scanning pixels of MM elements
static const char mm_masks[NUM_MM_MASKS][16][16 + 1] =
" XXX XXXX ",
" XX XXXXX ",
},
+ {
+ " X",
+ " XX",
+ " XXX",
+ " XXXX",
+ " XXXXX",
+ " XXXXXX",
+ " XXXXXXX",
+ " XXXXXXXX",
+ " XXXXXXXXX",
+ " XXXXXXXXXX",
+ " XXXXXXXXXXX",
+ " XXXXXXXXXXXX",
+ " XXXXXXXXXXXXX",
+ " XXXXXXXXXXXXXX",
+ " XXXXXXXXXXXXXXX",
+ "XXXXXXXXXXXXXXXX",
+ },
+ {
+ "X ",
+ "XX ",
+ "XXX ",
+ "XXXX ",
+ "XXXXX ",
+ "XXXXXX ",
+ "XXXXXXX ",
+ "XXXXXXXX ",
+ "XXXXXXXXX ",
+ "XXXXXXXXXX ",
+ "XXXXXXXXXXX ",
+ "XXXXXXXXXXXX ",
+ "XXXXXXXXXXXXX ",
+ "XXXXXXXXXXXXXX ",
+ "XXXXXXXXXXXXXXX ",
+ "XXXXXXXXXXXXXXXX",
+ },
+ {
+ "XXXXXXXXXXXXXXXX",
+ "XXXXXXXXXXXXXXX ",
+ "XXXXXXXXXXXXXX ",
+ "XXXXXXXXXXXXX ",
+ "XXXXXXXXXXXX ",
+ "XXXXXXXXXXX ",
+ "XXXXXXXXXX ",
+ "XXXXXXXXX ",
+ "XXXXXXXX ",
+ "XXXXXXX ",
+ "XXXXXX ",
+ "XXXXX ",
+ "XXXX ",
+ "XXX ",
+ "XX ",
+ "X ",
+ },
+ {
+ "XXXXXXXXXXXXXXXX",
+ " XXXXXXXXXXXXXXX",
+ " XXXXXXXXXXXXXX",
+ " XXXXXXXXXXXXX",
+ " XXXXXXXXXXXX",
+ " XXXXXXXXXXX",
+ " XXXXXXXXXX",
+ " XXXXXXXXX",
+ " XXXXXXXX",
+ " XXXXXXX",
+ " XXXXXX",
+ " XXXXX",
+ " XXXX",
+ " XXX",
+ " XX",
+ " X",
+ },
{
"XXXXXXXXXXXXXXXX",
"XXXXXXXXXXXXXXXX",
IS_LASER(element) ||
IS_RECEIVER(element))
return 4 * element_phase;
+ else if (IS_DF_SLOPE(element))
+ return 4 + (element_phase % 2) * 8;
else
return element_phase;
}
return MM_MASK_GRID_1 + get_element_phase(element);
else if (IS_DF_GRID(element))
return MM_MASK_RECTANGLE;
+ else if (IS_DF_SLOPE(element))
+ return MM_MASK_SLOPE_1 + get_element_phase(element);
else if (IS_RECTANGLE(element))
return MM_MASK_RECTANGLE;
else
break;
}
+ boolean diagonally_adjacent_hit = FALSE;
+
// 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)
{
+ diagonally_adjacent_hit = TRUE;
+
// compare the two diagonally adjacent elements
int xoffset = 2;
int yoffset = 2 * (diag_1 ? -1 : +1);
break;
}
}
+ else if (IS_DF_SLOPE(element))
+ {
+ if (diagonally_adjacent_hit)
+ {
+ laser.overloaded = TRUE;
+
+ break;
+ }
+
+ if (hit_mask == HIT_MASK_LEFT ||
+ hit_mask == HIT_MASK_RIGHT ||
+ hit_mask == HIT_MASK_TOP ||
+ hit_mask == HIT_MASK_BOTTOM)
+ {
+ if (HitReflectingWalls(element, hit_mask))
+ break;
+ }
+ else
+ {
+ if (HitElement(element, hit_mask))
+ break;
+ }
+ }
else
{
if (HitElement(element, hit_mask))
static boolean HitElement(int element, int hit_mask)
{
- if (HitOnlyAnEdge(hit_mask))
- return FALSE;
+ if (IS_DF_SLOPE(element))
+ {
+ int mirrored_angle = get_mirrored_angle(laser.current_angle,
+ get_element_angle(element));
+ int opposite_angle = get_opposite_angle(laser.current_angle);
+
+ // check if laser is reflected by slope by 180°
+ if (mirrored_angle == opposite_angle)
+ {
+ LX += XS;
+ LY += YS;
+
+ AddDamagedField(LX / TILEX, LY / TILEY);
+
+ laser.overloaded = TRUE;
+
+ return TRUE;
+ }
+ }
+ else
+ {
+ if (HitOnlyAnEdge(hit_mask))
+ return FALSE;
+ }
if (IS_MOVING(ELX, ELY) || IS_BLOCKED(ELX, ELY))
element = MovingOrBlocked2Element_MM(ELX, ELY);
AddDamagedField(ELX, ELY);
+ boolean through_center = ((ELX * TILEX + 14 - LX) * YS ==
+ (ELY * TILEY + 14 - LY) * XS);
+
// this is more precise: check if laser would go through the center
- if ((ELX * TILEX + 14 - LX) * YS != (ELY * TILEY + 14 - LY) * XS)
+ if (!IS_DF_SLOPE(element) && !through_center)
{
int skip_count = 0;
return TRUE;
}
- if (!IS_BEAMER(element) &&
- !IS_FIBRE_OPTIC(element) &&
- !IS_GRID_WOOD(element) &&
- element != EL_FUEL_EMPTY)
+ if (IS_DF_SLOPE(element) && !through_center)
+ {
+ int correction = 2;
+
+ if (hit_mask == HIT_MASK_ALL)
+ {
+ // laser already inside slope -- go back half step
+ LX -= XS / 2;
+ LY -= YS / 2;
+
+ correction = 1;
+ }
+
+ AddLaserEdge(LX, LY);
+
+ LX -= (ABS(XS) < ABS(YS) ? correction * SIGN(XS) : 0);
+ LY -= (ABS(YS) < ABS(XS) ? correction * SIGN(YS) : 0);
+ }
+ else if (!IS_BEAMER(element) &&
+ !IS_FIBRE_OPTIC(element) &&
+ !IS_GRID_WOOD(element) &&
+ element != EL_FUEL_EMPTY)
{
#if 0
if ((ELX * TILEX + 14 - LX) * YS == (ELY * TILEY + 14 - LY) * XS)
IS_DF_MIRROR(element) ||
IS_DF_MIRROR_AUTO(element) ||
IS_DF_MIRROR_FIXED(element) ||
+ IS_DF_SLOPE(element) ||
element == EL_PRISM ||
element == EL_REFRACTOR)
{
IS_MIRROR_FIXED(element) ||
IS_DF_MIRROR(element) ||
IS_DF_MIRROR_AUTO(element) ||
- IS_DF_MIRROR_FIXED(element))
+ IS_DF_MIRROR_FIXED(element) ||
+ IS_DF_SLOPE(element))
laser.current_angle = get_mirrored_angle(laser.current_angle,
get_element_angle(element));
(get_opposite_angle(laser.current_angle) ==
laser.damage[laser.num_damages - 1].angle ? TRUE : FALSE);
+ if (IS_DF_SLOPE(element))
+ {
+ // handle special cases for slope element
+
+ if (IS_45_ANGLE(laser.current_angle))
+ {
+ int elx, ely;
+
+ elx = getLevelFromLaserX(LX);
+ ely = getLevelFromLaserY(LY);
+
+ if (IN_LEV_FIELD(elx, ely))
+ {
+ int element_next = Tile[elx][ely];
+
+ // check if slope is followed by slope with opposite orientation
+ if (IS_DF_SLOPE(element_next) && ABS(element - element_next) == 2)
+ laser.overloaded = TRUE;
+ }
+
+ int nr = element - EL_DF_SLOPE_START;
+ int dx = (nr == 0 ? (XS > 0 ? TILEX - 1 : -1) :
+ nr == 1 ? (XS > 0 ? TILEX : 1) :
+ nr == 2 ? (XS > 0 ? TILEX : 1) :
+ nr == 3 ? (XS > 0 ? TILEX - 1 : -1) : 0);
+ int dy = (nr == 0 ? (YS > 0 ? TILEY - 1 : -1) :
+ nr == 1 ? (YS > 0 ? TILEY - 1 : -1) :
+ nr == 2 ? (YS > 0 ? TILEY : 0) :
+ nr == 3 ? (YS > 0 ? TILEY : 0) : 0);
+
+ int px = ELX * TILEX + dx;
+ int py = ELY * TILEY + dy;
+
+ dx = px % TILEX;
+ dy = py % TILEY;
+
+ elx = getLevelFromLaserX(px);
+ ely = getLevelFromLaserY(py);
+
+ if (IN_LEV_FIELD(elx, ely))
+ {
+ int element_side = Tile[elx][ely];
+
+ // check if end of slope is blocked by other element
+ if (IS_WALL(element_side) || IS_WALL_CHANGING(element_side))
+ {
+ int pos = dy / MINI_TILEY * 2 + dx / MINI_TILEX;
+
+ if (element & (1 << pos))
+ laser.overloaded = TRUE;
+ }
+ else
+ {
+ int pos = getMaskFromElement(element_side);
+
+ if (mm_masks[pos][dx / 2][dx / 2] == 'X')
+ laser.overloaded = TRUE;
+ }
+ }
+ }
+ }
+
return (laser.overloaded ? TRUE : FALSE);
}