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 */
13 #define ACID_PLAYER /* player gets killed by acid, but without explosion */
15 #define RANDOM_BUG /* handle problem with old tapes using 64-bit random */
17 #define RANDOM(x) ((seed = seed << 31 | seed >> 1) % x)
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_player[GAME_TILE_MAX] =
64 [Xfake_acid_1_player] = 1,
65 [Xfake_acid_2_player] = 1,
66 [Xfake_acid_3_player] = 1,
67 [Xfake_acid_4_player] = 1,
68 [Xfake_acid_5_player] = 1,
69 [Xfake_acid_6_player] = 1,
70 [Xfake_acid_7_player] = 1,
71 [Xfake_acid_8_player] = 1
74 static const byte add_player[GAME_TILE_MAX] =
77 [Xsplash_e] = Zplayer,
78 [Xsplash_w] = Zplayer,
79 [Xfake_acid_1] = Xfake_acid_1_player,
80 [Xfake_acid_2] = Xfake_acid_2_player,
81 [Xfake_acid_3] = Xfake_acid_3_player,
82 [Xfake_acid_4] = Xfake_acid_4_player,
83 [Xfake_acid_5] = Xfake_acid_5_player,
84 [Xfake_acid_6] = Xfake_acid_6_player,
85 [Xfake_acid_7] = Xfake_acid_7_player,
86 [Xfake_acid_8] = Xfake_acid_8_player
89 static const byte remove_player[GAME_TILE_MAX] =
92 [Xfake_acid_1_player] = Xfake_acid_1,
93 [Xfake_acid_2_player] = Xfake_acid_2,
94 [Xfake_acid_3_player] = Xfake_acid_3,
95 [Xfake_acid_4_player] = Xfake_acid_4,
96 [Xfake_acid_5_player] = Xfake_acid_5,
97 [Xfake_acid_6_player] = Xfake_acid_6,
98 [Xfake_acid_7_player] = Xfake_acid_7,
99 [Xfake_acid_8_player] = Xfake_acid_8
102 static const byte is_amoeba[GAME_TILE_MAX] =
116 static byte is_android_blank[GAME_TILE_MAX] =
131 static const byte is_android_walkable[GAME_TILE_MAX] =
147 static void Lboom_generic(int x, int y, int element, int element_middle)
149 boom[x-1][y-1] = element;
150 boom[x][y-1] = element;
151 boom[x+1][y-1] = element;
152 boom[x-1][y] = element;
153 boom[x][y] = element_middle;
154 boom[x+1][y] = element;
155 boom[x-1][y+1] = element;
156 boom[x][y+1] = element;
157 boom[x+1][y+1] = element;
160 static void Lboom_bug(int x, int y)
162 if (game_em.use_old_explosions)
165 Lboom_generic(x, y, Xemerald, Xdiamond);
167 #if PLAY_ELEMENT_SOUND
168 play_element_sound(x, y, SOUND_boom, Xbug_1_n);
172 static void Lboom_tank(int x, int y)
174 if (game_em.use_old_explosions)
177 Lboom_generic(x, y, Xblank, Xblank);
179 #if PLAY_ELEMENT_SOUND
180 play_element_sound(x, y, SOUND_boom, Xtank_1_n);
184 static void Lboom_eater(int x, int y)
186 if (game_em.use_old_explosions)
189 boom[x-1][y-1] = lev.eater_array[lev.eater_pos][0];
190 boom[x][y-1] = lev.eater_array[lev.eater_pos][1];
191 boom[x+1][y-1] = lev.eater_array[lev.eater_pos][2];
192 boom[x-1][y] = lev.eater_array[lev.eater_pos][3];
193 boom[x][y] = lev.eater_array[lev.eater_pos][4];
194 boom[x+1][y] = lev.eater_array[lev.eater_pos][5];
195 boom[x-1][y+1] = lev.eater_array[lev.eater_pos][6];
196 boom[x][y+1] = lev.eater_array[lev.eater_pos][7];
197 boom[x+1][y+1] = lev.eater_array[lev.eater_pos][8];
199 lev.eater_pos = (lev.eater_pos + 1) % lev.num_eater_arrays;
201 #if PLAY_ELEMENT_SOUND
202 play_element_sound(x, y, SOUND_boom, Xeater_n);
206 static void Lboom_bug_old(int x, int y)
208 if (!game_em.use_old_explosions)
214 static void Lboom_tank_old(int x, int y)
216 if (!game_em.use_old_explosions)
222 static void Lboom_eater_old(int x, int y)
224 if (!game_em.use_old_explosions)
230 static void Lboom_bug_new(int x, int y, boolean chain_explosion)
232 if (game_em.use_old_explosions)
241 static void Lboom_tank_new(int x, int y, boolean chain_explosion)
243 if (game_em.use_old_explosions)
252 static void Lboom_eater_new(int x, int y, boolean chain_explosion)
254 if (game_em.use_old_explosions)
263 static void Lboom_cave_new(int x, int y, int element)
265 if (game_em.use_old_explosions)
268 cave[x][y] = element;
271 static void Lboom_next_new(int x, int y, int element)
273 if (game_em.use_old_explosions)
276 next[x][y] = element;
279 static void Lpush_element_old(int x, int y, int element)
281 if (!game_em.use_old_push_elements)
284 cave[x][y] = element;
285 next[x][y] = element;
288 static boolean player_killed(struct PLAYER *ply)
296 if (lev.killed_out_of_time && game.time_limit)
299 switch (cave[x][y-1])
320 switch (cave[x+1][y])
341 switch (cave[x][y+1])
362 switch (cave[x-1][y])
397 case Xfake_acid_1_player:
398 case Xfake_acid_2_player:
399 case Xfake_acid_3_player:
400 case Xfake_acid_4_player:
401 case Xfake_acid_5_player:
402 case Xfake_acid_6_player:
403 case Xfake_acid_7_player:
404 case Xfake_acid_8_player:
415 static void kill_player(struct PLAYER *ply)
422 switch (cave[x][y-1])
432 cave[x][y-1] = Xboom_bug;
433 Lboom_bug_new(x, y-1, TRUE);
444 cave[x][y-1] = Xboom_tank;
445 Lboom_tank_new(x, y-1, TRUE);
449 switch (cave[x+1][y])
459 cave[x+1][y] = Xboom_bug;
460 Lboom_bug_new(x+1, y, TRUE);
471 cave[x+1][y] = Xboom_tank;
472 Lboom_tank_new(x+1, y, TRUE);
476 switch (cave[x][y+1])
486 cave[x][y+1] = Xboom_bug;
487 Lboom_bug_new(x, y+1, TRUE);
498 cave[x][y+1] = Xboom_tank;
499 Lboom_tank_new(x, y+1, TRUE);
503 switch (cave[x-1][y])
513 cave[x-1][y] = Xboom_bug;
514 Lboom_bug_new(x-1, y, TRUE);
525 cave[x-1][y] = Xboom_tank;
526 Lboom_tank_new(x-1, y, TRUE);
537 play_element_sound(x, y, SOUND_exit_leave, Xexit_1);
541 play_element_sound(x, y, SOUND_die, Zplayer);
560 cave[x][y] = Xboom_1;
566 static boolean player_digfield(struct PLAYER *ply, int dx, int dy)
568 int anim = (dx < 0 ? 3 : dx > 0 ? 1 : dy < 0 ? 0 : dy > 0 ? 2 : 2);
573 boolean result = TRUE;
575 if (!dx && !dy) /* no direction specified */
578 if (dx && dy && ply->joy_snap) /* more than one direction specified */
581 if (!ply->joy_snap) /* player wants to move */
583 int element = cave[x][y];
587 /* fire is released */
599 cave[x][y] = add_player[element];
600 next[x][y] = add_player[element];
602 play_element_sound(x, y, SOUND_blank, Xblank);
603 ply->anim = PLY_walk_n + anim;
617 if (cave[x+1][y-1] == Xblank)
618 cave[x+1][y-1] = Xsplash_e;
619 if (cave[x-1][y-1] == Xblank)
620 cave[x-1][y-1] = Xsplash_w;
621 play_element_sound(x, y, SOUND_acid, Xacid_1);
642 ply->anim = PLY_walk_n + anim;
648 cave[x][y] = (dy ? (dy < 0 ? Ygrass_nB : Ygrass_sB) :
649 (dx > 0 ? Ygrass_eB : Ygrass_wB));
650 next[x][y] = Zplayer;
651 play_element_sound(x, y, SOUND_dirt, Xgrass);
652 ply->anim = PLY_walk_n + anim;
658 cave[x][y] = (dy ? (dy < 0 ? Ydirt_nB : Ydirt_sB) :
659 (dx > 0 ? Ydirt_eB : Ydirt_wB));
660 next[x][y] = Zplayer;
661 play_element_sound(x, y, SOUND_dirt, Xdirt);
662 ply->anim = PLY_walk_n + anim;
669 cave[x][y] = Ydiamond_blank;
670 next[x][y] = Zplayer;
671 play_element_sound(x, y, SOUND_collect, element);
672 lev.score += lev.diamond_score;
673 lev.gems_needed = lev.gems_needed < 3 ? 0 : lev.gems_needed - 3;
674 game.snapshot.collected_item = TRUE;
675 ply->anim = PLY_walk_n + anim;
682 cave[x][y] = Yemerald_blank;
683 next[x][y] = Zplayer;
684 play_element_sound(x, y, SOUND_collect, element);
685 lev.score += lev.emerald_score;
686 lev.gems_needed = lev.gems_needed < 1 ? 0 : lev.gems_needed - 1;
687 game.snapshot.collected_item = TRUE;
688 ply->anim = PLY_walk_n + anim;
694 cave[x][y] = Ydynamite_blank;
695 next[x][y] = Zplayer;
696 play_element_sound(x, y, SOUND_collect, element);
697 lev.score += lev.dynamite_score;
698 ply->dynamite = ply->dynamite > 9998 ? 9999 : ply->dynamite + 1;
699 ply->anim = PLY_walk_n + anim;
706 cave[x][y] = Ykey_1_blank;
711 cave[x][y] = Ykey_2_blank;
716 cave[x][y] = Ykey_3_blank;
721 cave[x][y] = Ykey_4_blank;
726 cave[x][y] = Ykey_5_blank;
731 cave[x][y] = Ykey_6_blank;
736 cave[x][y] = Ykey_7_blank;
741 cave[x][y] = Ykey_8_blank;
746 next[x][y] = Zplayer;
747 play_element_sound(x, y, SOUND_collect, element);
748 lev.score += lev.key_score;
749 ply->anim = PLY_walk_n + anim;
755 cave[x][y] = Ylenses_blank;
756 next[x][y] = Zplayer;
757 play_element_sound(x, y, SOUND_collect, element);
758 lev.score += lev.lenses_score;
759 lev.lenses_cnt = lev.lenses_time;
760 ply->anim = PLY_walk_n + anim;
766 cave[x][y] = Ymagnify_blank;
767 next[x][y] = Zplayer;
768 play_element_sound(x, y, SOUND_collect, element);
769 lev.score += lev.magnify_score;
770 lev.magnify_cnt = lev.magnify_time;
771 ply->anim = PLY_walk_n + anim;
780 if (game_em.use_push_delay && RANDOM(32) < 16)
781 goto stone_push_anim;
783 switch (cave[x+dx][y])
796 cave[x+dx][y] = dx > 0 ? Ystone_e : Ystone_w;
797 next[x+dx][y] = Xstone_pause;
808 if (cave[x+dx+1][y-1] == Xblank)
809 cave[x+dx+1][y-1] = Xsplash_e;
810 if (cave[x+dx-1][y-1] == Xblank)
811 cave[x+dx-1][y-1] = Xsplash_w;
812 play_element_sound(x, y, SOUND_acid, Xacid_1);
816 cave[x][y] = dx > 0 ? Ystone_eB : Ystone_wB;
817 next[x][y] = Zplayer;
818 play_element_sound(x, y, SOUND_roll, Xstone);
825 ply->anim = PLY_push_n + anim;
832 if (game_em.use_push_delay && RANDOM(32) < 22)
835 switch (cave[x+dx][y])
848 cave[x+dx][y] = dx > 0 ? Ybomb_e : Ybomb_w;
849 next[x+dx][y] = Xbomb_pause;
860 if (cave[x+dx+1][y-1] == Xblank)
861 cave[x+dx+1][y-1] = Xsplash_e;
862 if (cave[x+dx-1][y-1] == Xblank)
863 cave[x+dx-1][y-1] = Xsplash_w;
864 play_element_sound(x, y, SOUND_acid, Xacid_1);
868 cave[x][y] = dx > 0 ? Ybomb_eB : Ybomb_wB;
869 next[x][y] = Zplayer;
870 play_element_sound(x, y, SOUND_roll, Xbomb);
877 ply->anim = PLY_push_n + anim;
884 if (game_em.use_push_delay && RANDOM(32) < 19)
887 switch (cave[x+dx][y])
900 cave[x+dx][y] = dx > 0 ? Ynut_e : Ynut_w;
901 next[x+dx][y] = Xnut_pause;
912 if (cave[x+dx+1][y-1] == Xblank)
913 cave[x+dx+1][y-1] = Xsplash_e;
914 if (cave[x+dx-1][y-1] == Xblank)
915 cave[x+dx-1][y-1] = Xsplash_w;
916 play_element_sound(x, y, SOUND_acid, Xacid_1);
920 cave[x][y] = dx > 0 ? Ynut_eB : Ynut_wB;
921 next[x][y] = Zplayer;
922 play_element_sound(x, y, SOUND_roll, Xnut);
929 ply->anim = PLY_push_n + anim;
936 switch (cave[x+dx][y])
949 cave[x+dx][y] = dx > 0 ? Yspring_e : Yspring_w;
950 next[x+dx][y] = dx > 0 ? Xspring_e : Xspring_w;
961 if (cave[x+dx+1][y-1] == Xblank)
962 cave[x+dx+1][y-1] = Xsplash_e;
963 if (cave[x+dx-1][y-1] == Xblank)
964 cave[x+dx-1][y-1] = Xsplash_w;
965 play_element_sound(x, y, SOUND_acid, Xacid_1);
969 cave[x][y] = dx > 0 ? Yspring_eB : Yspring_wB;
970 next[x][y] = Zplayer;
971 play_element_sound(x, y, SOUND_roll, Xspring);
977 cave[x][y] = dx > 0 ? Yspring_alien_eB : Yspring_alien_wB;
978 cave[x+dx][y] = dx > 0 ? Yspring_alien_e : Yspring_alien_w;
979 next[x][y] = Zplayer;
980 next[x+dx][y] = dx > 0 ? Xspring_e : Xspring_w;
981 play_element_sound(x, y, SOUND_slurp, Xalien);
982 lev.score += lev.slurp_score;
987 ply->anim = PLY_push_n + anim;
994 case Xsand_stonein_1:
995 case Xsand_stonein_2:
996 case Xsand_stonein_3:
997 case Xsand_stonein_4:
1001 ply->anim = PLY_push_n + anim;
1005 switch (cave[x+dx][y+dy])
1018 cave[x+dx][y+dy] = (dy ? (dy < 0 ? Yballoon_n : Yballoon_s) :
1019 (dx > 0 ? Yballoon_e : Yballoon_w));
1020 next[x+dx][y+dy] = Xballoon;
1031 if (cave[x+dx+1][y+dy-1] == Xblank)
1032 cave[x+dx+1][y+dy-1] = Xsplash_e;
1033 if (cave[x+dx-1][y+dy-1] == Xblank)
1034 cave[x+dx-1][y+dy-1] = Xsplash_w;
1035 play_element_sound(x, y, SOUND_acid, Xacid_1);
1039 cave[x][y] = (dy ? (dy < 0 ? Yballoon_nB : Yballoon_sB) :
1040 (dx > 0 ? Yballoon_eB : Yballoon_wB));
1041 next[x][y] = Zplayer;
1042 play_element_sound(x, y, SOUND_push, Xballoon);
1048 ply->anim = PLY_push_n + anim;
1060 switch (cave[x+dx][y+dy])
1073 cave[x+dx][y+dy] = (dy ? (dy < 0 ? Yandroid_n : Yandroid_s) :
1074 (dx > 0 ? Yandroid_e : Yandroid_w));
1075 next[x+dx][y+dy] = (dy ? (dy < 0 ? Xandroid_2_n : Xandroid_2_s) :
1076 (dx > 0 ? Xandroid_2_e : Xandroid_2_w));
1087 if (cave[x+dx+1][y+dy-1] == Xblank)
1088 cave[x+dx+1][y+dy-1] = Xsplash_e;
1089 if (cave[x+dx-1][y+dy-1] == Xblank)
1090 cave[x+dx-1][y+dy-1] = Xsplash_w;
1091 play_element_sound(x, y, SOUND_acid, Xacid_1);
1095 cave[x][y] = (dy ? (dy < 0 ? Yandroid_nB : Yandroid_sB) :
1096 (dx > 0 ? Yandroid_eB : Yandroid_wB));
1097 next[x][y] = Zplayer;
1098 play_element_sound(x, y, SOUND_push, Xandroid);
1104 ply->anim = PLY_push_n + anim;
1109 if (ply->keys & 0x01)
1116 if (ply->keys & 0x02)
1123 if (ply->keys & 0x04)
1130 if (ply->keys & 0x08)
1137 if (ply->keys & 0x10)
1144 if (ply->keys & 0x20)
1151 if (ply->keys & 0x40)
1158 if (ply->keys & 0x80)
1165 if (!is_blank[cave[x+dx][y+dy]])
1168 int element_next = cave[x+dx][y+dy];
1170 cave[x+dx][y+dy] = add_player[element_next];
1171 next[x+dx][y+dy] = add_player[element_next];
1173 play_element_sound(x, y, SOUND_door, element);
1174 ply->anim = PLY_walk_n + anim;
1180 play_element_sound(x, y, SOUND_press, element);
1181 lev.wheel_cnt = lev.wheel_time;
1187 lev.wind_direction = 0;
1191 lev.wind_direction = 1;
1195 lev.wind_direction = 2;
1199 lev.wind_direction = 3;
1203 lev.wind_direction = dy ? (dy < 0 ? 0 : 2) : (dx > 0 ? 1 : 3);
1208 play_element_sound(x, y, SOUND_press, element);
1209 lev.wind_cnt = lev.wind_time;
1213 play_element_sound(x, y, SOUND_press, element);
1218 play_element_sound(x, y, SOUND_press, element);
1219 lev.ball_cnt = lev.ball_time;
1220 lev.ball_active = !lev.ball_active;
1224 cave[x][y] = Yplant;
1225 next[x][y] = Xplant;
1226 play_element_sound(x, y, SOUND_blank, Xplant);
1227 ply->anim = PLY_walk_n + anim;
1238 game_em.level_solved = TRUE;
1240 ply->anim = PLY_walk_n + anim;
1247 if (ply->x == oldx && ply->y == oldy) /* no movement */
1250 else /* player wants to snap */
1252 int element = cave[x][y];
1256 /* fire is pressed */
1259 cave[x][y] = Ygrass_blank;
1260 next[x][y] = Xblank;
1261 play_element_sound(x, y, SOUND_dirt, element);
1262 ply->anim = PLY_shoot_n + anim;
1266 cave[x][y] = Ydirt_blank;
1267 next[x][y] = Xblank;
1268 play_element_sound(x, y, SOUND_dirt, element);
1269 ply->anim = PLY_shoot_n + anim;
1273 case Xdiamond_pause:
1274 cave[x][y] = Ydiamond_blank;
1275 next[x][y] = Xblank;
1276 play_element_sound(x, y, SOUND_collect, element);
1277 lev.score += lev.diamond_score;
1278 lev.gems_needed = lev.gems_needed < 3 ? 0 : lev.gems_needed - 3;
1279 game.snapshot.collected_item = TRUE;
1280 ply->anim = PLY_walk_n + anim;
1284 case Xemerald_pause:
1285 cave[x][y] = Yemerald_blank;
1286 next[x][y] = Xblank;
1287 play_element_sound(x, y, SOUND_collect, element);
1288 lev.score += lev.emerald_score;
1289 lev.gems_needed = lev.gems_needed < 1 ? 0 : lev.gems_needed - 1;
1290 game.snapshot.collected_item = TRUE;
1291 ply->anim = PLY_walk_n + anim;
1295 cave[x][y] = Ydynamite_blank;
1296 next[x][y] = Xblank;
1297 play_element_sound(x, y, SOUND_collect, element);
1298 lev.score += lev.dynamite_score;
1299 ply->dynamite = ply->dynamite > 9998 ? 9999 : ply->dynamite + 1;
1300 ply->anim = PLY_walk_n + anim;
1305 cave[x][y] = Ykey_1_blank;
1310 cave[x][y] = Ykey_2_blank;
1315 cave[x][y] = Ykey_3_blank;
1320 cave[x][y] = Ykey_4_blank;
1325 cave[x][y] = Ykey_5_blank;
1330 cave[x][y] = Ykey_6_blank;
1335 cave[x][y] = Ykey_7_blank;
1340 cave[x][y] = Ykey_8_blank;
1345 next[x][y] = Xblank;
1346 play_element_sound(x, y, SOUND_collect, element);
1347 lev.score += lev.key_score;
1348 ply->anim = PLY_walk_n + anim;
1352 cave[x][y] = Ylenses_blank;
1353 next[x][y] = Xblank;
1354 play_element_sound(x, y, SOUND_collect, element);
1355 lev.score += lev.lenses_score;
1356 lev.lenses_cnt = lev.lenses_time;
1357 ply->anim = PLY_walk_n + anim;
1361 cave[x][y] = Ymagnify_blank;
1362 next[x][y] = Xblank;
1363 play_element_sound(x, y, SOUND_collect, element);
1364 lev.score += lev.magnify_score;
1365 lev.magnify_cnt = lev.magnify_time;
1366 ply->anim = PLY_walk_n + anim;
1374 /* check for wrap-around movement */
1375 if (ply->x < lev.left ||
1376 ply->x > lev.right - 1)
1377 play_element_sound(oldx, oldy, SOUND_door, Xdoor_1);
1382 static void check_player(struct PLAYER *ply)
1390 game_em.last_player_direction[ply->num] = MV_NONE;
1392 if (ply->joy_w) /* west */
1397 else if (ply->joy_e) /* east */
1403 if (ply->joy_n) /* north */
1408 else if (ply->joy_s) /* south */
1420 boolean players_visible_before_move;
1421 boolean players_visible_after_move;
1424 players_visible_before_move = checkIfAllPlayersFitToScreen();
1429 players_visible_after_move = checkIfAllPlayersFitToScreen();
1432 player is allowed to move only in the following cases:
1433 - it is not needed to display all players (not focussed to all players)
1434 - all players are (still or again) visible after the move
1435 - some players were already outside visible screen area before the move
1437 can_move = (game.centered_player_nr != -1 ||
1438 players_visible_after_move ||
1439 !players_visible_before_move);
1455 if (dx == 0 && dy == 0)
1457 ply->joy_stick = FALSE;
1461 if (++ply->dynamite_cnt == 5 && ply->dynamite)
1463 cave[x][y] = Xdynamite_1;
1464 play_element_sound(x, y, SOUND_dynamite, Xdynamite_1);
1470 ply->dynamite_cnt = 0;
1473 /* be a bit more random if the player doesn't move */
1474 game_em.random += 7;
1479 ply->joy_stick = TRUE;
1485 ply->dynamite_cnt = 0; /* reset dynamite timer if we move */
1487 seed = game_em.random;
1489 if (!ply->joy_snap) /* player wants to move */
1491 boolean moved = FALSE;
1493 if (ply->last_move_dir & MV_HORIZONTAL)
1495 if (!(moved = player_digfield(ply, 0, dy)))
1496 moved = player_digfield(ply, dx, 0);
1500 if (!(moved = player_digfield(ply, dx, 0)))
1501 moved = player_digfield(ply, 0, dy);
1507 ply->last_move_dir = (dx < 0 ? MV_LEFT : MV_RIGHT);
1508 else if (oldy != ply->y)
1509 ply->last_move_dir = (dy < 0 ? MV_UP : MV_DOWN);
1511 game_em.any_player_moving = TRUE;
1512 game_em.last_moving_player = ply->num;
1513 game_em.last_player_direction[ply->num] = ply->last_move_dir;
1516 else /* player wants to snap */
1518 game_em.any_player_snapping = player_digfield(ply, dx, dy);
1521 game_em.random = seed;
1524 static void set_nearest_player_xy(int x, int y, int *dx, int *dy)
1526 int distance, distance_shortest = CAVE_WIDTH + CAVE_HEIGHT;
1529 /* default values if no players are alive anymore */
1533 for (i = 0; i < MAX_PLAYERS; i++)
1538 distance = ABS(ply[i].x - x) + ABS(ply[i].y - y);
1540 if (distance < distance_shortest)
1545 distance_shortest = distance;
1550 static void Lacid_1(int x, int y)
1552 next[x][y] = Xacid_2;
1555 static void Lacid_2(int x, int y)
1557 next[x][y] = Xacid_3;
1560 static void Lacid_3(int x, int y)
1562 next[x][y] = Xacid_4;
1565 static void Lacid_4(int x, int y)
1567 next[x][y] = Xacid_5;
1570 static void Lacid_5(int x, int y)
1572 next[x][y] = Xacid_6;
1575 static void Lacid_6(int x, int y)
1577 next[x][y] = Xacid_7;
1580 static void Lacid_7(int x, int y)
1582 next[x][y] = Xacid_8;
1585 static void Lacid_8(int x, int y)
1587 next[x][y] = Xacid_1;
1590 static void Lfake_acid_1(int x, int y)
1592 next[x][y] = Xfake_acid_2;
1595 static void Lfake_acid_2(int x, int y)
1597 next[x][y] = Xfake_acid_3;
1600 static void Lfake_acid_3(int x, int y)
1602 next[x][y] = Xfake_acid_4;
1605 static void Lfake_acid_4(int x, int y)
1607 next[x][y] = Xfake_acid_5;
1610 static void Lfake_acid_5(int x, int y)
1612 next[x][y] = Xfake_acid_6;
1615 static void Lfake_acid_6(int x, int y)
1617 next[x][y] = Xfake_acid_7;
1620 static void Lfake_acid_7(int x, int y)
1622 next[x][y] = Xfake_acid_8;
1625 static void Lfake_acid_8(int x, int y)
1627 next[x][y] = Xfake_acid_1;
1630 static void Landroid(int x, int y)
1634 if (lev.android_clone_cnt == 0)
1636 if (!is_android_blank[cave[x-1][y-1]] &&
1637 !is_android_blank[cave[x][y-1]] &&
1638 !is_android_blank[cave[x+1][y-1]] &&
1639 !is_android_blank[cave[x-1][y]] &&
1640 !is_android_blank[cave[x+1][y]] &&
1641 !is_android_blank[cave[x-1][y+1]] &&
1642 !is_android_blank[cave[x][y+1]] &&
1643 !is_android_blank[cave[x+1][y+1]])
1648 /* randomly find an object to clone */
1650 case 0: /* S,NE,W,NW,SE,E,SW,N */
1651 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1652 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1653 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1654 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1655 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1656 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1657 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1658 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1661 case 1: /* NW,SE,N,S,NE,SW,E,W */
1662 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1663 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1664 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1665 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1666 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1667 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1668 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1669 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1672 case 2: /* SW,E,S,W,N,NW,SE,NE */
1673 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1674 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1675 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1676 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1677 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1678 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1679 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1680 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1683 case 3: /* N,SE,NE,E,W,S,NW,SW */
1684 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1685 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1686 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1687 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1688 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1689 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1690 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1691 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1694 case 4: /* SE,NW,E,NE,SW,W,N,S */
1695 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1696 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1697 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1698 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1699 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1700 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1701 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1702 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1705 case 5: /* NE,W,SE,SW,S,N,E,NW */
1706 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1707 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1708 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1709 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1710 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1711 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1712 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1713 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1716 case 6: /* E,N,SW,S,NW,NE,SE,W */
1717 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1718 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1719 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1720 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1721 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1722 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1723 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1724 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1727 case 7: /* W,SW,NW,N,E,SE,NE,S */
1728 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1729 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1730 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1731 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1732 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1733 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1734 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1735 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1739 next[x][y] = temp; /* the item we chose to clone */
1740 play_element_sound(x, y, SOUND_android_clone, temp);
1744 /* randomly find a direction to move */
1746 case 0: /* S,NE,W,NW,SE,E,SW,N */
1747 if (is_android_blank[cave[x][y+1]]) goto android_s;
1748 if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
1749 if (is_android_blank[cave[x-1][y]]) goto android_w;
1750 if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
1751 if (is_android_blank[cave[x+1][y+1]]) goto android_se;
1752 if (is_android_blank[cave[x+1][y]]) goto android_e;
1753 if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
1754 if (is_android_blank[cave[x][y-1]]) goto android_n;
1757 case 1: /* NW,SE,N,S,NE,SW,E,W */
1758 if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
1759 if (is_android_blank[cave[x+1][y+1]]) goto android_se;
1760 if (is_android_blank[cave[x][y-1]]) goto android_n;
1761 if (is_android_blank[cave[x][y+1]]) goto android_s;
1762 if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
1763 if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
1764 if (is_android_blank[cave[x+1][y]]) goto android_e;
1765 if (is_android_blank[cave[x-1][y]]) goto android_w;
1768 case 2: /* SW,E,S,W,N,NW,SE,NE */
1769 if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
1770 if (is_android_blank[cave[x+1][y]]) goto android_e;
1771 if (is_android_blank[cave[x][y+1]]) goto android_s;
1772 if (is_android_blank[cave[x-1][y]]) goto android_w;
1773 if (is_android_blank[cave[x][y-1]]) goto android_n;
1774 if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
1775 if (is_android_blank[cave[x+1][y+1]]) goto android_se;
1776 if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
1779 case 3: /* N,SE,NE,E,W,S,NW,SW */
1780 if (is_android_blank[cave[x][y-1]]) goto android_n;
1781 if (is_android_blank[cave[x+1][y+1]]) goto android_se;
1782 if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
1783 if (is_android_blank[cave[x+1][y]]) goto android_e;
1784 if (is_android_blank[cave[x-1][y]]) goto android_w;
1785 if (is_android_blank[cave[x][y+1]]) goto android_s;
1786 if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
1787 if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
1790 case 4: /* SE,NW,E,NE,SW,W,N,S */
1791 if (is_android_blank[cave[x+1][y+1]]) goto android_se;
1792 if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
1793 if (is_android_blank[cave[x+1][y]]) goto android_e;
1794 if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
1795 if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
1796 if (is_android_blank[cave[x-1][y]]) goto android_w;
1797 if (is_android_blank[cave[x][y-1]]) goto android_n;
1798 if (is_android_blank[cave[x][y+1]]) goto android_s;
1801 case 5: /* NE,W,SE,SW,S,N,E,NW */
1802 if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
1803 if (is_android_blank[cave[x-1][y]]) goto android_w;
1804 if (is_android_blank[cave[x+1][y+1]]) goto android_se;
1805 if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
1806 if (is_android_blank[cave[x][y+1]]) goto android_s;
1807 if (is_android_blank[cave[x][y-1]]) goto android_n;
1808 if (is_android_blank[cave[x+1][y]]) goto android_e;
1809 if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
1812 case 6: /* E,N,SW,S,NW,NE,SE,W */
1813 if (is_android_blank[cave[x+1][y]]) goto android_e;
1814 if (is_android_blank[cave[x][y-1]]) goto android_n;
1815 if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
1816 if (is_android_blank[cave[x][y+1]]) goto android_s;
1817 if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
1818 if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
1819 if (is_android_blank[cave[x+1][y+1]]) goto android_se;
1820 if (is_android_blank[cave[x-1][y]]) goto android_w;
1823 case 7: /* W,SW,NW,N,E,SE,NE,S */
1824 if (is_android_blank[cave[x-1][y]]) goto android_w;
1825 if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
1826 if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
1827 if (is_android_blank[cave[x][y-1]]) goto android_n;
1828 if (is_android_blank[cave[x+1][y]]) goto android_e;
1829 if (is_android_blank[cave[x+1][y+1]]) goto android_se;
1830 if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
1831 if (is_android_blank[cave[x][y+1]]) goto android_s;
1837 if (lev.android_move_cnt == 0)
1839 if (is_player[cave[x-1][y-1]] ||
1840 is_player[cave[x][y-1]] ||
1841 is_player[cave[x+1][y-1]] ||
1842 is_player[cave[x-1][y]] ||
1843 is_player[cave[x+1][y]] ||
1844 is_player[cave[x-1][y+1]] ||
1845 is_player[cave[x][y+1]] ||
1846 is_player[cave[x+1][y+1]])
1849 set_nearest_player_xy(x, y, &dx, &dy);
1851 next[x][y] = Xblank; /* assume we will move */
1852 temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
1858 /* attempt clockwise move first if direct path is blocked */
1860 case 0: /* north west */
1861 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1862 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1863 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1867 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1868 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1869 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1872 case 2: /* north east */
1873 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1874 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1875 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1879 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1880 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1881 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1884 case 4: /* nowhere */
1888 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1889 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1890 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1893 case 6: /* south west */
1894 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1895 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1896 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1900 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1901 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1902 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1905 case 8: /* south east */
1906 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1907 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1908 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1916 /* attempt counterclockwise move first if direct path is blocked */
1918 case 0: /* north west */
1919 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1920 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1921 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1925 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1926 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1927 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1930 case 2: /* north east */
1931 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1932 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1933 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1937 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1938 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1939 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1942 case 4: /* nowhere */
1946 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1947 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1948 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1951 case 6: /* south west */
1952 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1953 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1954 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1958 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1959 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1960 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1963 case 8: /* south east */
1964 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1965 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1966 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1973 next[x][y] = Xandroid;
1977 cave[x][y] = Yandroid_nB;
1978 cave[x][y-1] = Yandroid_n;
1979 next[x][y-1] = Xandroid;
1980 play_element_sound(x, y, SOUND_android_move, Xandroid);
1984 cave[x][y] = Yandroid_neB;
1985 cave[x+1][y-1] = Yandroid_ne;
1986 next[x+1][y-1] = Xandroid;
1987 play_element_sound(x, y, SOUND_android_move, Xandroid);
1991 cave[x][y] = Yandroid_eB;
1992 cave[x+1][y] = Yandroid_e;
1993 next[x+1][y] = Xandroid;
1994 play_element_sound(x, y, SOUND_android_move, Xandroid);
1998 cave[x][y] = Yandroid_seB;
1999 cave[x+1][y+1] = Yandroid_se;
2000 next[x+1][y+1] = Xandroid;
2001 play_element_sound(x, y, SOUND_android_move, Xandroid);
2005 cave[x][y] = Yandroid_sB;
2006 cave[x][y+1] = Yandroid_s;
2007 next[x][y+1] = Xandroid;
2008 play_element_sound(x, y, SOUND_android_move, Xandroid);
2012 cave[x][y] = Yandroid_swB;
2013 cave[x-1][y+1] = Yandroid_sw;
2014 next[x-1][y+1] = Xandroid;
2015 play_element_sound(x, y, SOUND_android_move, Xandroid);
2019 cave[x][y] = Yandroid_wB;
2020 cave[x-1][y] = Yandroid_w;
2021 next[x-1][y] = Xandroid;
2022 play_element_sound(x, y, SOUND_android_move, Xandroid);
2026 cave[x][y] = Yandroid_nwB;
2027 cave[x-1][y-1] = Yandroid_nw;
2028 next[x-1][y-1] = Xandroid;
2029 play_element_sound(x, y, SOUND_android_move, Xandroid);
2033 static void Landroid_1_n(int x, int y)
2035 switch (cave[x][y-1])
2048 cave[x][y] = Yandroid_nB;
2049 next[x][y] = Xblank;
2050 cave[x][y-1] = Yandroid_n;
2051 next[x][y-1] = Xandroid;
2052 play_element_sound(x, y, SOUND_android_move, Xandroid_1_n);
2063 cave[x][y] = Yandroid_nB;
2064 next[x][y] = Xblank;
2065 if (cave[x+1][y-2] == Xblank)
2066 cave[x+1][y-2] = Xsplash_e;
2067 if (cave[x-1][y-2] == Xblank)
2068 cave[x-1][y-2] = Xsplash_w;
2069 play_element_sound(x, y, SOUND_acid, Xacid_1);
2078 static void Landroid_2_n(int x, int y)
2080 switch (cave[x][y-1])
2093 cave[x][y] = Yandroid_nB;
2094 next[x][y] = Xblank;
2095 cave[x][y-1] = Yandroid_n;
2096 next[x][y-1] = Xandroid_1_n;
2097 play_element_sound(x, y, SOUND_android_move, Xandroid_2_n);
2108 cave[x][y] = Yandroid_nB;
2109 next[x][y] = Xblank;
2110 if (cave[x+1][y-2] == Xblank)
2111 cave[x+1][y-2] = Xsplash_e;
2112 if (cave[x-1][y-2] == Xblank)
2113 cave[x-1][y-2] = Xsplash_w;
2114 play_element_sound(x, y, SOUND_acid, Xacid_1);
2123 static void Landroid_1_e(int x, int y)
2125 switch (cave[x+1][y])
2138 cave[x][y] = Yandroid_eB;
2139 next[x][y] = Xblank;
2140 cave[x+1][y] = Yandroid_e;
2141 next[x+1][y] = Xandroid;
2142 play_element_sound(x, y, SOUND_android_move, Xandroid_1_e);
2153 cave[x][y] = Yandroid_eB;
2154 next[x][y] = Xblank;
2155 if (cave[x+2][y-1] == Xblank)
2156 cave[x+2][y-1] = Xsplash_e;
2157 if (cave[x][y-1] == Xblank)
2158 cave[x][y-1] = Xsplash_w;
2159 play_element_sound(x, y, SOUND_acid, Xacid_1);
2168 static void Landroid_2_e(int x, int y)
2170 switch (cave[x+1][y])
2183 cave[x][y] = Yandroid_eB;
2184 next[x][y] = Xblank;
2185 cave[x+1][y] = Yandroid_e;
2186 next[x+1][y] = Xandroid_1_e;
2187 play_element_sound(x, y, SOUND_android_move, Xandroid_2_e);
2198 cave[x][y] = Yandroid_eB;
2199 next[x][y] = Xblank;
2200 if (cave[x+2][y-1] == Xblank)
2201 cave[x+2][y-1] = Xsplash_e;
2202 if (cave[x][y-1] == Xblank)
2203 cave[x][y-1] = Xsplash_w;
2204 play_element_sound(x, y, SOUND_acid, Xacid_1);
2213 static void Landroid_1_s(int x, int y)
2215 switch (cave[x][y+1])
2228 cave[x][y] = Yandroid_sB;
2229 next[x][y] = Xblank;
2230 cave[x][y+1] = Yandroid_s;
2231 next[x][y+1] = Xandroid;
2232 play_element_sound(x, y, SOUND_android_move, Xandroid_1_s);
2243 cave[x][y] = Yandroid_sB;
2244 next[x][y] = Xblank;
2245 if (cave[x+1][y] == Xblank)
2246 cave[x+1][y] = Xsplash_e;
2247 if (cave[x-1][y] == Xblank)
2248 cave[x-1][y] = Xsplash_w;
2249 play_element_sound(x, y, SOUND_acid, Xacid_1);
2258 static void Landroid_2_s(int x, int y)
2260 switch (cave[x][y+1])
2273 cave[x][y] = Yandroid_sB;
2274 next[x][y] = Xblank;
2275 cave[x][y+1] = Yandroid_s;
2276 next[x][y+1] = Xandroid_1_s;
2277 play_element_sound(x, y, SOUND_android_move, Xandroid_2_s);
2288 cave[x][y] = Yandroid_sB;
2289 next[x][y] = Xblank;
2290 if (cave[x+1][y] == Xblank)
2291 cave[x+1][y] = Xsplash_e;
2292 if (cave[x-1][y] == Xblank)
2293 cave[x-1][y] = Xsplash_w;
2294 play_element_sound(x, y, SOUND_acid, Xacid_1);
2303 static void Landroid_1_w(int x, int y)
2305 switch (cave[x-1][y])
2318 cave[x][y] = Yandroid_wB;
2319 next[x][y] = Xblank;
2320 cave[x-1][y] = Yandroid_w;
2321 next[x-1][y] = Xandroid;
2322 play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
2333 cave[x][y] = Yandroid_wB;
2334 next[x][y] = Xblank;
2335 if (cave[x][y-1] == Xblank)
2336 cave[x][y-1] = Xsplash_e;
2337 if (cave[x-2][y-1] == Xblank)
2338 cave[x-2][y-1] = Xsplash_w;
2339 play_element_sound(x, y, SOUND_acid, Xacid_1);
2348 static void Landroid_2_w(int x, int y)
2350 switch (cave[x-1][y])
2363 cave[x][y] = Yandroid_wB;
2364 next[x][y] = Xblank;
2365 cave[x-1][y] = Yandroid_w;
2366 next[x-1][y] = Xandroid_1_w;
2367 play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
2378 cave[x][y] = Yandroid_wB;
2379 next[x][y] = Xblank;
2380 if (cave[x][y-1] == Xblank)
2381 cave[x][y-1] = Xsplash_e;
2382 if (cave[x-2][y-1] == Xblank)
2383 cave[x-2][y-1] = Xsplash_w;
2384 play_element_sound(x, y, SOUND_acid, Xacid_1);
2393 static void Leater_n(int x, int y)
2395 if (cave[x+1][y] == Xdiamond)
2397 cave[x+1][y] = Ydiamond_blank;
2398 next[x+1][y] = Xblank;
2399 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2403 if (cave[x][y+1] == Xdiamond)
2405 cave[x][y+1] = Ydiamond_blank;
2406 next[x][y+1] = Xblank;
2407 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2411 if (cave[x-1][y] == Xdiamond)
2413 cave[x-1][y] = Ydiamond_blank;
2414 next[x-1][y] = Xblank;
2415 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2419 if (cave[x][y-1] == Xdiamond)
2421 cave[x][y-1] = Ydiamond_blank;
2422 next[x][y-1] = Xblank;
2423 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2427 switch (cave[x][y-1])
2441 case Xfake_acid_1_player:
2442 case Xfake_acid_2_player:
2443 case Xfake_acid_3_player:
2444 case Xfake_acid_4_player:
2445 case Xfake_acid_5_player:
2446 case Xfake_acid_6_player:
2447 case Xfake_acid_7_player:
2448 case Xfake_acid_8_player:
2451 cave[x][y] = Yeater_nB;
2452 next[x][y] = Xblank;
2453 cave[x][y-1] = Yeater_n;
2454 next[x][y-1] = Xeater_n;
2465 cave[x][y] = Yeater_nB;
2466 next[x][y] = Xblank;
2467 if (cave[x+1][y-2] == Xblank)
2468 cave[x+1][y-2] = Xsplash_e;
2469 if (cave[x-1][y-2] == Xblank)
2470 cave[x-1][y-2] = Xsplash_w;
2471 play_element_sound(x, y, SOUND_acid, Xacid_1);
2475 next[x][y] = RANDOM(2) ? Xeater_e : Xeater_w;
2476 play_element_sound(x, y, SOUND_eater, Xeater_n);
2481 static void Leater_e(int x, int y)
2483 if (cave[x][y+1] == Xdiamond)
2485 cave[x][y+1] = Ydiamond_blank;
2486 next[x][y+1] = Xblank;
2487 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2491 if (cave[x-1][y] == Xdiamond)
2493 cave[x-1][y] = Ydiamond_blank;
2494 next[x-1][y] = Xblank;
2495 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2499 if (cave[x][y-1] == Xdiamond)
2501 cave[x][y-1] = Ydiamond_blank;
2502 next[x][y-1] = Xblank;
2503 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2507 if (cave[x+1][y] == Xdiamond)
2509 cave[x+1][y] = Ydiamond_blank;
2510 next[x+1][y] = Xblank;
2511 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2515 switch (cave[x+1][y])
2529 case Xfake_acid_1_player:
2530 case Xfake_acid_2_player:
2531 case Xfake_acid_3_player:
2532 case Xfake_acid_4_player:
2533 case Xfake_acid_5_player:
2534 case Xfake_acid_6_player:
2535 case Xfake_acid_7_player:
2536 case Xfake_acid_8_player:
2539 cave[x][y] = Yeater_eB;
2540 next[x][y] = Xblank;
2541 cave[x+1][y] = Yeater_e;
2542 next[x+1][y] = Xeater_e;
2553 cave[x][y] = Yeater_eB;
2554 next[x][y] = Xblank;
2555 if (cave[x+2][y-1] == Xblank)
2556 cave[x+2][y-1] = Xsplash_e;
2557 if (cave[x][y-1] == Xblank)
2558 cave[x][y-1] = Xsplash_w;
2559 play_element_sound(x, y, SOUND_acid, Xacid_1);
2563 next[x][y] = RANDOM(2) ? Xeater_n : Xeater_s;
2564 play_element_sound(x, y, SOUND_eater, Xeater_e);
2569 static void Leater_s(int x, int y)
2571 if (cave[x-1][y] == Xdiamond)
2573 cave[x-1][y] = Ydiamond_blank;
2574 next[x-1][y] = Xblank;
2575 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2579 if (cave[x][y-1] == Xdiamond)
2581 cave[x][y-1] = Ydiamond_blank;
2582 next[x][y-1] = Xblank;
2583 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2587 if (cave[x+1][y] == Xdiamond)
2589 cave[x+1][y] = Ydiamond_blank;
2590 next[x+1][y] = Xblank;
2591 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2595 if (cave[x][y+1] == Xdiamond)
2597 cave[x][y+1] = Ydiamond_blank;
2598 next[x][y+1] = Xblank;
2599 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2603 switch (cave[x][y+1])
2617 case Xfake_acid_1_player:
2618 case Xfake_acid_2_player:
2619 case Xfake_acid_3_player:
2620 case Xfake_acid_4_player:
2621 case Xfake_acid_5_player:
2622 case Xfake_acid_6_player:
2623 case Xfake_acid_7_player:
2624 case Xfake_acid_8_player:
2627 cave[x][y] = Yeater_sB;
2628 next[x][y] = Xblank;
2629 cave[x][y+1] = Yeater_s;
2630 next[x][y+1] = Xeater_s;
2641 cave[x][y] = Yeater_sB;
2642 next[x][y] = Xblank;
2643 if (cave[x+1][y] == Xblank)
2644 cave[x+1][y] = Xsplash_e;
2645 if (cave[x-1][y] == Xblank)
2646 cave[x-1][y] = Xsplash_w;
2647 play_element_sound(x, y, SOUND_acid, Xacid_1);
2651 next[x][y] = RANDOM(2) ? Xeater_e : Xeater_w;
2652 play_element_sound(x, y, SOUND_eater, Xeater_s);
2657 static void Leater_w(int x, int y)
2659 if (cave[x][y-1] == Xdiamond)
2661 cave[x][y-1] = Ydiamond_blank;
2662 next[x][y-1] = Xblank;
2663 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2667 if (cave[x+1][y] == Xdiamond)
2669 cave[x+1][y] = Ydiamond_blank;
2670 next[x+1][y] = Xblank;
2671 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2675 if (cave[x][y+1] == Xdiamond)
2677 cave[x][y+1] = Ydiamond_blank;
2678 next[x][y+1] = Xblank;
2679 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2683 if (cave[x-1][y] == Xdiamond)
2685 cave[x-1][y] = Ydiamond_blank;
2686 next[x-1][y] = Xblank;
2687 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2691 switch (cave[x-1][y])
2705 case Xfake_acid_1_player:
2706 case Xfake_acid_2_player:
2707 case Xfake_acid_3_player:
2708 case Xfake_acid_4_player:
2709 case Xfake_acid_5_player:
2710 case Xfake_acid_6_player:
2711 case Xfake_acid_7_player:
2712 case Xfake_acid_8_player:
2715 cave[x][y] = Yeater_wB;
2716 next[x][y] = Xblank;
2717 cave[x-1][y] = Yeater_w;
2718 next[x-1][y] = Xeater_w;
2729 cave[x][y] = Yeater_wB;
2730 next[x][y] = Xblank;
2731 if (cave[x][y-1] == Xblank)
2732 cave[x][y-1] = Xsplash_e;
2733 if (cave[x-2][y-1] == Xblank)
2734 cave[x-2][y-1] = Xsplash_w;
2735 play_element_sound(x, y, SOUND_acid, Xacid_1);
2739 next[x][y] = RANDOM(2) ? Xeater_n : Xeater_s;
2740 play_element_sound(x, y, SOUND_eater, Xeater_w);
2745 static void Lalien(int x, int y)
2756 set_nearest_player_xy(x, y, &dx, &dy);
2763 switch (cave[x][y-1])
2777 case Xfake_acid_1_player:
2778 case Xfake_acid_2_player:
2779 case Xfake_acid_3_player:
2780 case Xfake_acid_4_player:
2781 case Xfake_acid_5_player:
2782 case Xfake_acid_6_player:
2783 case Xfake_acid_7_player:
2784 case Xfake_acid_8_player:
2787 cave[x][y] = Yalien_nB;
2788 next[x][y] = Xblank;
2789 cave[x][y-1] = Yalien_n;
2790 next[x][y-1] = Xalien_pause;
2791 play_element_sound(x, y, SOUND_alien, Xalien);
2802 cave[x][y] = Yalien_nB;
2803 next[x][y] = Xblank;
2804 if (cave[x+1][y-2] == Xblank)
2805 cave[x+1][y-2] = Xsplash_e;
2806 if (cave[x-1][y-2] == Xblank)
2807 cave[x-1][y-2] = Xsplash_w;
2808 play_element_sound(x, y, SOUND_acid, Xacid_1);
2814 switch (cave[x][y+1])
2828 case Xfake_acid_1_player:
2829 case Xfake_acid_2_player:
2830 case Xfake_acid_3_player:
2831 case Xfake_acid_4_player:
2832 case Xfake_acid_5_player:
2833 case Xfake_acid_6_player:
2834 case Xfake_acid_7_player:
2835 case Xfake_acid_8_player:
2838 cave[x][y] = Yalien_sB;
2839 next[x][y] = Xblank;
2840 cave[x][y+1] = Yalien_s;
2841 next[x][y+1] = Xalien_pause;
2842 play_element_sound(x, y, SOUND_alien, Xalien);
2853 cave[x][y] = Yalien_sB;
2854 next[x][y] = Xblank;
2855 if (cave[x+1][y] == Xblank)
2856 cave[x+1][y] = Xsplash_e;
2857 if (cave[x-1][y] == Xblank)
2858 cave[x-1][y] = Xsplash_w;
2859 play_element_sound(x, y, SOUND_acid, Xacid_1);
2868 switch (cave[x+1][y])
2882 case Xfake_acid_1_player:
2883 case Xfake_acid_2_player:
2884 case Xfake_acid_3_player:
2885 case Xfake_acid_4_player:
2886 case Xfake_acid_5_player:
2887 case Xfake_acid_6_player:
2888 case Xfake_acid_7_player:
2889 case Xfake_acid_8_player:
2892 cave[x][y] = Yalien_eB;
2893 next[x][y] = Xblank;
2894 cave[x+1][y] = Yalien_e;
2895 next[x+1][y] = Xalien_pause;
2896 play_element_sound(x, y, SOUND_alien, Xalien);
2907 cave[x][y] = Yalien_eB;
2908 next[x][y] = Xblank;
2909 if (cave[x+2][y-1] == Xblank)
2910 cave[x+2][y-1] = Xsplash_e;
2911 if (cave[x][y-1] == Xblank)
2912 cave[x][y-1] = Xsplash_w;
2913 play_element_sound(x, y, SOUND_acid, Xacid_1);
2919 switch (cave[x-1][y])
2933 case Xfake_acid_1_player:
2934 case Xfake_acid_2_player:
2935 case Xfake_acid_3_player:
2936 case Xfake_acid_4_player:
2937 case Xfake_acid_5_player:
2938 case Xfake_acid_6_player:
2939 case Xfake_acid_7_player:
2940 case Xfake_acid_8_player:
2943 cave[x][y] = Yalien_wB;
2944 next[x][y] = Xblank;
2945 cave[x-1][y] = Yalien_w;
2946 next[x-1][y] = Xalien_pause;
2947 play_element_sound(x, y, SOUND_alien, Xalien);
2958 cave[x][y] = Yalien_wB;
2959 next[x][y] = Xblank;
2960 if (cave[x][y-1] == Xblank)
2961 cave[x][y-1] = Xsplash_e;
2962 if (cave[x-2][y-1] == Xblank)
2963 cave[x-2][y-1] = Xsplash_w;
2964 play_element_sound(x, y, SOUND_acid, Xacid_1);
2971 static void Lalien_pause(int x, int y)
2973 next[x][y] = Xalien;
2976 static void Lbug_n(int x, int y)
2978 switch (cave[x][y-1])
2992 case Xfake_acid_1_player:
2993 case Xfake_acid_2_player:
2994 case Xfake_acid_3_player:
2995 case Xfake_acid_4_player:
2996 case Xfake_acid_5_player:
2997 case Xfake_acid_6_player:
2998 case Xfake_acid_7_player:
2999 case Xfake_acid_8_player:
3002 cave[x][y] = Ybug_nB;
3003 next[x][y] = Xblank;
3004 cave[x][y-1] = Ybug_n;
3005 next[x][y-1] = Xbug_1_n;
3006 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
3017 cave[x][y] = Ybug_nB;
3018 next[x][y] = Xblank;
3019 if (cave[x+1][y-2] == Xblank)
3020 cave[x+1][y-2] = Xsplash_e;
3021 if (cave[x-1][y-2] == Xblank)
3022 cave[x-1][y-2] = Xsplash_w;
3023 play_element_sound(x, y, SOUND_acid, Xacid_1);
3027 cave[x][y] = Ybug_n_w;
3028 next[x][y] = Xbug_2_w;
3029 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
3034 static void Lbug_1_n(int x, int y)
3036 if (is_amoeba[cave[x][y-1]] ||
3037 is_amoeba[cave[x+1][y]] ||
3038 is_amoeba[cave[x][y+1]] ||
3039 is_amoeba[cave[x-1][y]])
3047 switch (cave[x+1][y])
3061 case Xfake_acid_1_player:
3062 case Xfake_acid_2_player:
3063 case Xfake_acid_3_player:
3064 case Xfake_acid_4_player:
3065 case Xfake_acid_5_player:
3066 case Xfake_acid_6_player:
3067 case Xfake_acid_7_player:
3068 case Xfake_acid_8_player:
3079 cave[x][y] = Ybug_n_e;
3080 next[x][y] = Xbug_2_e;
3081 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
3090 static void Lbug_2_n(int x, int y)
3092 if (is_amoeba[cave[x][y-1]] ||
3093 is_amoeba[cave[x+1][y]] ||
3094 is_amoeba[cave[x][y+1]] ||
3095 is_amoeba[cave[x-1][y]])
3106 static void Lbug_e(int x, int y)
3108 switch (cave[x+1][y])
3122 case Xfake_acid_1_player:
3123 case Xfake_acid_2_player:
3124 case Xfake_acid_3_player:
3125 case Xfake_acid_4_player:
3126 case Xfake_acid_5_player:
3127 case Xfake_acid_6_player:
3128 case Xfake_acid_7_player:
3129 case Xfake_acid_8_player:
3132 cave[x][y] = Ybug_eB;
3133 next[x][y] = Xblank;
3134 cave[x+1][y] = Ybug_e;
3135 next[x+1][y] = Xbug_1_e;
3136 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
3147 cave[x][y] = Ybug_eB;
3148 next[x][y] = Xblank;
3149 if (cave[x+2][y-1] == Xblank)
3150 cave[x+2][y-1] = Xsplash_e;
3151 if (cave[x][y-1] == Xblank)
3152 cave[x][y-1] = Xsplash_w;
3153 play_element_sound(x, y, SOUND_acid, Xacid_1);
3157 cave[x][y] = Ybug_e_n;
3158 next[x][y] = Xbug_2_n;
3159 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
3164 static void Lbug_1_e(int x, int y)
3166 if (is_amoeba[cave[x][y-1]] ||
3167 is_amoeba[cave[x+1][y]] ||
3168 is_amoeba[cave[x][y+1]] ||
3169 is_amoeba[cave[x-1][y]])
3177 switch (cave[x][y+1])
3191 case Xfake_acid_1_player:
3192 case Xfake_acid_2_player:
3193 case Xfake_acid_3_player:
3194 case Xfake_acid_4_player:
3195 case Xfake_acid_5_player:
3196 case Xfake_acid_6_player:
3197 case Xfake_acid_7_player:
3198 case Xfake_acid_8_player:
3209 cave[x][y] = Ybug_e_s;
3210 next[x][y] = Xbug_2_s;
3211 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
3220 static void Lbug_2_e(int x, int y)
3222 if (is_amoeba[cave[x][y-1]] ||
3223 is_amoeba[cave[x+1][y]] ||
3224 is_amoeba[cave[x][y+1]] ||
3225 is_amoeba[cave[x-1][y]])
3236 static void Lbug_s(int x, int y)
3238 switch (cave[x][y+1])
3252 case Xfake_acid_1_player:
3253 case Xfake_acid_2_player:
3254 case Xfake_acid_3_player:
3255 case Xfake_acid_4_player:
3256 case Xfake_acid_5_player:
3257 case Xfake_acid_6_player:
3258 case Xfake_acid_7_player:
3259 case Xfake_acid_8_player:
3262 cave[x][y] = Ybug_sB;
3263 next[x][y] = Xblank;
3264 cave[x][y+1] = Ybug_s;
3265 next[x][y+1] = Xbug_1_s;
3266 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3277 cave[x][y] = Ybug_sB;
3278 next[x][y] = Xblank;
3279 if (cave[x+1][y] == Xblank)
3280 cave[x+1][y] = Xsplash_e;
3281 if (cave[x-1][y] == Xblank)
3282 cave[x-1][y] = Xsplash_w;
3283 play_element_sound(x, y, SOUND_acid, Xacid_1);
3287 cave[x][y] = Ybug_s_e;
3288 next[x][y] = Xbug_2_e;
3289 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3294 static void Lbug_1_s(int x, int y)
3296 if (is_amoeba[cave[x][y-1]] ||
3297 is_amoeba[cave[x+1][y]] ||
3298 is_amoeba[cave[x][y+1]] ||
3299 is_amoeba[cave[x-1][y]])
3307 switch (cave[x-1][y])
3321 case Xfake_acid_1_player:
3322 case Xfake_acid_2_player:
3323 case Xfake_acid_3_player:
3324 case Xfake_acid_4_player:
3325 case Xfake_acid_5_player:
3326 case Xfake_acid_6_player:
3327 case Xfake_acid_7_player:
3328 case Xfake_acid_8_player:
3339 cave[x][y] = Ybug_s_w;
3340 next[x][y] = Xbug_2_w;
3341 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3350 static void Lbug_2_s(int x, int y)
3352 if (is_amoeba[cave[x][y-1]] ||
3353 is_amoeba[cave[x+1][y]] ||
3354 is_amoeba[cave[x][y+1]] ||
3355 is_amoeba[cave[x-1][y]])
3366 static void Lbug_w(int x, int y)
3368 switch (cave[x-1][y])
3382 case Xfake_acid_1_player:
3383 case Xfake_acid_2_player:
3384 case Xfake_acid_3_player:
3385 case Xfake_acid_4_player:
3386 case Xfake_acid_5_player:
3387 case Xfake_acid_6_player:
3388 case Xfake_acid_7_player:
3389 case Xfake_acid_8_player:
3392 cave[x][y] = Ybug_wB;
3393 next[x][y] = Xblank;
3394 cave[x-1][y] = Ybug_w;
3395 next[x-1][y] = Xbug_1_w;
3396 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3407 cave[x][y] = Ybug_wB;
3408 next[x][y] = Xblank;
3409 if (cave[x][y-1] == Xblank)
3410 cave[x][y-1] = Xsplash_e;
3411 if (cave[x-2][y-1] == Xblank)
3412 cave[x-2][y-1] = Xsplash_w;
3413 play_element_sound(x, y, SOUND_acid, Xacid_1);
3417 cave[x][y] = Ybug_w_s;
3418 next[x][y] = Xbug_2_s;
3419 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3424 static void Lbug_1_w(int x, int y)
3426 if (is_amoeba[cave[x][y-1]] ||
3427 is_amoeba[cave[x+1][y]] ||
3428 is_amoeba[cave[x][y+1]] ||
3429 is_amoeba[cave[x-1][y]])
3437 switch (cave[x][y-1])
3451 case Xfake_acid_1_player:
3452 case Xfake_acid_2_player:
3453 case Xfake_acid_3_player:
3454 case Xfake_acid_4_player:
3455 case Xfake_acid_5_player:
3456 case Xfake_acid_6_player:
3457 case Xfake_acid_7_player:
3458 case Xfake_acid_8_player:
3469 cave[x][y] = Ybug_w_n;
3470 next[x][y] = Xbug_2_n;
3471 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3480 static void Lbug_2_w(int x, int y)
3482 if (is_amoeba[cave[x][y-1]] ||
3483 is_amoeba[cave[x+1][y]] ||
3484 is_amoeba[cave[x][y+1]] ||
3485 is_amoeba[cave[x-1][y]])
3496 static void Ltank_n(int x, int y)
3498 switch (cave[x][y-1])
3512 case Xfake_acid_1_player:
3513 case Xfake_acid_2_player:
3514 case Xfake_acid_3_player:
3515 case Xfake_acid_4_player:
3516 case Xfake_acid_5_player:
3517 case Xfake_acid_6_player:
3518 case Xfake_acid_7_player:
3519 case Xfake_acid_8_player:
3522 cave[x][y] = Ytank_nB;
3523 next[x][y] = Xblank;
3524 cave[x][y-1] = Ytank_n;
3525 next[x][y-1] = Xtank_1_n;
3526 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3537 cave[x][y] = Ytank_nB;
3538 next[x][y] = Xblank;
3539 if (cave[x+1][y-2] == Xblank)
3540 cave[x+1][y-2] = Xsplash_e;
3541 if (cave[x-1][y-2] == Xblank)
3542 cave[x-1][y-2] = Xsplash_w;
3543 play_element_sound(x, y, SOUND_acid, Xacid_1);
3547 cave[x][y] = Ytank_n_e;
3548 next[x][y] = Xtank_2_e;
3549 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3554 static void Ltank_1_n(int x, int y)
3556 if (is_amoeba[cave[x][y-1]] ||
3557 is_amoeba[cave[x+1][y]] ||
3558 is_amoeba[cave[x][y+1]] ||
3559 is_amoeba[cave[x-1][y]])
3567 switch (cave[x-1][y])
3581 case Xfake_acid_1_player:
3582 case Xfake_acid_2_player:
3583 case Xfake_acid_3_player:
3584 case Xfake_acid_4_player:
3585 case Xfake_acid_5_player:
3586 case Xfake_acid_6_player:
3587 case Xfake_acid_7_player:
3588 case Xfake_acid_8_player:
3599 cave[x][y] = Ytank_n_w;
3600 next[x][y] = Xtank_2_w;
3601 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3610 static void Ltank_2_n(int x, int y)
3612 if (is_amoeba[cave[x][y-1]] ||
3613 is_amoeba[cave[x+1][y]] ||
3614 is_amoeba[cave[x][y+1]] ||
3615 is_amoeba[cave[x-1][y]])
3626 static void Ltank_e(int x, int y)
3628 switch (cave[x+1][y])
3642 case Xfake_acid_1_player:
3643 case Xfake_acid_2_player:
3644 case Xfake_acid_3_player:
3645 case Xfake_acid_4_player:
3646 case Xfake_acid_5_player:
3647 case Xfake_acid_6_player:
3648 case Xfake_acid_7_player:
3649 case Xfake_acid_8_player:
3652 cave[x][y] = Ytank_eB;
3653 next[x][y] = Xblank;
3654 cave[x+1][y] = Ytank_e;
3655 next[x+1][y] = Xtank_1_e;
3656 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3667 cave[x][y] = Ytank_eB;
3668 next[x][y] = Xblank;
3669 if (cave[x+2][y-1] == Xblank)
3670 cave[x+2][y-1] = Xsplash_e;
3671 if (cave[x][y-1] == Xblank)
3672 cave[x][y-1] = Xsplash_w;
3673 play_element_sound(x, y, SOUND_acid, Xacid_1);
3677 cave[x][y] = Ytank_e_s;
3678 next[x][y] = Xtank_2_s;
3679 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3684 static void Ltank_1_e(int x, int y)
3686 if (is_amoeba[cave[x][y-1]] ||
3687 is_amoeba[cave[x+1][y]] ||
3688 is_amoeba[cave[x][y+1]] ||
3689 is_amoeba[cave[x-1][y]])
3697 switch (cave[x][y-1])
3711 case Xfake_acid_1_player:
3712 case Xfake_acid_2_player:
3713 case Xfake_acid_3_player:
3714 case Xfake_acid_4_player:
3715 case Xfake_acid_5_player:
3716 case Xfake_acid_6_player:
3717 case Xfake_acid_7_player:
3718 case Xfake_acid_8_player:
3729 cave[x][y] = Ytank_e_n;
3730 next[x][y] = Xtank_2_n;
3731 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3740 static void Ltank_2_e(int x, int y)
3742 if (is_amoeba[cave[x][y-1]] ||
3743 is_amoeba[cave[x+1][y]] ||
3744 is_amoeba[cave[x][y+1]] ||
3745 is_amoeba[cave[x-1][y]])
3756 static void Ltank_s(int x, int y)
3758 switch (cave[x][y+1])
3772 case Xfake_acid_1_player:
3773 case Xfake_acid_2_player:
3774 case Xfake_acid_3_player:
3775 case Xfake_acid_4_player:
3776 case Xfake_acid_5_player:
3777 case Xfake_acid_6_player:
3778 case Xfake_acid_7_player:
3779 case Xfake_acid_8_player:
3782 cave[x][y] = Ytank_sB;
3783 next[x][y] = Xblank;
3784 cave[x][y+1] = Ytank_s;
3785 next[x][y+1] = Xtank_1_s;
3786 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3797 cave[x][y] = Ytank_sB;
3798 next[x][y] = Xblank;
3799 if (cave[x+1][y] == Xblank)
3800 cave[x+1][y] = Xsplash_e;
3801 if (cave[x-1][y] == Xblank)
3802 cave[x-1][y] = Xsplash_w;
3803 play_element_sound(x, y, SOUND_acid, Xacid_1);
3807 cave[x][y] = Ytank_s_w;
3808 next[x][y] = Xtank_2_w;
3809 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3814 static void Ltank_1_s(int x, int y)
3816 if (is_amoeba[cave[x][y-1]] ||
3817 is_amoeba[cave[x+1][y]] ||
3818 is_amoeba[cave[x][y+1]] ||
3819 is_amoeba[cave[x-1][y]])
3827 switch (cave[x+1][y])
3841 case Xfake_acid_1_player:
3842 case Xfake_acid_2_player:
3843 case Xfake_acid_3_player:
3844 case Xfake_acid_4_player:
3845 case Xfake_acid_5_player:
3846 case Xfake_acid_6_player:
3847 case Xfake_acid_7_player:
3848 case Xfake_acid_8_player:
3859 cave[x][y] = Ytank_s_e;
3860 next[x][y] = Xtank_2_e;
3861 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3870 static void Ltank_2_s(int x, int y)
3872 if (is_amoeba[cave[x][y-1]] ||
3873 is_amoeba[cave[x+1][y]] ||
3874 is_amoeba[cave[x][y+1]] ||
3875 is_amoeba[cave[x-1][y]])
3886 static void Ltank_w(int x, int y)
3888 switch (cave[x-1][y])
3902 case Xfake_acid_1_player:
3903 case Xfake_acid_2_player:
3904 case Xfake_acid_3_player:
3905 case Xfake_acid_4_player:
3906 case Xfake_acid_5_player:
3907 case Xfake_acid_6_player:
3908 case Xfake_acid_7_player:
3909 case Xfake_acid_8_player:
3912 cave[x][y] = Ytank_wB;
3913 next[x][y] = Xblank;
3914 cave[x-1][y] = Ytank_w;
3915 next[x-1][y] = Xtank_1_w;
3916 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3927 cave[x][y] = Ytank_wB;
3928 next[x][y] = Xblank;
3929 if (cave[x][y-1] == Xblank)
3930 cave[x][y-1] = Xsplash_e;
3931 if (cave[x-2][y-1] == Xblank)
3932 cave[x-2][y-1] = Xsplash_w;
3933 play_element_sound(x, y, SOUND_acid, Xacid_1);
3937 cave[x][y] = Ytank_w_n;
3938 next[x][y] = Xtank_2_n;
3939 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3944 static void Ltank_1_w(int x, int y)
3946 if (is_amoeba[cave[x][y-1]] ||
3947 is_amoeba[cave[x+1][y]] ||
3948 is_amoeba[cave[x][y+1]] ||
3949 is_amoeba[cave[x-1][y]])
3957 switch (cave[x][y+1])
3971 case Xfake_acid_1_player:
3972 case Xfake_acid_2_player:
3973 case Xfake_acid_3_player:
3974 case Xfake_acid_4_player:
3975 case Xfake_acid_5_player:
3976 case Xfake_acid_6_player:
3977 case Xfake_acid_7_player:
3978 case Xfake_acid_8_player:
3989 cave[x][y] = Ytank_w_s;
3990 next[x][y] = Xtank_2_s;
3991 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
4000 static void Ltank_2_w(int x, int y)
4002 if (is_amoeba[cave[x][y-1]] ||
4003 is_amoeba[cave[x+1][y]] ||
4004 is_amoeba[cave[x][y+1]] ||
4005 is_amoeba[cave[x-1][y]])
4016 static void Lemerald(int x, int y)
4018 switch (cave[x][y+1])
4031 cave[x][y] = Yemerald_sB;
4032 next[x][y] = Xblank;
4033 cave[x][y+1] = Yemerald_s;
4034 next[x][y+1] = Xemerald_fall;
4045 cave[x][y] = Yemerald_sB;
4046 next[x][y] = Xblank;
4047 if (cave[x+1][y] == Xblank)
4048 cave[x+1][y] = Xsplash_e;
4049 if (cave[x-1][y] == Xblank)
4050 cave[x-1][y] = Xsplash_w;
4051 play_element_sound(x, y, SOUND_acid, Xacid_1);
4064 case Xemerald_pause:
4066 case Xdiamond_pause:
4110 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4112 cave[x][y] = Yemerald_eB;
4113 next[x][y] = Xblank;
4114 cave[x+1][y] = Yemerald_e;
4115 next[x+1][y] = Xemerald_pause;
4116 if (cave[x][y+1] == Xbumper)
4117 cave[x][y+1] = Ybumper;
4121 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4123 cave[x][y] = Yemerald_wB;
4124 next[x][y] = Xblank;
4125 cave[x-1][y] = Yemerald_w;
4126 next[x-1][y] = Xemerald_pause;
4127 if (cave[x][y+1] == Xbumper)
4128 cave[x][y+1] = Ybumper;
4134 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4136 cave[x][y] = Yemerald_wB;
4137 next[x][y] = Xblank;
4138 cave[x-1][y] = Yemerald_w;
4139 next[x-1][y] = Xemerald_pause;
4140 if (cave[x][y+1] == Xbumper)
4141 cave[x][y+1] = Ybumper;
4145 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4147 cave[x][y] = Yemerald_eB;
4148 next[x][y] = Xblank;
4149 cave[x+1][y] = Yemerald_e;
4150 next[x+1][y] = Xemerald_pause;
4151 if (cave[x][y+1] == Xbumper)
4152 cave[x][y+1] = Ybumper;
4158 if (++lev.shine_cnt > 50)
4160 lev.shine_cnt = RANDOM(8);
4161 cave[x][y] = Xemerald_shine;
4168 static void Lemerald_pause(int x, int y)
4170 switch (cave[x][y+1])
4183 cave[x][y] = Yemerald_sB;
4184 next[x][y] = Xblank;
4185 cave[x][y+1] = Yemerald_s;
4186 next[x][y+1] = Xemerald_fall;
4197 cave[x][y] = Yemerald_sB;
4198 next[x][y] = Xblank;
4199 if (cave[x+1][y] == Xblank)
4200 cave[x+1][y] = Xsplash_e;
4201 if (cave[x-1][y] == Xblank)
4202 cave[x-1][y] = Xsplash_w;
4203 play_element_sound(x, y, SOUND_acid, Xacid_1);
4207 cave[x][y] = Xemerald;
4208 next[x][y] = Xemerald;
4213 static void Lemerald_fall(int x, int y)
4215 switch (cave[x][y+1])
4229 case Xfake_acid_1_player:
4230 case Xfake_acid_2_player:
4231 case Xfake_acid_3_player:
4232 case Xfake_acid_4_player:
4233 case Xfake_acid_5_player:
4234 case Xfake_acid_6_player:
4235 case Xfake_acid_7_player:
4236 case Xfake_acid_8_player:
4237 cave[x][y] = Yemerald_sB;
4238 next[x][y] = Xblank;
4239 cave[x][y+1] = Yemerald_s;
4240 next[x][y+1] = Xemerald_fall;
4251 cave[x][y] = Yemerald_sB;
4252 next[x][y] = Xblank;
4253 if (cave[x+1][y] == Xblank)
4254 cave[x+1][y] = Xsplash_e;
4255 if (cave[x-1][y] == Xblank)
4256 cave[x-1][y] = Xsplash_w;
4257 play_element_sound(x, y, SOUND_acid, Xacid_1);
4261 if (lev.wonderwall_time > 0)
4263 lev.wonderwall_active = TRUE;
4264 cave[x][y] = Yemerald_sB;
4265 next[x][y] = Xblank;
4266 if (is_blank[cave[x][y+2]])
4268 cave[x][y+2] = Ydiamond_s;
4269 next[x][y+2] = Xdiamond_fall;
4271 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
4276 cave[x][y] = Xemerald;
4277 next[x][y] = Xemerald;
4278 play_element_sound(x, y, SOUND_diamond, Xemerald);
4283 static void Ldiamond(int x, int y)
4285 switch (cave[x][y+1])
4298 cave[x][y] = Ydiamond_sB;
4299 next[x][y] = Xblank;
4300 cave[x][y+1] = Ydiamond_s;
4301 next[x][y+1] = Xdiamond_fall;
4312 cave[x][y] = Ydiamond_sB;
4313 next[x][y] = Xblank;
4314 if (cave[x+1][y] == Xblank)
4315 cave[x+1][y] = Xsplash_e;
4316 if (cave[x-1][y] == Xblank)
4317 cave[x-1][y] = Xsplash_w;
4318 play_element_sound(x, y, SOUND_acid, Xacid_1);
4331 case Xemerald_pause:
4333 case Xdiamond_pause:
4377 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4379 cave[x][y] = Ydiamond_eB;
4380 next[x][y] = Xblank;
4381 cave[x+1][y] = Ydiamond_e;
4382 next[x+1][y] = Xdiamond_pause;
4383 if (cave[x][y+1] == Xbumper)
4384 cave[x][y+1] = Ybumper;
4388 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4390 cave[x][y] = Ydiamond_wB;
4391 next[x][y] = Xblank;
4392 cave[x-1][y] = Ydiamond_w;
4393 next[x-1][y] = Xdiamond_pause;
4394 if (cave[x][y+1] == Xbumper)
4395 cave[x][y+1] = Ybumper;
4401 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4403 cave[x][y] = Ydiamond_wB;
4404 next[x][y] = Xblank;
4405 cave[x-1][y] = Ydiamond_w;
4406 next[x-1][y] = Xdiamond_pause;
4407 if (cave[x][y+1] == Xbumper)
4408 cave[x][y+1] = Ybumper;
4412 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4414 cave[x][y] = Ydiamond_eB;
4415 next[x][y] = Xblank;
4416 cave[x+1][y] = Ydiamond_e;
4417 next[x+1][y] = Xdiamond_pause;
4418 if (cave[x][y+1] == Xbumper)
4419 cave[x][y+1] = Ybumper;
4425 if (++lev.shine_cnt > 50)
4427 lev.shine_cnt = RANDOM(8);
4428 cave[x][y] = Xdiamond_shine;
4435 static void Ldiamond_pause(int x, int y)
4437 switch (cave[x][y+1])
4450 cave[x][y] = Ydiamond_sB;
4451 next[x][y] = Xblank;
4452 cave[x][y+1] = Ydiamond_s;
4453 next[x][y+1] = Xdiamond_fall;
4464 cave[x][y] = Ydiamond_sB;
4465 next[x][y] = Xblank;
4466 if (cave[x+1][y] == Xblank)
4467 cave[x+1][y] = Xsplash_e;
4468 if (cave[x-1][y] == Xblank)
4469 cave[x-1][y] = Xsplash_w;
4470 play_element_sound(x, y, SOUND_acid, Xacid_1);
4474 cave[x][y] = Xdiamond;
4475 next[x][y] = Xdiamond;
4480 static void Ldiamond_fall(int x, int y)
4482 switch (cave[x][y+1])
4496 case Xfake_acid_1_player:
4497 case Xfake_acid_2_player:
4498 case Xfake_acid_3_player:
4499 case Xfake_acid_4_player:
4500 case Xfake_acid_5_player:
4501 case Xfake_acid_6_player:
4502 case Xfake_acid_7_player:
4503 case Xfake_acid_8_player:
4504 cave[x][y] = Ydiamond_sB;
4505 next[x][y] = Xblank;
4506 cave[x][y+1] = Ydiamond_s;
4507 next[x][y+1] = Xdiamond_fall;
4518 cave[x][y] = Ydiamond_sB;
4519 next[x][y] = Xblank;
4520 if (cave[x+1][y] == Xblank)
4521 cave[x+1][y] = Xsplash_e;
4522 if (cave[x-1][y] == Xblank)
4523 cave[x-1][y] = Xsplash_w;
4524 play_element_sound(x, y, SOUND_acid, Xacid_1);
4528 if (lev.wonderwall_time > 0)
4530 lev.wonderwall_active = TRUE;
4531 cave[x][y] = Ydiamond_sB;
4532 next[x][y] = Xblank;
4533 if (is_blank[cave[x][y+2]])
4535 cave[x][y+2] = Ystone_s;
4536 next[x][y+2] = Xstone_fall;
4538 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
4543 cave[x][y] = Xdiamond;
4544 next[x][y] = Xdiamond;
4545 play_element_sound(x, y, SOUND_diamond, Xdiamond);
4550 static void Lstone(int x, int y)
4552 switch (cave[x][y+1])
4567 cave[x][y] = Ystone_sB;
4568 next[x][y] = Xblank;
4569 cave[x][y+1] = Ystone_s;
4570 next[x][y+1] = Xstone_fall;
4581 cave[x][y] = Ystone_sB;
4582 next[x][y] = Xblank;
4583 if (cave[x+1][y] == Xblank)
4584 cave[x+1][y] = Xsplash_e;
4585 if (cave[x-1][y] == Xblank)
4586 cave[x-1][y] = Xsplash_w;
4587 play_element_sound(x, y, SOUND_acid, Xacid_1);
4591 cave[x][y] = Xsand_stonein_1;
4592 next[x][y] = Xsand_stonein_2;
4593 cave[x][y+1] = Xsand_sandstone_1;
4594 next[x][y+1] = Xsand_sandstone_2;
4607 case Xemerald_pause:
4609 case Xdiamond_pause:
4646 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4648 cave[x][y] = Ystone_eB;
4649 next[x][y] = Xblank;
4650 cave[x+1][y] = Ystone_e;
4651 next[x+1][y] = Xstone_pause;
4652 if (cave[x][y+1] == Xbumper)
4653 cave[x][y+1] = Ybumper;
4657 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4659 cave[x][y] = Ystone_wB;
4660 next[x][y] = Xblank;
4661 cave[x-1][y] = Ystone_w;
4662 next[x-1][y] = Xstone_pause;
4663 if (cave[x][y+1] == Xbumper)
4664 cave[x][y+1] = Ybumper;
4670 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4672 cave[x][y] = Ystone_wB;
4673 next[x][y] = Xblank;
4674 cave[x-1][y] = Ystone_w;
4675 next[x-1][y] = Xstone_pause;
4676 if (cave[x][y+1] == Xbumper)
4677 cave[x][y+1] = Ybumper;
4681 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4683 cave[x][y] = Ystone_eB;
4684 next[x][y] = Xblank;
4685 cave[x+1][y] = Ystone_e;
4686 next[x+1][y] = Xstone_pause;
4687 if (cave[x][y+1] == Xbumper)
4688 cave[x][y+1] = Ybumper;
4695 static void Lstone_pause(int x, int y)
4697 switch (cave[x][y+1])
4710 cave[x][y] = Ystone_sB;
4711 next[x][y] = Xblank;
4712 cave[x][y+1] = Ystone_s;
4713 next[x][y+1] = Xstone_fall;
4724 cave[x][y] = Ystone_sB;
4725 next[x][y] = Xblank;
4726 if (cave[x+1][y] == Xblank)
4727 cave[x+1][y] = Xsplash_e;
4728 if (cave[x-1][y] == Xblank)
4729 cave[x-1][y] = Xsplash_w;
4730 play_element_sound(x, y, SOUND_acid, Xacid_1);
4734 cave[x][y] = Xstone;
4735 next[x][y] = Xstone;
4740 static void Lstone_fall(int x, int y)
4742 switch (cave[x][y+1])
4756 case Xfake_acid_1_player:
4757 case Xfake_acid_2_player:
4758 case Xfake_acid_3_player:
4759 case Xfake_acid_4_player:
4760 case Xfake_acid_5_player:
4761 case Xfake_acid_6_player:
4762 case Xfake_acid_7_player:
4763 case Xfake_acid_8_player:
4764 cave[x][y] = Ystone_sB;
4765 next[x][y] = Xblank;
4766 cave[x][y+1] = Ystone_s;
4767 next[x][y+1] = Xstone_fall;
4778 cave[x][y] = Ystone_sB;
4779 next[x][y] = Xblank;
4780 if (cave[x+1][y] == Xblank)
4781 cave[x+1][y] = Xsplash_e;
4782 if (cave[x-1][y] == Xblank)
4783 cave[x-1][y] = Xsplash_w;
4784 play_element_sound(x, y, SOUND_acid, Xacid_1);
4791 cave[x][y] = Ystone_sB;
4792 Lboom_next_new(x, y, Xblank);
4793 cave[x][y+1] = Yeater_stone;
4794 next[x][y+1] = Zeater;
4795 Lboom_eater_old(x, y+1);
4796 score += lev.eater_score;
4801 cave[x][y] = Ystone_sB;
4802 Lboom_next_new(x, y, Xblank);
4803 cave[x][y+1] = Yalien_stone;
4804 next[x][y+1] = Ztank;
4805 Lboom_tank_old(x, y+1);
4806 score += lev.alien_score;
4817 cave[x][y] = Ystone_sB;
4818 Lboom_next_new(x, y, Xblank);
4819 cave[x][y+1] = Ybug_stone;
4820 next[x][y+1] = Zbug;
4821 Lboom_bug_old(x, y+1);
4822 score += lev.bug_score;
4833 cave[x][y] = Ystone_sB;
4834 Lboom_next_new(x, y, Xblank);
4835 cave[x][y+1] = Ytank_stone;
4836 next[x][y+1] = Ztank;
4837 Lboom_tank_old(x, y+1);
4838 score += lev.tank_score;
4842 case Xdiamond_pause:
4843 switch (cave[x][y+2])
4857 case Xfake_acid_1_player:
4858 case Xfake_acid_2_player:
4859 case Xfake_acid_3_player:
4860 case Xfake_acid_4_player:
4861 case Xfake_acid_5_player:
4862 case Xfake_acid_6_player:
4863 case Xfake_acid_7_player:
4864 case Xfake_acid_8_player:
4907 next[x][y] = Xstone;
4908 play_element_sound(x, y, SOUND_stone, Xstone);
4912 cave[x][y] = Ystone_sB;
4913 next[x][y] = Xblank;
4914 cave[x][y+1] = Ydiamond_stone;
4915 next[x][y+1] = Xstone_pause;
4916 play_element_sound(x, y, SOUND_squash, Xdiamond);
4921 Lboom_cave_new(x, y, Xstone);
4922 Lboom_next_new(x, y, Xstone);
4923 cave[x][y+1] = Ybomb_blank;
4924 next[x][y+1] = Ztank;
4925 Lboom_tank_old(x, y+1);
4930 next[x][y] = Xstone;
4931 cave[x][y+1] = Ynut_stone;
4932 next[x][y+1] = Xemerald;
4933 play_element_sound(x, y, SOUND_crack, Xnut);
4934 score += lev.nut_score;
4940 switch (cave[x+1][y+1])
4955 cave[x][y+1] = Xspring_e;
4959 cave[x][y+1] = Xspring_w;
4965 switch (cave[x-1][y+1])
4980 cave[x][y+1] = Xspring_w;
4983 cave[x][y+1] = Xspring_e;
4988 next[x][y] = Xstone;
4992 if (lev.wonderwall_time > 0)
4994 lev.wonderwall_active = TRUE;
4995 cave[x][y] = Ystone_sB;
4996 next[x][y] = Xblank;
4997 if (is_blank[cave[x][y+2]])
4999 cave[x][y+2] = Yemerald_s;
5000 next[x][y+2] = Xemerald_fall;
5002 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
5007 cave[x][y] = Xstone;
5008 next[x][y] = Xstone;
5009 play_element_sound(x, y, SOUND_stone, Xstone);
5014 static void Lbomb(int x, int y)
5016 switch (cave[x][y+1])
5029 cave[x][y] = Ybomb_sB;
5030 next[x][y] = Xblank;
5031 cave[x][y+1] = Ybomb_s;
5032 next[x][y+1] = Xbomb_fall;
5043 cave[x][y] = Ybomb_sB;
5044 next[x][y] = Xblank;
5045 if (cave[x+1][y] == Xblank)
5046 cave[x+1][y] = Xsplash_e;
5047 if (cave[x-1][y] == Xblank)
5048 cave[x-1][y] = Xsplash_w;
5049 play_element_sound(x, y, SOUND_acid, Xacid_1);
5062 case Xemerald_pause:
5064 case Xdiamond_pause:
5099 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5101 cave[x][y] = Ybomb_eB;
5102 next[x][y] = Xblank;
5103 cave[x+1][y] = Ybomb_e;
5104 next[x+1][y] = Xbomb_pause;
5105 if (cave[x][y+1] == Xbumper)
5106 cave[x][y+1] = Ybumper;
5110 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5112 cave[x][y] = Ybomb_wB;
5113 next[x][y] = Xblank;
5114 cave[x-1][y] = Ybomb_w;
5115 next[x-1][y] = Xbomb_pause;
5116 if (cave[x][y+1] == Xbumper)
5117 cave[x][y+1] = Ybumper;
5123 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5125 cave[x][y] = Ybomb_wB;
5126 next[x][y] = Xblank;
5127 cave[x-1][y] = Ybomb_w;
5128 next[x-1][y] = Xbomb_pause;
5129 if (cave[x][y+1] == Xbumper)
5130 cave[x][y+1] = Ybumper;
5134 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5136 cave[x][y] = Ybomb_eB;
5137 next[x][y] = Xblank;
5138 cave[x+1][y] = Ybomb_e;
5139 next[x+1][y] = Xbomb_pause;
5140 if (cave[x][y+1] == Xbumper)
5141 cave[x][y+1] = Ybumper;
5148 static void Lbomb_pause(int x, int y)
5150 switch (cave[x][y+1])
5163 cave[x][y] = Ybomb_sB;
5164 next[x][y] = Xblank;
5165 cave[x][y+1] = Ybomb_s;
5166 next[x][y+1] = Xbomb_fall;
5177 cave[x][y] = Ybomb_sB;
5178 next[x][y] = Xblank;
5179 if (cave[x+1][y] == Xblank)
5180 cave[x+1][y] = Xsplash_e;
5181 if (cave[x-1][y] == Xblank)
5182 cave[x-1][y] = Xsplash_w;
5183 play_element_sound(x, y, SOUND_acid, Xacid_1);
5193 static void Lbomb_fall(int x, int y)
5195 switch (cave[x][y+1])
5208 cave[x][y] = Ybomb_sB;
5209 next[x][y] = Xblank;
5210 cave[x][y+1] = Ybomb_s;
5211 next[x][y+1] = Xbomb_fall;
5222 cave[x][y] = Ybomb_sB;
5223 next[x][y] = Xblank;
5224 if (cave[x+1][y] == Xblank)
5225 cave[x+1][y] = Xsplash_e;
5226 if (cave[x-1][y] == Xblank)
5227 cave[x-1][y] = Xsplash_w;
5228 play_element_sound(x, y, SOUND_acid, Xacid_1);
5232 cave[x][y] = Ybomb_blank;
5234 Lboom_tank_old(x, y);
5239 static void Lnut(int x, int y)
5241 switch (cave[x][y+1])
5254 cave[x][y] = Ynut_sB;
5255 next[x][y] = Xblank;
5256 cave[x][y+1] = Ynut_s;
5257 next[x][y+1] = Xnut_fall;
5268 cave[x][y] = Ynut_sB;
5269 next[x][y] = Xblank;
5270 if (cave[x+1][y] == Xblank)
5271 cave[x+1][y] = Xsplash_e;
5272 if (cave[x-1][y] == Xblank)
5273 cave[x-1][y] = Xsplash_w;
5274 play_element_sound(x, y, SOUND_acid, Xacid_1);
5287 case Xemerald_pause:
5289 case Xdiamond_pause:
5324 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5326 cave[x][y] = Ynut_eB;
5327 next[x][y] = Xblank;
5328 cave[x+1][y] = Ynut_e;
5329 next[x+1][y] = Xnut_pause;
5330 if (cave[x][y+1] == Xbumper)
5331 cave[x][y+1] = Ybumper;
5335 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5337 cave[x][y] = Ynut_wB;
5338 next[x][y] = Xblank;
5339 cave[x-1][y] = Ynut_w;
5340 next[x-1][y] = Xnut_pause;
5341 if (cave[x][y+1] == Xbumper)
5342 cave[x][y+1] = Ybumper;
5348 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5350 cave[x][y] = Ynut_wB;
5351 next[x][y] = Xblank;
5352 cave[x-1][y] = Ynut_w;
5353 next[x-1][y] = Xnut_pause;
5354 if (cave[x][y+1] == Xbumper)
5355 cave[x][y+1] = Ybumper;
5359 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5361 cave[x][y] = Ynut_eB;
5362 next[x][y] = Xblank;
5363 cave[x+1][y] = Ynut_e;
5364 next[x+1][y] = Xnut_pause;
5365 if (cave[x][y+1] == Xbumper)
5366 cave[x][y+1] = Ybumper;
5373 static void Lnut_pause(int x, int y)
5375 switch (cave[x][y+1])
5388 cave[x][y] = Ynut_sB;
5389 next[x][y] = Xblank;
5390 cave[x][y+1] = Ynut_s;
5391 next[x][y+1] = Xnut_fall;
5402 cave[x][y] = Ynut_sB;
5403 next[x][y] = Xblank;
5404 if (cave[x+1][y] == Xblank)
5405 cave[x+1][y] = Xsplash_e;
5406 if (cave[x-1][y] == Xblank)
5407 cave[x-1][y] = Xsplash_w;
5408 play_element_sound(x, y, SOUND_acid, Xacid_1);
5418 static void Lnut_fall(int x, int y)
5420 switch (cave[x][y+1])
5434 case Xfake_acid_1_player:
5435 case Xfake_acid_2_player:
5436 case Xfake_acid_3_player:
5437 case Xfake_acid_4_player:
5438 case Xfake_acid_5_player:
5439 case Xfake_acid_6_player:
5440 case Xfake_acid_7_player:
5441 case Xfake_acid_8_player:
5442 cave[x][y] = Ynut_sB;
5443 next[x][y] = Xblank;
5444 cave[x][y+1] = Ynut_s;
5445 next[x][y+1] = Xnut_fall;
5456 cave[x][y] = Ynut_sB;
5457 next[x][y] = Xblank;
5458 if (cave[x+1][y] == Xblank)
5459 cave[x+1][y] = Xsplash_e;
5460 if (cave[x-1][y] == Xblank)
5461 cave[x-1][y] = Xsplash_w;
5462 play_element_sound(x, y, SOUND_acid, Xacid_1);
5468 play_element_sound(x, y, SOUND_nut, Xnut);
5473 static void Lspring(int x, int y)
5475 switch (cave[x][y+1])
5490 cave[x][y] = Yspring_sB;
5491 next[x][y] = Xblank;
5492 cave[x][y+1] = Yspring_s;
5493 next[x][y+1] = Xspring_fall;
5504 cave[x][y] = Yspring_sB;
5505 next[x][y] = Xblank;
5506 if (cave[x+1][y] == Xblank)
5507 cave[x+1][y] = Xsplash_e;
5508 if (cave[x-1][y] == Xblank)
5509 cave[x-1][y] = Xsplash_w;
5510 play_element_sound(x, y, SOUND_acid, Xacid_1);
5523 case Xemerald_pause:
5525 case Xdiamond_pause:
5560 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5562 cave[x][y] = Yspring_eB;
5563 next[x][y] = Xblank;
5564 cave[x+1][y] = Yspring_e;
5566 next[x+1][y] = Xspring_e;
5568 next[x+1][y] = Xspring_pause;
5570 if (cave[x][y+1] == Xbumper)
5571 cave[x][y+1] = Ybumper;
5575 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5577 cave[x][y] = Yspring_wB;
5578 next[x][y] = Xblank;
5579 cave[x-1][y] = Yspring_w;
5581 next[x-1][y] = Xspring_w;
5583 next[x-1][y] = Xspring_pause;
5585 if (cave[x][y+1] == Xbumper)
5586 cave[x][y+1] = Ybumper;
5592 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5594 cave[x][y] = Yspring_wB;
5595 next[x][y] = Xblank;
5596 cave[x-1][y] = Yspring_w;
5598 next[x-1][y] = Xspring_w;
5600 next[x-1][y] = Xspring_pause;
5602 if (cave[x][y+1] == Xbumper)
5603 cave[x][y+1] = Ybumper;
5607 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5609 cave[x][y] = Yspring_eB;
5610 next[x][y] = Xblank;
5611 cave[x+1][y] = Yspring_e;
5613 next[x+1][y] = Xspring_e;
5615 next[x+1][y] = Xspring_pause;
5617 if (cave[x][y+1] == Xbumper)
5618 cave[x][y+1] = Ybumper;
5625 static void Lspring_pause(int x, int y)
5627 switch (cave[x][y+1])
5640 cave[x][y] = Yspring_sB;
5641 next[x][y] = Xblank;
5642 cave[x][y+1] = Yspring_s;
5643 next[x][y+1] = Xspring_fall;
5654 cave[x][y] = Yspring_sB;
5655 next[x][y] = Xblank;
5656 if (cave[x+1][y] == Xblank)
5657 cave[x+1][y] = Xsplash_e;
5658 if (cave[x-1][y] == Xblank)
5659 cave[x-1][y] = Xsplash_w;
5660 play_element_sound(x, y, SOUND_acid, Xacid_1);
5664 cave[x][y] = Xspring;
5665 next[x][y] = Xspring;
5670 static void Lspring_e(int x, int y)
5672 switch (cave[x][y+1])
5685 cave[x][y] = Yspring_sB;
5686 next[x][y] = Xblank;
5687 cave[x][y+1] = Yspring_s;
5688 next[x][y+1] = Xspring_fall;
5699 cave[x][y] = Yspring_sB;
5700 next[x][y] = Xblank;
5701 if (cave[x+1][y] == Xblank)
5702 cave[x+1][y] = Xsplash_e;
5703 if (cave[x-1][y] == Xblank)
5704 cave[x-1][y] = Xsplash_w;
5705 play_element_sound(x, y, SOUND_acid, Xacid_1);
5709 cave[x][y+1] = Ybumper;
5712 switch (cave[x+1][y])
5729 cave[x][y] = Yspring_eB;
5730 next[x][y] = Xblank;
5731 cave[x+1][y] = Yspring_e;
5732 next[x+1][y] = Xspring_e;
5743 cave[x][y] = Yspring_eB;
5744 next[x][y] = Xblank;
5745 if (cave[x+2][y-1] == Xblank)
5746 cave[x+2][y-1] = Xsplash_e;
5747 if (cave[x][y-1] == Xblank)
5748 cave[x][y-1] = Xsplash_w;
5749 play_element_sound(x, y, SOUND_acid, Xacid_1);
5758 cave[x][y] = Yspring_alien_eB;
5759 next[x][y] = Xblank;
5760 cave[x+1][y] = Yspring_alien_e;
5761 next[x+1][y] = Xspring_e;
5762 play_element_sound(x, y, SOUND_slurp, Xalien);
5763 score += lev.slurp_score;
5768 cave[x+1][y] = Ybumper;
5769 next[x][y] = Xspring_w;
5770 play_element_sound(x, y, SOUND_spring, Xspring);
5774 cave[x][y] = Xspring;
5775 next[x][y] = Xspring;
5776 play_element_sound(x, y, SOUND_spring, Xspring);
5781 static void Lspring_w(int x, int y)
5783 switch (cave[x][y+1])
5796 cave[x][y] = Yspring_sB;
5797 next[x][y] = Xblank;
5798 cave[x][y+1] = Yspring_s;
5799 next[x][y+1] = Xspring_fall;
5810 cave[x][y] = Yspring_sB;
5811 next[x][y] = Xblank;
5812 if (cave[x+1][y] == Xblank)
5813 cave[x+1][y] = Xsplash_e;
5814 if (cave[x-1][y] == Xblank)
5815 cave[x-1][y] = Xsplash_w;
5816 play_element_sound(x, y, SOUND_acid, Xacid_1);
5820 cave[x][y+1] = Ybumper;
5823 switch (cave[x-1][y])
5840 cave[x][y] = Yspring_wB;
5841 next[x][y] = Xblank;
5842 cave[x-1][y] = Yspring_w;
5843 next[x-1][y] = Xspring_w;
5854 cave[x][y] = Yspring_wB;
5855 next[x][y] = Xblank;
5856 if (cave[x][y-1] == Xblank)
5857 cave[x][y-1] = Xsplash_e;
5858 if (cave[x-2][y-1] == Xblank)
5859 cave[x-2][y-1] = Xsplash_w;
5860 play_element_sound(x, y, SOUND_acid, Xacid_1);
5869 cave[x][y] = Yspring_alien_wB;
5870 next[x][y] = Xblank;
5871 cave[x-1][y] = Yspring_alien_w;
5872 next[x-1][y] = Xspring_w;
5873 play_element_sound(x, y, SOUND_slurp, Xalien);
5874 score += lev.slurp_score;
5879 cave[x-1][y] = Ybumper;
5880 next[x][y] = Xspring_e;
5881 play_element_sound(x, y, SOUND_spring, Xspring);
5885 cave[x][y] = Xspring;
5886 next[x][y] = Xspring;
5887 play_element_sound(x, y, SOUND_spring, Xspring);
5892 static void Lspring_fall(int x, int y)
5894 switch (cave[x][y+1])
5908 case Xfake_acid_1_player:
5909 case Xfake_acid_2_player:
5910 case Xfake_acid_3_player:
5911 case Xfake_acid_4_player:
5912 case Xfake_acid_5_player:
5913 case Xfake_acid_6_player:
5914 case Xfake_acid_7_player:
5915 case Xfake_acid_8_player:
5916 cave[x][y] = Yspring_sB;
5917 next[x][y] = Xblank;
5918 cave[x][y+1] = Yspring_s;
5919 next[x][y+1] = Xspring_fall;
5930 cave[x][y] = Yspring_sB;
5931 next[x][y] = Xblank;
5932 if (cave[x+1][y] == Xblank)
5933 cave[x+1][y] = Xsplash_e;
5934 if (cave[x-1][y] == Xblank)
5935 cave[x-1][y] = Xsplash_w;
5936 play_element_sound(x, y, SOUND_acid, Xacid_1);
5943 cave[x][y] = Yspring_sB;
5944 next[x][y] = Xblank;
5945 cave[x][y+1] = Yeater_spring;
5946 next[x][y+1] = Zeater;
5947 Lboom_eater_old(x, y+1);
5948 score += lev.eater_score;
5953 cave[x][y] = Yspring_sB;
5954 next[x][y] = Xblank;
5955 cave[x][y+1] = Yalien_spring;
5956 next[x][y+1] = Ztank;
5957 Lboom_tank_old(x, y+1);
5958 score += lev.alien_score;
5969 cave[x][y] = Yspring_sB;
5970 next[x][y] = Xblank;
5971 cave[x][y+1] = Ybug_spring;
5972 next[x][y+1] = Zbug;
5973 Lboom_bug_old(x, y+1);
5974 score += lev.bug_score;
5985 cave[x][y] = Yspring_sB;
5986 next[x][y] = Xblank;
5987 cave[x][y+1] = Ytank_spring;
5988 next[x][y+1] = Ztank;
5989 Lboom_tank_old(x, y+1);
5990 score += lev.tank_score;
5995 cave[x][y] = Xspring;
5996 next[x][y] = Xspring;
5997 cave[x][y+1] = Ybomb_blank;
5998 next[x][y+1] = Ztank;
5999 Lboom_tank_old(x, y+1);
6003 cave[x][y] = Xspring;
6004 next[x][y] = Xspring;
6005 play_element_sound(x, y, SOUND_spring, Xspring);
6010 static void Lpush_emerald_e(int x, int y)
6012 cave[x][y] = Yemerald_eB;
6013 next[x][y] = Xblank;
6015 switch (cave[x+1][y])
6018 if (!game_em.use_old_push_elements)
6031 Lpush_element_old(x, y, Xemerald);
6043 if (game_em.use_old_push_into_acid)
6045 if (cave[x+2][y-1] == Xblank)
6046 cave[x+2][y-1] = Xsplash_e;
6047 if (cave[x][y-1] == Xblank)
6048 cave[x][y-1] = Xsplash_w;
6049 play_element_sound(x, y, SOUND_acid, Xacid_1);
6054 cave[x+1][y] = Yemerald_e;
6055 next[x+1][y] = Xemerald_pause;
6058 static void Lpush_emerald_w(int x, int y)
6060 cave[x][y] = Yemerald_wB;
6061 next[x][y] = Xblank;
6063 switch (cave[x-1][y])
6066 if (!game_em.use_old_push_elements)
6079 Lpush_element_old(x, y, Xemerald);
6091 if (game_em.use_old_push_into_acid)
6093 if (cave[x][y-1] == Xblank)
6094 cave[x][y-1] = Xsplash_e;
6095 if (cave[x-2][y-1] == Xblank)
6096 cave[x-2][y-1] = Xsplash_w;
6097 play_element_sound(x, y, SOUND_acid, Xacid_1);
6102 cave[x-1][y] = Yemerald_w;
6103 next[x-1][y] = Xemerald_pause;
6106 static void Lpush_diamond_e(int x, int y)
6108 cave[x][y] = Ydiamond_eB;
6109 next[x][y] = Xblank;
6111 switch (cave[x+1][y])
6114 if (!game_em.use_old_push_elements)
6127 Lpush_element_old(x, y, Xdiamond);
6139 if (game_em.use_old_push_into_acid)
6141 if (cave[x+2][y-1] == Xblank)
6142 cave[x+2][y-1] = Xsplash_e;
6143 if (cave[x][y-1] == Xblank)
6144 cave[x][y-1] = Xsplash_w;
6145 play_element_sound(x, y, SOUND_acid, Xacid_1);
6150 cave[x+1][y] = Ydiamond_e;
6151 next[x+1][y] = Xdiamond_pause;
6154 static void Lpush_diamond_w(int x, int y)
6156 cave[x][y] = Ydiamond_wB;
6157 next[x][y] = Xblank;
6159 switch (cave[x-1][y])
6162 if (!game_em.use_old_push_elements)
6175 Lpush_element_old(x, y, Xdiamond);
6187 if (game_em.use_old_push_into_acid)
6189 if (cave[x][y-1] == Xblank)
6190 cave[x][y-1] = Xsplash_e;
6191 if (cave[x-2][y-1] == Xblank)
6192 cave[x-2][y-1] = Xsplash_w;
6193 play_element_sound(x, y, SOUND_acid, Xacid_1);
6198 cave[x-1][y] = Ydiamond_w;
6199 next[x-1][y] = Xdiamond_pause;
6202 static void Lpush_stone_e(int x, int y)
6204 cave[x][y] = Ystone_eB;
6205 next[x][y] = Xblank;
6207 switch (cave[x+1][y])
6210 if (!game_em.use_old_push_elements)
6223 Lpush_element_old(x, y, Xstone);
6235 if (game_em.use_old_push_into_acid)
6237 if (cave[x+2][y-1] == Xblank)
6238 cave[x+2][y-1] = Xsplash_e;
6239 if (cave[x][y-1] == Xblank)
6240 cave[x][y-1] = Xsplash_w;
6241 play_element_sound(x, y, SOUND_acid, Xacid_1);
6246 cave[x+1][y] = Ystone_e;
6247 next[x+1][y] = Xstone_pause;
6250 static void Lpush_stone_w(int x, int y)
6252 cave[x][y] = Ystone_wB;
6253 next[x][y] = Xblank;
6255 switch (cave[x-1][y])
6258 if (!game_em.use_old_push_elements)
6271 Lpush_element_old(x, y, Xstone);
6283 if (game_em.use_old_push_into_acid)
6285 if (cave[x][y-1] == Xblank)
6286 cave[x][y-1] = Xsplash_e;
6287 if (cave[x-2][y-1] == Xblank)
6288 cave[x-2][y-1] = Xsplash_w;
6289 play_element_sound(x, y, SOUND_acid, Xacid_1);
6294 cave[x-1][y] = Ystone_w;
6295 next[x-1][y] = Xstone_pause;
6298 static void Lpush_bomb_e(int x, int y)
6300 cave[x][y] = Ybomb_eB;
6301 next[x][y] = Xblank;
6303 switch (cave[x+1][y])
6306 if (!game_em.use_old_push_elements)
6319 Lpush_element_old(x, y, Xbomb);
6331 if (game_em.use_old_push_into_acid)
6333 if (cave[x+2][y-1] == Xblank)
6334 cave[x+2][y-1] = Xsplash_e;
6335 if (cave[x][y-1] == Xblank)
6336 cave[x][y-1] = Xsplash_w;
6337 play_element_sound(x, y, SOUND_acid, Xacid_1);
6342 cave[x+1][y] = Ybomb_e;
6343 next[x+1][y] = Xbomb_pause;
6346 static void Lpush_bomb_w(int x, int y)
6348 cave[x][y] = Ybomb_wB;
6349 next[x][y] = Xblank;
6351 switch (cave[x-1][y])
6354 if (!game_em.use_old_push_elements)
6367 Lpush_element_old(x, y, Xbomb);
6379 if (game_em.use_old_push_into_acid)
6381 if (cave[x][y-1] == Xblank)
6382 cave[x][y-1] = Xsplash_e;
6383 if (cave[x-2][y-1] == Xblank)
6384 cave[x-2][y-1] = Xsplash_w;
6385 play_element_sound(x, y, SOUND_acid, Xacid_1);
6390 cave[x-1][y] = Ybomb_w;
6391 next[x-1][y] = Xbomb_pause;
6394 static void Lpush_nut_e(int x, int y)
6396 cave[x][y] = Ynut_eB;
6397 next[x][y] = Xblank;
6399 switch (cave[x+1][y])
6402 if (!game_em.use_old_push_elements)
6415 Lpush_element_old(x, y, Xnut);
6427 if (game_em.use_old_push_into_acid)
6429 if (cave[x+2][y-1] == Xblank)
6430 cave[x+2][y-1] = Xsplash_e;
6431 if (cave[x][y-1] == Xblank)
6432 cave[x][y-1] = Xsplash_w;
6433 play_element_sound(x, y, SOUND_acid, Xacid_1);
6438 cave[x+1][y] = Ynut_e;
6439 next[x+1][y] = Xnut_pause;
6442 static void Lpush_nut_w(int x, int y)
6444 cave[x][y] = Ynut_wB;
6445 next[x][y] = Xblank;
6447 switch (cave[x-1][y])
6450 if (!game_em.use_old_push_elements)
6463 Lpush_element_old(x, y, Xnut);
6475 if (game_em.use_old_push_into_acid)
6477 if (cave[x][y-1] == Xblank)
6478 cave[x][y-1] = Xsplash_e;
6479 if (cave[x-2][y-1] == Xblank)
6480 cave[x-2][y-1] = Xsplash_w;
6481 play_element_sound(x, y, SOUND_acid, Xacid_1);
6486 cave[x-1][y] = Ynut_w;
6487 next[x-1][y] = Xnut_pause;
6490 static void Lpush_spring_e(int x, int y)
6492 cave[x][y] = Yspring_eB;
6493 next[x][y] = Xblank;
6495 switch (cave[x+1][y])
6498 if (!game_em.use_old_push_elements)
6511 Lpush_element_old(x, y, Xspring);
6523 if (game_em.use_old_push_into_acid)
6525 if (cave[x+2][y-1] == Xblank)
6526 cave[x+2][y-1] = Xsplash_e;
6527 if (cave[x][y-1] == Xblank)
6528 cave[x][y-1] = Xsplash_w;
6529 play_element_sound(x, y, SOUND_acid, Xacid_1);
6534 cave[x+1][y] = Yspring_e;
6535 next[x+1][y] = Xspring_e;
6538 static void Lpush_spring_w(int x, int y)
6540 cave[x][y] = Yspring_wB;
6541 next[x][y] = Xblank;
6543 switch (cave[x-1][y])
6546 if (!game_em.use_old_push_elements)
6559 Lpush_element_old(x, y, Xspring);
6571 if (game_em.use_old_push_into_acid)
6573 if (cave[x][y-1] == Xblank)
6574 cave[x][y-1] = Xsplash_e;
6575 if (cave[x-2][y-1] == Xblank)
6576 cave[x-2][y-1] = Xsplash_w;
6577 play_element_sound(x, y, SOUND_acid, Xacid_1);
6582 cave[x-1][y] = Yspring_w;
6583 next[x-1][y] = Xspring_w;
6586 static void Ldynamite_1(int x, int y)
6588 play_element_sound(x, y, SOUND_tick, Xdynamite_1);
6589 next[x][y] = Xdynamite_2;
6592 static void Ldynamite_2(int x, int y)
6594 play_element_sound(x, y, SOUND_tick, Xdynamite_2);
6595 next[x][y] = Xdynamite_3;
6598 static void Ldynamite_3(int x, int y)
6600 play_element_sound(x, y, SOUND_tick, Xdynamite_3);
6601 next[x][y] = Xdynamite_4;
6604 static void Ldynamite_4(int x, int y)
6606 play_element_sound(x, y, SOUND_tick, Xdynamite_4);
6607 next[x][y] = Zdynamite;
6609 Lboom_generic(x, y, Xblank, Xblank);
6612 static void Lfake_door_1(int x, int y)
6614 if (lev.magnify_cnt)
6615 cave[x][y] = Xdoor_1;
6618 static void Lfake_door_2(int x, int y)
6620 if (lev.magnify_cnt)
6621 cave[x][y] = Xdoor_2;
6624 static void Lfake_door_3(int x, int y)
6626 if (lev.magnify_cnt)
6627 cave[x][y] = Xdoor_3;
6630 static void Lfake_door_4(int x, int y)
6632 if (lev.magnify_cnt)
6633 cave[x][y] = Xdoor_4;
6636 static void Lfake_door_5(int x, int y)
6638 if (lev.magnify_cnt)
6639 cave[x][y] = Xdoor_5;
6642 static void Lfake_door_6(int x, int y)
6644 if (lev.magnify_cnt)
6645 cave[x][y] = Xdoor_6;
6648 static void Lfake_door_7(int x, int y)
6650 if (lev.magnify_cnt)
6651 cave[x][y] = Xdoor_7;
6654 static void Lfake_door_8(int x, int y)
6656 if (lev.magnify_cnt)
6657 cave[x][y] = Xdoor_8;
6660 static void Lballoon(int x, int y)
6662 if (lev.wind_cnt == 0)
6665 switch (lev.wind_direction)
6668 switch (cave[x][y-1])
6681 cave[x][y] = Yballoon_nB;
6682 next[x][y] = Xblank;
6683 cave[x][y-1] = Yballoon_n;
6684 next[x][y-1] = Xballoon;
6695 cave[x][y] = Yballoon_nB;
6696 next[x][y] = Xblank;
6697 if (cave[x+1][y-2] == Xblank)
6698 cave[x+1][y-2] = Xsplash_e;
6699 if (cave[x-1][y-2] == Xblank)
6700 cave[x-1][y-2] = Xsplash_w;
6701 play_element_sound(x, y, SOUND_acid, Xacid_1);
6707 switch (cave[x+1][y])
6720 cave[x][y] = Yballoon_eB;
6721 next[x][y] = Xblank;
6722 cave[x+1][y] = Yballoon_e;
6723 next[x+1][y] = Xballoon;
6734 cave[x][y] = Yballoon_eB;
6735 next[x][y] = Xblank;
6736 if (cave[x+2][y-1] == Xblank)
6737 cave[x+2][y-1] = Xsplash_e;
6738 if (cave[x][y-1] == Xblank)
6739 cave[x][y-1] = Xsplash_w;
6740 play_element_sound(x, y, SOUND_acid, Xacid_1);
6746 switch (cave[x][y+1])
6759 cave[x][y] = Yballoon_sB;
6760 next[x][y] = Xblank;
6761 cave[x][y+1] = Yballoon_s;
6762 next[x][y+1] = Xballoon;
6773 cave[x][y] = Yballoon_sB;
6774 next[x][y] = Xblank;
6775 if (cave[x+1][y] == Xblank)
6776 cave[x+1][y] = Xsplash_e;
6777 if (cave[x-1][y] == Xblank)
6778 cave[x-1][y] = Xsplash_w;
6779 play_element_sound(x, y, SOUND_acid, Xacid_1);
6785 switch (cave[x-1][y])
6798 cave[x][y] = Yballoon_wB;
6799 next[x][y] = Xblank;
6800 cave[x-1][y] = Yballoon_w;
6801 next[x-1][y] = Xballoon;
6812 cave[x][y] = Yballoon_wB;
6813 next[x][y] = Xblank;
6814 if (cave[x][y-1] == Xblank)
6815 cave[x][y-1] = Xsplash_e;
6816 if (cave[x-2][y-1] == Xblank)
6817 cave[x-2][y-1] = Xsplash_w;
6818 play_element_sound(x, y, SOUND_acid, Xacid_1);
6825 static void Lball_common(int x, int y)
6827 play_element_sound(x, y, SOUND_ball, Xball_1);
6829 if (lev.ball_random)
6834 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
6835 is_blank[cave[x-1][y-1]])
6837 cave[x-1][y-1] = Yball_blank;
6838 next[x-1][y-1] = lev.ball_array[lev.ball_pos][0];
6843 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
6844 is_blank[cave[x][y-1]])
6846 cave[x][y-1] = Yball_blank;
6847 next[x][y-1] = lev.ball_array[lev.ball_pos][1];
6852 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
6853 is_blank[cave[x+1][y-1]])
6855 cave[x+1][y-1] = Yball_blank;
6856 next[x+1][y-1] = lev.ball_array[lev.ball_pos][2];
6861 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
6862 is_blank[cave[x-1][y]])
6864 cave[x-1][y] = Yball_blank;
6865 next[x-1][y] = lev.ball_array[lev.ball_pos][3];
6870 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
6871 is_blank[cave[x+1][y]])
6873 cave[x+1][y] = Yball_blank;
6874 next[x+1][y] = lev.ball_array[lev.ball_pos][4];
6879 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
6880 is_blank[cave[x-1][y+1]])
6882 cave[x-1][y+1] = Yball_blank;
6883 next[x-1][y+1] = lev.ball_array[lev.ball_pos][5];
6888 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
6889 is_blank[cave[x][y+1]])
6891 cave[x][y+1] = Yball_blank;
6892 next[x][y+1] = lev.ball_array[lev.ball_pos][6];
6897 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
6898 is_blank[cave[x+1][y+1]])
6900 cave[x+1][y+1] = Yball_blank;
6901 next[x+1][y+1] = lev.ball_array[lev.ball_pos][7];
6908 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
6909 is_blank[cave[x-1][y-1]])
6911 cave[x-1][y-1] = Yball_blank;
6912 next[x-1][y-1] = lev.ball_array[lev.ball_pos][0];
6915 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
6916 is_blank[cave[x][y-1]])
6918 cave[x][y-1] = Yball_blank;
6919 next[x][y-1] = lev.ball_array[lev.ball_pos][1];
6922 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
6923 is_blank[cave[x+1][y-1]])
6925 cave[x+1][y-1] = Yball_blank;
6926 next[x+1][y-1] = lev.ball_array[lev.ball_pos][2];
6929 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
6930 is_blank[cave[x-1][y]])
6932 cave[x-1][y] = Yball_blank;
6933 next[x-1][y] = lev.ball_array[lev.ball_pos][3];
6936 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
6937 is_blank[cave[x+1][y]])
6939 cave[x+1][y] = Yball_blank;
6940 next[x+1][y] = lev.ball_array[lev.ball_pos][4];
6943 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
6944 is_blank[cave[x-1][y+1]])
6946 cave[x-1][y+1] = Yball_blank;
6947 next[x-1][y+1] = lev.ball_array[lev.ball_pos][5];
6950 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
6951 is_blank[cave[x][y+1]])
6953 cave[x][y+1] = Yball_blank;
6954 next[x][y+1] = lev.ball_array[lev.ball_pos][6];
6957 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
6958 is_blank[cave[x+1][y+1]])
6960 cave[x+1][y+1] = Yball_blank;
6961 next[x+1][y+1] = lev.ball_array[lev.ball_pos][7];
6965 lev.ball_pos = (lev.ball_pos + 1) % lev.num_ball_arrays;
6968 static void Lball_1(int x, int y)
6970 if (!lev.ball_active)
6973 cave[x][y] = Yball_1;
6974 next[x][y] = Xball_2;
6981 static void Lball_2(int x, int y)
6983 if (!lev.ball_active)
6986 cave[x][y] = Yball_2;
6987 next[x][y] = Xball_1;
6994 static void Ldrip(int x, int y)
6996 next[x][y] = Xdrip_fall;
6999 static void Ldrip_fall(int x, int y)
7003 switch (cave[x][y+1])
7017 case Xfake_acid_1_player:
7018 case Xfake_acid_2_player:
7019 case Xfake_acid_3_player:
7020 case Xfake_acid_4_player:
7021 case Xfake_acid_5_player:
7022 case Xfake_acid_6_player:
7023 case Xfake_acid_7_player:
7024 case Xfake_acid_8_player:
7027 cave[x][y] = Ydrip_1_sB;
7028 next[x][y] = Xdrip_stretchB;
7029 cave[x][y+1] = Ydrip_1_s;
7030 next[x][y+1] = Xdrip_stretch;
7041 cave[x][y] = Ydrip_1_sB;
7042 next[x][y] = Xdrip_stretchB;
7043 if (cave[x+1][y] == Xblank)
7044 cave[x+1][y] = Xsplash_e;
7045 if (cave[x-1][y] == Xblank)
7046 cave[x-1][y] = Xsplash_w;
7047 play_element_sound(x, y, SOUND_acid, Xacid_1);
7053 case 0: temp = Xamoeba_1; break;
7054 case 1: temp = Xamoeba_2; break;
7055 case 2: temp = Xamoeba_3; break;
7056 case 3: temp = Xamoeba_4; break;
7057 case 4: temp = Xamoeba_5; break;
7058 case 5: temp = Xamoeba_6; break;
7059 case 6: temp = Xamoeba_7; break;
7060 case 7: temp = Xamoeba_8; break;
7065 play_element_sound(x, y, SOUND_drip, Xdrip_fall);
7070 static void Ldrip_stretch(int x, int y)
7072 cave[x][y] = Ydrip_2_s;
7073 next[x][y] = Xdrip_fall;
7076 static void Ldrip_stretchB(int x, int y)
7078 cave[x][y] = Ydrip_2_sB;
7079 next[x][y] = Xblank;
7082 static void Lwonderwall(int x, int y)
7084 if (lev.wonderwall_time > 0 && lev.wonderwall_active)
7086 cave[x][y] = Ywonderwall;
7087 play_element_sound(x, y, SOUND_wonder, Xwonderwall);
7091 static void Lwheel(int x, int y)
7093 if (lev.wheel_cnt && x == lev.wheel_x && y == lev.wheel_y)
7094 cave[x][y] = Ywheel;
7097 static void Lswitch(int x, int y)
7099 if (lev.ball_active)
7100 cave[x][y] = Yswitch;
7103 static void Lfake_blank(int x, int y)
7106 cave[x][y] = Yfake_blank;
7109 static void Lfake_grass(int x, int y)
7111 if (lev.magnify_cnt)
7112 cave[x][y] = Yfake_grass;
7115 static void Lfake_amoeba(int x, int y)
7118 cave[x][y] = Yfake_amoeba;
7121 static void Lsand_stone(int x, int y)
7123 switch (cave[x][y+1])
7136 cave[x][y] = Xsand_stonesand_quickout_1;
7137 next[x][y] = Xsand_stonesand_quickout_2;
7138 cave[x][y+1] = Xsand_stoneout_1;
7139 next[x][y+1] = Xsand_stoneout_2;
7150 cave[x][y] = Xsand_stonesand_quickout_1;
7151 next[x][y] = Xsand_stonesand_quickout_2;
7152 if (cave[x+1][y] == Xblank)
7153 cave[x+1][y] = Xsplash_e;
7154 if (cave[x-1][y] == Xblank)
7155 cave[x-1][y] = Xsplash_w;
7156 play_element_sound(x, y, SOUND_acid, Xacid_1);
7160 cave[x][y] = Xsand_stonesand_1;
7161 next[x][y] = Xsand_stonesand_2;
7162 cave[x][y+1] = Xsand_sandstone_1;
7163 next[x][y+1] = Xsand_sandstone_2;
7168 static void Lsand_stonein_1(int x, int y)
7170 next[x][y] = Xsand_stonein_2;
7173 static void Lsand_stonein_2(int x, int y)
7175 next[x][y] = Xsand_stonein_3;
7178 static void Lsand_stonein_3(int x, int y)
7180 next[x][y] = Xsand_stonein_4;
7183 static void Lsand_stonein_4(int x, int y)
7185 next[x][y] = Xblank;
7188 static void Lsand_sandstone_1(int x, int y)
7190 next[x][y] = Xsand_sandstone_2;
7193 static void Lsand_sandstone_2(int x, int y)
7195 next[x][y] = Xsand_sandstone_3;
7198 static void Lsand_sandstone_3(int x, int y)
7200 next[x][y] = Xsand_sandstone_4;
7203 static void Lsand_sandstone_4(int x, int y)
7205 next[x][y] = Xsand_stone;
7208 static void Lsand_stonesand_1(int x, int y)
7210 next[x][y] = Xsand_stonesand_2;
7213 static void Lsand_stonesand_2(int x, int y)
7215 next[x][y] = Xsand_stonesand_3;
7218 static void Lsand_stonesand_3(int x, int y)
7220 next[x][y] = Xsand_stonesand_4;
7223 static void Lsand_stonesand_4(int x, int y)
7228 static void Lsand_stoneout_1(int x, int y)
7230 next[x][y] = Xsand_stoneout_2;
7233 static void Lsand_stoneout_2(int x, int y)
7235 next[x][y] = Xstone_fall;
7238 static void Lsand_stonesand_quickout_1(int x, int y)
7240 next[x][y] = Xsand_stonesand_quickout_2;
7243 static void Lsand_stonesand_quickout_2(int x, int y)
7248 static void Lslide_ns(int x, int y)
7250 if (is_blank[cave[x][y-1]])
7252 cave[x][y-1] = Yslide_ns_blank;
7253 next[x][y-1] = Xslide_ns;
7254 play_element_sound(x, y, SOUND_slide, Xslide_ns);
7257 if (is_blank[cave[x][y+1]])
7259 cave[x][y+1] = Yslide_ns_blank;
7260 next[x][y+1] = Xslide_ns;
7261 play_element_sound(x, y, SOUND_slide, Xslide_ns);
7265 static void Lslide_ew(int x, int y)
7267 if (is_blank[cave[x+1][y]])
7269 cave[x+1][y] = Yslide_ew_blank;
7270 next[x+1][y] = Xslide_ew;
7271 play_element_sound(x, y, SOUND_slide, Xslide_ew);
7274 if (is_blank[cave[x-1][y]])
7276 cave[x-1][y] = Yslide_ew_blank;
7277 next[x-1][y] = Xslide_ew;
7278 play_element_sound(x, y, SOUND_slide, Xslide_ew);
7282 static void Lexit(int x, int y)
7284 if (lev.gems_needed > 0)
7287 switch (RANDOM(64) / 21)
7290 cave[x][y] = Xexit_1;
7291 next[x][y] = Xexit_2;
7295 cave[x][y] = Xexit_2;
7296 next[x][y] = Xexit_3;
7300 cave[x][y] = Xexit_3;
7301 next[x][y] = Xexit_1;
7305 play_element_sound(x, y, SOUND_exit_open, Xexit);
7308 static void Lexit_1(int x, int y)
7310 next[x][y] = Xexit_2;
7313 static void Lexit_2(int x, int y)
7315 next[x][y] = Xexit_3;
7318 static void Lexit_3(int x, int y)
7320 next[x][y] = Xexit_1;
7323 static void Lpause(int x, int y)
7325 next[x][y] = Xblank;
7328 static void Lamoeba(int x, int y)
7348 if (is_amoeba[cave[x][y-1]] ||
7349 is_amoeba[cave[x+1][y]] ||
7350 is_amoeba[cave[x][y+1]] ||
7351 is_amoeba[cave[x-1][y]])
7356 static void Lboom_one(int x, int y, boolean by_dynamite)
7417 cave[x][y] = Xboom_android;
7428 cave[x][y] = Xboom_bug;
7429 Lboom_bug_new(x, y, TRUE);
7435 cave[x][y] = Xboom_tank;
7436 Lboom_tank_new(x, y, TRUE);
7440 cave[x][y] = Xboom_1;
7445 static void Lboom_nine(int x, int y, boolean by_dynamite)
7447 Lboom_one(x, y-1, by_dynamite);
7448 Lboom_one(x-1, y, by_dynamite);
7449 Lboom_one(x+1, y, by_dynamite);
7450 Lboom_one(x, y+1, by_dynamite);
7451 Lboom_one(x-1, y-1, by_dynamite);
7452 Lboom_one(x+1, y-1, by_dynamite);
7453 Lboom_one(x-1, y+1, by_dynamite);
7454 Lboom_one(x+1, y+1, by_dynamite);
7456 cave[x][y] = Xboom_1;
7459 static void Lexplode(int x, int y)
7464 Lboom_bug_new(x, y, FALSE);
7465 Lboom_nine(x, y, FALSE);
7469 Lboom_tank_new(x, y, FALSE);
7470 Lboom_nine(x, y, FALSE);
7474 Lboom_eater_new(x, y, FALSE);
7475 Lboom_nine(x, y, FALSE);
7479 Lboom_nine(x, y, TRUE);
7483 Lboom_nine(x, y, FALSE);
7488 static void Lboom_1(int x, int y)
7490 next[x][y] = Xboom_2;
7491 #if !PLAY_ELEMENT_SOUND
7492 if (x != lev.exit_x && y != lev.exit_y)
7493 play_sound(x, y, SOUND_boom);
7495 lev.exit_x = lev.exit_y = -1;
7499 static void Lboom_2(int x, int y)
7501 next[x][y] = boom[x][y];
7504 static void Lboom_android(int x, int y)
7506 #if PLAY_ELEMENT_SOUND
7507 play_element_sound(x, y, SOUND_boom, Xandroid);
7513 static void Lchain(int x, int y)
7518 static void handle_tile(int x, int y)
7522 case Xacid_1: Lacid_1(x, y); break;
7523 case Xacid_2: Lacid_2(x, y); break;
7524 case Xacid_3: Lacid_3(x, y); break;
7525 case Xacid_4: Lacid_4(x, y); break;
7526 case Xacid_5: Lacid_5(x, y); break;
7527 case Xacid_6: Lacid_6(x, y); break;
7528 case Xacid_7: Lacid_7(x, y); break;
7529 case Xacid_8: Lacid_8(x, y); break;
7531 case Xfake_acid_1: Lfake_acid_1(x, y); break;
7532 case Xfake_acid_2: Lfake_acid_2(x, y); break;
7533 case Xfake_acid_3: Lfake_acid_3(x, y); break;
7534 case Xfake_acid_4: Lfake_acid_4(x, y); break;
7535 case Xfake_acid_5: Lfake_acid_5(x, y); break;
7536 case Xfake_acid_6: Lfake_acid_6(x, y); break;
7537 case Xfake_acid_7: Lfake_acid_7(x, y); break;
7538 case Xfake_acid_8: Lfake_acid_8(x, y); break;
7540 case Xandroid: Landroid(x, y); break;
7541 case Xandroid_1_n: Landroid_1_n(x, y); break;
7542 case Xandroid_2_n: Landroid_2_n(x, y); break;
7543 case Xandroid_1_e: Landroid_1_e(x, y); break;
7544 case Xandroid_2_e: Landroid_2_e(x, y); break;
7545 case Xandroid_1_s: Landroid_1_s(x, y); break;
7546 case Xandroid_2_s: Landroid_2_s(x, y); break;
7547 case Xandroid_1_w: Landroid_1_w(x, y); break;
7548 case Xandroid_2_w: Landroid_2_w(x, y); break;
7550 case Xeater_n: Leater_n(x, y); break;
7551 case Xeater_e: Leater_e(x, y); break;
7552 case Xeater_s: Leater_s(x, y); break;
7553 case Xeater_w: Leater_w(x, y); break;
7555 case Xalien: Lalien(x, y); break;
7556 case Xalien_pause: Lalien_pause(x, y); break;
7558 case Xbug_1_n: Lbug_1_n(x, y); break;
7559 case Xbug_2_n: Lbug_2_n(x, y); break;
7560 case Xbug_1_e: Lbug_1_e(x, y); break;
7561 case Xbug_2_e: Lbug_2_e(x, y); break;
7562 case Xbug_1_s: Lbug_1_s(x, y); break;
7563 case Xbug_2_s: Lbug_2_s(x, y); break;
7564 case Xbug_1_w: Lbug_1_w(x, y); break;
7565 case Xbug_2_w: Lbug_2_w(x, y); break;
7567 case Xtank_1_n: Ltank_1_n(x, y); break;
7568 case Xtank_2_n: Ltank_2_n(x, y); break;
7569 case Xtank_1_e: Ltank_1_e(x, y); break;
7570 case Xtank_2_e: Ltank_2_e(x, y); break;
7571 case Xtank_1_s: Ltank_1_s(x, y); break;
7572 case Xtank_2_s: Ltank_2_s(x, y); break;
7573 case Xtank_1_w: Ltank_1_w(x, y); break;
7574 case Xtank_2_w: Ltank_2_w(x, y); break;
7576 case Xemerald: Lemerald(x, y); break;
7577 case Xemerald_pause: Lemerald_pause(x, y); break;
7578 case Xemerald_fall: Lemerald_fall(x, y); break;
7580 case Xdiamond: Ldiamond(x, y); break;
7581 case Xdiamond_pause: Ldiamond_pause(x, y); break;
7582 case Xdiamond_fall: Ldiamond_fall(x, y); break;
7584 case Xstone: Lstone(x, y); break;
7585 case Xstone_pause: Lstone_pause(x, y); break;
7586 case Xstone_fall: Lstone_fall(x, y); break;
7588 case Xbomb: Lbomb(x, y); break;
7589 case Xbomb_pause: Lbomb_pause(x, y); break;
7590 case Xbomb_fall: Lbomb_fall(x, y); break;
7592 case Xnut: Lnut(x, y); break;
7593 case Xnut_pause: Lnut_pause(x, y); break;
7594 case Xnut_fall: Lnut_fall(x, y); break;
7596 case Xspring: Lspring(x, y); break;
7597 case Xspring_pause: Lspring_pause(x, y); break;
7598 case Xspring_e: Lspring_e(x, y); break;
7599 case Xspring_w: Lspring_w(x, y); break;
7600 case Xspring_fall: Lspring_fall(x, y); break;
7602 case Xpush_emerald_e: Lpush_emerald_e(x, y); break;
7603 case Xpush_emerald_w: Lpush_emerald_w(x, y); break;
7604 case Xpush_diamond_e: Lpush_diamond_e(x, y); break;
7605 case Xpush_diamond_w: Lpush_diamond_w(x, y); break;
7606 case Xpush_stone_e: Lpush_stone_e(x, y); break;
7607 case Xpush_stone_w: Lpush_stone_w(x, y); break;
7608 case Xpush_bomb_e: Lpush_bomb_e(x, y); break;
7609 case Xpush_bomb_w: Lpush_bomb_w(x, y); break;
7610 case Xpush_nut_e: Lpush_nut_e(x, y); break;
7611 case Xpush_nut_w: Lpush_nut_w(x, y); break;
7612 case Xpush_spring_e: Lpush_spring_e(x, y); break;
7613 case Xpush_spring_w: Lpush_spring_w(x, y); break;
7615 case Xdynamite_1: Ldynamite_1(x, y); break;
7616 case Xdynamite_2: Ldynamite_2(x, y); break;
7617 case Xdynamite_3: Ldynamite_3(x, y); break;
7618 case Xdynamite_4: Ldynamite_4(x, y); break;
7620 case Xfake_door_1: Lfake_door_1(x, y); break;
7621 case Xfake_door_2: Lfake_door_2(x, y); break;
7622 case Xfake_door_3: Lfake_door_3(x, y); break;
7623 case Xfake_door_4: Lfake_door_4(x, y); break;
7624 case Xfake_door_5: Lfake_door_5(x, y); break;
7625 case Xfake_door_6: Lfake_door_6(x, y); break;
7626 case Xfake_door_7: Lfake_door_7(x, y); break;
7627 case Xfake_door_8: Lfake_door_8(x, y); break;
7629 case Xballoon: Lballoon(x, y); break;
7631 case Xball_1: Lball_1(x, y); break;
7632 case Xball_2: Lball_2(x, y); break;
7634 case Xdrip: Ldrip(x, y); break;
7635 case Xdrip_fall: Ldrip_fall(x, y); break;
7636 case Xdrip_stretch: Ldrip_stretch(x, y); break;
7637 case Xdrip_stretchB: Ldrip_stretchB(x, y); break;
7639 case Xwonderwall: Lwonderwall(x, y); break;
7641 case Xwheel: Lwheel(x, y); break;
7643 case Xswitch: Lswitch(x, y); break;
7645 case Xfake_blank: Lfake_blank(x, y); break;
7646 case Xfake_grass: Lfake_grass(x, y); break;
7647 case Xfake_amoeba: Lfake_amoeba(x, y); break;
7649 case Xsand_stone: Lsand_stone(x, y); break;
7650 case Xsand_stonein_1: Lsand_stonein_1(x, y); break;
7651 case Xsand_stonein_2: Lsand_stonein_2(x, y); break;
7652 case Xsand_stonein_3: Lsand_stonein_3(x, y); break;
7653 case Xsand_stonein_4: Lsand_stonein_4(x, y); break;
7654 case Xsand_sandstone_1: Lsand_sandstone_1(x, y); break;
7655 case Xsand_sandstone_2: Lsand_sandstone_2(x, y); break;
7656 case Xsand_sandstone_3: Lsand_sandstone_3(x, y); break;
7657 case Xsand_sandstone_4: Lsand_sandstone_4(x, y); break;
7658 case Xsand_stonesand_1: Lsand_stonesand_1(x, y); break;
7659 case Xsand_stonesand_2: Lsand_stonesand_2(x, y); break;
7660 case Xsand_stonesand_3: Lsand_stonesand_3(x, y); break;
7661 case Xsand_stonesand_4: Lsand_stonesand_4(x, y); break;
7662 case Xsand_stoneout_1: Lsand_stoneout_1(x, y); break;
7663 case Xsand_stoneout_2: Lsand_stoneout_2(x, y); break;
7664 case Xsand_stonesand_quickout_1: Lsand_stonesand_quickout_1(x, y); break;
7665 case Xsand_stonesand_quickout_2: Lsand_stonesand_quickout_2(x, y); break;
7667 case Xslide_ns: Lslide_ns(x, y); break;
7668 case Xslide_ew: Lslide_ew(x, y); break;
7670 case Xexit: Lexit(x, y); break;
7671 case Xexit_1: Lexit_1(x, y); break;
7672 case Xexit_2: Lexit_2(x, y); break;
7673 case Xexit_3: Lexit_3(x, y); break;
7675 case Xpause: Lpause(x, y); break;
7677 case Xchain: Lchain(x, y); break;
7678 case Xboom_bug: Lboom_bug(x, y); break;
7679 case Xboom_tank: Lboom_tank(x, y); break;
7680 case Xboom_android: Lboom_android(x, y); break;
7681 case Xboom_1: Lboom_1(x, y); break;
7682 case Xboom_2: Lboom_2(x, y); break;
7686 boolean logic_check_wrap(void)
7690 for (i = 0; i < MAX_PLAYERS; i++)
7695 /* check for wrap-around movement */
7696 if (ply[i].x < lev.left ||
7697 ply[i].x > lev.right - 1)
7704 void logic_move(void)
7708 for (i = 0; i < MAX_PLAYERS; i++)
7713 /* check for wrap-around movement */
7714 if (ply[i].x < lev.left ||
7715 ply[i].x > lev.right - 1)
7717 int direction = (ply[i].x < lev.left ? -1 : 1);
7719 ply[i].x += -direction * lev.width;
7721 if (!lev.infinite_true)
7722 ply[i].y += direction;
7724 game.centered_player_nr_next = i;
7725 game.set_centered_player = TRUE;
7726 game.set_centered_player_wrap = TRUE;
7729 ply[i].prev_x = ply[i].x;
7730 ply[i].prev_y = ply[i].y;
7731 ply[i].anim = PLY_still;
7735 static void logic_players(void)
7744 game_em.any_player_moving = FALSE;
7745 game_em.any_player_snapping = FALSE;
7747 /* must test for death and actually kill separately */
7748 for (i = 0; i < MAX_PLAYERS; i++)
7750 boolean ply_kill = player_killed(&ply[i]);
7752 if (ply[i].alive && ply_kill)
7753 kill_player(&ply[i]);
7758 start_check_nr = ((game_em.random & 128 ? 0 : 1) * 2 +
7759 (game_em.random & 256 ? 0 : 1));
7761 for (i = 0; i < MAX_PLAYERS; i++)
7763 int check_nr = (start_check_nr + i) % MAX_PLAYERS;
7765 if (ply[check_nr].alive)
7766 check_player(&ply[check_nr]);
7769 for (i = 0; i < MAX_PLAYERS; i++)
7774 if (is_player[cave[ply[i].prev_x][ply[i].prev_y]])
7776 int element = cave[ply[i].prev_x][ply[i].prev_y];
7778 cave[ply[i].prev_x][ply[i].prev_y] = remove_player[element];
7779 next[ply[i].prev_x][ply[i].prev_y] = remove_player[element];
7782 if (is_blank[cave[ply[i].x][ply[i].y]])
7784 int element = cave[ply[i].x][ply[i].y];
7786 cave[ply[i].x][ply[i].y] = add_player[element];
7787 next[ply[i].x][ply[i].y] = add_player[element];
7791 /* check for wheel at wrap-around position */
7792 if (lev.wheel_x < lev.left ||
7793 lev.wheel_x > lev.right - 1)
7795 int direction = (lev.wheel_x < lev.left ? -1 : 1);
7797 lev.wheel_x += -direction * lev.width;
7799 if (!lev.infinite_true)
7800 lev.wheel_y += direction;
7804 static void logic_objects(void)
7812 seed = game_em.random;
7815 for (y = lev.top; y < lev.bottom; y++)
7816 for (x = lev.left; x < lev.right; x++)
7819 if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
7820 lev.score += score; /* only add a score if someone is alive */
7822 game_em.game_over = TRUE;
7824 game_em.random = seed;
7826 /* triple buffering */
7827 void *temp = lev.cave;
7828 lev.cave = lev.next;
7829 lev.next = lev.draw;
7833 static void logic_globals(void)
7848 /* update variables */
7850 if (lev.score > 9999)
7853 if (lev.android_move_cnt-- == 0)
7854 lev.android_move_cnt = lev.android_move_time;
7855 if (lev.android_clone_cnt-- == 0)
7856 lev.android_clone_cnt = lev.android_clone_time;
7857 if (lev.ball_active)
7858 if (lev.ball_cnt-- == 0)
7859 lev.ball_cnt = lev.ball_time;
7862 if (lev.magnify_cnt)
7868 if (lev.wonderwall_time > 0 && lev.wonderwall_active)
7869 lev.wonderwall_time--;
7872 play_element_sound(lev.wheel_x, lev.wheel_y, SOUND_wheel, Xwheel);
7876 random = game_em.random;
7878 for (count = lev.amoeba_time; count--;)
7880 x = lev.left - 1 + (random >> 10) % (CAVE_WIDTH + 2);
7881 y = lev.top - 1 + (random >> 20) % (CAVE_HEIGHT + 2);
7883 if (x >= lev.left && x < lev.right &&
7884 y >= lev.top && y < lev.bottom)
7887 random = random * 129 + 1;
7890 if (!game_em.use_random_bug)
7891 random = (uint32_t)random;
7895 game_em.random = random;
7897 /* handle explosions */
7899 for (y = lev.top; y < lev.bottom; y++)
7900 for (x = lev.left; x < lev.right; x++)
7903 /* triple buffering */
7905 for (y = lev.top; y < lev.bottom; y++)
7906 for (x = lev.left; x < lev.right; x++)
7907 next[x][y] = cave[x][y];
7910 void logic_init(void)
7912 int splash_is_blank = !game_em.use_old_android;
7914 is_android_blank[Xsplash_e] = splash_is_blank;
7915 is_android_blank[Xsplash_w] = splash_is_blank;