5 * my own version of the emerald mine engine
11 #define SPRING_ROLL /* spring rolling off round things continues to roll */
12 #define ACID_ROLL /* rolling objects go into acid rather than remove it */
14 #define USE_CHANGED_ACID_STUFF
16 #define RANDOM_RAW (seed = seed << 31 | seed >> 1)
17 #define RANDOM(x) (RANDOM_RAW & (x - 1))
19 static short **cave, **next, **boom;
20 static unsigned int seed;
23 static const byte is_blank[GAME_TILE_MAX] =
38 static const byte is_blank_or_acid[GAME_TILE_MAX] =
61 static const byte is_fake_acid[GAME_TILE_MAX] =
73 static const byte is_amoeba[GAME_TILE_MAX] =
87 static const byte is_android_walkable[GAME_TILE_MAX] =
103 static void Lboom_generic(int x, int y, int element, int element_middle)
105 boom[x-1][y-1] = element;
106 boom[x][y-1] = element;
107 boom[x+1][y-1] = element;
108 boom[x-1][y] = element;
109 boom[x][y] = element_middle;
110 boom[x+1][y] = element;
111 boom[x-1][y+1] = element;
112 boom[x][y+1] = element;
113 boom[x+1][y+1] = element;
116 static void Lboom_bug(int x, int y)
118 if (game_em.use_old_explosions)
121 Lboom_generic(x, y, Xemerald, Xdiamond);
123 #if PLAY_ELEMENT_SOUND
124 play_element_sound(x, y, SOUND_boom, Xbug_1_n);
128 static void Lboom_tank(int x, int y)
130 if (game_em.use_old_explosions)
133 Lboom_generic(x, y, Xblank, Xblank);
135 #if PLAY_ELEMENT_SOUND
136 play_element_sound(x, y, SOUND_boom, Xtank_1_n);
140 static void Lboom_eater(int x, int y)
142 if (game_em.use_old_explosions)
145 boom[x-1][y-1] = lev.eater_array[lev.eater_pos][0];
146 boom[x][y-1] = lev.eater_array[lev.eater_pos][1];
147 boom[x+1][y-1] = lev.eater_array[lev.eater_pos][2];
148 boom[x-1][y] = lev.eater_array[lev.eater_pos][3];
149 boom[x][y] = lev.eater_array[lev.eater_pos][4];
150 boom[x+1][y] = lev.eater_array[lev.eater_pos][5];
151 boom[x-1][y+1] = lev.eater_array[lev.eater_pos][6];
152 boom[x][y+1] = lev.eater_array[lev.eater_pos][7];
153 boom[x+1][y+1] = lev.eater_array[lev.eater_pos][8];
155 lev.eater_pos = (lev.eater_pos + 1) & 7;
157 #if PLAY_ELEMENT_SOUND
158 play_element_sound(x, y, SOUND_boom, Xeater_n);
162 static void Lboom_bug_old(int x, int y)
164 if (!game_em.use_old_explosions)
170 static void Lboom_tank_old(int x, int y)
172 if (!game_em.use_old_explosions)
178 static void Lboom_eater_old(int x, int y)
180 if (!game_em.use_old_explosions)
186 static void Lboom_bug_new(int x, int y, boolean chain_explosion)
188 if (game_em.use_old_explosions)
197 static void Lboom_tank_new(int x, int y, boolean chain_explosion)
199 if (game_em.use_old_explosions)
208 static void Lboom_eater_new(int x, int y, boolean chain_explosion)
210 if (game_em.use_old_explosions)
219 static boolean player_killed(struct PLAYER *ply)
227 if (lev.killed_out_of_time && setup.time_limit)
230 switch (cave[x][y-1])
251 switch (cave[x+1][y])
272 switch (cave[x][y+1])
293 switch (cave[x-1][y])
338 static void kill_player(struct PLAYER *ply)
345 switch (cave[x][y-1])
355 cave[x][y-1] = Xboom_bug;
356 Lboom_bug_new(x, y-1, TRUE);
367 cave[x][y-1] = Xboom_tank;
368 Lboom_tank_new(x, y-1, TRUE);
372 switch (cave[x+1][y])
382 cave[x+1][y] = Xboom_bug;
383 Lboom_bug_new(x+1, y, TRUE);
394 cave[x+1][y] = Xboom_tank;
395 Lboom_tank_new(x+1, y, TRUE);
399 switch (cave[x][y+1])
409 cave[x][y+1] = Xboom_bug;
410 Lboom_bug_new(x, y+1, TRUE);
421 cave[x][y+1] = Xboom_tank;
422 Lboom_tank_new(x, y+1, TRUE);
426 switch (cave[x-1][y])
436 cave[x-1][y] = Xboom_bug;
437 Lboom_bug_new(x-1, y, TRUE);
448 cave[x-1][y] = Xboom_tank;
449 Lboom_tank_new(x-1, y, TRUE);
460 play_element_sound(x, y, SOUND_exit_leave, Xexit_1);
464 play_element_sound(x, y, SOUND_die, Zplayer);
470 #ifdef USE_CHANGED_ACID_STUFF
483 cave[x][y] = Xboom_1;
489 static boolean player_digfield(struct PLAYER *ply, int dx, int dy)
491 int anim = (dx < 0 ? 3 : dx > 0 ? 1 : dy < 0 ? 0 : dy > 0 ? 2 : 2);
496 boolean result = TRUE;
498 if (!dx && !dy) /* no direction specified */
501 if (dx && dy && ply->joy_snap) /* more than one direction specified */
504 if (ply->joy_snap == 0) /* player wants to move */
506 int element = cave[x][y];
510 /* fire is released */
514 cave[x][y] = Zplayer;
515 next[x][y] = Zplayer;
524 play_element_sound(x, y, SOUND_blank, Xblank);
525 ply->anim = PLY_walk_n + anim;
530 #ifdef USE_CHANGED_ACID_STUFF
539 if (cave[x+1][y-1] == Xblank)
540 cave[x+1][y-1] = Xsplash_e;
541 if (cave[x-1][y-1] == Xblank)
542 cave[x-1][y-1] = Xsplash_w;
543 play_element_sound(x, y, SOUND_acid, Xacid_1);
565 #ifndef USE_CHANGED_ACID_STUFF
575 ply->anim = PLY_walk_n + anim;
581 cave[x][y] = (dy ? (dy < 0 ? Ygrass_nB : Ygrass_sB) :
582 (dx > 0 ? Ygrass_eB : Ygrass_wB));
583 next[x][y] = Zplayer;
584 play_element_sound(x, y, SOUND_dirt, Xgrass);
585 ply->anim = PLY_walk_n + anim;
591 cave[x][y] = (dy ? (dy < 0 ? Ydirt_nB : Ydirt_sB) :
592 (dx > 0 ? Ydirt_eB : Ydirt_wB));
593 next[x][y] = Zplayer;
594 play_element_sound(x, y, SOUND_dirt, Xdirt);
595 ply->anim = PLY_walk_n + anim;
602 cave[x][y] = Ydiamond_blank;
603 next[x][y] = Zplayer;
604 play_element_sound(x, y, SOUND_collect, element);
605 lev.score += lev.diamond_score;
606 lev.gems_needed = lev.gems_needed < 3 ? 0 : lev.gems_needed - 3;
607 game.snapshot.collected_item = TRUE;
608 ply->anim = PLY_walk_n + anim;
615 cave[x][y] = Yemerald_blank;
616 next[x][y] = Zplayer;
617 play_element_sound(x, y, SOUND_collect, element);
618 lev.score += lev.emerald_score;
619 lev.gems_needed = lev.gems_needed < 1 ? 0 : lev.gems_needed - 1;
620 game.snapshot.collected_item = TRUE;
621 ply->anim = PLY_walk_n + anim;
627 cave[x][y] = Ydynamite_blank;
628 next[x][y] = Zplayer;
629 play_element_sound(x, y, SOUND_collect, element);
630 lev.score += lev.dynamite_score;
631 ply->dynamite = ply->dynamite > 9998 ? 9999 : ply->dynamite + 1;
632 ply->anim = PLY_walk_n + anim;
639 cave[x][y] = Ykey_1_blank;
644 cave[x][y] = Ykey_2_blank;
649 cave[x][y] = Ykey_3_blank;
654 cave[x][y] = Ykey_4_blank;
659 cave[x][y] = Ykey_5_blank;
664 cave[x][y] = Ykey_6_blank;
669 cave[x][y] = Ykey_7_blank;
674 cave[x][y] = Ykey_8_blank;
679 next[x][y] = Zplayer;
680 play_element_sound(x, y, SOUND_collect, element);
681 lev.score += lev.key_score;
682 ply->anim = PLY_walk_n + anim;
688 cave[x][y] = Ylenses_blank;
689 next[x][y] = Zplayer;
690 play_element_sound(x, y, SOUND_collect, element);
691 lev.score += lev.lenses_score;
692 lev.lenses_cnt = lev.lenses_time;
693 ply->anim = PLY_walk_n + anim;
699 cave[x][y] = Ymagnify_blank;
700 next[x][y] = Zplayer;
701 play_element_sound(x, y, SOUND_collect, element);
702 lev.score += lev.magnify_score;
703 lev.magnify_cnt = lev.magnify_time;
704 ply->anim = PLY_walk_n + anim;
713 switch (cave[x+dx][y])
726 cave[x+dx][y] = dx > 0 ? Ystone_e : Ystone_w;
727 next[x+dx][y] = Xstone_pause;
738 if (cave[x+dx+1][y-1] == Xblank)
739 cave[x+dx+1][y-1] = Xsplash_e;
740 if (cave[x+dx-1][y-1] == Xblank)
741 cave[x+dx-1][y-1] = Xsplash_w;
742 play_element_sound(x, y, SOUND_acid, Xacid_1);
746 cave[x][y] = dx > 0 ? Ystone_eB : Ystone_wB;
747 next[x][y] = Zplayer;
748 play_element_sound(x, y, SOUND_roll, Xstone);
753 ply->anim = PLY_push_n + anim;
760 switch (cave[x+dx][y])
773 cave[x+dx][y] = dx > 0 ? Ybomb_e : Ybomb_w;
774 next[x+dx][y] = Xbomb_pause;
785 if (cave[x+dx+1][y-1] == Xblank)
786 cave[x+dx+1][y-1] = Xsplash_e;
787 if (cave[x+dx-1][y-1] == Xblank)
788 cave[x+dx-1][y-1] = Xsplash_w;
789 play_element_sound(x, y, SOUND_acid, Xacid_1);
793 cave[x][y] = dx > 0 ? Ybomb_eB : Ybomb_wB;
794 next[x][y] = Zplayer;
795 play_element_sound(x, y, SOUND_roll, Xbomb);
800 ply->anim = PLY_push_n + anim;
807 switch (cave[x+dx][y])
820 cave[x+dx][y] = dx > 0 ? Ynut_e : Ynut_w;
821 next[x+dx][y] = Xnut_pause;
832 if (cave[x+dx+1][y-1] == Xblank)
833 cave[x+dx+1][y-1] = Xsplash_e;
834 if (cave[x+dx-1][y-1] == Xblank)
835 cave[x+dx-1][y-1] = Xsplash_w;
836 play_element_sound(x, y, SOUND_acid, Xacid_1);
840 cave[x][y] = dx > 0 ? Ynut_eB : Ynut_wB;
841 next[x][y] = Zplayer;
842 play_element_sound(x, y, SOUND_roll, Xnut);
847 ply->anim = PLY_push_n + anim;
854 switch (cave[x+dx][y])
867 cave[x+dx][y] = dx > 0 ? Yspring_e : Yspring_w;
868 next[x+dx][y] = dx > 0 ? Xspring_e : Xspring_w;
879 if (cave[x+dx+1][y-1] == Xblank)
880 cave[x+dx+1][y-1] = Xsplash_e;
881 if (cave[x+dx-1][y-1] == Xblank)
882 cave[x+dx-1][y-1] = Xsplash_w;
883 play_element_sound(x, y, SOUND_acid, Xacid_1);
887 cave[x][y] = dx > 0 ? Yspring_eB : Yspring_wB;
888 next[x][y] = Zplayer;
889 play_element_sound(x, y, SOUND_roll, Xspring);
895 cave[x][y] = dx > 0 ? Yspring_alien_eB : Yspring_alien_wB;
896 cave[x+dx][y] = dx > 0 ? Yspring_alien_e : Yspring_alien_w;
897 next[x][y] = Zplayer;
898 next[x+dx][y] = dx > 0 ? Xspring_e : Xspring_w;
899 play_element_sound(x, y, SOUND_slurp, Xalien);
900 lev.score += lev.slurp_score;
905 ply->anim = PLY_push_n + anim;
912 case Xsand_stonein_1:
913 case Xsand_stonein_2:
914 case Xsand_stonein_3:
915 case Xsand_stonein_4:
919 ply->anim = PLY_push_n + anim;
923 switch (cave[x+dx][y+dy])
936 cave[x+dx][y+dy] = (dy ? (dy < 0 ? Yballoon_n : Yballoon_s) :
937 (dx > 0 ? Yballoon_e : Yballoon_w));
938 next[x+dx][y+dy] = Xballoon;
949 if (cave[x+dx+1][y+dy-1] == Xblank)
950 cave[x+dx+1][y+dy-1] = Xsplash_e;
951 if (cave[x+dx-1][y+dy-1] == Xblank)
952 cave[x+dx-1][y+dy-1] = Xsplash_w;
953 play_element_sound(x, y, SOUND_acid, Xacid_1);
957 cave[x][y] = (dy ? (dy < 0 ? Yballoon_nB : Yballoon_sB) :
958 (dx > 0 ? Yballoon_eB : Yballoon_wB));
959 next[x][y] = Zplayer;
960 play_element_sound(x, y, SOUND_push, Xballoon);
966 ply->anim = PLY_push_n + anim;
978 switch (cave[x+dx][y+dy])
991 cave[x+dx][y+dy] = (dy ? (dy < 0 ? Yandroid_n : Yandroid_s) :
992 (dx > 0 ? Yandroid_e : Yandroid_w));
993 next[x+dx][y+dy] = (dy ? (dy < 0 ? Xandroid_2_n : Xandroid_2_s) :
994 (dx > 0 ? Xandroid_2_e : Xandroid_2_w));
1005 if (cave[x+dx+1][y+dy-1] == Xblank)
1006 cave[x+dx+1][y+dy-1] = Xsplash_e;
1007 if (cave[x+dx-1][y+dy-1] == Xblank)
1008 cave[x+dx-1][y+dy-1] = Xsplash_w;
1009 play_element_sound(x, y, SOUND_acid, Xacid_1);
1013 cave[x][y] = (dy ? (dy < 0 ? Yandroid_nB : Yandroid_sB) :
1014 (dx > 0 ? Yandroid_eB : Yandroid_wB));
1015 next[x][y] = Zplayer;
1016 play_element_sound(x, y, SOUND_push, Xandroid);
1022 ply->anim = PLY_push_n + anim;
1027 if (ply->keys & 0x01)
1034 if (ply->keys & 0x02)
1041 if (ply->keys & 0x04)
1048 if (ply->keys & 0x08)
1055 if (ply->keys & 0x10)
1062 if (ply->keys & 0x20)
1069 if (ply->keys & 0x40)
1076 if (ply->keys & 0x80)
1083 if (!is_blank[cave[x+dx][y+dy]])
1086 if (!is_fake_acid[cave[x+dx][y+dy]])
1088 cave[x+dx][y+dy] = Zplayer;
1089 next[x+dx][y+dy] = Zplayer;
1092 play_element_sound(x, y, SOUND_door, element);
1093 ply->anim = PLY_walk_n + anim;
1099 play_element_sound(x, y, SOUND_press, element);
1100 lev.wheel_cnt = lev.wheel_time;
1106 lev.wind_direction = 0;
1110 lev.wind_direction = 1;
1114 lev.wind_direction = 2;
1118 lev.wind_direction = 3;
1122 lev.wind_direction = dy ? (dy < 0 ? 0 : 2) : (dx > 0 ? 1 : 3);
1127 play_element_sound(x, y, SOUND_press, element);
1128 lev.wind_cnt = lev.wind_time;
1132 play_element_sound(x, y, SOUND_press, element);
1137 play_element_sound(x, y, SOUND_press, element);
1138 lev.ball_cnt = lev.ball_time;
1139 lev.ball_state = !lev.ball_state;
1143 cave[x][y] = Yplant;
1144 next[x][y] = Xplant;
1145 play_element_sound(x, y, SOUND_blank, Xplant);
1146 ply->anim = PLY_walk_n + anim;
1157 game_em.level_solved = TRUE;
1159 ply->anim = PLY_walk_n + anim;
1166 if (ply->x == oldx && ply->y == oldy) /* no movement */
1169 else /* player wants to snap */
1171 int element = cave[x][y];
1175 /* fire is pressed */
1178 cave[x][y] = Ygrass_blank;
1179 next[x][y] = Xblank;
1180 play_element_sound(x, y, SOUND_dirt, element);
1181 ply->anim = PLY_shoot_n + anim;
1185 cave[x][y] = Ydirt_blank;
1186 next[x][y] = Xblank;
1187 play_element_sound(x, y, SOUND_dirt, element);
1188 ply->anim = PLY_shoot_n + anim;
1192 case Xdiamond_pause:
1193 cave[x][y] = Ydiamond_blank;
1194 next[x][y] = Xblank;
1195 play_element_sound(x, y, SOUND_collect, element);
1196 lev.score += lev.diamond_score;
1197 lev.gems_needed = lev.gems_needed < 3 ? 0 : lev.gems_needed - 3;
1198 game.snapshot.collected_item = TRUE;
1199 ply->anim = PLY_walk_n + anim;
1203 case Xemerald_pause:
1204 cave[x][y] = Yemerald_blank;
1205 next[x][y] = Xblank;
1206 play_element_sound(x, y, SOUND_collect, element);
1207 lev.score += lev.emerald_score;
1208 lev.gems_needed = lev.gems_needed < 1 ? 0 : lev.gems_needed - 1;
1209 game.snapshot.collected_item = TRUE;
1210 ply->anim = PLY_walk_n + anim;
1214 cave[x][y] = Ydynamite_blank;
1215 next[x][y] = Xblank;
1216 play_element_sound(x, y, SOUND_collect, element);
1217 lev.score += lev.dynamite_score;
1218 ply->dynamite = ply->dynamite > 9998 ? 9999 : ply->dynamite + 1;
1219 ply->anim = PLY_walk_n + anim;
1224 cave[x][y] = Ykey_1_blank;
1229 cave[x][y] = Ykey_2_blank;
1234 cave[x][y] = Ykey_3_blank;
1239 cave[x][y] = Ykey_4_blank;
1244 cave[x][y] = Ykey_5_blank;
1249 cave[x][y] = Ykey_6_blank;
1254 cave[x][y] = Ykey_7_blank;
1259 cave[x][y] = Ykey_8_blank;
1264 next[x][y] = Xblank;
1265 play_element_sound(x, y, SOUND_collect, element);
1266 lev.score += lev.key_score;
1267 ply->anim = PLY_walk_n + anim;
1271 cave[x][y] = Ylenses_blank;
1272 next[x][y] = Xblank;
1273 play_element_sound(x, y, SOUND_collect, element);
1274 lev.score += lev.lenses_score;
1275 lev.lenses_cnt = lev.lenses_time;
1276 ply->anim = PLY_walk_n + anim;
1280 cave[x][y] = Ymagnify_blank;
1281 next[x][y] = Xblank;
1282 play_element_sound(x, y, SOUND_collect, element);
1283 lev.score += lev.magnify_score;
1284 lev.magnify_cnt = lev.magnify_time;
1285 ply->anim = PLY_walk_n + anim;
1296 static void check_player(struct PLAYER *ply)
1304 game_em.last_player_direction[ply->num] = MV_NONE;
1306 if (ply->joy_w) /* west */
1311 else if (ply->joy_e) /* east */
1317 if (ply->joy_n) /* north */
1322 else if (ply->joy_s) /* south */
1334 boolean players_visible_before_move;
1335 boolean players_visible_after_move;
1338 players_visible_before_move = checkIfAllPlayersFitToScreen();
1343 players_visible_after_move = checkIfAllPlayersFitToScreen();
1346 player is allowed to move only in the following cases:
1347 - it is not needed to display all players (not focussed to all players)
1348 - all players are (still or again) visible after the move
1349 - some players were already outside visible screen area before the move
1351 can_move = (game.centered_player_nr != -1 ||
1352 players_visible_after_move ||
1353 !players_visible_before_move);
1360 ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0;
1366 if (dx == 0 && dy == 0)
1372 if (++ply->dynamite_cnt == 5 && ply->dynamite)
1374 cave[x][y] = Xdynamite_1;
1375 play_element_sound(x, y, SOUND_dynamite, Xdynamite_1);
1381 ply->dynamite_cnt = 0;
1384 /* be a bit more random if the player doesn't move */
1385 game_em.random += 7;
1391 ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0;
1392 ply->dynamite_cnt = 0; /* reset dynamite timer if we move */
1394 if (ply->joy_snap == 0) /* player wants to move */
1396 boolean moved = FALSE;
1398 if (ply->last_move_dir & MV_HORIZONTAL)
1400 if (!(moved = player_digfield(ply, 0, dy)))
1401 moved = player_digfield(ply, dx, 0);
1405 if (!(moved = player_digfield(ply, dx, 0)))
1406 moved = player_digfield(ply, 0, dy);
1412 ply->last_move_dir = (dx < 0 ? MV_LEFT : MV_RIGHT);
1413 else if (oldy != ply->y)
1414 ply->last_move_dir = (dy < 0 ? MV_UP : MV_DOWN);
1416 game_em.any_player_moving = TRUE;
1417 game_em.last_moving_player = ply->num;
1418 game_em.last_player_direction[ply->num] = ply->last_move_dir;
1421 else /* player wants to snap */
1423 game_em.any_player_snapping = player_digfield(ply, dx, dy);
1427 static void set_nearest_player_xy(int x, int y, int *dx, int *dy)
1429 int distance, distance_shortest = CAVE_WIDTH + CAVE_HEIGHT;
1432 /* default values if no players are alive anymore */
1436 for (i = 0; i < MAX_PLAYERS; i++)
1441 distance = ABS(ply[i].x - x) + ABS(ply[i].y - y);
1443 if (distance < distance_shortest)
1448 distance_shortest = distance;
1453 static void Lacid_1(int x, int y)
1455 next[x][y] = Xacid_2;
1458 static void Lacid_2(int x, int y)
1460 next[x][y] = Xacid_3;
1463 static void Lacid_3(int x, int y)
1465 next[x][y] = Xacid_4;
1468 static void Lacid_4(int x, int y)
1470 next[x][y] = Xacid_5;
1473 static void Lacid_5(int x, int y)
1475 next[x][y] = Xacid_6;
1478 static void Lacid_6(int x, int y)
1480 next[x][y] = Xacid_7;
1483 static void Lacid_7(int x, int y)
1485 next[x][y] = Xacid_8;
1488 static void Lacid_8(int x, int y)
1490 next[x][y] = Xacid_1;
1493 static void Lfake_acid_1(int x, int y)
1495 next[x][y] = Xfake_acid_2;
1498 static void Lfake_acid_2(int x, int y)
1500 next[x][y] = Xfake_acid_3;
1503 static void Lfake_acid_3(int x, int y)
1505 next[x][y] = Xfake_acid_4;
1508 static void Lfake_acid_4(int x, int y)
1510 next[x][y] = Xfake_acid_5;
1513 static void Lfake_acid_5(int x, int y)
1515 next[x][y] = Xfake_acid_6;
1518 static void Lfake_acid_6(int x, int y)
1520 next[x][y] = Xfake_acid_7;
1523 static void Lfake_acid_7(int x, int y)
1525 next[x][y] = Xfake_acid_8;
1528 static void Lfake_acid_8(int x, int y)
1530 next[x][y] = Xfake_acid_1;
1533 static void Landroid(int x, int y)
1537 if (lev.android_clone_cnt == 0)
1539 if (!is_blank[cave[x-1][y-1]] &&
1540 !is_blank[cave[x][y-1]] &&
1541 !is_blank[cave[x+1][y-1]] &&
1542 !is_blank[cave[x-1][y]] &&
1543 !is_blank[cave[x+1][y]] &&
1544 !is_blank[cave[x-1][y+1]] &&
1545 !is_blank[cave[x][y+1]] &&
1546 !is_blank[cave[x+1][y+1]])
1551 /* randomly find an object to clone */
1553 case 0: /* S,NE,W,NW,SE,E,SW,N */
1554 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1555 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1556 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1557 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1558 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1559 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1560 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1561 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1564 case 1: /* NW,SE,N,S,NE,SW,E,W */
1565 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1566 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1567 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1568 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1569 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1570 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1571 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1572 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1575 case 2: /* SW,E,S,W,N,NW,SE,NE */
1576 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1577 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1578 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1579 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1580 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1581 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1582 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1583 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1586 case 3: /* N,SE,NE,E,W,S,NW,SW */
1587 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1588 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1589 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1590 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1591 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1592 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1593 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1594 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1597 case 4: /* SE,NW,E,NE,SW,W,N,S */
1598 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1599 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1600 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1601 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1602 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1603 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1604 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1605 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1608 case 5: /* NE,W,SE,SW,S,N,E,NW */
1609 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1610 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1611 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1612 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1613 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1614 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1615 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1616 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1619 case 6: /* E,N,SW,S,NW,NE,SE,W */
1620 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1621 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1622 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1623 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1624 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1625 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1626 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1627 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1630 case 7: /* W,SW,NW,N,E,SE,NE,S */
1631 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1632 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1633 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1634 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1635 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1636 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1637 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1638 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1642 next[x][y] = temp; /* the item we chose to clone */
1643 play_element_sound(x, y, SOUND_android_clone, temp);
1647 /* randomly find a direction to move */
1649 case 0: /* S,NE,W,NW,SE,E,SW,N */
1650 if (is_blank[cave[x][y+1]]) goto android_s;
1651 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1652 if (is_blank[cave[x-1][y]]) goto android_w;
1653 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1654 if (is_blank[cave[x+1][y+1]]) goto android_se;
1655 if (is_blank[cave[x+1][y]]) goto android_e;
1656 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1657 if (is_blank[cave[x][y-1]]) goto android_n;
1660 case 1: /* NW,SE,N,S,NE,SW,E,W */
1661 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1662 if (is_blank[cave[x+1][y+1]]) goto android_se;
1663 if (is_blank[cave[x][y-1]]) goto android_n;
1664 if (is_blank[cave[x][y+1]]) goto android_s;
1665 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1666 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1667 if (is_blank[cave[x+1][y]]) goto android_e;
1668 if (is_blank[cave[x-1][y]]) goto android_w;
1671 case 2: /* SW,E,S,W,N,NW,SE,NE */
1672 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1673 if (is_blank[cave[x+1][y]]) goto android_e;
1674 if (is_blank[cave[x][y+1]]) goto android_s;
1675 if (is_blank[cave[x-1][y]]) goto android_w;
1676 if (is_blank[cave[x][y-1]]) goto android_n;
1677 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1678 if (is_blank[cave[x+1][y+1]]) goto android_se;
1679 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1682 case 3: /* N,SE,NE,E,W,S,NW,SW */
1683 if (is_blank[cave[x][y-1]]) goto android_n;
1684 if (is_blank[cave[x+1][y+1]]) goto android_se;
1685 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1686 if (is_blank[cave[x+1][y]]) goto android_e;
1687 if (is_blank[cave[x-1][y]]) goto android_w;
1688 if (is_blank[cave[x][y+1]]) goto android_s;
1689 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1690 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1693 case 4: /* SE,NW,E,NE,SW,W,N,S */
1694 if (is_blank[cave[x+1][y+1]]) goto android_se;
1695 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1696 if (is_blank[cave[x+1][y]]) goto android_e;
1697 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1698 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1699 if (is_blank[cave[x-1][y]]) goto android_w;
1700 if (is_blank[cave[x][y-1]]) goto android_n;
1701 if (is_blank[cave[x][y+1]]) goto android_s;
1704 case 5: /* NE,W,SE,SW,S,N,E,NW */
1705 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1706 if (is_blank[cave[x-1][y]]) goto android_w;
1707 if (is_blank[cave[x+1][y+1]]) goto android_se;
1708 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1709 if (is_blank[cave[x][y+1]]) goto android_s;
1710 if (is_blank[cave[x][y-1]]) goto android_n;
1711 if (is_blank[cave[x+1][y]]) goto android_e;
1712 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1715 case 6: /* E,N,SW,S,NW,NE,SE,W */
1716 if (is_blank[cave[x+1][y]]) goto android_e;
1717 if (is_blank[cave[x][y-1]]) goto android_n;
1718 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1719 if (is_blank[cave[x][y+1]]) goto android_s;
1720 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1721 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1722 if (is_blank[cave[x+1][y+1]]) goto android_se;
1723 if (is_blank[cave[x-1][y]]) goto android_w;
1726 case 7: /* W,SW,NW,N,E,SE,NE,S */
1727 if (is_blank[cave[x-1][y]]) goto android_w;
1728 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1729 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1730 if (is_blank[cave[x][y-1]]) goto android_n;
1731 if (is_blank[cave[x+1][y]]) goto android_e;
1732 if (is_blank[cave[x+1][y+1]]) goto android_se;
1733 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1734 if (is_blank[cave[x][y+1]]) goto android_s;
1740 if (lev.android_move_cnt == 0)
1742 if (cave[x-1][y-1] == Zplayer ||
1743 cave[x][y-1] == Zplayer ||
1744 cave[x+1][y-1] == Zplayer ||
1745 cave[x-1][y] == Zplayer ||
1746 cave[x+1][y] == Zplayer ||
1747 cave[x-1][y+1] == Zplayer ||
1748 cave[x][y+1] == Zplayer ||
1749 cave[x+1][y+1] == Zplayer)
1752 set_nearest_player_xy(x, y, &dx, &dy);
1754 next[x][y] = Xblank; /* assume we will move */
1755 temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
1761 /* attempt clockwise move first if direct path is blocked */
1763 case 0: /* north west */
1764 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1765 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1766 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1770 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1771 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1772 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1775 case 2: /* north east */
1776 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1777 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1778 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1782 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1783 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1784 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1787 case 4: /* nowhere */
1791 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1792 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1793 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1796 case 6: /* south west */
1797 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1798 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1799 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1803 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1804 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1805 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1808 case 8: /* south east */
1809 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1810 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1811 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1819 /* attempt counterclockwise move first if direct path is blocked */
1821 case 0: /* north west */
1822 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1823 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1824 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1828 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1829 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1830 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1833 case 2: /* north east */
1834 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1835 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1836 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1840 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1841 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1842 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1845 case 4: /* nowhere */
1849 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1850 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1851 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1854 case 6: /* south west */
1855 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1856 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1857 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1861 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1862 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1863 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1866 case 8: /* south east */
1867 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1868 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1869 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1876 next[x][y] = Xandroid;
1880 cave[x][y] = Yandroid_nB;
1881 cave[x][y-1] = Yandroid_n;
1882 next[x][y-1] = Xandroid;
1883 play_element_sound(x, y, SOUND_android_move, Xandroid);
1887 cave[x][y] = Yandroid_neB;
1888 cave[x+1][y-1] = Yandroid_ne;
1889 next[x+1][y-1] = Xandroid;
1890 play_element_sound(x, y, SOUND_android_move, Xandroid);
1894 cave[x][y] = Yandroid_eB;
1895 cave[x+1][y] = Yandroid_e;
1896 next[x+1][y] = Xandroid;
1897 play_element_sound(x, y, SOUND_android_move, Xandroid);
1901 cave[x][y] = Yandroid_seB;
1902 cave[x+1][y+1] = Yandroid_se;
1903 next[x+1][y+1] = Xandroid;
1904 play_element_sound(x, y, SOUND_android_move, Xandroid);
1908 cave[x][y] = Yandroid_sB;
1909 cave[x][y+1] = Yandroid_s;
1910 next[x][y+1] = Xandroid;
1911 play_element_sound(x, y, SOUND_android_move, Xandroid);
1915 cave[x][y] = Yandroid_swB;
1916 cave[x-1][y+1] = Yandroid_sw;
1917 next[x-1][y+1] = Xandroid;
1918 play_element_sound(x, y, SOUND_android_move, Xandroid);
1922 cave[x][y] = Yandroid_wB;
1923 cave[x-1][y] = Yandroid_w;
1924 next[x-1][y] = Xandroid;
1925 play_element_sound(x, y, SOUND_android_move, Xandroid);
1929 cave[x][y] = Yandroid_nwB;
1930 cave[x-1][y-1] = Yandroid_nw;
1931 next[x-1][y-1] = Xandroid;
1932 play_element_sound(x, y, SOUND_android_move, Xandroid);
1936 static void Landroid_1_n(int x, int y)
1938 switch (cave[x][y-1])
1951 cave[x][y] = Yandroid_nB;
1952 next[x][y] = Xblank;
1953 cave[x][y-1] = Yandroid_n;
1954 next[x][y-1] = Xandroid;
1955 play_element_sound(x, y, SOUND_android_move, Xandroid_1_n);
1966 cave[x][y] = Yandroid_nB;
1967 next[x][y] = Xblank;
1968 if (cave[x+1][y-2] == Xblank)
1969 cave[x+1][y-2] = Xsplash_e;
1970 if (cave[x-1][y-2] == Xblank)
1971 cave[x-1][y-2] = Xsplash_w;
1972 play_element_sound(x, y, SOUND_acid, Xacid_1);
1981 static void Landroid_2_n(int x, int y)
1983 switch (cave[x][y-1])
1996 cave[x][y] = Yandroid_nB;
1997 next[x][y] = Xblank;
1998 cave[x][y-1] = Yandroid_n;
1999 next[x][y-1] = Xandroid_1_n;
2000 play_element_sound(x, y, SOUND_android_move, Xandroid_2_n);
2011 cave[x][y] = Yandroid_nB;
2012 next[x][y] = Xblank;
2013 if (cave[x+1][y-2] == Xblank)
2014 cave[x+1][y-2] = Xsplash_e;
2015 if (cave[x-1][y-2] == Xblank)
2016 cave[x-1][y-2] = Xsplash_w;
2017 play_element_sound(x, y, SOUND_acid, Xacid_1);
2026 static void Landroid_1_e(int x, int y)
2028 switch (cave[x+1][y])
2041 cave[x][y] = Yandroid_eB;
2042 next[x][y] = Xblank;
2043 cave[x+1][y] = Yandroid_e;
2044 next[x+1][y] = Xandroid;
2045 play_element_sound(x, y, SOUND_android_move, Xandroid_1_e);
2056 cave[x][y] = Yandroid_eB;
2057 next[x][y] = Xblank;
2058 if (cave[x+2][y-1] == Xblank)
2059 cave[x+2][y-1] = Xsplash_e;
2060 if (cave[x][y-1] == Xblank)
2061 cave[x][y-1] = Xsplash_w;
2062 play_element_sound(x, y, SOUND_acid, Xacid_1);
2071 static void Landroid_2_e(int x, int y)
2073 switch (cave[x+1][y])
2086 cave[x][y] = Yandroid_eB;
2087 next[x][y] = Xblank;
2088 cave[x+1][y] = Yandroid_e;
2089 next[x+1][y] = Xandroid_1_e;
2090 play_element_sound(x, y, SOUND_android_move, Xandroid_2_e);
2101 cave[x][y] = Yandroid_eB;
2102 next[x][y] = Xblank;
2103 if (cave[x+2][y-1] == Xblank)
2104 cave[x+2][y-1] = Xsplash_e;
2105 if (cave[x][y-1] == Xblank)
2106 cave[x][y-1] = Xsplash_w;
2107 play_element_sound(x, y, SOUND_acid, Xacid_1);
2116 static void Landroid_1_s(int x, int y)
2118 switch (cave[x][y+1])
2131 cave[x][y] = Yandroid_sB;
2132 next[x][y] = Xblank;
2133 cave[x][y+1] = Yandroid_s;
2134 next[x][y+1] = Xandroid;
2135 play_element_sound(x, y, SOUND_android_move, Xandroid_1_s);
2146 cave[x][y] = Yandroid_sB;
2147 next[x][y] = Xblank;
2148 if (cave[x+1][y] == Xblank)
2149 cave[x+1][y] = Xsplash_e;
2150 if (cave[x-1][y] == Xblank)
2151 cave[x-1][y] = Xsplash_w;
2152 play_element_sound(x, y, SOUND_acid, Xacid_1);
2161 static void Landroid_2_s(int x, int y)
2163 switch (cave[x][y+1])
2176 cave[x][y] = Yandroid_sB;
2177 next[x][y] = Xblank;
2178 cave[x][y+1] = Yandroid_s;
2179 next[x][y+1] = Xandroid_1_s;
2180 play_element_sound(x, y, SOUND_android_move, Xandroid_2_s);
2191 cave[x][y] = Yandroid_sB;
2192 next[x][y] = Xblank;
2193 if (cave[x+1][y] == Xblank)
2194 cave[x+1][y] = Xsplash_e;
2195 if (cave[x-1][y] == Xblank)
2196 cave[x-1][y] = Xsplash_w;
2197 play_element_sound(x, y, SOUND_acid, Xacid_1);
2206 static void Landroid_1_w(int x, int y)
2208 switch (cave[x-1][y])
2221 cave[x][y] = Yandroid_wB;
2222 next[x][y] = Xblank;
2223 cave[x-1][y] = Yandroid_w;
2224 next[x-1][y] = Xandroid;
2225 play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
2236 cave[x][y] = Yandroid_wB;
2237 next[x][y] = Xblank;
2238 if (cave[x][y-1] == Xblank)
2239 cave[x][y-1] = Xsplash_e;
2240 if (cave[x-2][y-1] == Xblank)
2241 cave[x-2][y-1] = Xsplash_w;
2242 play_element_sound(x, y, SOUND_acid, Xacid_1);
2251 static void Landroid_2_w(int x, int y)
2253 switch (cave[x-1][y])
2266 cave[x][y] = Yandroid_wB;
2267 next[x][y] = Xblank;
2268 cave[x-1][y] = Yandroid_w;
2269 next[x-1][y] = Xandroid_1_w;
2270 play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
2281 cave[x][y] = Yandroid_wB;
2282 next[x][y] = Xblank;
2283 if (cave[x][y-1] == Xblank)
2284 cave[x][y-1] = Xsplash_e;
2285 if (cave[x-2][y-1] == Xblank)
2286 cave[x-2][y-1] = Xsplash_w;
2287 play_element_sound(x, y, SOUND_acid, Xacid_1);
2296 static void Leater_n(int x, int y)
2298 if (cave[x+1][y] == Xdiamond)
2300 cave[x+1][y] = Ydiamond_blank;
2301 next[x+1][y] = Xblank;
2302 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2306 if (cave[x][y+1] == Xdiamond)
2308 cave[x][y+1] = Ydiamond_blank;
2309 next[x][y+1] = Xblank;
2310 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2314 if (cave[x-1][y] == Xdiamond)
2316 cave[x-1][y] = Ydiamond_blank;
2317 next[x-1][y] = Xblank;
2318 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2322 if (cave[x][y-1] == Xdiamond)
2324 cave[x][y-1] = Ydiamond_blank;
2325 next[x][y-1] = Xblank;
2326 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2330 switch (cave[x][y-1])
2346 cave[x][y] = Yeater_nB;
2347 next[x][y] = Xblank;
2348 cave[x][y-1] = Yeater_n;
2349 next[x][y-1] = Xeater_n;
2360 cave[x][y] = Yeater_nB;
2361 next[x][y] = Xblank;
2362 if (cave[x+1][y-2] == Xblank)
2363 cave[x+1][y-2] = Xsplash_e;
2364 if (cave[x-1][y-2] == Xblank)
2365 cave[x-1][y-2] = Xsplash_w;
2366 play_element_sound(x, y, SOUND_acid, Xacid_1);
2370 next[x][y] = RANDOM(2) ? Xeater_e : Xeater_w;
2371 play_element_sound(x, y, SOUND_eater, Xeater_n);
2376 static void Leater_e(int x, int y)
2378 if (cave[x][y+1] == Xdiamond)
2380 cave[x][y+1] = Ydiamond_blank;
2381 next[x][y+1] = Xblank;
2382 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2386 if (cave[x-1][y] == Xdiamond)
2388 cave[x-1][y] = Ydiamond_blank;
2389 next[x-1][y] = Xblank;
2390 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2394 if (cave[x][y-1] == Xdiamond)
2396 cave[x][y-1] = Ydiamond_blank;
2397 next[x][y-1] = Xblank;
2398 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2402 if (cave[x+1][y] == Xdiamond)
2404 cave[x+1][y] = Ydiamond_blank;
2405 next[x+1][y] = Xblank;
2406 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2410 switch (cave[x+1][y])
2426 cave[x][y] = Yeater_eB;
2427 next[x][y] = Xblank;
2428 cave[x+1][y] = Yeater_e;
2429 next[x+1][y] = Xeater_e;
2440 cave[x][y] = Yeater_eB;
2441 next[x][y] = Xblank;
2442 if (cave[x+2][y-1] == Xblank)
2443 cave[x+2][y-1] = Xsplash_e;
2444 if (cave[x][y-1] == Xblank)
2445 cave[x][y-1] = Xsplash_w;
2446 play_element_sound(x, y, SOUND_acid, Xacid_1);
2450 next[x][y] = RANDOM(2) ? Xeater_n : Xeater_s;
2451 play_element_sound(x, y, SOUND_eater, Xeater_e);
2456 static void Leater_s(int x, int y)
2458 if (cave[x-1][y] == Xdiamond)
2460 cave[x-1][y] = Ydiamond_blank;
2461 next[x-1][y] = Xblank;
2462 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2466 if (cave[x][y-1] == Xdiamond)
2468 cave[x][y-1] = Ydiamond_blank;
2469 next[x][y-1] = Xblank;
2470 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2474 if (cave[x+1][y] == Xdiamond)
2476 cave[x+1][y] = Ydiamond_blank;
2477 next[x+1][y] = Xblank;
2478 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2482 if (cave[x][y+1] == Xdiamond)
2484 cave[x][y+1] = Ydiamond_blank;
2485 next[x][y+1] = Xblank;
2486 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2490 switch (cave[x][y+1])
2506 cave[x][y] = Yeater_sB;
2507 next[x][y] = Xblank;
2508 cave[x][y+1] = Yeater_s;
2509 next[x][y+1] = Xeater_s;
2520 cave[x][y] = Yeater_sB;
2521 next[x][y] = Xblank;
2522 if (cave[x+1][y] == Xblank)
2523 cave[x+1][y] = Xsplash_e;
2524 if (cave[x-1][y] == Xblank)
2525 cave[x-1][y] = Xsplash_w;
2526 play_element_sound(x, y, SOUND_acid, Xacid_1);
2530 next[x][y] = RANDOM(2) ? Xeater_e : Xeater_w;
2531 play_element_sound(x, y, SOUND_eater, Xeater_s);
2536 static void Leater_w(int x, int y)
2538 if (cave[x][y-1] == Xdiamond)
2540 cave[x][y-1] = Ydiamond_blank;
2541 next[x][y-1] = Xblank;
2542 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2546 if (cave[x+1][y] == Xdiamond)
2548 cave[x+1][y] = Ydiamond_blank;
2549 next[x+1][y] = Xblank;
2550 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2554 if (cave[x][y+1] == Xdiamond)
2556 cave[x][y+1] = Ydiamond_blank;
2557 next[x][y+1] = Xblank;
2558 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2562 if (cave[x-1][y] == Xdiamond)
2564 cave[x-1][y] = Ydiamond_blank;
2565 next[x-1][y] = Xblank;
2566 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2570 switch (cave[x-1][y])
2586 cave[x][y] = Yeater_wB;
2587 next[x][y] = Xblank;
2588 cave[x-1][y] = Yeater_w;
2589 next[x-1][y] = Xeater_w;
2600 cave[x][y] = Yeater_wB;
2601 next[x][y] = Xblank;
2602 if (cave[x][y-1] == Xblank)
2603 cave[x][y-1] = Xsplash_e;
2604 if (cave[x-2][y-1] == Xblank)
2605 cave[x-2][y-1] = Xsplash_w;
2606 play_element_sound(x, y, SOUND_acid, Xacid_1);
2610 next[x][y] = RANDOM(2) ? Xeater_n : Xeater_s;
2611 play_element_sound(x, y, SOUND_eater, Xeater_w);
2616 static void Lalien(int x, int y)
2627 set_nearest_player_xy(x, y, &dx, &dy);
2634 switch (cave[x][y-1])
2650 cave[x][y] = Yalien_nB;
2651 next[x][y] = Xblank;
2652 cave[x][y-1] = Yalien_n;
2653 next[x][y-1] = Xalien_pause;
2654 play_element_sound(x, y, SOUND_alien, Xalien);
2665 cave[x][y] = Yalien_nB;
2666 next[x][y] = Xblank;
2667 if (cave[x+1][y-2] == Xblank)
2668 cave[x+1][y-2] = Xsplash_e;
2669 if (cave[x-1][y-2] == Xblank)
2670 cave[x-1][y-2] = Xsplash_w;
2671 play_element_sound(x, y, SOUND_acid, Xacid_1);
2677 switch (cave[x][y+1])
2693 cave[x][y] = Yalien_sB;
2694 next[x][y] = Xblank;
2695 cave[x][y+1] = Yalien_s;
2696 next[x][y+1] = Xalien_pause;
2697 play_element_sound(x, y, SOUND_alien, Xalien);
2708 cave[x][y] = Yalien_sB;
2709 next[x][y] = Xblank;
2710 if (cave[x+1][y] == Xblank)
2711 cave[x+1][y] = Xsplash_e;
2712 if (cave[x-1][y] == Xblank)
2713 cave[x-1][y] = Xsplash_w;
2714 play_element_sound(x, y, SOUND_acid, Xacid_1);
2723 switch (cave[x+1][y])
2739 cave[x][y] = Yalien_eB;
2740 next[x][y] = Xblank;
2741 cave[x+1][y] = Yalien_e;
2742 next[x+1][y] = Xalien_pause;
2743 play_element_sound(x, y, SOUND_alien, Xalien);
2754 cave[x][y] = Yalien_eB;
2755 next[x][y] = Xblank;
2756 if (cave[x+2][y-1] == Xblank)
2757 cave[x+2][y-1] = Xsplash_e;
2758 if (cave[x][y-1] == Xblank)
2759 cave[x][y-1] = Xsplash_w;
2760 play_element_sound(x, y, SOUND_acid, Xacid_1);
2766 switch (cave[x-1][y])
2782 cave[x][y] = Yalien_wB;
2783 next[x][y] = Xblank;
2784 cave[x-1][y] = Yalien_w;
2785 next[x-1][y] = Xalien_pause;
2786 play_element_sound(x, y, SOUND_alien, Xalien);
2797 cave[x][y] = Yalien_wB;
2798 next[x][y] = Xblank;
2799 if (cave[x][y-1] == Xblank)
2800 cave[x][y-1] = Xsplash_e;
2801 if (cave[x-2][y-1] == Xblank)
2802 cave[x-2][y-1] = Xsplash_w;
2803 play_element_sound(x, y, SOUND_acid, Xacid_1);
2810 static void Lalien_pause(int x, int y)
2812 next[x][y] = Xalien;
2815 static void Lbug_n(int x, int y)
2817 switch (cave[x][y-1])
2833 cave[x][y] = Ybug_nB;
2834 next[x][y] = Xblank;
2835 cave[x][y-1] = Ybug_n;
2836 next[x][y-1] = Xbug_1_n;
2837 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2848 cave[x][y] = Ybug_nB;
2849 next[x][y] = Xblank;
2850 if (cave[x+1][y-2] == Xblank)
2851 cave[x+1][y-2] = Xsplash_e;
2852 if (cave[x-1][y-2] == Xblank)
2853 cave[x-1][y-2] = Xsplash_w;
2854 play_element_sound(x, y, SOUND_acid, Xacid_1);
2858 cave[x][y] = Ybug_n_w;
2859 next[x][y] = Xbug_2_w;
2860 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2865 static void Lbug_1_n(int x, int y)
2867 if (is_amoeba[cave[x][y-1]] ||
2868 is_amoeba[cave[x+1][y]] ||
2869 is_amoeba[cave[x][y+1]] ||
2870 is_amoeba[cave[x-1][y]])
2878 switch (cave[x+1][y])
2902 cave[x][y] = Ybug_n_e;
2903 next[x][y] = Xbug_2_e;
2904 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2913 static void Lbug_2_n(int x, int y)
2915 if (is_amoeba[cave[x][y-1]] ||
2916 is_amoeba[cave[x+1][y]] ||
2917 is_amoeba[cave[x][y+1]] ||
2918 is_amoeba[cave[x-1][y]])
2929 static void Lbug_e(int x, int y)
2931 switch (cave[x+1][y])
2947 cave[x][y] = Ybug_eB;
2948 next[x][y] = Xblank;
2949 cave[x+1][y] = Ybug_e;
2950 next[x+1][y] = Xbug_1_e;
2951 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
2962 cave[x][y] = Ybug_eB;
2963 next[x][y] = Xblank;
2964 if (cave[x+2][y-1] == Xblank)
2965 cave[x+2][y-1] = Xsplash_e;
2966 if (cave[x][y-1] == Xblank)
2967 cave[x][y-1] = Xsplash_w;
2968 play_element_sound(x, y, SOUND_acid, Xacid_1);
2972 cave[x][y] = Ybug_e_n;
2973 next[x][y] = Xbug_2_n;
2974 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
2979 static void Lbug_1_e(int x, int y)
2981 if (is_amoeba[cave[x][y-1]] ||
2982 is_amoeba[cave[x+1][y]] ||
2983 is_amoeba[cave[x][y+1]] ||
2984 is_amoeba[cave[x-1][y]])
2992 switch (cave[x][y+1])
3016 cave[x][y] = Ybug_e_s;
3017 next[x][y] = Xbug_2_s;
3018 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
3027 static void Lbug_2_e(int x, int y)
3029 if (is_amoeba[cave[x][y-1]] ||
3030 is_amoeba[cave[x+1][y]] ||
3031 is_amoeba[cave[x][y+1]] ||
3032 is_amoeba[cave[x-1][y]])
3043 static void Lbug_s(int x, int y)
3045 switch (cave[x][y+1])
3061 cave[x][y] = Ybug_sB;
3062 next[x][y] = Xblank;
3063 cave[x][y+1] = Ybug_s;
3064 next[x][y+1] = Xbug_1_s;
3065 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3076 cave[x][y] = Ybug_sB;
3077 next[x][y] = Xblank;
3078 if (cave[x+1][y] == Xblank)
3079 cave[x+1][y] = Xsplash_e;
3080 if (cave[x-1][y] == Xblank)
3081 cave[x-1][y] = Xsplash_w;
3082 play_element_sound(x, y, SOUND_acid, Xacid_1);
3086 cave[x][y] = Ybug_s_e;
3087 next[x][y] = Xbug_2_e;
3088 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3093 static void Lbug_1_s(int x, int y)
3095 if (is_amoeba[cave[x][y-1]] ||
3096 is_amoeba[cave[x+1][y]] ||
3097 is_amoeba[cave[x][y+1]] ||
3098 is_amoeba[cave[x-1][y]])
3106 switch (cave[x-1][y])
3130 cave[x][y] = Ybug_s_w;
3131 next[x][y] = Xbug_2_w;
3132 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3141 static void Lbug_2_s(int x, int y)
3143 if (is_amoeba[cave[x][y-1]] ||
3144 is_amoeba[cave[x+1][y]] ||
3145 is_amoeba[cave[x][y+1]] ||
3146 is_amoeba[cave[x-1][y]])
3157 static void Lbug_w(int x, int y)
3159 switch (cave[x-1][y])
3175 cave[x][y] = Ybug_wB;
3176 next[x][y] = Xblank;
3177 cave[x-1][y] = Ybug_w;
3178 next[x-1][y] = Xbug_1_w;
3179 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3190 cave[x][y] = Ybug_wB;
3191 next[x][y] = Xblank;
3192 if (cave[x][y-1] == Xblank)
3193 cave[x][y-1] = Xsplash_e;
3194 if (cave[x-2][y-1] == Xblank)
3195 cave[x-2][y-1] = Xsplash_w;
3196 play_element_sound(x, y, SOUND_acid, Xacid_1);
3200 cave[x][y] = Ybug_w_s;
3201 next[x][y] = Xbug_2_s;
3202 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3207 static void Lbug_1_w(int x, int y)
3209 if (is_amoeba[cave[x][y-1]] ||
3210 is_amoeba[cave[x+1][y]] ||
3211 is_amoeba[cave[x][y+1]] ||
3212 is_amoeba[cave[x-1][y]])
3220 switch (cave[x][y-1])
3244 cave[x][y] = Ybug_w_n;
3245 next[x][y] = Xbug_2_n;
3246 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3255 static void Lbug_2_w(int x, int y)
3257 if (is_amoeba[cave[x][y-1]] ||
3258 is_amoeba[cave[x+1][y]] ||
3259 is_amoeba[cave[x][y+1]] ||
3260 is_amoeba[cave[x-1][y]])
3271 static void Ltank_n(int x, int y)
3273 switch (cave[x][y-1])
3289 cave[x][y] = Ytank_nB;
3290 next[x][y] = Xblank;
3291 cave[x][y-1] = Ytank_n;
3292 next[x][y-1] = Xtank_1_n;
3293 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3304 cave[x][y] = Ytank_nB;
3305 next[x][y] = Xblank;
3306 if (cave[x+1][y-2] == Xblank)
3307 cave[x+1][y-2] = Xsplash_e;
3308 if (cave[x-1][y-2] == Xblank)
3309 cave[x-1][y-2] = Xsplash_w;
3310 play_element_sound(x, y, SOUND_acid, Xacid_1);
3314 cave[x][y] = Ytank_n_e;
3315 next[x][y] = Xtank_2_e;
3316 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3321 static void Ltank_1_n(int x, int y)
3323 if (is_amoeba[cave[x][y-1]] ||
3324 is_amoeba[cave[x+1][y]] ||
3325 is_amoeba[cave[x][y+1]] ||
3326 is_amoeba[cave[x-1][y]])
3334 switch (cave[x-1][y])
3358 cave[x][y] = Ytank_n_w;
3359 next[x][y] = Xtank_2_w;
3360 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3369 static void Ltank_2_n(int x, int y)
3371 if (is_amoeba[cave[x][y-1]] ||
3372 is_amoeba[cave[x+1][y]] ||
3373 is_amoeba[cave[x][y+1]] ||
3374 is_amoeba[cave[x-1][y]])
3385 static void Ltank_e(int x, int y)
3387 switch (cave[x+1][y])
3403 cave[x][y] = Ytank_eB;
3404 next[x][y] = Xblank;
3405 cave[x+1][y] = Ytank_e;
3406 next[x+1][y] = Xtank_1_e;
3407 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3418 cave[x][y] = Ytank_eB;
3419 next[x][y] = Xblank;
3420 if (cave[x+2][y-1] == Xblank)
3421 cave[x+2][y-1] = Xsplash_e;
3422 if (cave[x][y-1] == Xblank)
3423 cave[x][y-1] = Xsplash_w;
3424 play_element_sound(x, y, SOUND_acid, Xacid_1);
3428 cave[x][y] = Ytank_e_s;
3429 next[x][y] = Xtank_2_s;
3430 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3435 static void Ltank_1_e(int x, int y)
3437 if (is_amoeba[cave[x][y-1]] ||
3438 is_amoeba[cave[x+1][y]] ||
3439 is_amoeba[cave[x][y+1]] ||
3440 is_amoeba[cave[x-1][y]])
3448 switch (cave[x][y-1])
3472 cave[x][y] = Ytank_e_n;
3473 next[x][y] = Xtank_2_n;
3474 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3483 static void Ltank_2_e(int x, int y)
3485 if (is_amoeba[cave[x][y-1]] ||
3486 is_amoeba[cave[x+1][y]] ||
3487 is_amoeba[cave[x][y+1]] ||
3488 is_amoeba[cave[x-1][y]])
3499 static void Ltank_s(int x, int y)
3501 switch (cave[x][y+1])
3517 cave[x][y] = Ytank_sB;
3518 next[x][y] = Xblank;
3519 cave[x][y+1] = Ytank_s;
3520 next[x][y+1] = Xtank_1_s;
3521 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3532 cave[x][y] = Ytank_sB;
3533 next[x][y] = Xblank;
3534 if (cave[x+1][y] == Xblank)
3535 cave[x+1][y] = Xsplash_e;
3536 if (cave[x-1][y] == Xblank)
3537 cave[x-1][y] = Xsplash_w;
3538 play_element_sound(x, y, SOUND_acid, Xacid_1);
3542 cave[x][y] = Ytank_s_w;
3543 next[x][y] = Xtank_2_w;
3544 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3549 static void Ltank_1_s(int x, int y)
3551 if (is_amoeba[cave[x][y-1]] ||
3552 is_amoeba[cave[x+1][y]] ||
3553 is_amoeba[cave[x][y+1]] ||
3554 is_amoeba[cave[x-1][y]])
3562 switch (cave[x+1][y])
3586 cave[x][y] = Ytank_s_e;
3587 next[x][y] = Xtank_2_e;
3588 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3597 static void Ltank_2_s(int x, int y)
3599 if (is_amoeba[cave[x][y-1]] ||
3600 is_amoeba[cave[x+1][y]] ||
3601 is_amoeba[cave[x][y+1]] ||
3602 is_amoeba[cave[x-1][y]])
3613 static void Ltank_w(int x, int y)
3615 switch (cave[x-1][y])
3631 cave[x][y] = Ytank_wB;
3632 next[x][y] = Xblank;
3633 cave[x-1][y] = Ytank_w;
3634 next[x-1][y] = Xtank_1_w;
3635 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3646 cave[x][y] = Ytank_wB;
3647 next[x][y] = Xblank;
3648 if (cave[x][y-1] == Xblank)
3649 cave[x][y-1] = Xsplash_e;
3650 if (cave[x-2][y-1] == Xblank)
3651 cave[x-2][y-1] = Xsplash_w;
3652 play_element_sound(x, y, SOUND_acid, Xacid_1);
3656 cave[x][y] = Ytank_w_n;
3657 next[x][y] = Xtank_2_n;
3658 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3663 static void Ltank_1_w(int x, int y)
3665 if (is_amoeba[cave[x][y-1]] ||
3666 is_amoeba[cave[x+1][y]] ||
3667 is_amoeba[cave[x][y+1]] ||
3668 is_amoeba[cave[x-1][y]])
3676 switch (cave[x][y+1])
3700 cave[x][y] = Ytank_w_s;
3701 next[x][y] = Xtank_2_s;
3702 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3711 static void Ltank_2_w(int x, int y)
3713 if (is_amoeba[cave[x][y-1]] ||
3714 is_amoeba[cave[x+1][y]] ||
3715 is_amoeba[cave[x][y+1]] ||
3716 is_amoeba[cave[x-1][y]])
3727 static void Lemerald(int x, int y)
3729 switch (cave[x][y+1])
3742 cave[x][y] = Yemerald_sB;
3743 next[x][y] = Xblank;
3744 cave[x][y+1] = Yemerald_s;
3745 next[x][y+1] = Xemerald_fall;
3756 cave[x][y] = Yemerald_sB;
3757 next[x][y] = Xblank;
3758 if (cave[x+1][y] == Xblank)
3759 cave[x+1][y] = Xsplash_e;
3760 if (cave[x-1][y] == Xblank)
3761 cave[x-1][y] = Xsplash_w;
3762 play_element_sound(x, y, SOUND_acid, Xacid_1);
3775 case Xemerald_pause:
3777 case Xdiamond_pause:
3821 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
3823 cave[x][y] = Yemerald_eB;
3824 next[x][y] = Xblank;
3825 cave[x+1][y] = Yemerald_e;
3826 next[x+1][y] = Xemerald_pause;
3827 if (cave[x][y+1] == Xbumper)
3828 cave[x][y+1] = Ybumper;
3832 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
3834 cave[x][y] = Yemerald_wB;
3835 next[x][y] = Xblank;
3836 cave[x-1][y] = Yemerald_w;
3837 next[x-1][y] = Xemerald_pause;
3838 if (cave[x][y+1] == Xbumper)
3839 cave[x][y+1] = Ybumper;
3845 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
3847 cave[x][y] = Yemerald_wB;
3848 next[x][y] = Xblank;
3849 cave[x-1][y] = Yemerald_w;
3850 next[x-1][y] = Xemerald_pause;
3851 if (cave[x][y+1] == Xbumper)
3852 cave[x][y+1] = Ybumper;
3856 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
3858 cave[x][y] = Yemerald_eB;
3859 next[x][y] = Xblank;
3860 cave[x+1][y] = Yemerald_e;
3861 next[x+1][y] = Xemerald_pause;
3862 if (cave[x][y+1] == Xbumper)
3863 cave[x][y+1] = Ybumper;
3869 if (++lev.shine_cnt > 50)
3871 lev.shine_cnt = RANDOM(8);
3872 cave[x][y] = Xemerald_shine;
3879 static void Lemerald_pause(int x, int y)
3881 switch (cave[x][y+1])
3894 cave[x][y] = Yemerald_sB;
3895 next[x][y] = Xblank;
3896 cave[x][y+1] = Yemerald_s;
3897 next[x][y+1] = Xemerald_fall;
3908 cave[x][y] = Yemerald_sB;
3909 next[x][y] = Xblank;
3910 if (cave[x+1][y] == Xblank)
3911 cave[x+1][y] = Xsplash_e;
3912 if (cave[x-1][y] == Xblank)
3913 cave[x-1][y] = Xsplash_w;
3914 play_element_sound(x, y, SOUND_acid, Xacid_1);
3918 cave[x][y] = Xemerald;
3919 next[x][y] = Xemerald;
3924 static void Lemerald_fall(int x, int y)
3926 switch (cave[x][y+1])
3940 cave[x][y] = Yemerald_sB;
3941 next[x][y] = Xblank;
3942 cave[x][y+1] = Yemerald_s;
3943 next[x][y+1] = Xemerald_fall;
3954 cave[x][y] = Yemerald_sB;
3955 next[x][y] = Xblank;
3956 if (cave[x+1][y] == Xblank)
3957 cave[x+1][y] = Xsplash_e;
3958 if (cave[x-1][y] == Xblank)
3959 cave[x-1][y] = Xsplash_w;
3960 play_element_sound(x, y, SOUND_acid, Xacid_1);
3964 if (lev.wonderwall_time)
3966 lev.wonderwall_state = 1;
3967 cave[x][y] = Yemerald_sB;
3968 next[x][y] = Xblank;
3969 if (is_blank[cave[x][y+2]])
3971 cave[x][y+2] = Ydiamond_s;
3972 next[x][y+2] = Xdiamond_fall;
3974 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
3979 cave[x][y] = Xemerald;
3980 next[x][y] = Xemerald;
3981 play_element_sound(x, y, SOUND_diamond, Xemerald);
3986 static void Ldiamond(int x, int y)
3988 switch (cave[x][y+1])
4001 cave[x][y] = Ydiamond_sB;
4002 next[x][y] = Xblank;
4003 cave[x][y+1] = Ydiamond_s;
4004 next[x][y+1] = Xdiamond_fall;
4015 cave[x][y] = Ydiamond_sB;
4016 next[x][y] = Xblank;
4017 if (cave[x+1][y] == Xblank)
4018 cave[x+1][y] = Xsplash_e;
4019 if (cave[x-1][y] == Xblank)
4020 cave[x-1][y] = Xsplash_w;
4021 play_element_sound(x, y, SOUND_acid, Xacid_1);
4034 case Xemerald_pause:
4036 case Xdiamond_pause:
4080 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4082 cave[x][y] = Ydiamond_eB;
4083 next[x][y] = Xblank;
4084 cave[x+1][y] = Ydiamond_e;
4085 next[x+1][y] = Xdiamond_pause;
4086 if (cave[x][y+1] == Xbumper)
4087 cave[x][y+1] = Ybumper;
4091 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4093 cave[x][y] = Ydiamond_wB;
4094 next[x][y] = Xblank;
4095 cave[x-1][y] = Ydiamond_w;
4096 next[x-1][y] = Xdiamond_pause;
4097 if (cave[x][y+1] == Xbumper)
4098 cave[x][y+1] = Ybumper;
4104 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4106 cave[x][y] = Ydiamond_wB;
4107 next[x][y] = Xblank;
4108 cave[x-1][y] = Ydiamond_w;
4109 next[x-1][y] = Xdiamond_pause;
4110 if (cave[x][y+1] == Xbumper)
4111 cave[x][y+1] = Ybumper;
4115 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4117 cave[x][y] = Ydiamond_eB;
4118 next[x][y] = Xblank;
4119 cave[x+1][y] = Ydiamond_e;
4120 next[x+1][y] = Xdiamond_pause;
4121 if (cave[x][y+1] == Xbumper)
4122 cave[x][y+1] = Ybumper;
4128 if (++lev.shine_cnt > 50)
4130 lev.shine_cnt = RANDOM(8);
4131 cave[x][y] = Xdiamond_shine;
4138 static void Ldiamond_pause(int x, int y)
4140 switch (cave[x][y+1])
4153 cave[x][y] = Ydiamond_sB;
4154 next[x][y] = Xblank;
4155 cave[x][y+1] = Ydiamond_s;
4156 next[x][y+1] = Xdiamond_fall;
4167 cave[x][y] = Ydiamond_sB;
4168 next[x][y] = Xblank;
4169 if (cave[x+1][y] == Xblank)
4170 cave[x+1][y] = Xsplash_e;
4171 if (cave[x-1][y] == Xblank)
4172 cave[x-1][y] = Xsplash_w;
4173 play_element_sound(x, y, SOUND_acid, Xacid_1);
4177 cave[x][y] = Xdiamond;
4178 next[x][y] = Xdiamond;
4183 static void Ldiamond_fall(int x, int y)
4185 switch (cave[x][y+1])
4199 cave[x][y] = Ydiamond_sB;
4200 next[x][y] = Xblank;
4201 cave[x][y+1] = Ydiamond_s;
4202 next[x][y+1] = Xdiamond_fall;
4213 cave[x][y] = Ydiamond_sB;
4214 next[x][y] = Xblank;
4215 if (cave[x+1][y] == Xblank)
4216 cave[x+1][y] = Xsplash_e;
4217 if (cave[x-1][y] == Xblank)
4218 cave[x-1][y] = Xsplash_w;
4219 play_element_sound(x, y, SOUND_acid, Xacid_1);
4223 if (lev.wonderwall_time)
4225 lev.wonderwall_state = 1;
4226 cave[x][y] = Ydiamond_sB;
4227 next[x][y] = Xblank;
4228 if (is_blank[cave[x][y+2]])
4230 cave[x][y+2] = Ystone_s;
4231 next[x][y+2] = Xstone_fall;
4233 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
4238 cave[x][y] = Xdiamond;
4239 next[x][y] = Xdiamond;
4240 play_element_sound(x, y, SOUND_diamond, Xdiamond);
4245 static void Lstone(int x, int y)
4247 switch (cave[x][y+1])
4262 cave[x][y] = Ystone_sB;
4263 next[x][y] = Xblank;
4264 cave[x][y+1] = Ystone_s;
4265 next[x][y+1] = Xstone_fall;
4276 cave[x][y] = Ystone_sB;
4277 next[x][y] = Xblank;
4278 if (cave[x+1][y] == Xblank)
4279 cave[x+1][y] = Xsplash_e;
4280 if (cave[x-1][y] == Xblank)
4281 cave[x-1][y] = Xsplash_w;
4282 play_element_sound(x, y, SOUND_acid, Xacid_1);
4286 cave[x][y] = Xsand_stonein_1;
4287 next[x][y] = Xsand_stonein_2;
4288 cave[x][y+1] = Xsand_sandstone_1;
4289 next[x][y+1] = Xsand_sandstone_2;
4302 case Xemerald_pause:
4304 case Xdiamond_pause:
4341 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4343 cave[x][y] = Ystone_eB;
4344 next[x][y] = Xblank;
4345 cave[x+1][y] = Ystone_e;
4346 next[x+1][y] = Xstone_pause;
4347 if (cave[x][y+1] == Xbumper)
4348 cave[x][y+1] = Ybumper;
4352 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4354 cave[x][y] = Ystone_wB;
4355 next[x][y] = Xblank;
4356 cave[x-1][y] = Ystone_w;
4357 next[x-1][y] = Xstone_pause;
4358 if (cave[x][y+1] == Xbumper)
4359 cave[x][y+1] = Ybumper;
4365 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4367 cave[x][y] = Ystone_wB;
4368 next[x][y] = Xblank;
4369 cave[x-1][y] = Ystone_w;
4370 next[x-1][y] = Xstone_pause;
4371 if (cave[x][y+1] == Xbumper)
4372 cave[x][y+1] = Ybumper;
4376 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4378 cave[x][y] = Ystone_eB;
4379 next[x][y] = Xblank;
4380 cave[x+1][y] = Ystone_e;
4381 next[x+1][y] = Xstone_pause;
4382 if (cave[x][y+1] == Xbumper)
4383 cave[x][y+1] = Ybumper;
4390 static void Lstone_pause(int x, int y)
4392 switch (cave[x][y+1])
4405 cave[x][y] = Ystone_sB;
4406 next[x][y] = Xblank;
4407 cave[x][y+1] = Ystone_s;
4408 next[x][y+1] = Xstone_fall;
4419 cave[x][y] = Ystone_sB;
4420 next[x][y] = Xblank;
4421 if (cave[x+1][y] == Xblank)
4422 cave[x+1][y] = Xsplash_e;
4423 if (cave[x-1][y] == Xblank)
4424 cave[x-1][y] = Xsplash_w;
4425 play_element_sound(x, y, SOUND_acid, Xacid_1);
4429 cave[x][y] = Xstone;
4430 next[x][y] = Xstone;
4435 static void Lstone_fall(int x, int y)
4437 switch (cave[x][y+1])
4451 cave[x][y] = Ystone_sB;
4452 next[x][y] = Xblank;
4453 cave[x][y+1] = Ystone_s;
4454 next[x][y+1] = Xstone_fall;
4465 cave[x][y] = Ystone_sB;
4466 next[x][y] = Xblank;
4467 if (cave[x+1][y] == Xblank)
4468 cave[x+1][y] = Xsplash_e;
4469 if (cave[x-1][y] == Xblank)
4470 cave[x-1][y] = Xsplash_w;
4471 play_element_sound(x, y, SOUND_acid, Xacid_1);
4478 cave[x][y] = Ystone_sB;
4479 next[x][y] = Xblank;
4480 cave[x][y+1] = Yeater_stone;
4481 next[x][y+1] = Zeater;
4482 Lboom_eater_old(x, y+1);
4483 score += lev.eater_score;
4488 cave[x][y] = Ystone_sB;
4489 next[x][y] = Xblank;
4490 cave[x][y+1] = Yalien_stone;
4491 next[x][y+1] = Ztank;
4492 Lboom_tank_old(x, y+1);
4493 score += lev.alien_score;
4504 cave[x][y] = Ystone_sB;
4505 next[x][y] = Xblank;
4506 cave[x][y+1] = Ybug_stone;
4507 next[x][y+1] = Zbug;
4508 Lboom_bug_old(x, y+1);
4509 score += lev.bug_score;
4520 cave[x][y] = Ystone_sB;
4521 next[x][y] = Xblank;
4522 cave[x][y+1] = Ytank_stone;
4523 next[x][y+1] = Ztank;
4524 Lboom_tank_old(x, y+1);
4525 score += lev.tank_score;
4529 case Xdiamond_pause:
4530 switch (cave[x][y+2])
4586 next[x][y] = Xstone;
4587 play_element_sound(x, y, SOUND_stone, Xstone);
4591 cave[x][y] = Ystone_sB;
4592 next[x][y] = Xblank;
4593 cave[x][y+1] = Ydiamond_stone;
4594 next[x][y+1] = Xstone_pause;
4595 play_element_sound(x, y, SOUND_squash, Xdiamond);
4600 cave[x][y] = Xstone;
4601 next[x][y] = Xstone;
4602 cave[x][y+1] = Ybomb_blank;
4603 next[x][y+1] = Ztank;
4604 Lboom_tank_old(x, y+1);
4609 next[x][y] = Xstone;
4610 cave[x][y+1] = Ynut_stone;
4611 next[x][y+1] = Xemerald;
4612 play_element_sound(x, y, SOUND_crack, Xnut);
4613 score += lev.nut_score;
4619 switch (cave[x+1][y+1])
4634 cave[x][y+1] = Xspring_e;
4638 cave[x][y+1] = Xspring_w;
4644 switch (cave[x-1][y+1])
4659 cave[x][y+1] = Xspring_w;
4662 cave[x][y+1] = Xspring_e;
4667 next[x][y] = Xstone;
4671 if (lev.wonderwall_time)
4673 lev.wonderwall_state = 1;
4674 cave[x][y] = Ystone_sB;
4675 next[x][y] = Xblank;
4676 if (is_blank[cave[x][y+2]])
4678 cave[x][y+2] = Yemerald_s;
4679 next[x][y+2] = Xemerald_fall;
4681 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
4686 cave[x][y] = Xstone;
4687 next[x][y] = Xstone;
4688 play_element_sound(x, y, SOUND_stone, Xstone);
4693 static void Lbomb(int x, int y)
4695 switch (cave[x][y+1])
4708 cave[x][y] = Ybomb_sB;
4709 next[x][y] = Xblank;
4710 cave[x][y+1] = Ybomb_s;
4711 next[x][y+1] = Xbomb_fall;
4722 cave[x][y] = Ybomb_sB;
4723 next[x][y] = Xblank;
4724 if (cave[x+1][y] == Xblank)
4725 cave[x+1][y] = Xsplash_e;
4726 if (cave[x-1][y] == Xblank)
4727 cave[x-1][y] = Xsplash_w;
4728 play_element_sound(x, y, SOUND_acid, Xacid_1);
4741 case Xemerald_pause:
4743 case Xdiamond_pause:
4778 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4780 cave[x][y] = Ybomb_eB;
4781 next[x][y] = Xblank;
4782 cave[x+1][y] = Ybomb_e;
4783 next[x+1][y] = Xbomb_pause;
4784 if (cave[x][y+1] == Xbumper)
4785 cave[x][y+1] = Ybumper;
4789 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4791 cave[x][y] = Ybomb_wB;
4792 next[x][y] = Xblank;
4793 cave[x-1][y] = Ybomb_w;
4794 next[x-1][y] = Xbomb_pause;
4795 if (cave[x][y+1] == Xbumper)
4796 cave[x][y+1] = Ybumper;
4802 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4804 cave[x][y] = Ybomb_wB;
4805 next[x][y] = Xblank;
4806 cave[x-1][y] = Ybomb_w;
4807 next[x-1][y] = Xbomb_pause;
4808 if (cave[x][y+1] == Xbumper)
4809 cave[x][y+1] = Ybumper;
4813 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4815 cave[x][y] = Ybomb_eB;
4816 next[x][y] = Xblank;
4817 cave[x+1][y] = Ybomb_e;
4818 next[x+1][y] = Xbomb_pause;
4819 if (cave[x][y+1] == Xbumper)
4820 cave[x][y+1] = Ybumper;
4827 static void Lbomb_pause(int x, int y)
4829 switch (cave[x][y+1])
4842 cave[x][y] = Ybomb_sB;
4843 next[x][y] = Xblank;
4844 cave[x][y+1] = Ybomb_s;
4845 next[x][y+1] = Xbomb_fall;
4856 cave[x][y] = Ybomb_sB;
4857 next[x][y] = Xblank;
4858 if (cave[x+1][y] == Xblank)
4859 cave[x+1][y] = Xsplash_e;
4860 if (cave[x-1][y] == Xblank)
4861 cave[x-1][y] = Xsplash_w;
4862 play_element_sound(x, y, SOUND_acid, Xacid_1);
4872 static void Lbomb_fall(int x, int y)
4874 switch (cave[x][y+1])
4887 cave[x][y] = Ybomb_sB;
4888 next[x][y] = Xblank;
4889 cave[x][y+1] = Ybomb_s;
4890 next[x][y+1] = Xbomb_fall;
4901 cave[x][y] = Ybomb_sB;
4902 next[x][y] = Xblank;
4903 if (cave[x+1][y] == Xblank)
4904 cave[x+1][y] = Xsplash_e;
4905 if (cave[x-1][y] == Xblank)
4906 cave[x-1][y] = Xsplash_w;
4907 play_element_sound(x, y, SOUND_acid, Xacid_1);
4911 cave[x][y] = Ybomb_blank;
4913 Lboom_tank_old(x, y);
4918 static void Lnut(int x, int y)
4920 switch (cave[x][y+1])
4933 cave[x][y] = Ynut_sB;
4934 next[x][y] = Xblank;
4935 cave[x][y+1] = Ynut_s;
4936 next[x][y+1] = Xnut_fall;
4947 cave[x][y] = Ynut_sB;
4948 next[x][y] = Xblank;
4949 if (cave[x+1][y] == Xblank)
4950 cave[x+1][y] = Xsplash_e;
4951 if (cave[x-1][y] == Xblank)
4952 cave[x-1][y] = Xsplash_w;
4953 play_element_sound(x, y, SOUND_acid, Xacid_1);
4966 case Xemerald_pause:
4968 case Xdiamond_pause:
5003 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5005 cave[x][y] = Ynut_eB;
5006 next[x][y] = Xblank;
5007 cave[x+1][y] = Ynut_e;
5008 next[x+1][y] = Xnut_pause;
5009 if (cave[x][y+1] == Xbumper)
5010 cave[x][y+1] = Ybumper;
5014 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5016 cave[x][y] = Ynut_wB;
5017 next[x][y] = Xblank;
5018 cave[x-1][y] = Ynut_w;
5019 next[x-1][y] = Xnut_pause;
5020 if (cave[x][y+1] == Xbumper)
5021 cave[x][y+1] = Ybumper;
5027 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5029 cave[x][y] = Ynut_wB;
5030 next[x][y] = Xblank;
5031 cave[x-1][y] = Ynut_w;
5032 next[x-1][y] = Xnut_pause;
5033 if (cave[x][y+1] == Xbumper)
5034 cave[x][y+1] = Ybumper;
5038 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5040 cave[x][y] = Ynut_eB;
5041 next[x][y] = Xblank;
5042 cave[x+1][y] = Ynut_e;
5043 next[x+1][y] = Xnut_pause;
5044 if (cave[x][y+1] == Xbumper)
5045 cave[x][y+1] = Ybumper;
5052 static void Lnut_pause(int x, int y)
5054 switch (cave[x][y+1])
5067 cave[x][y] = Ynut_sB;
5068 next[x][y] = Xblank;
5069 cave[x][y+1] = Ynut_s;
5070 next[x][y+1] = Xnut_fall;
5081 cave[x][y] = Ynut_sB;
5082 next[x][y] = Xblank;
5083 if (cave[x+1][y] == Xblank)
5084 cave[x+1][y] = Xsplash_e;
5085 if (cave[x-1][y] == Xblank)
5086 cave[x-1][y] = Xsplash_w;
5087 play_element_sound(x, y, SOUND_acid, Xacid_1);
5097 static void Lnut_fall(int x, int y)
5099 switch (cave[x][y+1])
5113 cave[x][y] = Ynut_sB;
5114 next[x][y] = Xblank;
5115 cave[x][y+1] = Ynut_s;
5116 next[x][y+1] = Xnut_fall;
5127 cave[x][y] = Ynut_sB;
5128 next[x][y] = Xblank;
5129 if (cave[x+1][y] == Xblank)
5130 cave[x+1][y] = Xsplash_e;
5131 if (cave[x-1][y] == Xblank)
5132 cave[x-1][y] = Xsplash_w;
5133 play_element_sound(x, y, SOUND_acid, Xacid_1);
5139 play_element_sound(x, y, SOUND_nut, Xnut);
5144 static void Lspring(int x, int y)
5146 switch (cave[x][y+1])
5161 cave[x][y] = Yspring_sB;
5162 next[x][y] = Xblank;
5163 cave[x][y+1] = Yspring_s;
5164 next[x][y+1] = Xspring_fall;
5175 cave[x][y] = Yspring_sB;
5176 next[x][y] = Xblank;
5177 if (cave[x+1][y] == Xblank)
5178 cave[x+1][y] = Xsplash_e;
5179 if (cave[x-1][y] == Xblank)
5180 cave[x-1][y] = Xsplash_w;
5181 play_element_sound(x, y, SOUND_acid, Xacid_1);
5194 case Xemerald_pause:
5196 case Xdiamond_pause:
5231 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5233 cave[x][y] = Yspring_eB;
5234 next[x][y] = Xblank;
5235 cave[x+1][y] = Yspring_e;
5237 next[x+1][y] = Xspring_e;
5239 next[x+1][y] = Xspring_pause;
5241 if (cave[x][y+1] == Xbumper)
5242 cave[x][y+1] = Ybumper;
5246 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5248 cave[x][y] = Yspring_wB;
5249 next[x][y] = Xblank;
5250 cave[x-1][y] = Yspring_w;
5252 next[x-1][y] = Xspring_w;
5254 next[x-1][y] = Xspring_pause;
5256 if (cave[x][y+1] == Xbumper)
5257 cave[x][y+1] = Ybumper;
5263 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5265 cave[x][y] = Yspring_wB;
5266 next[x][y] = Xblank;
5267 cave[x-1][y] = Yspring_w;
5269 next[x-1][y] = Xspring_w;
5271 next[x-1][y] = Xspring_pause;
5273 if (cave[x][y+1] == Xbumper)
5274 cave[x][y+1] = Ybumper;
5278 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5280 cave[x][y] = Yspring_eB;
5281 next[x][y] = Xblank;
5282 cave[x+1][y] = Yspring_e;
5284 next[x+1][y] = Xspring_e;
5286 next[x+1][y] = Xspring_pause;
5288 if (cave[x][y+1] == Xbumper)
5289 cave[x][y+1] = Ybumper;
5296 static void Lspring_pause(int x, int y)
5298 switch (cave[x][y+1])
5311 cave[x][y] = Yspring_sB;
5312 next[x][y] = Xblank;
5313 cave[x][y+1] = Yspring_s;
5314 next[x][y+1] = Xspring_fall;
5325 cave[x][y] = Yspring_sB;
5326 next[x][y] = Xblank;
5327 if (cave[x+1][y] == Xblank)
5328 cave[x+1][y] = Xsplash_e;
5329 if (cave[x-1][y] == Xblank)
5330 cave[x-1][y] = Xsplash_w;
5331 play_element_sound(x, y, SOUND_acid, Xacid_1);
5335 cave[x][y] = Xspring;
5336 next[x][y] = Xspring;
5341 static void Lspring_e(int x, int y)
5343 switch (cave[x][y+1])
5356 cave[x][y] = Yspring_sB;
5357 next[x][y] = Xblank;
5358 cave[x][y+1] = Yspring_s;
5359 next[x][y+1] = Xspring_fall;
5370 cave[x][y] = Yspring_sB;
5371 next[x][y] = Xblank;
5372 if (cave[x+1][y] == Xblank)
5373 cave[x+1][y] = Xsplash_e;
5374 if (cave[x-1][y] == Xblank)
5375 cave[x-1][y] = Xsplash_w;
5376 play_element_sound(x, y, SOUND_acid, Xacid_1);
5380 cave[x][y+1] = Ybumper;
5383 switch (cave[x+1][y])
5400 cave[x][y] = Yspring_eB;
5401 next[x][y] = Xblank;
5402 cave[x+1][y] = Yspring_e;
5403 next[x+1][y] = Xspring_e;
5414 cave[x][y] = Yspring_eB;
5415 next[x][y] = Xblank;
5416 if (cave[x+2][y-1] == Xblank)
5417 cave[x+2][y-1] = Xsplash_e;
5418 if (cave[x][y-1] == Xblank)
5419 cave[x][y-1] = Xsplash_w;
5420 play_element_sound(x, y, SOUND_acid, Xacid_1);
5429 cave[x][y] = Yspring_alien_eB;
5430 next[x][y] = Xblank;
5431 cave[x+1][y] = Yspring_alien_e;
5432 next[x+1][y] = Xspring_e;
5433 play_element_sound(x, y, SOUND_slurp, Xalien);
5434 score += lev.slurp_score;
5439 cave[x+1][y] = Ybumper;
5440 next[x][y] = Xspring_w;
5441 play_element_sound(x, y, SOUND_spring, Xspring);
5445 cave[x][y] = Xspring;
5446 next[x][y] = Xspring;
5447 play_element_sound(x, y, SOUND_spring, Xspring);
5452 static void Lspring_w(int x, int y)
5454 switch (cave[x][y+1])
5467 cave[x][y] = Yspring_sB;
5468 next[x][y] = Xblank;
5469 cave[x][y+1] = Yspring_s;
5470 next[x][y+1] = Xspring_fall;
5481 cave[x][y] = Yspring_sB;
5482 next[x][y] = Xblank;
5483 if (cave[x+1][y] == Xblank)
5484 cave[x+1][y] = Xsplash_e;
5485 if (cave[x-1][y] == Xblank)
5486 cave[x-1][y] = Xsplash_w;
5487 play_element_sound(x, y, SOUND_acid, Xacid_1);
5491 cave[x][y+1] = Ybumper;
5494 switch (cave[x-1][y])
5511 cave[x][y] = Yspring_wB;
5512 next[x][y] = Xblank;
5513 cave[x-1][y] = Yspring_w;
5514 next[x-1][y] = Xspring_w;
5525 cave[x][y] = Yspring_wB;
5526 next[x][y] = Xblank;
5527 if (cave[x][y-1] == Xblank)
5528 cave[x][y-1] = Xsplash_e;
5529 if (cave[x-2][y-1] == Xblank)
5530 cave[x-2][y-1] = Xsplash_w;
5531 play_element_sound(x, y, SOUND_acid, Xacid_1);
5540 cave[x][y] = Yspring_alien_wB;
5541 next[x][y] = Xblank;
5542 cave[x-1][y] = Yspring_alien_w;
5543 next[x-1][y] = Xspring_w;
5544 play_element_sound(x, y, SOUND_slurp, Xalien);
5545 score += lev.slurp_score;
5550 cave[x-1][y] = Ybumper;
5551 next[x][y] = Xspring_e;
5552 play_element_sound(x, y, SOUND_spring, Xspring);
5556 cave[x][y] = Xspring;
5557 next[x][y] = Xspring;
5558 play_element_sound(x, y, SOUND_spring, Xspring);
5563 static void Lspring_fall(int x, int y)
5565 switch (cave[x][y+1])
5579 cave[x][y] = Yspring_sB;
5580 next[x][y] = Xblank;
5581 cave[x][y+1] = Yspring_s;
5582 next[x][y+1] = Xspring_fall;
5593 cave[x][y] = Yspring_sB;
5594 next[x][y] = Xblank;
5595 if (cave[x+1][y] == Xblank)
5596 cave[x+1][y] = Xsplash_e;
5597 if (cave[x-1][y] == Xblank)
5598 cave[x-1][y] = Xsplash_w;
5599 play_element_sound(x, y, SOUND_acid, Xacid_1);
5606 cave[x][y] = Yspring_sB;
5607 next[x][y] = Xblank;
5608 cave[x][y+1] = Yeater_spring;
5609 next[x][y+1] = Zeater;
5610 Lboom_eater_old(x, y+1);
5611 score += lev.eater_score;
5616 cave[x][y] = Yspring_sB;
5617 next[x][y] = Xblank;
5618 cave[x][y+1] = Yalien_spring;
5619 next[x][y+1] = Ztank;
5620 Lboom_tank_old(x, y+1);
5621 score += lev.alien_score;
5632 cave[x][y] = Yspring_sB;
5633 next[x][y] = Xblank;
5634 cave[x][y+1] = Ybug_spring;
5635 next[x][y+1] = Zbug;
5636 Lboom_bug_old(x, y+1);
5637 score += lev.bug_score;
5648 cave[x][y] = Yspring_sB;
5649 next[x][y] = Xblank;
5650 cave[x][y+1] = Ytank_spring;
5651 next[x][y+1] = Ztank;
5652 Lboom_tank_old(x, y+1);
5653 score += lev.tank_score;
5658 cave[x][y] = Xspring;
5659 next[x][y] = Xspring;
5660 cave[x][y+1] = Ybomb_blank;
5661 next[x][y+1] = Ztank;
5662 Lboom_tank_old(x, y+1);
5666 cave[x][y] = Xspring;
5667 next[x][y] = Xspring;
5668 play_element_sound(x, y, SOUND_spring, Xspring);
5673 static void Lpush_emerald_e(int x, int y)
5675 cave[x][y] = Yemerald_eB;
5676 next[x][y] = Xblank;
5678 switch (cave[x+1][y])
5702 if (cave[x+2][y-1] == Xblank)
5703 cave[x+2][y-1] = Xsplash_e;
5704 if (cave[x][y-1] == Xblank)
5705 cave[x][y-1] = Xsplash_w;
5706 play_element_sound(x, y, SOUND_acid, Xacid_1);
5711 cave[x+1][y] = Yemerald_e;
5712 next[x+1][y] = Xemerald_pause;
5715 static void Lpush_emerald_w(int x, int y)
5717 cave[x][y] = Yemerald_wB;
5718 next[x][y] = Xblank;
5720 switch (cave[x-1][y])
5744 if (cave[x][y-1] == Xblank)
5745 cave[x][y-1] = Xsplash_e;
5746 if (cave[x-2][y-1] == Xblank)
5747 cave[x-2][y-1] = Xsplash_w;
5748 play_element_sound(x, y, SOUND_acid, Xacid_1);
5753 cave[x-1][y] = Yemerald_w;
5754 next[x-1][y] = Xemerald_pause;
5757 static void Lpush_diamond_e(int x, int y)
5759 cave[x][y] = Ydiamond_eB;
5760 next[x][y] = Xblank;
5762 switch (cave[x+1][y])
5786 if (cave[x+2][y-1] == Xblank)
5787 cave[x+2][y-1] = Xsplash_e;
5788 if (cave[x][y-1] == Xblank)
5789 cave[x][y-1] = Xsplash_w;
5790 play_element_sound(x, y, SOUND_acid, Xacid_1);
5795 cave[x+1][y] = Ydiamond_e;
5796 next[x+1][y] = Xdiamond_pause;
5799 static void Lpush_diamond_w(int x, int y)
5801 cave[x][y] = Ydiamond_wB;
5802 next[x][y] = Xblank;
5804 switch (cave[x-1][y])
5828 if (cave[x][y-1] == Xblank)
5829 cave[x][y-1] = Xsplash_e;
5830 if (cave[x-2][y-1] == Xblank)
5831 cave[x-2][y-1] = Xsplash_w;
5832 play_element_sound(x, y, SOUND_acid, Xacid_1);
5837 cave[x-1][y] = Ydiamond_w;
5838 next[x-1][y] = Xdiamond_pause;
5841 static void Lpush_stone_e(int x, int y)
5843 cave[x][y] = Ystone_eB;
5844 next[x][y] = Xblank;
5846 switch (cave[x+1][y])
5870 if (cave[x+2][y-1] == Xblank)
5871 cave[x+2][y-1] = Xsplash_e;
5872 if (cave[x][y-1] == Xblank)
5873 cave[x][y-1] = Xsplash_w;
5874 play_element_sound(x, y, SOUND_acid, Xacid_1);
5879 cave[x+1][y] = Ystone_e;
5880 next[x+1][y] = Xstone_pause;
5883 static void Lpush_stone_w(int x, int y)
5885 cave[x][y] = Ystone_wB;
5886 next[x][y] = Xblank;
5888 switch (cave[x-1][y])
5912 if (cave[x][y-1] == Xblank)
5913 cave[x][y-1] = Xsplash_e;
5914 if (cave[x-2][y-1] == Xblank)
5915 cave[x-2][y-1] = Xsplash_w;
5916 play_element_sound(x, y, SOUND_acid, Xacid_1);
5921 cave[x-1][y] = Ystone_w;
5922 next[x-1][y] = Xstone_pause;
5925 static void Lpush_bomb_e(int x, int y)
5927 cave[x][y] = Ybomb_eB;
5928 next[x][y] = Xblank;
5930 switch (cave[x+1][y])
5954 if (cave[x+2][y-1] == Xblank)
5955 cave[x+2][y-1] = Xsplash_e;
5956 if (cave[x][y-1] == Xblank)
5957 cave[x][y-1] = Xsplash_w;
5958 play_element_sound(x, y, SOUND_acid, Xacid_1);
5963 cave[x+1][y] = Ybomb_e;
5964 next[x+1][y] = Xbomb_pause;
5967 static void Lpush_bomb_w(int x, int y)
5969 cave[x][y] = Ybomb_wB;
5970 next[x][y] = Xblank;
5972 switch (cave[x-1][y])
5996 if (cave[x][y-1] == Xblank)
5997 cave[x][y-1] = Xsplash_e;
5998 if (cave[x-2][y-1] == Xblank)
5999 cave[x-2][y-1] = Xsplash_w;
6000 play_element_sound(x, y, SOUND_acid, Xacid_1);
6005 cave[x-1][y] = Ybomb_w;
6006 next[x-1][y] = Xbomb_pause;
6009 static void Lpush_nut_e(int x, int y)
6011 cave[x][y] = Ynut_eB;
6012 next[x][y] = Xblank;
6014 switch (cave[x+1][y])
6038 if (cave[x+2][y-1] == Xblank)
6039 cave[x+2][y-1] = Xsplash_e;
6040 if (cave[x][y-1] == Xblank)
6041 cave[x][y-1] = Xsplash_w;
6042 play_element_sound(x, y, SOUND_acid, Xacid_1);
6047 cave[x+1][y] = Ynut_e;
6048 next[x+1][y] = Xnut_pause;
6051 static void Lpush_nut_w(int x, int y)
6053 cave[x][y] = Ynut_wB;
6054 next[x][y] = Xblank;
6056 switch (cave[x-1][y])
6080 if (cave[x][y-1] == Xblank)
6081 cave[x][y-1] = Xsplash_e;
6082 if (cave[x-2][y-1] == Xblank)
6083 cave[x-2][y-1] = Xsplash_w;
6084 play_element_sound(x, y, SOUND_acid, Xacid_1);
6089 cave[x-1][y] = Ynut_w;
6090 next[x-1][y] = Xnut_pause;
6093 static void Lpush_spring_e(int x, int y)
6095 cave[x][y] = Yspring_eB;
6096 next[x][y] = Xblank;
6098 switch (cave[x+1][y])
6122 if (cave[x+2][y-1] == Xblank)
6123 cave[x+2][y-1] = Xsplash_e;
6124 if (cave[x][y-1] == Xblank)
6125 cave[x][y-1] = Xsplash_w;
6126 play_element_sound(x, y, SOUND_acid, Xacid_1);
6131 cave[x+1][y] = Yspring_e;
6132 next[x+1][y] = Xspring_e;
6135 static void Lpush_spring_w(int x, int y)
6137 cave[x][y] = Yspring_wB;
6138 next[x][y] = Xblank;
6140 switch (cave[x-1][y])
6164 if (cave[x][y-1] == Xblank)
6165 cave[x][y-1] = Xsplash_e;
6166 if (cave[x-2][y-1] == Xblank)
6167 cave[x-2][y-1] = Xsplash_w;
6168 play_element_sound(x, y, SOUND_acid, Xacid_1);
6173 cave[x-1][y] = Yspring_w;
6174 next[x-1][y] = Xspring_w;
6177 static void Ldynamite_1(int x, int y)
6179 play_element_sound(x, y, SOUND_tick, Xdynamite_1);
6180 next[x][y] = Xdynamite_2;
6183 static void Ldynamite_2(int x, int y)
6185 play_element_sound(x, y, SOUND_tick, Xdynamite_2);
6186 next[x][y] = Xdynamite_3;
6189 static void Ldynamite_3(int x, int y)
6191 play_element_sound(x, y, SOUND_tick, Xdynamite_3);
6192 next[x][y] = Xdynamite_4;
6195 static void Ldynamite_4(int x, int y)
6197 play_element_sound(x, y, SOUND_tick, Xdynamite_4);
6198 next[x][y] = Zdynamite;
6200 Lboom_generic(x, y, Xblank, Xblank);
6203 static void Lfake_door_1(int x, int y)
6205 if (lev.magnify_cnt)
6206 cave[x][y] = Xdoor_1;
6209 static void Lfake_door_2(int x, int y)
6211 if (lev.magnify_cnt)
6212 cave[x][y] = Xdoor_2;
6215 static void Lfake_door_3(int x, int y)
6217 if (lev.magnify_cnt)
6218 cave[x][y] = Xdoor_3;
6221 static void Lfake_door_4(int x, int y)
6223 if (lev.magnify_cnt)
6224 cave[x][y] = Xdoor_4;
6227 static void Lfake_door_5(int x, int y)
6229 if (lev.magnify_cnt)
6230 cave[x][y] = Xdoor_5;
6233 static void Lfake_door_6(int x, int y)
6235 if (lev.magnify_cnt)
6236 cave[x][y] = Xdoor_6;
6239 static void Lfake_door_7(int x, int y)
6241 if (lev.magnify_cnt)
6242 cave[x][y] = Xdoor_7;
6245 static void Lfake_door_8(int x, int y)
6247 if (lev.magnify_cnt)
6248 cave[x][y] = Xdoor_8;
6251 static void Lballoon(int x, int y)
6253 if (lev.wind_cnt == 0)
6256 switch (lev.wind_direction)
6259 switch (cave[x][y-1])
6272 cave[x][y] = Yballoon_nB;
6273 next[x][y] = Xblank;
6274 cave[x][y-1] = Yballoon_n;
6275 next[x][y-1] = Xballoon;
6286 cave[x][y] = Yballoon_nB;
6287 next[x][y] = Xblank;
6288 if (cave[x+1][y-2] == Xblank)
6289 cave[x+1][y-2] = Xsplash_e;
6290 if (cave[x-1][y-2] == Xblank)
6291 cave[x-1][y-2] = Xsplash_w;
6292 play_element_sound(x, y, SOUND_acid, Xacid_1);
6298 switch (cave[x+1][y])
6311 cave[x][y] = Yballoon_eB;
6312 next[x][y] = Xblank;
6313 cave[x+1][y] = Yballoon_e;
6314 next[x+1][y] = Xballoon;
6325 cave[x][y] = Yballoon_eB;
6326 next[x][y] = Xblank;
6327 if (cave[x+2][y-1] == Xblank)
6328 cave[x+2][y-1] = Xsplash_e;
6329 if (cave[x][y-1] == Xblank)
6330 cave[x][y-1] = Xsplash_w;
6331 play_element_sound(x, y, SOUND_acid, Xacid_1);
6337 switch (cave[x][y+1])
6350 cave[x][y] = Yballoon_sB;
6351 next[x][y] = Xblank;
6352 cave[x][y+1] = Yballoon_s;
6353 next[x][y+1] = Xballoon;
6364 cave[x][y] = Yballoon_sB;
6365 next[x][y] = Xblank;
6366 if (cave[x+1][y] == Xblank)
6367 cave[x+1][y] = Xsplash_e;
6368 if (cave[x-1][y] == Xblank)
6369 cave[x-1][y] = Xsplash_w;
6370 play_element_sound(x, y, SOUND_acid, Xacid_1);
6376 switch (cave[x-1][y])
6389 cave[x][y] = Yballoon_wB;
6390 next[x][y] = Xblank;
6391 cave[x-1][y] = Yballoon_w;
6392 next[x-1][y] = Xballoon;
6403 cave[x][y] = Yballoon_wB;
6404 next[x][y] = Xblank;
6405 if (cave[x][y-1] == Xblank)
6406 cave[x][y-1] = Xsplash_e;
6407 if (cave[x-2][y-1] == Xblank)
6408 cave[x-2][y-1] = Xsplash_w;
6409 play_element_sound(x, y, SOUND_acid, Xacid_1);
6416 static void Lball_common(int x, int y)
6418 play_element_sound(x, y, SOUND_ball, Xball_1);
6420 if (lev.ball_random)
6425 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
6426 is_blank[cave[x-1][y-1]])
6428 cave[x-1][y-1] = Yball_blank;
6429 next[x-1][y-1] = lev.ball_array[lev.ball_pos][0];
6434 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
6435 is_blank[cave[x][y-1]])
6437 cave[x][y-1] = Yball_blank;
6438 next[x][y-1] = lev.ball_array[lev.ball_pos][1];
6443 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
6444 is_blank[cave[x+1][y-1]])
6446 cave[x+1][y-1] = Yball_blank;
6447 next[x+1][y-1] = lev.ball_array[lev.ball_pos][2];
6452 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
6453 is_blank[cave[x-1][y]])
6455 cave[x-1][y] = Yball_blank;
6456 next[x-1][y] = lev.ball_array[lev.ball_pos][3];
6461 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
6462 is_blank[cave[x+1][y]])
6464 cave[x+1][y] = Yball_blank;
6465 next[x+1][y] = lev.ball_array[lev.ball_pos][4];
6470 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
6471 is_blank[cave[x-1][y+1]])
6473 cave[x-1][y+1] = Yball_blank;
6474 next[x-1][y+1] = lev.ball_array[lev.ball_pos][5];
6479 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
6480 is_blank[cave[x][y+1]])
6482 cave[x][y+1] = Yball_blank;
6483 next[x][y+1] = lev.ball_array[lev.ball_pos][6];
6488 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
6489 is_blank[cave[x+1][y+1]])
6491 cave[x+1][y+1] = Yball_blank;
6492 next[x+1][y+1] = lev.ball_array[lev.ball_pos][7];
6499 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
6500 is_blank[cave[x-1][y-1]])
6502 cave[x-1][y-1] = Yball_blank;
6503 next[x-1][y-1] = lev.ball_array[lev.ball_pos][0];
6506 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
6507 is_blank[cave[x][y-1]])
6509 cave[x][y-1] = Yball_blank;
6510 next[x][y-1] = lev.ball_array[lev.ball_pos][1];
6513 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
6514 is_blank[cave[x+1][y-1]])
6516 cave[x+1][y-1] = Yball_blank;
6517 next[x+1][y-1] = lev.ball_array[lev.ball_pos][2];
6520 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
6521 is_blank[cave[x-1][y]])
6523 cave[x-1][y] = Yball_blank;
6524 next[x-1][y] = lev.ball_array[lev.ball_pos][3];
6527 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
6528 is_blank[cave[x+1][y]])
6530 cave[x+1][y] = Yball_blank;
6531 next[x+1][y] = lev.ball_array[lev.ball_pos][4];
6534 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
6535 is_blank[cave[x-1][y+1]])
6537 cave[x-1][y+1] = Yball_blank;
6538 next[x-1][y+1] = lev.ball_array[lev.ball_pos][5];
6541 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
6542 is_blank[cave[x][y+1]])
6544 cave[x][y+1] = Yball_blank;
6545 next[x][y+1] = lev.ball_array[lev.ball_pos][6];
6548 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
6549 is_blank[cave[x+1][y+1]])
6551 cave[x+1][y+1] = Yball_blank;
6552 next[x+1][y+1] = lev.ball_array[lev.ball_pos][7];
6556 lev.ball_pos = (lev.ball_pos + 1) % lev.num_ball_arrays;
6559 static void Lball_1(int x, int y)
6561 if (lev.ball_state == 0)
6564 cave[x][y] = Yball_1;
6565 next[x][y] = Xball_2;
6572 static void Lball_2(int x, int y)
6574 if (lev.ball_state == 0)
6577 cave[x][y] = Yball_2;
6578 next[x][y] = Xball_1;
6585 static void Ldrip(int x, int y)
6587 next[x][y] = Xdrip_fall;
6590 static void Ldrip_fall(int x, int y)
6594 switch (cave[x][y+1])
6610 cave[x][y] = Ydrip_1_sB;
6611 next[x][y] = Xdrip_stretchB;
6612 cave[x][y+1] = Ydrip_1_s;
6613 next[x][y+1] = Xdrip_stretch;
6624 cave[x][y] = Ydrip_1_sB;
6625 next[x][y] = Xdrip_stretchB;
6626 if (cave[x+1][y] == Xblank)
6627 cave[x+1][y] = Xsplash_e;
6628 if (cave[x-1][y] == Xblank)
6629 cave[x-1][y] = Xsplash_w;
6630 play_element_sound(x, y, SOUND_acid, Xacid_1);
6636 case 0: temp = Xamoeba_1; break;
6637 case 1: temp = Xamoeba_2; break;
6638 case 2: temp = Xamoeba_3; break;
6639 case 3: temp = Xamoeba_4; break;
6640 case 4: temp = Xamoeba_5; break;
6641 case 5: temp = Xamoeba_6; break;
6642 case 6: temp = Xamoeba_7; break;
6643 case 7: temp = Xamoeba_8; break;
6648 play_element_sound(x, y, SOUND_drip, Xdrip_fall);
6653 static void Ldrip_stretch(int x, int y)
6655 cave[x][y] = Ydrip_2_s;
6656 next[x][y] = Xdrip_fall;
6659 static void Ldrip_stretchB(int x, int y)
6661 cave[x][y] = Ydrip_2_sB;
6662 next[x][y] = Xblank;
6665 static void Lwonderwall(int x, int y)
6667 if (lev.wonderwall_time && lev.wonderwall_state)
6669 cave[x][y] = Ywonderwall;
6670 play_element_sound(x, y, SOUND_wonder, Xwonderwall);
6674 static void Lwheel(int x, int y)
6676 if (lev.wheel_cnt && x == lev.wheel_x && y == lev.wheel_y)
6677 cave[x][y] = Ywheel;
6680 static void Lswitch(int x, int y)
6683 cave[x][y] = Yswitch;
6686 static void Lfake_blank(int x, int y)
6689 cave[x][y] = Yfake_blank;
6692 static void Lfake_grass(int x, int y)
6694 if (lev.magnify_cnt)
6695 cave[x][y] = Yfake_grass;
6698 static void Lfake_amoeba(int x, int y)
6701 cave[x][y] = Yfake_amoeba;
6704 static void Lsand_stone(int x, int y)
6706 switch (cave[x][y+1])
6719 cave[x][y] = Xsand_stonesand_quickout_1;
6720 next[x][y] = Xsand_stonesand_quickout_2;
6721 cave[x][y+1] = Xsand_stoneout_1;
6722 next[x][y+1] = Xsand_stoneout_2;
6733 cave[x][y] = Xsand_stonesand_quickout_1;
6734 next[x][y] = Xsand_stonesand_quickout_2;
6735 if (cave[x+1][y] == Xblank)
6736 cave[x+1][y] = Xsplash_e;
6737 if (cave[x-1][y] == Xblank)
6738 cave[x-1][y] = Xsplash_w;
6739 play_element_sound(x, y, SOUND_acid, Xacid_1);
6743 cave[x][y] = Xsand_stonesand_1;
6744 next[x][y] = Xsand_stonesand_2;
6745 cave[x][y+1] = Xsand_sandstone_1;
6746 next[x][y+1] = Xsand_sandstone_2;
6751 static void Lsand_stonein_1(int x, int y)
6753 next[x][y] = Xsand_stonein_2;
6756 static void Lsand_stonein_2(int x, int y)
6758 next[x][y] = Xsand_stonein_3;
6761 static void Lsand_stonein_3(int x, int y)
6763 next[x][y] = Xsand_stonein_4;
6766 static void Lsand_stonein_4(int x, int y)
6768 next[x][y] = Xblank;
6771 static void Lsand_sandstone_1(int x, int y)
6773 next[x][y] = Xsand_sandstone_2;
6776 static void Lsand_sandstone_2(int x, int y)
6778 next[x][y] = Xsand_sandstone_3;
6781 static void Lsand_sandstone_3(int x, int y)
6783 next[x][y] = Xsand_sandstone_4;
6786 static void Lsand_sandstone_4(int x, int y)
6788 next[x][y] = Xsand_stone;
6791 static void Lsand_stonesand_1(int x, int y)
6793 next[x][y] = Xsand_stonesand_2;
6796 static void Lsand_stonesand_2(int x, int y)
6798 next[x][y] = Xsand_stonesand_3;
6801 static void Lsand_stonesand_3(int x, int y)
6803 next[x][y] = Xsand_stonesand_4;
6806 static void Lsand_stonesand_4(int x, int y)
6811 static void Lsand_stoneout_1(int x, int y)
6813 next[x][y] = Xsand_stoneout_2;
6816 static void Lsand_stoneout_2(int x, int y)
6818 next[x][y] = Xstone_fall;
6821 static void Lsand_stonesand_quickout_1(int x, int y)
6823 next[x][y] = Xsand_stonesand_quickout_2;
6826 static void Lsand_stonesand_quickout_2(int x, int y)
6831 static void Lslide_ns(int x, int y)
6833 if (is_blank[cave[x][y-1]])
6835 cave[x][y-1] = Yslide_ns_blank;
6836 next[x][y-1] = Xslide_ns;
6837 play_element_sound(x, y, SOUND_slide, Xslide_ns);
6840 if (is_blank[cave[x][y+1]])
6842 cave[x][y+1] = Yslide_ns_blank;
6843 next[x][y+1] = Xslide_ns;
6844 play_element_sound(x, y, SOUND_slide, Xslide_ns);
6848 static void Lslide_ew(int x, int y)
6850 if (is_blank[cave[x+1][y]])
6852 cave[x+1][y] = Yslide_ew_blank;
6853 next[x+1][y] = Xslide_ew;
6854 play_element_sound(x, y, SOUND_slide, Xslide_ew);
6857 if (is_blank[cave[x-1][y]])
6859 cave[x-1][y] = Yslide_ew_blank;
6860 next[x-1][y] = Xslide_ew;
6861 play_element_sound(x, y, SOUND_slide, Xslide_ew);
6865 static void Lexit(int x, int y)
6867 if (lev.gems_needed > 0)
6870 switch (RANDOM(64) / 21)
6873 cave[x][y] = Xexit_1;
6874 next[x][y] = Xexit_2;
6878 cave[x][y] = Xexit_2;
6879 next[x][y] = Xexit_3;
6883 cave[x][y] = Xexit_3;
6884 next[x][y] = Xexit_1;
6888 play_element_sound(x, y, SOUND_exit_open, Xexit);
6891 static void Lexit_1(int x, int y)
6893 next[x][y] = Xexit_2;
6896 static void Lexit_2(int x, int y)
6898 next[x][y] = Xexit_3;
6901 static void Lexit_3(int x, int y)
6903 next[x][y] = Xexit_1;
6906 static void Lpause(int x, int y)
6908 next[x][y] = Xblank;
6911 static void Lamoeba(int x, int y)
6931 if (is_amoeba[cave[x][y-1]] ||
6932 is_amoeba[cave[x+1][y]] ||
6933 is_amoeba[cave[x][y+1]] ||
6934 is_amoeba[cave[x-1][y]])
6939 static void Lboom_one(int x, int y, boolean by_dynamite)
7000 cave[x][y] = Xboom_android;
7011 cave[x][y] = Xboom_bug;
7012 Lboom_bug_new(x, y, TRUE);
7018 cave[x][y] = Xboom_tank;
7019 Lboom_tank_new(x, y, TRUE);
7023 cave[x][y] = Xboom_1;
7028 static void Lboom_nine(int x, int y, boolean by_dynamite)
7030 Lboom_one(x, y-1, by_dynamite);
7031 Lboom_one(x-1, y, by_dynamite);
7032 Lboom_one(x+1, y, by_dynamite);
7033 Lboom_one(x, y+1, by_dynamite);
7034 Lboom_one(x-1, y-1, by_dynamite);
7035 Lboom_one(x+1, y-1, by_dynamite);
7036 Lboom_one(x-1, y+1, by_dynamite);
7037 Lboom_one(x+1, y+1, by_dynamite);
7039 cave[x][y] = Xboom_1;
7042 static void Lexplode(int x, int y)
7047 Lboom_bug_new(x, y, FALSE);
7048 Lboom_nine(x, y, FALSE);
7052 Lboom_tank_new(x, y, FALSE);
7053 Lboom_nine(x, y, FALSE);
7057 Lboom_eater_new(x, y, FALSE);
7058 Lboom_nine(x, y, FALSE);
7062 Lboom_nine(x, y, TRUE);
7066 Lboom_nine(x, y, FALSE);
7071 static void Lboom_1(int x, int y)
7073 next[x][y] = Xboom_2;
7074 #if !PLAY_ELEMENT_SOUND
7075 if (x != lev.exit_x && y != lev.exit_y)
7076 play_sound(x, y, SOUND_boom);
7078 lev.exit_x = lev.exit_y = -1;
7082 static void Lboom_2(int x, int y)
7084 next[x][y] = boom[x][y];
7087 static void Lboom_android(int x, int y)
7089 #if PLAY_ELEMENT_SOUND
7090 play_element_sound(x, y, SOUND_boom, Xandroid);
7096 static void Lchain(int x, int y)
7101 static void handle_tile(int x, int y)
7105 case Xacid_1: Lacid_1(x, y); break;
7106 case Xacid_2: Lacid_2(x, y); break;
7107 case Xacid_3: Lacid_3(x, y); break;
7108 case Xacid_4: Lacid_4(x, y); break;
7109 case Xacid_5: Lacid_5(x, y); break;
7110 case Xacid_6: Lacid_6(x, y); break;
7111 case Xacid_7: Lacid_7(x, y); break;
7112 case Xacid_8: Lacid_8(x, y); break;
7114 case Xfake_acid_1: Lfake_acid_1(x, y); break;
7115 case Xfake_acid_2: Lfake_acid_2(x, y); break;
7116 case Xfake_acid_3: Lfake_acid_3(x, y); break;
7117 case Xfake_acid_4: Lfake_acid_4(x, y); break;
7118 case Xfake_acid_5: Lfake_acid_5(x, y); break;
7119 case Xfake_acid_6: Lfake_acid_6(x, y); break;
7120 case Xfake_acid_7: Lfake_acid_7(x, y); break;
7121 case Xfake_acid_8: Lfake_acid_8(x, y); break;
7123 case Xandroid: Landroid(x, y); break;
7124 case Xandroid_1_n: Landroid_1_n(x, y); break;
7125 case Xandroid_2_n: Landroid_2_n(x, y); break;
7126 case Xandroid_1_e: Landroid_1_e(x, y); break;
7127 case Xandroid_2_e: Landroid_2_e(x, y); break;
7128 case Xandroid_1_s: Landroid_1_s(x, y); break;
7129 case Xandroid_2_s: Landroid_2_s(x, y); break;
7130 case Xandroid_1_w: Landroid_1_w(x, y); break;
7131 case Xandroid_2_w: Landroid_2_w(x, y); break;
7133 case Xeater_n: Leater_n(x, y); break;
7134 case Xeater_e: Leater_e(x, y); break;
7135 case Xeater_s: Leater_s(x, y); break;
7136 case Xeater_w: Leater_w(x, y); break;
7138 case Xalien: Lalien(x, y); break;
7139 case Xalien_pause: Lalien_pause(x, y); break;
7141 case Xbug_1_n: Lbug_1_n(x, y); break;
7142 case Xbug_2_n: Lbug_2_n(x, y); break;
7143 case Xbug_1_e: Lbug_1_e(x, y); break;
7144 case Xbug_2_e: Lbug_2_e(x, y); break;
7145 case Xbug_1_s: Lbug_1_s(x, y); break;
7146 case Xbug_2_s: Lbug_2_s(x, y); break;
7147 case Xbug_1_w: Lbug_1_w(x, y); break;
7148 case Xbug_2_w: Lbug_2_w(x, y); break;
7150 case Xtank_1_n: Ltank_1_n(x, y); break;
7151 case Xtank_2_n: Ltank_2_n(x, y); break;
7152 case Xtank_1_e: Ltank_1_e(x, y); break;
7153 case Xtank_2_e: Ltank_2_e(x, y); break;
7154 case Xtank_1_s: Ltank_1_s(x, y); break;
7155 case Xtank_2_s: Ltank_2_s(x, y); break;
7156 case Xtank_1_w: Ltank_1_w(x, y); break;
7157 case Xtank_2_w: Ltank_2_w(x, y); break;
7159 case Xemerald: Lemerald(x, y); break;
7160 case Xemerald_pause: Lemerald_pause(x, y); break;
7161 case Xemerald_fall: Lemerald_fall(x, y); break;
7163 case Xdiamond: Ldiamond(x, y); break;
7164 case Xdiamond_pause: Ldiamond_pause(x, y); break;
7165 case Xdiamond_fall: Ldiamond_fall(x, y); break;
7167 case Xstone: Lstone(x, y); break;
7168 case Xstone_pause: Lstone_pause(x, y); break;
7169 case Xstone_fall: Lstone_fall(x, y); break;
7171 case Xbomb: Lbomb(x, y); break;
7172 case Xbomb_pause: Lbomb_pause(x, y); break;
7173 case Xbomb_fall: Lbomb_fall(x, y); break;
7175 case Xnut: Lnut(x, y); break;
7176 case Xnut_pause: Lnut_pause(x, y); break;
7177 case Xnut_fall: Lnut_fall(x, y); break;
7179 case Xspring: Lspring(x, y); break;
7180 case Xspring_pause: Lspring_pause(x, y); break;
7181 case Xspring_e: Lspring_e(x, y); break;
7182 case Xspring_w: Lspring_w(x, y); break;
7183 case Xspring_fall: Lspring_fall(x, y); break;
7185 case Xpush_emerald_e: Lpush_emerald_e(x, y); break;
7186 case Xpush_emerald_w: Lpush_emerald_w(x, y); break;
7187 case Xpush_diamond_e: Lpush_diamond_e(x, y); break;
7188 case Xpush_diamond_w: Lpush_diamond_w(x, y); break;
7189 case Xpush_stone_e: Lpush_stone_e(x, y); break;
7190 case Xpush_stone_w: Lpush_stone_w(x, y); break;
7191 case Xpush_bomb_e: Lpush_bomb_e(x, y); break;
7192 case Xpush_bomb_w: Lpush_bomb_w(x, y); break;
7193 case Xpush_nut_e: Lpush_nut_e(x, y); break;
7194 case Xpush_nut_w: Lpush_nut_w(x, y); break;
7195 case Xpush_spring_e: Lpush_spring_e(x, y); break;
7196 case Xpush_spring_w: Lpush_spring_w(x, y); break;
7198 case Xdynamite_1: Ldynamite_1(x, y); break;
7199 case Xdynamite_2: Ldynamite_2(x, y); break;
7200 case Xdynamite_3: Ldynamite_3(x, y); break;
7201 case Xdynamite_4: Ldynamite_4(x, y); break;
7203 case Xfake_door_1: Lfake_door_1(x, y); break;
7204 case Xfake_door_2: Lfake_door_2(x, y); break;
7205 case Xfake_door_3: Lfake_door_3(x, y); break;
7206 case Xfake_door_4: Lfake_door_4(x, y); break;
7207 case Xfake_door_5: Lfake_door_5(x, y); break;
7208 case Xfake_door_6: Lfake_door_6(x, y); break;
7209 case Xfake_door_7: Lfake_door_7(x, y); break;
7210 case Xfake_door_8: Lfake_door_8(x, y); break;
7212 case Xballoon: Lballoon(x, y); break;
7214 case Xball_1: Lball_1(x, y); break;
7215 case Xball_2: Lball_2(x, y); break;
7217 case Xdrip: Ldrip(x, y); break;
7218 case Xdrip_fall: Ldrip_fall(x, y); break;
7219 case Xdrip_stretch: Ldrip_stretch(x, y); break;
7220 case Xdrip_stretchB: Ldrip_stretchB(x, y); break;
7222 case Xwonderwall: Lwonderwall(x, y); break;
7224 case Xwheel: Lwheel(x, y); break;
7226 case Xswitch: Lswitch(x, y); break;
7228 case Xfake_blank: Lfake_blank(x, y); break;
7229 case Xfake_grass: Lfake_grass(x, y); break;
7230 case Xfake_amoeba: Lfake_amoeba(x, y); break;
7232 case Xsand_stone: Lsand_stone(x, y); break;
7233 case Xsand_stonein_1: Lsand_stonein_1(x, y); break;
7234 case Xsand_stonein_2: Lsand_stonein_2(x, y); break;
7235 case Xsand_stonein_3: Lsand_stonein_3(x, y); break;
7236 case Xsand_stonein_4: Lsand_stonein_4(x, y); break;
7237 case Xsand_sandstone_1: Lsand_sandstone_1(x, y); break;
7238 case Xsand_sandstone_2: Lsand_sandstone_2(x, y); break;
7239 case Xsand_sandstone_3: Lsand_sandstone_3(x, y); break;
7240 case Xsand_sandstone_4: Lsand_sandstone_4(x, y); break;
7241 case Xsand_stonesand_1: Lsand_stonesand_1(x, y); break;
7242 case Xsand_stonesand_2: Lsand_stonesand_2(x, y); break;
7243 case Xsand_stonesand_3: Lsand_stonesand_3(x, y); break;
7244 case Xsand_stonesand_4: Lsand_stonesand_4(x, y); break;
7245 case Xsand_stoneout_1: Lsand_stoneout_1(x, y); break;
7246 case Xsand_stoneout_2: Lsand_stoneout_2(x, y); break;
7247 case Xsand_stonesand_quickout_1: Lsand_stonesand_quickout_1(x, y); break;
7248 case Xsand_stonesand_quickout_2: Lsand_stonesand_quickout_2(x, y); break;
7250 case Xslide_ns: Lslide_ns(x, y); break;
7251 case Xslide_ew: Lslide_ew(x, y); break;
7253 case Xexit: Lexit(x, y); break;
7254 case Xexit_1: Lexit_1(x, y); break;
7255 case Xexit_2: Lexit_2(x, y); break;
7256 case Xexit_3: Lexit_3(x, y); break;
7258 case Xpause: Lpause(x, y); break;
7260 case Xchain: Lchain(x, y); break;
7261 case Xboom_bug: Lboom_bug(x, y); break;
7262 case Xboom_tank: Lboom_tank(x, y); break;
7263 case Xboom_android: Lboom_android(x, y); break;
7264 case Xboom_1: Lboom_1(x, y); break;
7265 case Xboom_2: Lboom_2(x, y); break;
7269 static void logic_players(void)
7278 game_em.any_player_moving = FALSE;
7279 game_em.any_player_snapping = FALSE;
7281 /* must test for death and actually kill separately */
7282 for (i = 0; i < MAX_PLAYERS; i++)
7284 boolean ply_kill = player_killed(&ply[i]);
7286 if (ply[i].alive && ply_kill)
7287 kill_player(&ply[i]);
7290 for (i = 0; i < MAX_PLAYERS; i++)
7295 /* check for wrap-around movement */
7296 if (ply[i].x < lev.left ||
7297 ply[i].x > lev.right - 1)
7299 ply[i].x = (ply[i].x < lev.left ? lev.right - 1 : lev.left);
7301 game.centered_player_nr_next = i;
7302 game.set_centered_player = TRUE;
7303 game.set_centered_player_wrap = TRUE;
7306 ply[i].prev_x = ply[i].x;
7307 ply[i].prev_y = ply[i].y;
7308 ply[i].anim = PLY_still;
7311 start_check_nr = ((game_em.random & 128 ? 0 : 1) * 2 +
7312 (game_em.random & 256 ? 0 : 1));
7314 for (i = 0; i < MAX_PLAYERS; i++)
7316 int check_nr = (start_check_nr + i) % MAX_PLAYERS;
7318 if (ply[check_nr].alive)
7319 check_player(&ply[check_nr]);
7322 for (i = 0; i < MAX_PLAYERS; i++)
7327 if (cave[ply[i].prev_x][ply[i].prev_y] == Zplayer)
7329 cave[ply[i].prev_x][ply[i].prev_y] = Xblank;
7330 next[ply[i].prev_x][ply[i].prev_y] = Xblank;
7333 if (cave[ply[i].x][ply[i].y] == Xblank)
7335 cave[ply[i].x][ply[i].y] = Zplayer;
7336 next[ply[i].x][ply[i].y] = Zplayer;
7341 static void logic_objects(void)
7349 seed = game_em.random;
7352 for (y = lev.top; y < lev.bottom; y++)
7353 for (x = lev.left; x < lev.right; x++)
7356 if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
7357 lev.score += score; /* only add a score if someone is alive */
7359 game_em.game_over = TRUE;
7361 game_em.random = seed;
7363 /* triple buffering */
7364 void *temp = lev.cave;
7365 lev.cave = lev.next;
7366 lev.next = lev.draw;
7370 static void logic_globals(void)
7375 unsigned int random;
7381 /* update variables */
7383 if (lev.score > 9999)
7386 if (lev.android_move_cnt-- == 0)
7387 lev.android_move_cnt = lev.android_move_time;
7388 if (lev.android_clone_cnt-- == 0)
7389 lev.android_clone_cnt = lev.android_clone_time;
7391 if (lev.ball_cnt-- == 0)
7392 lev.ball_cnt = lev.ball_time;
7395 if (lev.magnify_cnt)
7401 if (lev.wonderwall_time && lev.wonderwall_state)
7402 lev.wonderwall_time--;
7405 play_element_sound(lev.wheel_x, lev.wheel_y, SOUND_wheel, Xwheel);
7409 random = game_em.random;
7411 for (count = lev.amoeba_time; count--;)
7413 x = lev.left - 1 + (random >> 10) % (CAVE_WIDTH + 2);
7414 y = lev.top - 1 + (random >> 20) % (CAVE_HEIGHT + 2);
7416 if (x >= lev.left && x < lev.right &&
7417 y >= lev.top && y < lev.bottom)
7420 random = random * 129 + 1;
7423 game_em.random = random;
7425 /* handle explosions */
7427 for (y = lev.top; y < lev.bottom; y++)
7428 for (x = lev.left; x < lev.right; x++)
7431 /* triple buffering */
7433 for (y = lev.top; y < lev.bottom; y++)
7434 for (x = lev.left; x < lev.right; x++)
7435 next[x][y] = cave[x][y];