1 /* second part of synchro.
3 * game logic for monsters.
5 * one giant switch statement to process everything.
7 * this whole thing is a major bottleneck. the compiler must use registers.
14 #define SPRING_ROLL /* spring rolling off round things continues to roll */
16 #define RANDOM (random_em = random_em << 31 | random_em >> 1)
18 static unsigned int random_em;
21 static void set_nearest_player_xy(int x, int y, int *dx, int *dy)
23 int distance, distance_shortest = EM_MAX_CAVE_WIDTH + EM_MAX_CAVE_HEIGHT;
26 /* default values if no players are alive anymore */
30 for (i = 0; i < MAX_PLAYERS; i++)
35 distance = ABS(ply[i].x - x) + ABS(ply[i].y - y);
37 if (distance < distance_shortest)
42 distance_shortest = distance;
47 static void Lpush_stone_e(int x, int y)
64 Cave[y][x] = Ystone_eB;
65 Cave[y][x+1] = Ystone_e;
67 Next[y][x+1] = Xstone_pause;
72 static void Lpush_stone_w(int x, int y)
89 Cave[y][x] = Ystone_wB;
90 Cave[y][x-1] = Ystone_w;
92 Next[y][x-1] = Xstone_pause;
97 static void Lpush_nut_e(int x, int y)
114 Cave[y][x] = Ynut_eB;
115 Cave[y][x+1] = Ynut_e;
117 Next[y][x+1] = Xnut_pause;
122 static void Lpush_nut_w(int x, int y)
124 switch (Cave[y][x-1])
139 Cave[y][x] = Ynut_wB;
140 Cave[y][x-1] = Ynut_w;
142 Next[y][x-1] = Xnut_pause;
147 static void Lpush_spring_e(int x, int y)
149 switch (Cave[y][x+1])
159 Cave[y][x] = Xspring;
160 Next[y][x] = Xspring;
164 Cave[y][x] = Yspring_eB;
165 Cave[y][x+1] = Yspring_e;
167 Next[y][x+1] = Xspring_e;
172 static void Lpush_spring_w(int x, int y)
174 switch (Cave[y][x-1])
184 Cave[y][x] = Xspring;
185 Next[y][x] = Xspring;
189 Cave[y][x] = Yspring_wB;
190 Cave[y][x-1] = Yspring_w;
192 Next[y][x-1] = Xspring_w;
197 static void Lpush_emerald_e(int x, int y)
199 switch (Cave[y][x+1])
209 Cave[y][x] = Xemerald;
210 Next[y][x] = Xemerald;
214 Cave[y][x] = Yemerald_eB;
215 Cave[y][x+1] = Yemerald_e;
217 Next[y][x+1] = Xemerald_pause;
222 static void Lpush_emerald_w(int x, int y)
224 switch (Cave[y][x-1])
234 Cave[y][x] = Xemerald;
235 Next[y][x] = Xemerald;
239 Cave[y][x] = Yemerald_wB;
240 Cave[y][x-1] = Yemerald_w;
242 Next[y][x-1] = Xemerald_pause;
247 static void Lpush_diamond_e(int x, int y)
249 switch (Cave[y][x+1])
259 Cave[y][x] = Xdiamond;
260 Next[y][x] = Xdiamond;
264 Cave[y][x] = Ydiamond_eB;
265 Cave[y][x+1] = Ydiamond_e;
267 Next[y][x+1] = Xdiamond_pause;
272 static void Lpush_diamond_w(int x, int y)
274 switch (Cave[y][x-1])
284 Cave[y][x] = Xdiamond;
285 Next[y][x] = Xdiamond;
289 Cave[y][x] = Ydiamond_wB;
290 Cave[y][x-1] = Ydiamond_w;
292 Next[y][x-1] = Xdiamond_pause;
297 static void Lpush_bomb_e(int x, int y)
299 switch (Cave[y][x+1])
314 Cave[y][x] = Ybomb_eB;
315 Cave[y][x+1] = Ybomb_e;
317 Next[y][x+1] = Xbomb_pause;
322 static void Lpush_bomb_w(int x, int y)
324 switch (Cave[y][x-1])
339 Cave[y][x] = Ybomb_wB;
340 Cave[y][x-1] = Ybomb_w;
342 Next[y][x-1] = Xbomb_pause;
347 static void Lstone(int x, int y)
349 switch (Cave[y+1][x])
359 Cave[y][x] = Ystone_sB;
360 if (Cave[y][x+1] == Xblank)
361 Cave[y][x+1] = Xacid_splash_e;
362 if (Cave[y][x-1] == Xblank)
363 Cave[y][x-1] = Xacid_splash_w;
365 play_element_sound(x, y, SOUND_acid, Xacid_1);
383 Cave[y][x] = Ystone_sB;
384 Cave[y+1][x] = Ystone_s;
386 Next[y+1][x] = Xstone_fall;
390 Cave[y][x] = Xsand_stonein_1;
391 Cave[y+1][x] = Xsand_sandstone_1;
392 Next[y][x] = Xsand_stonein_2;
393 Next[y+1][x] = Xsand_sandstone_2;
444 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
446 Cave[y][x] = Ystone_eB;
447 Cave[y][x+1] = Ystone_e;
449 Next[y][x+1] = Xstone_pause;
453 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
455 Cave[y][x] = Ystone_wB;
456 Cave[y][x-1] = Ystone_w;
458 Next[y][x-1] = Xstone_pause;
464 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
466 Cave[y][x] = Ystone_wB;
467 Cave[y][x-1] = Ystone_w;
469 Next[y][x-1] = Xstone_pause;
473 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
475 Cave[y][x] = Ystone_eB;
476 Cave[y][x+1] = Ystone_e;
478 Next[y][x+1] = Xstone_pause;
485 static void Lstone_pause(int x, int y)
487 switch (Cave[y+1][x])
497 Cave[y][x] = Ystone_sB;
498 if (Cave[y][x+1] == Xblank)
499 Cave[y][x+1] = Xacid_splash_e;
500 if (Cave[y][x-1] == Xblank)
501 Cave[y][x-1] = Xacid_splash_w;
503 play_element_sound(x, y, SOUND_acid, Xacid_1);
519 Cave[y][x] = Ystone_sB;
520 Cave[y+1][x] = Ystone_s;
522 Next[y+1][x] = Xstone_fall;
532 static void Lstone_fall(int x, int y)
534 switch (Cave[y+1][x])
544 Cave[y][x] = Ystone_sB;
545 if (Cave[y][x+1] == Xblank)
546 Cave[y][x+1] = Xacid_splash_e;
547 if (Cave[y][x-1] == Xblank)
548 Cave[y][x-1] = Xacid_splash_w;
550 play_element_sound(x, y, SOUND_acid, Xacid_1);
567 Cave[y][x] = Ystone_sB;
568 Cave[y+1][x] = Ystone_s;
570 Next[y+1][x] = Xstone_fall;
575 Cave[y+1][x] = Ynut_stone;
577 Next[y+1][x] = Xemerald;
578 play_element_sound(x, y, SOUND_crack, Xnut);
579 score += lev.nut_score;
590 Cave[y][x] = Ystone_sB;
591 Cave[y+1][x] = Ybug_stone;
592 Next[y+1][x] = Znormal;
593 Boom[y][x-1] = Xemerald;
594 Boom[y][x] = Xemerald;
595 Boom[y][x+1] = Xemerald;
596 Boom[y+1][x-1] = Xemerald;
597 Boom[y+1][x] = Xdiamond;
598 Boom[y+1][x+1] = Xemerald;
599 Boom[y+2][x-1] = Xemerald;
600 Boom[y+2][x] = Xemerald;
601 Boom[y+2][x+1] = Xemerald;
602 #if PLAY_ELEMENT_SOUND
603 play_element_sound(x, y, SOUND_boom, Xstone_fall);
605 score += lev.bug_score;
616 Cave[y][x] = Ystone_sB;
617 Cave[y+1][x] = Ytank_stone;
618 Next[y+1][x] = Znormal;
619 Boom[y][x-1] = Xblank;
621 Boom[y][x+1] = Xblank;
622 Boom[y+1][x-1] = Xblank;
623 Boom[y+1][x] = Xblank;
624 Boom[y+1][x+1] = Xblank;
625 Boom[y+2][x-1] = Xblank;
626 Boom[y+2][x] = Xblank;
627 Boom[y+2][x+1] = Xblank;
628 #if PLAY_ELEMENT_SOUND
629 play_element_sound(x, y, SOUND_boom, Xstone_fall);
631 score += lev.tank_score;
637 switch (Cave[y+1][x+1])
644 Cave[y+1][x] = Xspring_e;
648 Cave[y+1][x] = Xspring_w;
654 switch (Cave[y+1][x-1])
661 Cave[y+1][x] = Xspring_w;
664 Cave[y+1][x] = Xspring_e;
676 Cave[y][x] = Ystone_sB;
677 Cave[y+1][x] = Yeater_stone;
678 Next[y+1][x] = Znormal;
679 Boom[y][x-1] = lev.eater_array[lev.eater_pos][0];
680 Boom[y][x] = lev.eater_array[lev.eater_pos][1];
681 Boom[y][x+1] = lev.eater_array[lev.eater_pos][2];
682 Boom[y+1][x-1] = lev.eater_array[lev.eater_pos][3];
683 Boom[y+1][x] = lev.eater_array[lev.eater_pos][4];
684 Boom[y+1][x+1] = lev.eater_array[lev.eater_pos][5];
685 Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
686 Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
687 Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
688 #if PLAY_ELEMENT_SOUND
689 play_element_sound(x, y, SOUND_boom, Xstone_fall);
691 lev.eater_pos = (lev.eater_pos + 1) & 7;
692 score += lev.eater_score;
697 Cave[y][x] = Ystone_sB;
698 Cave[y+1][x] = Yalien_stone;
699 Next[y+1][x] = Znormal;
700 Boom[y][x-1] = Xblank;
702 Boom[y][x+1] = Xblank;
703 Boom[y+1][x-1] = Xblank;
704 Boom[y+1][x] = Xblank;
705 Boom[y+1][x+1] = Xblank;
706 Boom[y+2][x-1] = Xblank;
707 Boom[y+2][x] = Xblank;
708 Boom[y+2][x+1] = Xblank;
709 #if PLAY_ELEMENT_SOUND
710 play_element_sound(x, y, SOUND_boom, Xstone_fall);
712 score += lev.alien_score;
717 switch (Cave[y+2][x])
766 play_element_sound(x, y, SOUND_stone, Xstone);
770 Cave[y][x] = Ystone_sB;
771 Cave[y+1][x] = Ydiamond_stone;
773 Next[y+1][x] = Xstone_pause;
774 play_element_sound(x, y, SOUND_squash, Xdiamond);
779 Cave[y+1][x] = Ybomb_blank;
780 Next[y+1][x] = Znormal;
781 Boom[y][x-1] = Xblank;
783 Boom[y][x+1] = Xblank;
784 Boom[y+1][x-1] = Xblank;
785 Boom[y+1][x] = Xblank;
786 Boom[y+1][x+1] = Xblank;
787 Boom[y+2][x-1] = Xblank;
788 Boom[y+2][x] = Xblank;
789 Boom[y+2][x+1] = Xblank;
790 #if PLAY_ELEMENT_SOUND
791 play_element_sound(x, y, SOUND_boom, Xstone_fall);
796 if (lev.wonderwall_time)
798 lev.wonderwall_state = 1;
799 Cave[y][x] = Ystone_sB;
801 if (tab_blank[Cave[y+2][x]])
803 Cave[y+2][x] = Yemerald_s;
804 Next[y+2][x] = Xemerald_fall;
808 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
815 play_element_sound(x, y, SOUND_stone, Xstone);
820 static void Lnut(int x, int y)
822 switch (Cave[y+1][x])
832 Cave[y][x] = Ynut_sB;
833 if (Cave[y][x+1] == Xblank)
834 Cave[y][x+1] = Xacid_splash_e;
835 if (Cave[y][x-1] == Xblank)
836 Cave[y][x-1] = Xacid_splash_w;
838 play_element_sound(x, y, SOUND_acid, Xacid_1);
844 Cave[y][x] = Ynut_sB;
845 Cave[y+1][x] = Ynut_s;
847 Next[y+1][x] = Xnut_fall;
896 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
898 Cave[y][x] = Ynut_eB;
899 Cave[y][x+1] = Ynut_e;
901 Next[y][x+1] = Xnut_pause;
905 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
907 Cave[y][x] = Ynut_wB;
908 Cave[y][x-1] = Ynut_w;
910 Next[y][x-1] = Xnut_pause;
916 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
918 Cave[y][x] = Ynut_wB;
919 Cave[y][x-1] = Ynut_w;
921 Next[y][x-1] = Xnut_pause;
925 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
927 Cave[y][x] = Ynut_eB;
928 Cave[y][x+1] = Ynut_e;
930 Next[y][x+1] = Xnut_pause;
937 static void Lnut_pause(int x, int y)
939 switch (Cave[y+1][x])
949 Cave[y][x] = Ynut_sB;
950 if (Cave[y][x+1] == Xblank)
951 Cave[y][x+1] = Xacid_splash_e;
952 if (Cave[y][x-1] == Xblank)
953 Cave[y][x-1] = Xacid_splash_w;
955 play_element_sound(x, y, SOUND_acid, Xacid_1);
961 Cave[y][x] = Ynut_sB;
962 Cave[y+1][x] = Ynut_s;
964 Next[y+1][x] = Xnut_fall;
974 static void Lnut_fall(int x, int y)
976 switch (Cave[y+1][x])
986 Cave[y][x] = Ynut_sB;
987 if (Cave[y][x+1] == Xblank)
988 Cave[y][x+1] = Xacid_splash_e;
989 if (Cave[y][x-1] == Xblank)
990 Cave[y][x-1] = Xacid_splash_w;
992 play_element_sound(x, y, SOUND_acid, Xacid_1);
999 Cave[y][x] = Ynut_sB;
1000 Cave[y+1][x] = Ynut_s;
1001 Next[y][x] = Xblank;
1002 Next[y+1][x] = Xnut_fall;
1008 play_element_sound(x, y, SOUND_nut, Xnut);
1013 static void Lboom_bug(int x, int y)
1015 Next[y][x] = Znormal;
1016 Boom[y-1][x-1] = Xemerald;
1017 Boom[y-1][x] = Xemerald;
1018 Boom[y-1][x+1] = Xemerald;
1019 Boom[y][x-1] = Xemerald;
1020 Boom[y][x] = Xdiamond;
1021 Boom[y][x+1] = Xemerald;
1022 Boom[y+1][x-1] = Xemerald;
1023 Boom[y+1][x] = Xemerald;
1024 Boom[y+1][x+1] = Xemerald;
1026 #if PLAY_ELEMENT_SOUND
1027 play_element_sound(x, y, SOUND_boom, element);
1031 static void Lboom_tank(int x, int y)
1033 Next[y][x] = Znormal;
1034 Boom[y-1][x-1] = Xblank;
1035 Boom[y-1][x] = Xblank;
1036 Boom[y-1][x+1] = Xblank;
1037 Boom[y][x-1] = Xblank;
1038 Boom[y][x] = Xblank;
1039 Boom[y][x+1] = Xblank;
1040 Boom[y+1][x-1] = Xblank;
1041 Boom[y+1][x] = Xblank;
1042 Boom[y+1][x+1] = Xblank;
1043 #if PLAY_ELEMENT_SOUND
1044 play_element_sound(x, y, SOUND_boom, element);
1048 static void Lbug_n(int x, int y)
1050 switch (Cave[y-1][x])
1060 Cave[y][x] = Ybug_nB;
1061 if (Cave[y-2][x+1] == Xblank)
1062 Cave[y-2][x+1] = Xacid_splash_e;
1063 if (Cave[y-2][x-1] == Xblank)
1064 Cave[y-2][x-1] = Xacid_splash_w;
1065 Next[y][x] = Xblank;
1066 play_element_sound(x, y, SOUND_acid, Xacid_1);
1070 case Xacid_splash_e:
1071 case Xacid_splash_w:
1075 Cave[y][x] = Ybug_nB;
1076 Cave[y-1][x] = Ybug_n;
1077 Next[y][x] = Xblank;
1078 Next[y-1][x] = Xbug_1_n;
1079 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
1083 Cave[y][x] = Ybug_n_w;
1084 Next[y][x] = Xbug_2_w;
1085 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
1090 static void Lbug_1_n(int x, int y)
1092 if (tab_amoeba[Cave[y-1][x]] ||
1093 tab_amoeba[Cave[y][x+1]] ||
1094 tab_amoeba[Cave[y+1][x]] ||
1095 tab_amoeba[Cave[y][x-1]])
1102 switch (Cave[y][x+1])
1105 case Xacid_splash_e:
1106 case Xacid_splash_w:
1118 Cave[y][x] = Ybug_n_e;
1119 Next[y][x] = Xbug_2_e;
1120 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
1129 static void Lbug_2_n(int x, int y)
1131 if (tab_amoeba[Cave[y-1][x]] ||
1132 tab_amoeba[Cave[y][x+1]] ||
1133 tab_amoeba[Cave[y+1][x]] ||
1134 tab_amoeba[Cave[y][x-1]])
1144 static void Lbug_e(int x, int y)
1146 switch (Cave[y][x+1])
1156 Cave[y][x] = Ybug_eB;
1157 if (Cave[y-1][x+2] == Xblank)
1158 Cave[y-1][x+2] = Xacid_splash_e;
1159 if (Cave[y-1][x] == Xblank)
1160 Cave[y-1][x] = Xacid_splash_w;
1161 Next[y][x] = Xblank;
1162 play_element_sound(x, y, SOUND_acid, Xacid_1);
1166 case Xacid_splash_e:
1167 case Xacid_splash_w:
1171 Cave[y][x] = Ybug_eB;
1172 Cave[y][x+1] = Ybug_e;
1173 Next[y][x] = Xblank;
1174 Next[y][x+1] = Xbug_1_e;
1175 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
1179 Cave[y][x] = Ybug_e_n;
1180 Next[y][x] = Xbug_2_n;
1181 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
1186 static void Lbug_1_e(int x, int y)
1188 if (tab_amoeba[Cave[y-1][x]] ||
1189 tab_amoeba[Cave[y][x+1]] ||
1190 tab_amoeba[Cave[y+1][x]] ||
1191 tab_amoeba[Cave[y][x-1]])
1198 switch (Cave[y+1][x])
1201 case Xacid_splash_e:
1202 case Xacid_splash_w:
1214 Cave[y][x] = Ybug_e_s;
1215 Next[y][x] = Xbug_2_s;
1216 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
1225 static void Lbug_2_e(int x, int y)
1227 if (tab_amoeba[Cave[y-1][x]] ||
1228 tab_amoeba[Cave[y][x+1]] ||
1229 tab_amoeba[Cave[y+1][x]] ||
1230 tab_amoeba[Cave[y][x-1]])
1240 static void Lbug_s(int x, int y)
1242 switch (Cave[y+1][x])
1252 Cave[y][x] = Ybug_sB;
1253 if (Cave[y][x+1] == Xblank)
1254 Cave[y][x+1] = Xacid_splash_e;
1255 if (Cave[y][x-1] == Xblank)
1256 Cave[y][x-1] = Xacid_splash_w;
1257 Next[y][x] = Xblank;
1258 play_element_sound(x, y, SOUND_acid, Xacid_1);
1262 case Xacid_splash_e:
1263 case Xacid_splash_w:
1267 Cave[y][x] = Ybug_sB;
1268 Cave[y+1][x] = Ybug_s;
1269 Next[y][x] = Xblank;
1270 Next[y+1][x] = Xbug_1_s;
1271 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
1275 Cave[y][x] = Ybug_s_e;
1276 Next[y][x] = Xbug_2_e;
1277 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
1282 static void Lbug_1_s(int x, int y)
1284 if (tab_amoeba[Cave[y-1][x]] ||
1285 tab_amoeba[Cave[y][x+1]] ||
1286 tab_amoeba[Cave[y+1][x]] ||
1287 tab_amoeba[Cave[y][x-1]])
1294 switch (Cave[y][x-1])
1297 case Xacid_splash_e:
1298 case Xacid_splash_w:
1310 Cave[y][x] = Ybug_s_w;
1311 Next[y][x] = Xbug_2_w;
1312 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
1321 static void Lbug_2_s(int x, int y)
1323 if (tab_amoeba[Cave[y-1][x]] ||
1324 tab_amoeba[Cave[y][x+1]] ||
1325 tab_amoeba[Cave[y+1][x]] ||
1326 tab_amoeba[Cave[y][x-1]])
1336 static void Lbug_w(int x, int y)
1338 switch (Cave[y][x-1])
1348 Cave[y][x] = Ybug_wB;
1349 if (Cave[y-1][x] == Xblank)
1350 Cave[y-1][x] = Xacid_splash_e;
1351 if (Cave[y-1][x-2] == Xblank)
1352 Cave[y-1][x-2] = Xacid_splash_w;
1353 Next[y][x] = Xblank;
1354 play_element_sound(x, y, SOUND_acid, Xacid_1);
1358 case Xacid_splash_e:
1359 case Xacid_splash_w:
1363 Cave[y][x] = Ybug_wB;
1364 Cave[y][x-1] = Ybug_w;
1365 Next[y][x] = Xblank;
1366 Next[y][x-1] = Xbug_1_w;
1367 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
1371 Cave[y][x] = Ybug_w_s;
1372 Next[y][x] = Xbug_2_s;
1373 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
1378 static void Lbug_1_w(int x, int y)
1380 if (tab_amoeba[Cave[y-1][x]] ||
1381 tab_amoeba[Cave[y][x+1]] ||
1382 tab_amoeba[Cave[y+1][x]] ||
1383 tab_amoeba[Cave[y][x-1]])
1390 switch (Cave[y-1][x])
1393 case Xacid_splash_e:
1394 case Xacid_splash_w:
1406 Cave[y][x] = Ybug_w_n;
1407 Next[y][x] = Xbug_2_n;
1408 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
1417 static void Lbug_2_w(int x, int y)
1419 if (tab_amoeba[Cave[y-1][x]] ||
1420 tab_amoeba[Cave[y][x+1]] ||
1421 tab_amoeba[Cave[y+1][x]] ||
1422 tab_amoeba[Cave[y][x-1]])
1432 static void Ltank_n(int x, int y)
1434 switch (Cave[y-1][x])
1444 Cave[y][x] = Ytank_nB;
1445 if (Cave[y-2][x+1] == Xblank)
1446 Cave[y-2][x+1] = Xacid_splash_e;
1447 if (Cave[y-2][x-1] == Xblank)
1448 Cave[y-2][x-1] = Xacid_splash_w;
1449 Next[y][x] = Xblank;
1450 play_element_sound(x, y, SOUND_acid, Xacid_1);
1454 case Xacid_splash_e:
1455 case Xacid_splash_w:
1459 Cave[y][x] = Ytank_nB;
1460 Cave[y-1][x] = Ytank_n;
1461 Next[y][x] = Xblank;
1462 Next[y-1][x] = Xtank_1_n;
1463 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
1467 Cave[y][x] = Ytank_n_e;
1468 Next[y][x] = Xtank_2_e;
1469 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
1474 static void Ltank_1_n(int x, int y)
1476 if (tab_amoeba[Cave[y-1][x]] ||
1477 tab_amoeba[Cave[y][x+1]] ||
1478 tab_amoeba[Cave[y+1][x]] ||
1479 tab_amoeba[Cave[y][x-1]])
1486 switch (Cave[y][x-1])
1489 case Xacid_splash_e:
1490 case Xacid_splash_w:
1502 Cave[y][x] = Ytank_n_w;
1503 Next[y][x] = Xtank_2_w;
1504 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
1513 static void Ltank_2_n(int x, int y)
1515 if (tab_amoeba[Cave[y-1][x]] ||
1516 tab_amoeba[Cave[y][x+1]] ||
1517 tab_amoeba[Cave[y+1][x]] ||
1518 tab_amoeba[Cave[y][x-1]])
1528 static void Ltank_e(int x, int y)
1530 switch (Cave[y][x+1])
1540 Cave[y][x] = Ytank_eB;
1541 if (Cave[y-1][x+2] == Xblank)
1542 Cave[y-1][x+2] = Xacid_splash_e;
1543 if (Cave[y-1][x] == Xblank)
1544 Cave[y-1][x] = Xacid_splash_w;
1545 Next[y][x] = Xblank;
1546 play_element_sound(x, y, SOUND_acid, Xacid_1);
1550 case Xacid_splash_e:
1551 case Xacid_splash_w:
1555 Cave[y][x] = Ytank_eB;
1556 Cave[y][x+1] = Ytank_e;
1557 Next[y][x] = Xblank;
1558 Next[y][x+1] = Xtank_1_e;
1559 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
1563 Cave[y][x] = Ytank_e_s;
1564 Next[y][x] = Xtank_2_s;
1565 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
1570 static void Ltank_1_e(int x, int y)
1572 if (tab_amoeba[Cave[y-1][x]] ||
1573 tab_amoeba[Cave[y][x+1]] ||
1574 tab_amoeba[Cave[y+1][x]] ||
1575 tab_amoeba[Cave[y][x-1]])
1582 switch (Cave[y-1][x])
1585 case Xacid_splash_e:
1586 case Xacid_splash_w:
1598 Cave[y][x] = Ytank_e_n;
1599 Next[y][x] = Xtank_2_n;
1600 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
1609 static void Ltank_2_e(int x, int y)
1611 if (tab_amoeba[Cave[y-1][x]] ||
1612 tab_amoeba[Cave[y][x+1]] ||
1613 tab_amoeba[Cave[y+1][x]] ||
1614 tab_amoeba[Cave[y][x-1]])
1624 static void Ltank_s(int x, int y)
1626 switch (Cave[y+1][x])
1636 Cave[y][x] = Ytank_sB;
1637 if (Cave[y][x+1] == Xblank)
1638 Cave[y][x+1] = Xacid_splash_e;
1639 if (Cave[y][x-1] == Xblank)
1640 Cave[y][x-1] = Xacid_splash_w;
1641 Next[y][x] = Xblank;
1642 play_element_sound(x, y, SOUND_acid, Xacid_1);
1646 case Xacid_splash_e:
1647 case Xacid_splash_w:
1651 Cave[y][x] = Ytank_sB;
1652 Cave[y+1][x] = Ytank_s;
1653 Next[y][x] = Xblank;
1654 Next[y+1][x] = Xtank_1_s;
1655 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
1659 Cave[y][x] = Ytank_s_w;
1660 Next[y][x] = Xtank_2_w;
1661 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
1666 static void Ltank_1_s(int x, int y)
1668 if (tab_amoeba[Cave[y-1][x]] ||
1669 tab_amoeba[Cave[y][x+1]] ||
1670 tab_amoeba[Cave[y+1][x]] ||
1671 tab_amoeba[Cave[y][x-1]])
1678 switch (Cave[y][x+1])
1681 case Xacid_splash_e:
1682 case Xacid_splash_w:
1694 Cave[y][x] = Ytank_s_e;
1695 Next[y][x] = Xtank_2_e;
1696 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
1705 static void Ltank_2_s(int x, int y)
1707 if (tab_amoeba[Cave[y-1][x]] ||
1708 tab_amoeba[Cave[y][x+1]] ||
1709 tab_amoeba[Cave[y+1][x]] ||
1710 tab_amoeba[Cave[y][x-1]])
1720 static void Ltank_w(int x, int y)
1722 switch (Cave[y][x-1])
1732 Cave[y][x] = Ytank_wB;
1733 if (Cave[y-1][x] == Xblank)
1734 Cave[y-1][x] = Xacid_splash_e;
1735 if (Cave[y-1][x-2] == Xblank)
1736 Cave[y-1][x-2] = Xacid_splash_w;
1737 Next[y][x] = Xblank;
1738 play_element_sound(x, y, SOUND_acid, Xacid_1);
1742 case Xacid_splash_e:
1743 case Xacid_splash_w:
1747 Cave[y][x] = Ytank_wB;
1748 Cave[y][x-1] = Ytank_w;
1749 Next[y][x] = Xblank;
1750 Next[y][x-1] = Xtank_1_w;
1751 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
1755 Cave[y][x] = Ytank_w_n;
1756 Next[y][x] = Xtank_2_n;
1757 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
1762 static void Ltank_1_w(int x, int y)
1764 if (tab_amoeba[Cave[y-1][x]] ||
1765 tab_amoeba[Cave[y][x+1]] ||
1766 tab_amoeba[Cave[y+1][x]] ||
1767 tab_amoeba[Cave[y][x-1]])
1774 switch (Cave[y+1][x])
1777 case Xacid_splash_e:
1778 case Xacid_splash_w:
1790 Cave[y][x] = Ytank_w_s;
1791 Next[y][x] = Xtank_2_s;
1792 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
1801 static void Ltank_2_w(int x, int y)
1803 if (tab_amoeba[Cave[y-1][x]] ||
1804 tab_amoeba[Cave[y][x+1]] ||
1805 tab_amoeba[Cave[y+1][x]] ||
1806 tab_amoeba[Cave[y][x-1]])
1816 static void Landroid(int x, int y)
1820 if (lev.android_clone_cnt == 0)
1822 if (Cave[y-1][x-1] != Xblank &&
1823 Cave[y-1][x] != Xblank &&
1824 Cave[y-1][x+1] != Xblank &&
1825 Cave[y][x-1] != Xblank &&
1826 Cave[y][x+1] != Xblank &&
1827 Cave[y+1][x-1] != Xblank &&
1828 Cave[y+1][x] != Xblank &&
1829 Cave[y+1][x+1] != Xblank)
1834 /* randomly find an object to clone */
1836 case 0: /* S,NE,W,NW,SE,E,SW,N */
1837 temp = lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1838 temp = lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1839 temp = lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1840 temp = lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1841 temp = lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1842 temp = lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1843 temp = lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1844 temp = lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1847 case 1: /* NW,SE,N,S,NE,SW,E,W */
1848 temp = lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1849 temp = lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1850 temp = lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1851 temp = lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1852 temp = lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1853 temp = lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1854 temp = lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1855 temp = lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1858 case 2: /* SW,E,S,W,N,NW,SE,NE */
1859 temp = lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1860 temp = lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1861 temp = lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1862 temp = lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1863 temp = lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1864 temp = lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1865 temp = lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1866 temp = lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1869 case 3: /* N,SE,NE,E,W,S,NW,SW */
1870 temp = lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1871 temp = lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1872 temp = lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1873 temp = lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1874 temp = lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1875 temp = lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1876 temp = lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1877 temp = lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1880 case 4: /* SE,NW,E,NE,SW,W,N,S */
1881 temp = lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1882 temp = lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1883 temp = lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1884 temp = lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1885 temp = lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1886 temp = lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1887 temp = lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1888 temp = lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1891 case 5: /* NE,W,SE,SW,S,N,E,NW */
1892 temp = lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1893 temp = lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1894 temp = lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1895 temp = lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1896 temp = lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1897 temp = lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1898 temp = lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1899 temp = lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1902 case 6: /* E,N,SW,S,NW,NE,SE,W */
1903 temp = lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1904 temp = lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1905 temp = lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1906 temp = lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1907 temp = lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1908 temp = lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1909 temp = lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1910 temp = lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1913 case 7: /* W,SW,NW,N,E,SE,NE,S */
1914 temp = lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1915 temp = lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1916 temp = lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1917 temp = lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1918 temp = lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1919 temp = lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1920 temp = lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1921 temp = lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1925 Next[y][x] = temp; /* the item we chose to clone */
1926 play_element_sound(x, y, SOUND_android_clone, temp);
1930 /* randomly find a direction to move */
1932 case 0: /* S,NE,W,NW,SE,E,SW,N */
1933 if (Cave[y+1][x] == Xblank) goto android_s;
1934 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1935 if (Cave[y][x-1] == Xblank) goto android_w;
1936 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1937 if (Cave[y+1][x+1] == Xblank) goto android_se;
1938 if (Cave[y][x+1] == Xblank) goto android_e;
1939 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1940 if (Cave[y-1][x] == Xblank) goto android_n;
1943 case 1: /* NW,SE,N,S,NE,SW,E,W */
1944 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1945 if (Cave[y+1][x+1] == Xblank) goto android_se;
1946 if (Cave[y-1][x] == Xblank) goto android_n;
1947 if (Cave[y+1][x] == Xblank) goto android_s;
1948 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1949 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1950 if (Cave[y][x+1] == Xblank) goto android_e;
1951 if (Cave[y][x-1] == Xblank) goto android_w;
1954 case 2: /* SW,E,S,W,N,NW,SE,NE */
1955 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1956 if (Cave[y][x+1] == Xblank) goto android_e;
1957 if (Cave[y+1][x] == Xblank) goto android_s;
1958 if (Cave[y][x-1] == Xblank) goto android_w;
1959 if (Cave[y-1][x] == Xblank) goto android_n;
1960 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1961 if (Cave[y+1][x+1] == Xblank) goto android_se;
1962 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1965 case 3: /* N,SE,NE,E,W,S,NW,SW */
1966 if (Cave[y-1][x] == Xblank) goto android_n;
1967 if (Cave[y+1][x+1] == Xblank) goto android_se;
1968 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1969 if (Cave[y][x+1] == Xblank) goto android_e;
1970 if (Cave[y][x-1] == Xblank) goto android_w;
1971 if (Cave[y+1][x] == Xblank) goto android_s;
1972 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1973 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1976 case 4: /* SE,NW,E,NE,SW,W,N,S */
1977 if (Cave[y+1][x+1] == Xblank) goto android_se;
1978 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1979 if (Cave[y][x+1] == Xblank) goto android_e;
1980 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1981 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1982 if (Cave[y][x-1] == Xblank) goto android_w;
1983 if (Cave[y-1][x] == Xblank) goto android_n;
1984 if (Cave[y+1][x] == Xblank) goto android_s;
1987 case 5: /* NE,W,SE,SW,S,N,E,NW */
1988 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1989 if (Cave[y][x-1] == Xblank) goto android_w;
1990 if (Cave[y+1][x+1] == Xblank) goto android_se;
1991 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1992 if (Cave[y+1][x] == Xblank) goto android_s;
1993 if (Cave[y-1][x] == Xblank) goto android_n;
1994 if (Cave[y][x+1] == Xblank) goto android_e;
1995 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1998 case 6: /* E,N,SW,S,NW,NE,SE,W */
1999 if (Cave[y][x+1] == Xblank) goto android_e;
2000 if (Cave[y-1][x] == Xblank) goto android_n;
2001 if (Cave[y+1][x-1] == Xblank) goto android_sw;
2002 if (Cave[y+1][x] == Xblank) goto android_s;
2003 if (Cave[y-1][x-1] == Xblank) goto android_nw;
2004 if (Cave[y-1][x+1] == Xblank) goto android_ne;
2005 if (Cave[y+1][x+1] == Xblank) goto android_se;
2006 if (Cave[y][x-1] == Xblank) goto android_w;
2009 case 7: /* W,SW,NW,N,E,SE,NE,S */
2010 if (Cave[y][x-1] == Xblank) goto android_w;
2011 if (Cave[y+1][x-1] == Xblank) goto android_sw;
2012 if (Cave[y-1][x-1] == Xblank) goto android_nw;
2013 if (Cave[y-1][x] == Xblank) goto android_n;
2014 if (Cave[y][x+1] == Xblank) goto android_e;
2015 if (Cave[y+1][x+1] == Xblank) goto android_se;
2016 if (Cave[y-1][x+1] == Xblank) goto android_ne;
2017 if (Cave[y+1][x] == Xblank) goto android_s;
2023 if (lev.android_move_cnt == 0)
2025 if (Cave[y-1][x-1] == Zplayer ||
2026 Cave[y-1][x] == Zplayer ||
2027 Cave[y-1][x+1] == Zplayer ||
2028 Cave[y][x-1] == Zplayer ||
2029 Cave[y][x+1] == Zplayer ||
2030 Cave[y+1][x-1] == Zplayer ||
2031 Cave[y+1][x] == Zplayer ||
2032 Cave[y+1][x+1] == Zplayer)
2035 set_nearest_player_xy(x, y, &dx, &dy);
2037 Next[y][x] = Xblank; /* assume we will move */
2038 temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
2044 /* attempt clockwise move first if direct path is blocked */
2046 case 0: /* north west */
2047 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
2048 if (tab_android_move[Cave[y-1][x]]) goto android_n;
2049 if (tab_android_move[Cave[y][x-1]]) goto android_w;
2053 if (tab_android_move[Cave[y-1][x]]) goto android_n;
2054 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
2055 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
2058 case 2: /* north east */
2059 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
2060 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2061 if (tab_android_move[Cave[y-1][x]]) goto android_n;
2065 if (tab_android_move[Cave[y][x-1]]) goto android_w;
2066 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
2067 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2070 case 4: /* nowhere */
2074 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2075 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2076 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
2079 case 6: /* south west */
2080 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2081 if (tab_android_move[Cave[y][x-1]]) goto android_w;
2082 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2086 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2087 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2088 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2091 case 8: /* south east */
2092 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2093 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2094 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2102 /* attempt counterclockwise move first if direct path is blocked */
2104 case 0: /* north west */
2105 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
2106 if (tab_android_move[Cave[y][x-1]]) goto android_w;
2107 if (tab_android_move[Cave[y-1][x]]) goto android_n;
2111 if (tab_android_move[Cave[y-1][x]]) goto android_n;
2112 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
2113 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
2116 case 2: /* north east */
2117 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
2118 if (tab_android_move[Cave[y-1][x]]) goto android_n;
2119 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2123 if (tab_android_move[Cave[y][x-1]]) goto android_w;
2124 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2125 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
2128 case 4: /* nowhere */
2132 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2133 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
2134 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2137 case 6: /* south west */
2138 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2139 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2140 if (tab_android_move[Cave[y][x-1]]) goto android_w;
2144 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2145 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2146 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2149 case 8: /* south east */
2150 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2151 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2152 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2159 Next[y][x] = Xandroid;
2163 Cave[y][x] = Yandroid_nB;
2164 Cave[y-1][x] = Yandroid_n;
2165 Next[y-1][x] = Xandroid;
2166 play_element_sound(x, y, SOUND_android_move, Xandroid);
2170 Cave[y][x] = Yandroid_neB;
2171 Cave[y-1][x+1] = Yandroid_ne;
2172 Next[y-1][x+1] = Xandroid;
2173 play_element_sound(x, y, SOUND_android_move, Xandroid);
2177 Cave[y][x] = Yandroid_eB;
2178 Cave[y][x+1] = Yandroid_e;
2179 Next[y][x+1] = Xandroid;
2180 play_element_sound(x, y, SOUND_android_move, Xandroid);
2184 Cave[y][x] = Yandroid_seB;
2185 Cave[y+1][x+1] = Yandroid_se;
2186 Next[y+1][x+1] = Xandroid;
2187 play_element_sound(x, y, SOUND_android_move, Xandroid);
2191 Cave[y][x] = Yandroid_sB;
2192 Cave[y+1][x] = Yandroid_s;
2193 Next[y+1][x] = Xandroid;
2194 play_element_sound(x, y, SOUND_android_move, Xandroid);
2198 Cave[y][x] = Yandroid_swB;
2199 Cave[y+1][x-1] = Yandroid_sw;
2200 Next[y+1][x-1] = Xandroid;
2201 play_element_sound(x, y, SOUND_android_move, Xandroid);
2205 Cave[y][x] = Yandroid_wB;
2206 Cave[y][x-1] = Yandroid_w;
2207 Next[y][x-1] = Xandroid;
2208 play_element_sound(x, y, SOUND_android_move, Xandroid);
2212 Cave[y][x] = Yandroid_nwB;
2213 Cave[y-1][x-1] = Yandroid_nw;
2214 Next[y-1][x-1] = Xandroid;
2215 play_element_sound(x, y, SOUND_android_move, Xandroid);
2219 static void Landroid_1_n(int x, int y)
2221 switch (Cave[y-1][x])
2231 Cave[y][x] = Yandroid_nB;
2232 if (Cave[y-2][x+1] == Xblank)
2233 Cave[y-2][x+1] = Xacid_splash_e;
2234 if (Cave[y-2][x-1] == Xblank)
2235 Cave[y-2][x-1] = Xacid_splash_w;
2236 Next[y][x] = Xblank;
2237 play_element_sound(x, y, SOUND_acid, Xacid_1);
2241 case Xacid_splash_e:
2242 case Xacid_splash_w:
2243 Cave[y][x] = Yandroid_nB;
2244 Cave[y-1][x] = Yandroid_n;
2245 Next[y][x] = Xblank;
2246 Next[y-1][x] = Xandroid;
2247 play_element_sound(x, y, SOUND_android_move, Xandroid_1_n);
2256 static void Landroid_2_n(int x, int y)
2258 switch (Cave[y-1][x])
2268 Cave[y][x] = Yandroid_nB;
2269 if (Cave[y-2][x+1] == Xblank)
2270 Cave[y-2][x+1] = Xacid_splash_e;
2271 if (Cave[y-2][x-1] == Xblank)
2272 Cave[y-2][x-1] = Xacid_splash_w;
2273 Next[y][x] = Xblank;
2274 play_element_sound(x, y, SOUND_acid, Xacid_1);
2278 case Xacid_splash_e:
2279 case Xacid_splash_w:
2280 Cave[y][x] = Yandroid_nB;
2281 Cave[y-1][x] = Yandroid_n;
2282 Next[y][x] = Xblank;
2283 Next[y-1][x] = Xandroid_1_n;
2284 play_element_sound(x, y, SOUND_android_move, Xandroid_2_n);
2293 static void Landroid_1_e(int x, int y)
2295 switch (Cave[y][x+1])
2305 Cave[y][x] = Yandroid_eB;
2306 if (Cave[y-1][x+2] == Xblank)
2307 Cave[y-1][x+2] = Xacid_splash_e;
2308 if (Cave[y-1][x] == Xblank)
2309 Cave[y-1][x] = Xacid_splash_w;
2310 Next[y][x] = Xblank;
2311 play_element_sound(x, y, SOUND_acid, Xacid_1);
2315 case Xacid_splash_e:
2316 case Xacid_splash_w:
2317 Cave[y][x] = Yandroid_eB;
2318 Cave[y][x+1] = Yandroid_e;
2319 Next[y][x] = Xblank;
2320 Next[y][x+1] = Xandroid;
2321 play_element_sound(x, y, SOUND_android_move, Xandroid_1_e);
2330 static void Landroid_2_e(int x, int y)
2332 switch (Cave[y][x+1])
2342 Cave[y][x] = Yandroid_eB;
2343 if (Cave[y-1][x+2] == Xblank)
2344 Cave[y-1][x+2] = Xacid_splash_e;
2345 if (Cave[y-1][x] == Xblank)
2346 Cave[y-1][x] = Xacid_splash_w;
2347 Next[y][x] = Xblank;
2348 play_element_sound(x, y, SOUND_acid, Xacid_1);
2352 case Xacid_splash_e:
2353 case Xacid_splash_w:
2354 Cave[y][x] = Yandroid_eB;
2355 Cave[y][x+1] = Yandroid_e;
2356 Next[y][x] = Xblank;
2357 Next[y][x+1] = Xandroid_1_e;
2358 play_element_sound(x, y, SOUND_android_move, Xandroid_2_e);
2367 static void Landroid_1_s(int x, int y)
2369 switch (Cave[y+1][x])
2379 Cave[y][x] = Yandroid_sB;
2380 if (Cave[y][x+1] == Xblank)
2381 Cave[y][x+1] = Xacid_splash_e;
2382 if (Cave[y][x-1] == Xblank)
2383 Cave[y][x-1] = Xacid_splash_w;
2384 Next[y][x] = Xblank;
2385 play_element_sound(x, y, SOUND_acid, Xacid_1);
2389 case Xacid_splash_e:
2390 case Xacid_splash_w:
2391 Cave[y][x] = Yandroid_sB;
2392 Cave[y+1][x] = Yandroid_s;
2393 Next[y][x] = Xblank;
2394 Next[y+1][x] = Xandroid;
2395 play_element_sound(x, y, SOUND_android_move, Xandroid_1_s);
2404 static void Landroid_2_s(int x, int y)
2406 switch (Cave[y+1][x])
2416 Cave[y][x] = Yandroid_sB;
2417 if (Cave[y][x+1] == Xblank)
2418 Cave[y][x+1] = Xacid_splash_e;
2419 if (Cave[y][x-1] == Xblank)
2420 Cave[y][x-1] = Xacid_splash_w;
2421 Next[y][x] = Xblank;
2422 play_element_sound(x, y, SOUND_acid, Xacid_1);
2426 case Xacid_splash_e:
2427 case Xacid_splash_w:
2428 Cave[y][x] = Yandroid_sB;
2429 Cave[y+1][x] = Yandroid_s;
2430 Next[y][x] = Xblank;
2431 Next[y+1][x] = Xandroid_1_s;
2432 play_element_sound(x, y, SOUND_android_move, Xandroid_2_s);
2441 static void Landroid_1_w(int x, int y)
2443 switch (Cave[y][x-1])
2453 Cave[y][x] = Yandroid_wB;
2454 if (Cave[y-1][x] == Xblank)
2455 Cave[y-1][x] = Xacid_splash_e;
2456 if (Cave[y-1][x-2] == Xblank)
2457 Cave[y-1][x-2] = Xacid_splash_w;
2458 Next[y][x] = Xblank;
2459 play_element_sound(x, y, SOUND_acid, Xacid_1);
2463 case Xacid_splash_e:
2464 case Xacid_splash_w:
2465 Cave[y][x] = Yandroid_wB;
2466 Cave[y][x-1] = Yandroid_w;
2467 Next[y][x] = Xblank;
2468 Next[y][x-1] = Xandroid;
2469 play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
2478 static void Landroid_2_w(int x, int y)
2480 switch (Cave[y][x-1])
2490 Cave[y][x] = Yandroid_wB;
2491 if (Cave[y-1][x] == Xblank)
2492 Cave[y-1][x] = Xacid_splash_e;
2493 if (Cave[y-1][x-2] == Xblank)
2494 Cave[y-1][x-2] = Xacid_splash_w;
2495 Next[y][x] = Xblank;
2496 play_element_sound(x, y, SOUND_acid, Xacid_1);
2500 case Xacid_splash_e:
2501 case Xacid_splash_w:
2502 Cave[y][x] = Yandroid_wB;
2503 Cave[y][x-1] = Yandroid_w;
2504 Next[y][x] = Xblank;
2505 Next[y][x-1] = Xandroid_1_w;
2506 play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
2515 static void Lspring(int x, int y)
2517 switch (Cave[y+1][x])
2527 Cave[y][x] = Yspring_sB;
2528 if (Cave[y][x+1] == Xblank)
2529 Cave[y][x+1] = Xacid_splash_e;
2530 if (Cave[y][x-1] == Xblank)
2531 Cave[y][x-1] = Xacid_splash_w;
2532 Next[y][x] = Xblank;
2533 play_element_sound(x, y, SOUND_acid, Xacid_1);
2537 case Xacid_splash_e:
2538 case Xacid_splash_w:
2541 Cave[y][x] = Yspring_sB;
2542 Cave[y+1][x] = Yspring_s;
2543 Next[y][x] = Xblank;
2544 Next[y+1][x] = Xspring_fall;
2563 case Xemerald_pause:
2565 case Xdiamond_pause:
2593 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
2595 Cave[y][x] = Yspring_eB;
2596 Cave[y][x+1] = Yspring_e;
2597 if (Cave[y+1][x] == Xbumper)
2598 Cave[y+1][x] = XbumperB;
2599 Next[y][x] = Xblank;
2602 Next[y][x+1] = Xspring_e;
2604 Next[y][x+1] = Xspring_pause;
2609 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
2611 Cave[y][x] = Yspring_wB;
2612 Cave[y][x-1] = Yspring_w;
2613 if (Cave[y+1][x] == Xbumper)
2614 Cave[y+1][x] = XbumperB;
2615 Next[y][x] = Xblank;
2618 Next[y][x-1] = Xspring_w;
2620 Next[y][x-1] = Xspring_pause;
2627 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
2629 Cave[y][x] = Yspring_wB;
2630 Cave[y][x-1] = Yspring_w;
2631 if (Cave[y+1][x] == Xbumper)
2632 Cave[y+1][x] = XbumperB;
2633 Next[y][x] = Xblank;
2636 Next[y][x-1] = Xspring_w;
2638 Next[y][x-1] = Xspring_pause;
2643 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
2645 Cave[y][x] = Yspring_eB;
2646 Cave[y][x+1] = Yspring_e;
2647 if (Cave[y+1][x] == Xbumper)
2648 Cave[y+1][x] = XbumperB;
2649 Next[y][x] = Xblank;
2652 Next[y][x+1] = Xspring_e;
2654 Next[y][x+1] = Xspring_pause;
2662 static void Lspring_pause(int x, int y)
2664 switch (Cave[y+1][x])
2674 Cave[y][x] = Yspring_sB;
2675 if (Cave[y][x+1] == Xblank)
2676 Cave[y][x+1] = Xacid_splash_e;
2677 if (Cave[y][x-1] == Xblank)
2678 Cave[y][x-1] = Xacid_splash_w;
2679 Next[y][x] = Xblank;
2680 play_element_sound(x, y, SOUND_acid, Xacid_1);
2684 case Xacid_splash_e:
2685 case Xacid_splash_w:
2686 Cave[y][x] = Yspring_sB;
2687 Cave[y+1][x] = Yspring_s;
2688 Next[y][x] = Xblank;
2689 Next[y+1][x] = Xspring_fall;
2693 Cave[y][x] = Xspring;
2694 Next[y][x] = Xspring;
2699 static void Lspring_e(int x, int y)
2701 switch (Cave[y+1][x])
2711 Cave[y][x] = Yspring_sB;
2712 if (Cave[y][x+1] == Xblank)
2713 Cave[y][x+1] = Xacid_splash_e;
2714 if (Cave[y][x-1] == Xblank)
2715 Cave[y][x-1] = Xacid_splash_w;
2716 Next[y][x] = Xblank;
2717 play_element_sound(x, y, SOUND_acid, Xacid_1);
2721 case Xacid_splash_e:
2722 case Xacid_splash_w:
2723 Cave[y][x] = Yspring_sB;
2724 Cave[y+1][x] = Yspring_s;
2725 Next[y][x] = Xblank;
2726 Next[y+1][x] = Xspring_fall;
2730 Cave[y+1][x] = XbumperB;
2733 switch (Cave[y][x+1])
2743 Cave[y][x] = Yspring_eB;
2744 if (Cave[y-1][x+2] == Xblank)
2745 Cave[y-1][x+2] = Xacid_splash_e;
2746 if (Cave[y-1][x] == Xblank)
2747 Cave[y-1][x] = Xacid_splash_w;
2748 Next[y][x] = Xblank;
2749 play_element_sound(x, y, SOUND_acid, Xacid_1);
2753 case Xacid_splash_e:
2754 case Xacid_splash_w:
2759 Cave[y][x] = Yspring_eB;
2760 Cave[y][x+1] = Yspring_e;
2761 Next[y][x] = Xblank;
2762 Next[y][x+1] = Xspring_e;
2771 Cave[y][x] = Yspring_alien_eB;
2772 Cave[y][x+1] = Yspring_alien_e;
2773 Next[y][x] = Xblank;
2774 Next[y][x+1] = Xspring_e;
2775 play_element_sound(x, y, SOUND_slurp, Xalien);
2776 score += lev.slurp_score;
2781 Cave[y][x+1] = XbumperB;
2782 Next[y][x] = Xspring_w;
2783 play_element_sound(x, y, SOUND_spring, Xspring);
2787 Cave[y][x] = Xspring;
2788 Next[y][x] = Xspring;
2789 play_element_sound(x, y, SOUND_spring, Xspring);
2794 static void Lspring_w(int x, int y)
2796 switch (Cave[y+1][x])
2806 Cave[y][x] = Yspring_sB;
2807 if (Cave[y][x+1] == Xblank)
2808 Cave[y][x+1] = Xacid_splash_e;
2809 if (Cave[y][x-1] == Xblank)
2810 Cave[y][x-1] = Xacid_splash_w;
2811 Next[y][x] = Xblank;
2812 play_element_sound(x, y, SOUND_acid, Xacid_1);
2816 case Xacid_splash_e:
2817 case Xacid_splash_w:
2818 Cave[y][x] = Yspring_sB;
2819 Cave[y+1][x] = Yspring_s;
2820 Next[y][x] = Xblank;
2821 Next[y+1][x] = Xspring_fall;
2825 Cave[y+1][x] = XbumperB;
2828 switch (Cave[y][x-1])
2838 Cave[y][x] = Yspring_wB;
2839 if (Cave[y-1][x] == Xblank)
2840 Cave[y-1][x] = Xacid_splash_e;
2841 if (Cave[y-1][x-2] == Xblank)
2842 Cave[y-1][x-2] = Xacid_splash_w;
2843 Next[y][x] = Xblank;
2844 play_element_sound(x, y, SOUND_acid, Xacid_1);
2848 case Xacid_splash_e:
2849 case Xacid_splash_w:
2854 Cave[y][x] = Yspring_wB;
2855 Cave[y][x-1] = Yspring_w;
2856 Next[y][x] = Xblank;
2857 Next[y][x-1] = Xspring_w;
2866 Cave[y][x] = Yspring_alien_wB;
2867 Cave[y][x-1] = Yspring_alien_w;
2868 Next[y][x] = Xblank;
2869 Next[y][x-1] = Xspring_w;
2870 play_element_sound(x, y, SOUND_slurp, Xalien);
2871 score += lev.slurp_score;
2876 Cave[y][x-1] = XbumperB;
2877 Next[y][x] = Xspring_e;
2878 play_element_sound(x, y, SOUND_spring, Xspring);
2882 Cave[y][x] = Xspring;
2883 Next[y][x] = Xspring;
2884 play_element_sound(x, y, SOUND_spring, Xspring);
2889 static void Lspring_fall(int x, int y)
2891 switch (Cave[y+1][x])
2901 Cave[y][x] = Yspring_sB;
2902 if (Cave[y][x+1] == Xblank)
2903 Cave[y][x+1] = Xacid_splash_e;
2904 if (Cave[y][x-1] == Xblank)
2905 Cave[y][x-1] = Xacid_splash_w;
2906 Next[y][x] = Xblank;
2907 play_element_sound(x, y, SOUND_acid, Xacid_1);
2911 case Xacid_splash_e:
2912 case Xacid_splash_w:
2914 Cave[y][x] = Yspring_sB;
2915 Cave[y+1][x] = Yspring_s;
2916 Next[y][x] = Xblank;
2917 Next[y+1][x] = Xspring_fall;
2922 Cave[y+1][x] = Ybomb_blank;
2923 Next[y+1][x] = Znormal;
2924 Boom[y][x-1] = Xblank;
2925 Boom[y][x] = Xblank;
2926 Boom[y][x+1] = Xblank;
2927 Boom[y+1][x-1] = Xblank;
2928 Boom[y+1][x] = Xblank;
2929 Boom[y+1][x+1] = Xblank;
2930 Boom[y+2][x-1] = Xblank;
2931 Boom[y+2][x] = Xblank;
2932 Boom[y+2][x+1] = Xblank;
2933 #if PLAY_ELEMENT_SOUND
2934 play_element_sound(x, y, SOUND_boom, Xspring_fall);
2946 Cave[y][x] = Yspring_sB;
2947 Cave[y+1][x] = Ybug_spring;
2948 Next[y+1][x] = Znormal;
2949 Boom[y][x-1] = Xemerald;
2950 Boom[y][x] = Xemerald;
2951 Boom[y][x+1] = Xemerald;
2952 Boom[y+1][x-1] = Xemerald;
2953 Boom[y+1][x] = Xdiamond;
2954 Boom[y+1][x+1] = Xemerald;
2955 Boom[y+2][x-1] = Xemerald;
2956 Boom[y+2][x] = Xemerald;
2957 Boom[y+2][x+1] = Xemerald;
2958 #if PLAY_ELEMENT_SOUND
2959 play_element_sound(x, y, SOUND_boom, Xspring_fall);
2961 score += lev.bug_score;
2972 Cave[y][x] = Yspring_sB;
2973 Cave[y+1][x] = Ytank_spring;
2974 Next[y+1][x] = Znormal;
2975 Boom[y][x-1] = Xblank;
2976 Boom[y][x] = Xblank;
2977 Boom[y][x+1] = Xblank;
2978 Boom[y+1][x-1] = Xblank;
2979 Boom[y+1][x] = Xblank;
2980 Boom[y+1][x+1] = Xblank;
2981 Boom[y+2][x-1] = Xblank;
2982 Boom[y+2][x] = Xblank;
2983 Boom[y+2][x+1] = Xblank;
2984 #if PLAY_ELEMENT_SOUND
2985 play_element_sound(x, y, SOUND_boom, Xspring_fall);
2987 score += lev.tank_score;
2994 Cave[y][x] = Yspring_sB;
2995 Cave[y+1][x] = Yeater_spring;
2996 Next[y+1][x] = Znormal;
2997 Boom[y][x-1] = lev.eater_array[lev.eater_pos][0];
2998 Boom[y][x] = lev.eater_array[lev.eater_pos][1];
2999 Boom[y][x+1] = lev.eater_array[lev.eater_pos][2];
3000 Boom[y+1][x-1] = lev.eater_array[lev.eater_pos][3];
3001 Boom[y+1][x] = lev.eater_array[lev.eater_pos][4];
3002 Boom[y+1][x+1] = lev.eater_array[lev.eater_pos][5];
3003 Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
3004 Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
3005 Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
3006 #if PLAY_ELEMENT_SOUND
3007 play_element_sound(x, y, SOUND_boom, Xspring_fall);
3009 lev.eater_pos = (lev.eater_pos + 1) & 7;
3010 score += lev.eater_score;
3015 Cave[y][x] = Yspring_sB;
3016 Cave[y+1][x] = Yalien_spring;
3017 Next[y+1][x] = Znormal;
3018 Boom[y][x-1] = Xblank;
3019 Boom[y][x] = Xblank;
3020 Boom[y][x+1] = Xblank;
3021 Boom[y+1][x-1] = Xblank;
3022 Boom[y+1][x] = Xblank;
3023 Boom[y+1][x+1] = Xblank;
3024 Boom[y+2][x-1] = Xblank;
3025 Boom[y+2][x] = Xblank;
3026 Boom[y+2][x+1] = Xblank;
3027 #if PLAY_ELEMENT_SOUND
3028 play_element_sound(x, y, SOUND_boom, Xspring_fall);
3030 score += lev.alien_score;
3034 Cave[y][x] = Xspring;
3035 Next[y][x] = Xspring;
3036 play_element_sound(x, y, SOUND_spring, Xspring);
3041 static void Leater_n(int x, int y)
3043 if (Cave[y][x+1] == Xdiamond)
3045 Cave[y][x+1] = Ydiamond_blank;
3046 Next[y][x+1] = Xblank;
3047 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
3051 if (Cave[y+1][x] == Xdiamond)
3053 Cave[y+1][x] = Ydiamond_blank;
3054 Next[y+1][x] = Xblank;
3055 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
3059 if (Cave[y][x-1] == Xdiamond)
3061 Cave[y][x-1] = Ydiamond_blank;
3062 Next[y][x-1] = Xblank;
3063 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
3067 if (Cave[y-1][x] == Xdiamond)
3069 Cave[y-1][x] = Ydiamond_blank;
3070 Next[y-1][x] = Xblank;
3071 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
3075 switch (Cave[y-1][x])
3085 Cave[y][x] = Yeater_nB;
3086 if (Cave[y-2][x+1] == Xblank)
3087 Cave[y-2][x+1] = Xacid_splash_e;
3088 if (Cave[y-2][x-1] == Xblank)
3089 Cave[y-2][x-1] = Xacid_splash_w;
3090 Next[y][x] = Xblank;
3091 play_element_sound(x, y, SOUND_acid, Xacid_1);
3095 case Xacid_splash_e:
3096 case Xacid_splash_w:
3100 Cave[y][x] = Yeater_nB;
3101 Cave[y-1][x] = Yeater_n;
3102 Next[y][x] = Xblank;
3103 Next[y-1][x] = Xeater_n;
3107 Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
3108 play_element_sound(x, y, SOUND_eater, Xeater_n);
3113 static void Leater_e(int x, int y)
3115 if (Cave[y+1][x] == Xdiamond)
3117 Cave[y+1][x] = Ydiamond_blank;
3118 Next[y+1][x] = Xblank;
3119 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
3123 if (Cave[y][x-1] == Xdiamond)
3125 Cave[y][x-1] = Ydiamond_blank;
3126 Next[y][x-1] = Xblank;
3127 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
3131 if (Cave[y-1][x] == Xdiamond)
3133 Cave[y-1][x] = Ydiamond_blank;
3134 Next[y-1][x] = Xblank;
3135 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
3139 if (Cave[y][x+1] == Xdiamond)
3141 Cave[y][x+1] = Ydiamond_blank;
3142 Next[y][x+1] = Xblank;
3143 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
3147 switch (Cave[y][x+1])
3157 Cave[y][x] = Yeater_eB;
3158 if (Cave[y-1][x+2] == Xblank)
3159 Cave[y-1][x+2] = Xacid_splash_e;
3160 if (Cave[y-1][x] == Xblank)
3161 Cave[y-1][x] = Xacid_splash_w;
3162 Next[y][x] = Xblank;
3163 play_element_sound(x, y, SOUND_acid, Xacid_1);
3167 case Xacid_splash_e:
3168 case Xacid_splash_w:
3172 Cave[y][x] = Yeater_eB;
3173 Cave[y][x+1] = Yeater_e;
3174 Next[y][x] = Xblank;
3175 Next[y][x+1] = Xeater_e;
3179 Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
3180 play_element_sound(x, y, SOUND_eater, Xeater_e);
3185 static void Leater_s(int x, int y)
3187 if (Cave[y][x-1] == Xdiamond)
3189 Cave[y][x-1] = Ydiamond_blank;
3190 Next[y][x-1] = Xblank;
3191 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
3195 if (Cave[y-1][x] == Xdiamond)
3197 Cave[y-1][x] = Ydiamond_blank;
3198 Next[y-1][x] = Xblank;
3199 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
3203 if (Cave[y][x+1] == Xdiamond)
3205 Cave[y][x+1] = Ydiamond_blank;
3206 Next[y][x+1] = Xblank;
3207 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
3211 if (Cave[y+1][x] == Xdiamond)
3213 Cave[y+1][x] = Ydiamond_blank;
3214 Next[y+1][x] = Xblank;
3215 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
3219 switch (Cave[y+1][x])
3229 Cave[y][x] = Yeater_sB;
3230 if (Cave[y][x+1] == Xblank)
3231 Cave[y][x+1] = Xacid_splash_e;
3232 if (Cave[y][x-1] == Xblank)
3233 Cave[y][x-1] = Xacid_splash_w;
3234 Next[y][x] = Xblank;
3235 play_element_sound(x, y, SOUND_acid, Xacid_1);
3239 case Xacid_splash_e:
3240 case Xacid_splash_w:
3244 Cave[y][x] = Yeater_sB;
3245 Cave[y+1][x] = Yeater_s;
3246 Next[y][x] = Xblank;
3247 Next[y+1][x] = Xeater_s;
3251 Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
3252 play_element_sound(x, y, SOUND_eater, Xeater_s);
3257 static void Leater_w(int x, int y)
3259 if (Cave[y-1][x] == Xdiamond)
3261 Cave[y-1][x] = Ydiamond_blank;
3262 Next[y-1][x] = Xblank;
3263 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
3267 if (Cave[y][x+1] == Xdiamond)
3269 Cave[y][x+1] = Ydiamond_blank;
3270 Next[y][x+1] = Xblank;
3271 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
3275 if (Cave[y+1][x] == Xdiamond)
3277 Cave[y+1][x] = Ydiamond_blank;
3278 Next[y+1][x] = Xblank;
3279 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
3283 if (Cave[y][x-1] == Xdiamond)
3285 Cave[y][x-1] = Ydiamond_blank;
3286 Next[y][x-1] = Xblank;
3287 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
3291 switch (Cave[y][x-1])
3301 Cave[y][x] = Yeater_wB;
3302 if (Cave[y-1][x] == Xblank)
3303 Cave[y-1][x] = Xacid_splash_e;
3304 if (Cave[y-1][x-2] == Xblank)
3305 Cave[y-1][x-2] = Xacid_splash_w;
3306 Next[y][x] = Xblank;
3307 play_element_sound(x, y, SOUND_acid, Xacid_1);
3311 case Xacid_splash_e:
3312 case Xacid_splash_w:
3316 Cave[y][x] = Yeater_wB;
3317 Cave[y][x-1] = Yeater_w;
3318 Next[y][x] = Xblank;
3319 Next[y][x-1] = Xeater_w;
3323 Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
3324 play_element_sound(x, y, SOUND_eater, Xeater_w);
3329 static void Lalien(int x, int y)
3340 set_nearest_player_xy(x, y, &dx, &dy);
3347 switch (Cave[y-1][x])
3357 Cave[y][x] = Yalien_nB;
3358 if (Cave[y-2][x+1] == Xblank)
3359 Cave[y-2][x+1] = Xacid_splash_e;
3360 if (Cave[y-2][x-1] == Xblank)
3361 Cave[y-2][x-1] = Xacid_splash_w;
3362 Next[y][x] = Xblank;
3363 play_element_sound(x, y, SOUND_acid, Xacid_1);
3367 case Xacid_splash_e:
3368 case Xacid_splash_w:
3372 Cave[y][x] = Yalien_nB;
3373 Cave[y-1][x] = Yalien_n;
3374 Next[y][x] = Xblank;
3375 Next[y-1][x] = Xalien_pause;
3376 play_element_sound(x, y, SOUND_alien, Xalien);
3382 switch (Cave[y+1][x])
3392 Cave[y][x] = Yalien_sB;
3393 Next[y][x] = Xblank;
3394 if (Cave[y][x+1] == Xblank)
3395 Cave[y][x+1] = Xacid_splash_e;
3396 if (Cave[y][x-1] == Xblank)
3397 Cave[y][x-1] = Xacid_splash_w;
3398 play_element_sound(x, y, SOUND_acid, Xacid_1);
3402 case Xacid_splash_e:
3403 case Xacid_splash_w:
3407 Cave[y][x] = Yalien_sB;
3408 Cave[y+1][x] = Yalien_s;
3409 Next[y][x] = Xblank;
3410 Next[y+1][x] = Xalien_pause;
3411 play_element_sound(x, y, SOUND_alien, Xalien);
3420 switch (Cave[y][x+1])
3430 Cave[y][x] = Yalien_eB;
3431 if (Cave[y-1][x+2] == Xblank)
3432 Cave[y-1][x+2] = Xacid_splash_e;
3433 if (Cave[y-1][x] == Xblank)
3434 Cave[y-1][x] = Xacid_splash_w;
3435 Next[y][x] = Xblank;
3436 play_element_sound(x, y, SOUND_acid, Xacid_1);
3440 case Xacid_splash_e:
3441 case Xacid_splash_w:
3445 Cave[y][x] = Yalien_eB;
3446 Cave[y][x+1] = Yalien_e;
3447 Next[y][x] = Xblank;
3448 Next[y][x+1] = Xalien_pause;
3449 play_element_sound(x, y, SOUND_alien, Xalien);
3455 switch (Cave[y][x-1])
3465 Cave[y][x] = Yalien_wB;
3466 if (Cave[y-1][x] == Xblank)
3467 Cave[y-1][x] = Xacid_splash_e;
3468 if (Cave[y-1][x-2] == Xblank)
3469 Cave[y-1][x-2] = Xacid_splash_w;
3470 Next[y][x] = Xblank;
3471 play_element_sound(x, y, SOUND_acid, Xacid_1);
3475 case Xacid_splash_e:
3476 case Xacid_splash_w:
3480 Cave[y][x] = Yalien_wB;
3481 Cave[y][x-1] = Yalien_w;
3482 Next[y][x] = Xblank;
3483 Next[y][x-1] = Xalien_pause;
3484 play_element_sound(x, y, SOUND_alien, Xalien);
3491 static void Lalien_pause(int x, int y)
3493 Next[y][x] = Xalien;
3496 static void Lemerald(int x, int y)
3498 switch (Cave[y+1][x])
3508 Cave[y][x] = Yemerald_sB;
3509 if (Cave[y][x+1] == Xblank)
3510 Cave[y][x+1] = Xacid_splash_e;
3511 if (Cave[y][x-1] == Xblank)
3512 Cave[y][x-1] = Xacid_splash_w;
3513 Next[y][x] = Xblank;
3514 play_element_sound(x, y, SOUND_acid, Xacid_1);
3518 case Xacid_splash_e:
3519 case Xacid_splash_w:
3520 Cave[y][x] = Yemerald_sB;
3521 Cave[y+1][x] = Yemerald_s;
3522 Next[y][x] = Xblank;
3523 Next[y+1][x] = Xemerald_fall;
3542 case Xemerald_pause:
3544 case Xdiamond_pause:
3581 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3583 Cave[y][x] = Yemerald_eB;
3584 Cave[y][x+1] = Yemerald_e;
3585 Next[y][x] = Xblank;
3586 Next[y][x+1] = Xemerald_pause;
3590 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3592 Cave[y][x] = Yemerald_wB;
3593 Cave[y][x-1] = Yemerald_w;
3594 Next[y][x] = Xblank;
3595 Next[y][x-1] = Xemerald_pause;
3601 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3603 Cave[y][x] = Yemerald_wB;
3604 Cave[y][x-1] = Yemerald_w;
3605 Next[y][x] = Xblank;
3606 Next[y][x-1] = Xemerald_pause;
3610 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3612 Cave[y][x] = Yemerald_eB;
3613 Cave[y][x+1] = Yemerald_e;
3614 Next[y][x] = Xblank;
3615 Next[y][x+1] = Xemerald_pause;
3621 if (++lev.shine_cnt > 50)
3623 lev.shine_cnt = RANDOM & 7;
3624 Cave[y][x] = Xemerald_shine;
3631 static void Lemerald_pause(int x, int y)
3633 switch (Cave[y+1][x])
3643 Cave[y][x] = Yemerald_sB;
3644 if (Cave[y][x+1] == Xblank)
3645 Cave[y][x+1] = Xacid_splash_e;
3646 if (Cave[y][x-1] == Xblank)
3647 Cave[y][x-1] = Xacid_splash_w;
3648 Next[y][x] = Xblank;
3649 play_element_sound(x, y, SOUND_acid, Xacid_1);
3653 case Xacid_splash_e:
3654 case Xacid_splash_w:
3655 Cave[y][x] = Yemerald_sB;
3656 Cave[y+1][x] = Yemerald_s;
3657 Next[y][x] = Xblank;
3658 Next[y+1][x] = Xemerald_fall;
3662 Cave[y][x] = Xemerald;
3663 Next[y][x] = Xemerald;
3668 static void Lemerald_fall(int x, int y)
3670 switch (Cave[y+1][x])
3680 Cave[y][x] = Yemerald_sB;
3681 if (Cave[y][x+1] == Xblank)
3682 Cave[y][x+1] = Xacid_splash_e;
3683 if (Cave[y][x-1] == Xblank)
3684 Cave[y][x-1] = Xacid_splash_w;
3685 Next[y][x] = Xblank;
3686 play_element_sound(x, y, SOUND_acid, Xacid_1);
3690 case Xacid_splash_e:
3691 case Xacid_splash_w:
3693 Cave[y][x] = Yemerald_sB;
3694 Cave[y+1][x] = Yemerald_s;
3695 Next[y][x] = Xblank;
3696 Next[y+1][x] = Xemerald_fall;
3700 if (lev.wonderwall_time)
3702 lev.wonderwall_state = 1;
3703 Cave[y][x] = Yemerald_sB;
3704 if (tab_blank[Cave[y+2][x]])
3706 Cave[y+2][x] = Ydiamond_s;
3707 Next[y+2][x] = Xdiamond_fall;
3710 Next[y][x] = Xblank;
3711 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
3716 Cave[y][x] = Xemerald;
3717 Next[y][x] = Xemerald;
3718 play_element_sound(x, y, SOUND_diamond, Xemerald);
3723 static void Ldiamond(int x, int y)
3725 switch (Cave[y+1][x])
3735 Cave[y][x] = Ydiamond_sB;
3736 if (Cave[y][x+1] == Xblank)
3737 Cave[y][x+1] = Xacid_splash_e;
3738 if (Cave[y][x-1] == Xblank)
3739 Cave[y][x-1] = Xacid_splash_w;
3740 Next[y][x] = Xblank;
3741 play_element_sound(x, y, SOUND_acid, Xacid_1);
3745 case Xacid_splash_e:
3746 case Xacid_splash_w:
3747 Cave[y][x] = Ydiamond_sB;
3748 Cave[y+1][x] = Ydiamond_s;
3749 Next[y][x] = Xblank;
3750 Next[y+1][x] = Xdiamond_fall;
3769 case Xemerald_pause:
3771 case Xdiamond_pause:
3808 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3810 Cave[y][x] = Ydiamond_eB;
3811 Cave[y][x+1] = Ydiamond_e;
3812 Next[y][x] = Xblank;
3813 Next[y][x+1] = Xdiamond_pause;
3817 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3819 Cave[y][x] = Ydiamond_wB;
3820 Cave[y][x-1] = Ydiamond_w;
3821 Next[y][x] = Xblank;
3822 Next[y][x-1] = Xdiamond_pause;
3828 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3830 Cave[y][x] = Ydiamond_wB;
3831 Cave[y][x-1] = Ydiamond_w;
3832 Next[y][x] = Xblank;
3833 Next[y][x-1] = Xdiamond_pause;
3837 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3839 Cave[y][x] = Ydiamond_eB;
3840 Cave[y][x+1] = Ydiamond_e;
3841 Next[y][x] = Xblank;
3842 Next[y][x+1] = Xdiamond_pause;
3848 if (++lev.shine_cnt > 50)
3850 lev.shine_cnt = RANDOM & 7;
3851 Cave[y][x] = Xdiamond_shine;
3858 static void Ldiamond_pause(int x, int y)
3860 switch (Cave[y+1][x])
3870 Cave[y][x] = Ydiamond_sB;
3871 if (Cave[y][x+1] == Xblank)
3872 Cave[y][x+1] = Xacid_splash_e;
3873 if (Cave[y][x-1] == Xblank)
3874 Cave[y][x-1] = Xacid_splash_w;
3875 Next[y][x] = Xblank;
3876 play_element_sound(x, y, SOUND_acid, Xacid_1);
3880 case Xacid_splash_e:
3881 case Xacid_splash_w:
3882 Cave[y][x] = Ydiamond_sB;
3883 Cave[y+1][x] = Ydiamond_s;
3884 Next[y][x] = Xblank;
3885 Next[y+1][x] = Xdiamond_fall;
3889 Cave[y][x] = Xdiamond;
3890 Next[y][x] = Xdiamond;
3895 static void Ldiamond_fall(int x, int y)
3897 switch (Cave[y+1][x])
3907 Cave[y][x] = Ydiamond_sB;
3908 if (Cave[y][x+1] == Xblank)
3909 Cave[y][x+1] = Xacid_splash_e;
3910 if (Cave[y][x-1] == Xblank)
3911 Cave[y][x-1] = Xacid_splash_w;
3912 Next[y][x] = Xblank;
3913 play_element_sound(x, y, SOUND_acid, Xacid_1);
3917 case Xacid_splash_e:
3918 case Xacid_splash_w:
3920 Cave[y][x] = Ydiamond_sB;
3921 Cave[y+1][x] = Ydiamond_s;
3922 Next[y][x] = Xblank;
3923 Next[y+1][x] = Xdiamond_fall;
3927 if (lev.wonderwall_time)
3929 lev.wonderwall_state = 1;
3930 Cave[y][x] = Ydiamond_sB;
3931 if (tab_blank[Cave[y+2][x]])
3933 Cave[y+2][x] = Ystone_s;
3934 Next[y+2][x] = Xstone_fall;
3937 Next[y][x] = Xblank;
3938 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
3943 Cave[y][x] = Xdiamond;
3944 Next[y][x] = Xdiamond;
3945 play_element_sound(x, y, SOUND_diamond, Xdiamond);
3950 static void Ldrip_fall(int x, int y)
3954 switch (Cave[y+1][x])
3964 Cave[y][x] = Ydrip_1_sB;
3965 if (Cave[y][x+1] == Xblank)
3966 Cave[y][x+1] = Xacid_splash_e;
3967 if (Cave[y][x-1] == Xblank)
3968 Cave[y][x-1] = Xacid_splash_w;
3969 Next[y][x] = Xdrip_stretchB;
3970 play_element_sound(x, y, SOUND_acid, Xacid_1);
3974 case Xacid_splash_e:
3975 case Xacid_splash_w:
3979 Cave[y][x] = Ydrip_1_sB;
3980 Cave[y+1][x] = Ydrip_1_s;
3981 Next[y][x] = Xdrip_stretchB;
3982 Next[y+1][x] = Xdrip_stretch;
4023 play_element_sound(x, y, SOUND_drip, Xdrip_fall);
4028 static void Ldrip_stretch(int x, int y)
4030 Cave[y][x] = Ydrip_2_s;
4031 Next[y][x] = Xdrip_fall;
4034 static void Ldrip_stretchB(int x, int y)
4036 Cave[y][x] = Ydrip_2_sB;
4037 Next[y][x] = Xblank;
4040 static void Ldrip(int x, int y)
4042 Next[y][x] = Xdrip_fall;
4045 static void Lbomb(int x, int y)
4047 switch (Cave[y+1][x])
4057 Cave[y][x] = Ybomb_sB;
4058 if (Cave[y][x+1] == Xblank)
4059 Cave[y][x+1] = Xacid_splash_e;
4060 if (Cave[y][x-1] == Xblank)
4061 Cave[y][x-1] = Xacid_splash_w;
4062 Next[y][x] = Xblank;
4063 play_element_sound(x, y, SOUND_acid, Xacid_1);
4067 case Xacid_splash_e:
4068 case Xacid_splash_w:
4069 Cave[y][x] = Ybomb_sB;
4070 Cave[y+1][x] = Ybomb_s;
4071 Next[y][x] = Xblank;
4072 Next[y+1][x] = Xbomb_fall;
4091 case Xemerald_pause:
4093 case Xdiamond_pause:
4121 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
4123 Cave[y][x] = Ybomb_eB;
4124 Cave[y][x+1] = Ybomb_e;
4125 Next[y][x] = Xblank;
4126 Next[y][x+1] = Xbomb_pause;
4130 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
4132 Cave[y][x] = Ybomb_wB;
4133 Cave[y][x-1] = Ybomb_w;
4134 Next[y][x] = Xblank;
4135 Next[y][x-1] = Xbomb_pause;
4141 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
4143 Cave[y][x] = Ybomb_wB;
4144 Cave[y][x-1] = Ybomb_w;
4145 Next[y][x] = Xblank;
4146 Next[y][x-1] = Xbomb_pause;
4150 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
4152 Cave[y][x] = Ybomb_eB;
4153 Cave[y][x+1] = Ybomb_e;
4154 Next[y][x] = Xblank;
4155 Next[y][x+1] = Xbomb_pause;
4162 static void Lbomb_pause(int x, int y)
4164 switch (Cave[y+1][x])
4174 Cave[y][x] = Ybomb_sB;
4175 if (Cave[y][x+1] == Xblank)
4176 Cave[y][x+1] = Xacid_splash_e;
4177 if (Cave[y][x-1] == Xblank)
4178 Cave[y][x-1] = Xacid_splash_w;
4179 Next[y][x] = Xblank;
4180 play_element_sound(x, y, SOUND_acid, Xacid_1);
4184 case Xacid_splash_e:
4185 case Xacid_splash_w:
4186 Cave[y][x] = Ybomb_sB;
4187 Cave[y+1][x] = Ybomb_s;
4188 Next[y][x] = Xblank;
4189 Next[y+1][x] = Xbomb_fall;
4199 static void Lbomb_fall(int x, int y)
4201 switch (Cave[y+1][x])
4211 Cave[y][x] = Ybomb_sB;
4212 if (Cave[y][x+1] == Xblank)
4213 Cave[y][x+1] = Xacid_splash_e;
4214 if (Cave[y][x-1] == Xblank)
4215 Cave[y][x-1] = Xacid_splash_w;
4216 Next[y][x] = Xblank;
4217 play_element_sound(x, y, SOUND_acid, Xacid_1);
4221 case Xacid_splash_e:
4222 case Xacid_splash_w:
4223 Cave[y][x] = Ybomb_sB;
4224 Cave[y+1][x] = Ybomb_s;
4225 Next[y][x] = Xblank;
4226 Next[y+1][x] = Xbomb_fall;
4230 Cave[y][x] = Ybomb_blank;
4231 Next[y][x] = Znormal;
4232 Boom[y-1][x-1] = Xblank;
4233 Boom[y-1][x] = Xblank;
4234 Boom[y-1][x+1] = Xblank;
4235 Boom[y][x-1] = Xblank;
4236 Boom[y][x] = Xblank;
4237 Boom[y][x+1] = Xblank;
4238 Boom[y+1][x-1] = Xblank;
4239 Boom[y+1][x] = Xblank;
4240 Boom[y+1][x+1] = Xblank;
4241 #if PLAY_ELEMENT_SOUND
4242 play_element_sound(x, y, SOUND_boom, Xbomb_fall);
4248 static void Lballoon(int x, int y)
4250 if (lev.wind_cnt == 0)
4253 switch (lev.wind_direction)
4256 switch (Cave[y-1][x])
4266 Cave[y][x] = Yballoon_nB;
4267 if (Cave[y-2][x+1] == Xblank)
4268 Cave[y-2][x+1] = Xacid_splash_e;
4269 if (Cave[y-2][x-1] == Xblank)
4270 Cave[y-2][x-1] = Xacid_splash_w;
4271 Next[y][x] = Xblank;
4272 play_element_sound(x, y, SOUND_acid, Xacid_1);
4276 case Xacid_splash_e:
4277 case Xacid_splash_w:
4278 Cave[y][x] = Yballoon_nB;
4279 Cave[y-1][x] = Yballoon_n;
4280 Next[y][x] = Xblank;
4281 Next[y-1][x] = Xballoon;
4287 switch (Cave[y][x+1])
4297 Cave[y][x] = Yballoon_eB;
4298 if (Cave[y-1][x+2] == Xblank)
4299 Cave[y-1][x+2] = Xacid_splash_e;
4300 if (Cave[y-1][x] == Xblank)
4301 Cave[y-1][x] = Xacid_splash_w;
4302 Next[y][x] = Xblank;
4303 play_element_sound(x, y, SOUND_acid, Xacid_1);
4307 case Xacid_splash_e:
4308 case Xacid_splash_w:
4309 Cave[y][x] = Yballoon_eB;
4310 Cave[y][x+1] = Yballoon_e;
4311 Next[y][x] = Xblank;
4312 Next[y][x+1] = Xballoon;
4318 switch (Cave[y+1][x])
4328 Cave[y][x] = Yballoon_sB;
4329 if (Cave[y][x+1] == Xblank)
4330 Cave[y][x+1] = Xacid_splash_e;
4331 if (Cave[y][x-1] == Xblank)
4332 Cave[y][x-1] = Xacid_splash_w;
4333 Next[y][x] = Xblank;
4334 play_element_sound(x, y, SOUND_acid, Xacid_1);
4338 case Xacid_splash_e:
4339 case Xacid_splash_w:
4340 Cave[y][x] = Yballoon_sB;
4341 Cave[y+1][x] = Yballoon_s;
4342 Next[y][x] = Xblank;
4343 Next[y+1][x] = Xballoon;
4349 switch (Cave[y][x-1])
4359 Cave[y][x] = Yballoon_wB;
4360 if (Cave[y-1][x] == Xblank)
4361 Cave[y-1][x] = Xacid_splash_e;
4362 if (Cave[y-1][x-2] == Xblank)
4363 Cave[y-1][x-2] = Xacid_splash_w;
4364 Next[y][x] = Xblank;
4365 play_element_sound(x, y, SOUND_acid, Xacid_1);
4369 case Xacid_splash_e:
4370 case Xacid_splash_w:
4371 Cave[y][x] = Yballoon_wB;
4372 Cave[y][x-1] = Yballoon_w;
4373 Next[y][x] = Xblank;
4374 Next[y][x-1] = Xballoon;
4381 static void Lacid_1(int x, int y)
4383 Next[y][x] = Xacid_2;
4386 static void Lacid_2(int x, int y)
4388 Next[y][x] = Xacid_3;
4391 static void Lacid_3(int x, int y)
4393 Next[y][x] = Xacid_4;
4396 static void Lacid_4(int x, int y)
4398 Next[y][x] = Xacid_5;
4401 static void Lacid_5(int x, int y)
4403 Next[y][x] = Xacid_6;
4406 static void Lacid_6(int x, int y)
4408 Next[y][x] = Xacid_7;
4411 static void Lacid_7(int x, int y)
4413 Next[y][x] = Xacid_8;
4416 static void Lacid_8(int x, int y)
4418 Next[y][x] = Xacid_1;
4421 static void Lfake_acid_1(int x, int y)
4423 Next[y][x] = Xfake_acid_2;
4426 static void Lfake_acid_2(int x, int y)
4428 Next[y][x] = Xfake_acid_3;
4431 static void Lfake_acid_3(int x, int y)
4433 Next[y][x] = Xfake_acid_4;
4436 static void Lfake_acid_4(int x, int y)
4438 Next[y][x] = Xfake_acid_5;
4441 static void Lfake_acid_5(int x, int y)
4443 Next[y][x] = Xfake_acid_6;
4446 static void Lfake_acid_6(int x, int y)
4448 Next[y][x] = Xfake_acid_7;
4451 static void Lfake_acid_7(int x, int y)
4453 Next[y][x] = Xfake_acid_8;
4456 static void Lfake_acid_8(int x, int y)
4458 Next[y][x] = Xfake_acid_1;
4461 static void Lball_common(int x, int y)
4463 play_element_sound(x, y, SOUND_ball, Xball_1);
4465 if (lev.ball_random)
4470 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
4471 tab_blank[Cave[y-1][x-1]])
4473 Cave[y-1][x-1] = Yball_blank;
4474 Next[y-1][x-1] = lev.ball_array[lev.ball_pos][0];
4479 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
4480 tab_blank[Cave[y-1][x]])
4482 Cave[y-1][x] = Yball_blank;
4483 Next[y-1][x] = lev.ball_array[lev.ball_pos][1];
4488 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
4489 tab_blank[Cave[y-1][x+1]])
4491 Cave[y-1][x+1] = Yball_blank;
4492 Next[y-1][x+1] = lev.ball_array[lev.ball_pos][2];
4497 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
4498 tab_blank[Cave[y][x-1]])
4500 Cave[y][x-1] = Yball_blank;
4501 Next[y][x-1] = lev.ball_array[lev.ball_pos][3];
4506 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
4507 tab_blank[Cave[y][x+1]])
4509 Cave[y][x+1] = Yball_blank;
4510 Next[y][x+1] = lev.ball_array[lev.ball_pos][4];
4515 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
4516 tab_blank[Cave[y+1][x-1]])
4518 Cave[y+1][x-1] = Yball_blank;
4519 Next[y+1][x-1] = lev.ball_array[lev.ball_pos][5];
4524 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
4525 tab_blank[Cave[y+1][x]])
4527 Cave[y+1][x] = Yball_blank;
4528 Next[y+1][x] = lev.ball_array[lev.ball_pos][6];
4533 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
4534 tab_blank[Cave[y+1][x+1]])
4536 Cave[y+1][x+1] = Yball_blank;
4537 Next[y+1][x+1] = lev.ball_array[lev.ball_pos][7];
4544 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
4545 tab_blank[Cave[y-1][x-1]])
4547 Cave[y-1][x-1] = Yball_blank;
4548 Next[y-1][x-1] = lev.ball_array[lev.ball_pos][0];
4551 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
4552 tab_blank[Cave[y-1][x]])
4554 Cave[y-1][x] = Yball_blank;
4555 Next[y-1][x] = lev.ball_array[lev.ball_pos][1];
4558 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
4559 tab_blank[Cave[y-1][x+1]])
4561 Cave[y-1][x+1] = Yball_blank;
4562 Next[y-1][x+1] = lev.ball_array[lev.ball_pos][2];
4565 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
4566 tab_blank[Cave[y][x-1]])
4568 Cave[y][x-1] = Yball_blank;
4569 Next[y][x-1] = lev.ball_array[lev.ball_pos][3];
4572 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
4573 tab_blank[Cave[y][x+1]])
4575 Cave[y][x+1] = Yball_blank;
4576 Next[y][x+1] = lev.ball_array[lev.ball_pos][4];
4579 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
4580 tab_blank[Cave[y+1][x-1]])
4582 Cave[y+1][x-1] = Yball_blank;
4583 Next[y+1][x-1] = lev.ball_array[lev.ball_pos][5];
4586 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
4587 tab_blank[Cave[y+1][x]])
4589 Cave[y+1][x] = Yball_blank;
4590 Next[y+1][x] = lev.ball_array[lev.ball_pos][6];
4593 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
4594 tab_blank[Cave[y+1][x+1]])
4596 Cave[y+1][x+1] = Yball_blank;
4597 Next[y+1][x+1] = lev.ball_array[lev.ball_pos][7];
4601 lev.ball_pos = (lev.ball_pos + 1) % lev.num_ball_arrays;
4604 static void Lball_1(int x, int y)
4606 if (lev.ball_state == 0)
4609 Cave[y][x] = Yball_1;
4610 Next[y][x] = Xball_2;
4617 static void Lball_2(int x, int y)
4619 if (lev.ball_state == 0)
4622 Cave[y][x] = Yball_2;
4623 Next[y][x] = Xball_1;
4630 static void Lslidewall_ns(int x, int y)
4632 if (tab_blank[Cave[y-1][x]])
4634 Cave[y-1][x] = Yslidewall_ns_blank;
4635 Next[y-1][x] = Xslidewall_ns;
4636 play_element_sound(x, y, SOUND_slidewall, Xslidewall_ns);
4639 if (tab_blank[Cave[y+1][x]])
4641 Cave[y+1][x] = Yslidewall_ns_blank;
4642 Next[y+1][x] = Xslidewall_ns;
4643 play_element_sound(x, y, SOUND_slidewall, Xslidewall_ns);
4647 static void Lslidewall_ew(int x, int y)
4649 if (tab_blank[Cave[y][x+1]])
4651 Cave[y][x+1] = Yslidewall_ew_blank;
4652 Next[y][x+1] = Xslidewall_ew;
4653 play_element_sound(x, y, SOUND_slidewall, Xslidewall_ew);
4656 if (tab_blank[Cave[y][x-1]])
4658 Cave[y][x-1] = Yslidewall_ew_blank;
4659 Next[y][x-1] = Xslidewall_ew;
4660 play_element_sound(x, y, SOUND_slidewall, Xslidewall_ew);
4664 static void Lwonderwall(int x, int y)
4666 if (lev.wonderwall_time && lev.wonderwall_state)
4668 Cave[y][x] = XwonderwallB;
4669 play_element_sound(x, y, SOUND_wonder, Xwonderwall);
4673 static void Lexit(int x, int y)
4675 if (lev.required > 0)
4678 int temp = RANDOM & 63;
4682 Cave[y][x] = Xexit_1;
4683 Next[y][x] = Xexit_2;
4687 Cave[y][x] = Xexit_2;
4688 Next[y][x] = Xexit_3;
4692 Cave[y][x] = Xexit_3;
4693 Next[y][x] = Xexit_1;
4696 play_element_sound(x, y, SOUND_exit_open, Xexit);
4699 static void Lexit_1(int x, int y)
4701 Next[y][x] = Xexit_2;
4704 static void Lexit_2(int x, int y)
4706 Next[y][x] = Xexit_3;
4709 static void Lexit_3(int x, int y)
4711 Next[y][x] = Xexit_1;
4714 static void Lpause(int x, int y)
4716 Next[y][x] = Xblank;
4719 static void Ldynamite_1(int x, int y)
4721 play_element_sound(x, y, SOUND_tick, Xdynamite_1);
4722 Next[y][x] = Xdynamite_2;
4725 static void Ldynamite_2(int x, int y)
4727 play_element_sound(x, y, SOUND_tick, Xdynamite_2);
4728 Next[y][x] = Xdynamite_3;
4731 static void Ldynamite_3(int x, int y)
4733 play_element_sound(x, y, SOUND_tick, Xdynamite_3);
4734 Next[y][x] = Xdynamite_4;
4737 static void Ldynamite_4(int x, int y)
4739 play_element_sound(x, y, SOUND_tick, Xdynamite_4);
4740 Next[y][x] = Zdynamite;
4741 Boom[y-1][x-1] = Xblank;
4742 Boom[y-1][x] = Xblank;
4743 Boom[y-1][x+1] = Xblank;
4744 Boom[y][x-1] = Xblank;
4745 Boom[y][x] = Xblank;
4746 Boom[y][x+1] = Xblank;
4747 Boom[y+1][x-1] = Xblank;
4748 Boom[y+1][x] = Xblank;
4749 Boom[y+1][x+1] = Xblank;
4752 static void Lwheel(int x, int y)
4754 if (lev.wheel_cnt && x == lev.wheel_x && y == lev.wheel_y)
4755 Cave[y][x] = XwheelB;
4758 static void Lswitch(int x, int y)
4761 Cave[y][x] = XswitchB;
4764 static void Lsand_stone(int x, int y)
4766 switch (Cave[y+1][x])
4776 Cave[y][x] = Xsand_stonesand_quickout_1;
4777 if (Cave[y][x+1] == Xblank)
4778 Cave[y][x+1] = Xacid_splash_e;
4779 if (Cave[y][x-1] == Xblank)
4780 Cave[y][x-1] = Xacid_splash_w;
4781 Next[y][x] = Xsand_stonesand_quickout_2;
4782 play_element_sound(x, y, SOUND_acid, Xacid_1);
4786 case Xacid_splash_e:
4787 case Xacid_splash_w:
4788 Cave[y][x] = Xsand_stonesand_quickout_1;
4789 Cave[y+1][x] = Xsand_stoneout_1;
4790 Next[y][x] = Xsand_stonesand_quickout_2;
4791 Next[y+1][x] = Xsand_stoneout_2;
4795 Cave[y][x] = Xsand_stonesand_1;
4796 Cave[y+1][x] = Xsand_sandstone_1;
4797 Next[y][x] = Xsand_stonesand_2;
4798 Next[y+1][x] = Xsand_sandstone_2;
4803 static void Lsand_stonein_1(int x, int y)
4805 Next[y][x] = Xsand_stonein_2;
4808 static void Lsand_stonein_2(int x, int y)
4810 Next[y][x] = Xsand_stonein_3;
4813 static void Lsand_stonein_3(int x, int y)
4815 Next[y][x] = Xsand_stonein_4;
4818 static void Lsand_stonein_4(int x, int y)
4820 Next[y][x] = Xblank;
4823 static void Lsand_stonesand_1(int x, int y)
4825 Next[y][x] = Xsand_stonesand_2;
4828 static void Lsand_stonesand_2(int x, int y)
4830 Next[y][x] = Xsand_stonesand_3;
4833 static void Lsand_stonesand_3(int x, int y)
4835 Next[y][x] = Xsand_stonesand_4;
4838 static void Lsand_stonesand_4(int x, int y)
4844 static void Lsand_stonesand_quickout_1(int x, int y)
4846 Next[y][x] = Xsand_stonesand_quickout_2;
4849 static void Lsand_stonesand_quickout_2(int x, int y)
4855 static void Lsand_stoneout_1(int x, int y)
4857 Next[y][x] = Xsand_stoneout_2;
4860 static void Lsand_stoneout_2(int x, int y)
4862 Next[y][x] = Xstone_fall;
4865 static void Lsand_sandstone_1(int x, int y)
4867 Next[y][x] = Xsand_sandstone_2;
4870 static void Lsand_sandstone_2(int x, int y)
4872 Next[y][x] = Xsand_sandstone_3;
4875 static void Lsand_sandstone_3(int x, int y)
4877 Next[y][x] = Xsand_sandstone_4;
4880 static void Lsand_sandstone_4(int x, int y)
4882 Next[y][x] = Xsand_stone;
4885 static void Lfake_amoeba(int x, int y)
4888 Cave[y][x] = Xfake_amoebaB;
4891 static void Lfake_blank(int x, int y)
4894 Cave[y][x] = Xfake_blankB;
4897 static void Lfake_grass(int x, int y)
4899 if (lev.magnify_cnt)
4900 Cave[y][x] = Xfake_grassB;
4903 static void Lfake_door_1(int x, int y)
4905 if (lev.magnify_cnt)
4906 Cave[y][x] = Xdoor_1;
4909 static void Lfake_door_2(int x, int y)
4911 if (lev.magnify_cnt)
4912 Cave[y][x] = Xdoor_2;
4915 static void Lfake_door_3(int x, int y)
4917 if (lev.magnify_cnt)
4918 Cave[y][x] = Xdoor_3;
4921 static void Lfake_door_4(int x, int y)
4923 if (lev.magnify_cnt)
4924 Cave[y][x] = Xdoor_4;
4927 static void Lfake_door_5(int x, int y)
4929 if (lev.magnify_cnt)
4930 Cave[y][x] = Xdoor_5;
4933 static void Lfake_door_6(int x, int y)
4935 if (lev.magnify_cnt)
4936 Cave[y][x] = Xdoor_6;
4939 static void Lfake_door_7(int x, int y)
4941 if (lev.magnify_cnt)
4942 Cave[y][x] = Xdoor_7;
4945 static void Lfake_door_8(int x, int y)
4947 if (lev.magnify_cnt)
4948 Cave[y][x] = Xdoor_8;
4951 static void Lboom_1(int x, int y)
4953 Next[y][x] = Xboom_2;
4954 #if !PLAY_ELEMENT_SOUND
4955 if (x != lev.exit_x && y != lev.exit_y)
4956 play_sound(x, y, SOUND_boom);
4958 lev.exit_x = lev.exit_y = -1;
4962 static void Lboom_2(int x, int y)
4964 Next[y][x] = Boom[y][x];
4967 static void Lboom_android(int x, int y)
4969 #if PLAY_ELEMENT_SOUND
4970 play_element_sound(x, y, SOUND_boom, Xandroid);
4976 void synchro_2(void)
4980 short *cave_cache = Cave[y]; /* might be a win */
4983 random_em = RandomEM;
4988 element = cave_cache[++x];
4995 /* --------------------------------------------------------------------- */
4998 Lpush_stone_e(x, y);
5002 Lpush_stone_w(x, y);
5013 case Xpush_spring_e:
5014 Lpush_spring_e(x, y);
5017 case Xpush_spring_w:
5018 Lpush_spring_w(x, y);
5021 case Xpush_emerald_e:
5022 Lpush_emerald_e(x, y);
5025 case Xpush_emerald_w:
5026 Lpush_emerald_w(x, y);
5029 case Xpush_diamond_e:
5030 Lpush_diamond_e(x, y);
5033 case Xpush_diamond_w:
5034 Lpush_diamond_w(x, y);
5045 /* --------------------------------------------------------------------- */
5051 /* --------------------------------------------------------------------- */
5057 /* --------------------------------------------------------------------- */
5063 /* --------------------------------------------------------------------- */
5069 /* --------------------------------------------------------------------- */
5075 /* --------------------------------------------------------------------- */
5081 /* --------------------------------------------------------------------- */
5091 /* --------------------------------------------------------------------- */
5101 /* --------------------------------------------------------------------- */
5111 /* --------------------------------------------------------------------- */
5121 /* --------------------------------------------------------------------- */
5131 /* --------------------------------------------------------------------- */
5141 /* --------------------------------------------------------------------- */
5151 /* --------------------------------------------------------------------- */
5161 /* --------------------------------------------------------------------- */
5167 /* --------------------------------------------------------------------- */
5177 /* --------------------------------------------------------------------- */
5187 /* --------------------------------------------------------------------- */
5197 /* --------------------------------------------------------------------- */
5207 /* --------------------------------------------------------------------- */
5213 /* --------------------------------------------------------------------- */
5216 Lspring_pause(x, y);
5219 /* --------------------------------------------------------------------- */
5225 /* --------------------------------------------------------------------- */
5231 /* --------------------------------------------------------------------- */
5237 /* --------------------------------------------------------------------- */
5243 /* --------------------------------------------------------------------- */
5249 /* --------------------------------------------------------------------- */
5255 /* --------------------------------------------------------------------- */
5261 /* --------------------------------------------------------------------- */
5271 /* --------------------------------------------------------------------- */
5277 /* --------------------------------------------------------------------- */
5279 case Xemerald_pause:
5280 Lemerald_pause(x, y);
5283 /* --------------------------------------------------------------------- */
5286 Lemerald_fall(x, y);
5289 /* --------------------------------------------------------------------- */
5295 /* --------------------------------------------------------------------- */
5297 case Xdiamond_pause:
5298 Ldiamond_pause(x, y);
5301 /* --------------------------------------------------------------------- */
5304 Ldiamond_fall(x, y);
5307 /* --------------------------------------------------------------------- */
5313 /* --------------------------------------------------------------------- */
5316 Ldrip_stretch(x, y);
5319 case Xdrip_stretchB:
5320 Ldrip_stretchB(x, y);
5327 /* --------------------------------------------------------------------- */
5333 /* --------------------------------------------------------------------- */
5339 /* --------------------------------------------------------------------- */
5345 /* --------------------------------------------------------------------- */
5351 /* --------------------------------------------------------------------- */
5417 /* --------------------------------------------------------------------- */
5427 /* --------------------------------------------------------------------- */
5430 Lslidewall_ns(x, y);
5434 Lslidewall_ew(x, y);
5437 /* --------------------------------------------------------------------- */
5443 /* --------------------------------------------------------------------- */
5461 /* --------------------------------------------------------------------- */
5467 /* --------------------------------------------------------------------- */
5485 /* --------------------------------------------------------------------- */
5491 /* --------------------------------------------------------------------- */
5497 /* --------------------------------------------------------------------- */
5503 case Xsand_stonein_1:
5504 Lsand_stonein_1(x, y);
5507 case Xsand_stonein_2:
5508 Lsand_stonein_2(x, y);
5511 case Xsand_stonein_3:
5512 Lsand_stonein_3(x, y);
5515 case Xsand_stonein_4:
5516 Lsand_stonein_4(x, y);
5519 case Xsand_stonesand_1:
5520 Lsand_stonesand_1(x, y);
5523 case Xsand_stonesand_2:
5524 Lsand_stonesand_2(x, y);
5527 case Xsand_stonesand_3:
5528 Lsand_stonesand_3(x, y);
5531 case Xsand_stonesand_4:
5532 Lsand_stonesand_4(x, y);
5536 case Xsand_stonesand_quickout_1:
5537 Lsand_stonesand_quickout_1(x, y);
5540 case Xsand_stonesand_quickout_2:
5541 Lsand_stonesand_quickout_2(x, y);
5545 case Xsand_stoneout_1:
5546 Lsand_stoneout_1(x, y);
5549 case Xsand_stoneout_2:
5550 Lsand_stoneout_2(x, y);
5553 case Xsand_sandstone_1:
5554 Lsand_sandstone_1(x, y);
5557 case Xsand_sandstone_2:
5558 Lsand_sandstone_2(x, y);
5561 case Xsand_sandstone_3:
5562 Lsand_sandstone_3(x, y);
5565 case Xsand_sandstone_4:
5566 Lsand_sandstone_4(x, y);
5569 /* --------------------------------------------------------------------- */
5575 /* --------------------------------------------------------------------- */
5581 /* --------------------------------------------------------------------- */
5587 /* --------------------------------------------------------------------- */
5621 /* --------------------------------------------------------------------- */
5632 Lboom_android(x, y);
5643 /* --------------------------------------------------------------------- */
5646 if (++y < HEIGHT - 1)
5649 cave_cache = Cave[y];
5662 if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
5663 lev.score += score; /* only add a score if someone is alive */
5665 game_em.game_over = TRUE;
5667 RandomEM = random_em;
5672 /* triple buffering */