changed name of game element in EM engine
[rocksndiamonds.git] / src / game_em / logic.c
index ae3a9541517d078149f94306388afc8ebca175a9..ffb4d8765a381c691296566aea3396d70d83e5b9 100644 (file)
@@ -9,6 +9,8 @@
 
 
 #define SPRING_ROLL    /* spring rolling off round things continues to roll */
+#define ACID_ROLL      /* rolling objects go into acid rather than remove it */
+
 #define USE_CHANGED_ACID_STUFF
 
 #define RANDOM_RAW     (seed = seed << 31 | seed >> 1)
@@ -113,7 +115,7 @@ static void Lboom_generic(int x, int y, int element, int element_middle)
 
 static void Lboom_bug(int x, int y, int by_element)
 {
-  next[x][y] = Znormal;
+  next[x][y] = Zbug;
 
   Lboom_generic(x, y, Xemerald, Xdiamond);
 
@@ -124,7 +126,7 @@ static void Lboom_bug(int x, int y, int by_element)
 
 static void Lboom_tank(int x, int y, int by_element)
 {
-  next[x][y] = Znormal;
+  next[x][y] = Ztank;
 
   Lboom_generic(x, y, Xblank, Xblank);
 
@@ -135,7 +137,7 @@ static void Lboom_tank(int x, int y, int by_element)
 
 static void Lboom_eater(int x, int y, int by_element)
 {
-  next[x][y] = Znormal;
+  next[x][y] = Zeater;
 
   boom[x-1][y-1] = lev.eater_array[lev.eater_pos][0];
   boom[x][y-1]   = lev.eater_array[lev.eater_pos][1];
@@ -301,7 +303,7 @@ static void kill_player(struct PLAYER *ply)
     case Xtank_2_e:
     case Xtank_2_s:
     case Xtank_2_w:
-      cave[x][y-1] = Xboom_bomb;
+      cave[x][y-1] = Xboom_tank;
       break;
   }
 
@@ -326,7 +328,7 @@ static void kill_player(struct PLAYER *ply)
     case Xtank_2_e:
     case Xtank_2_s:
     case Xtank_2_w:
-      cave[x+1][y] = Xboom_bomb;
+      cave[x+1][y] = Xboom_tank;
       break;
   }
 
@@ -351,7 +353,7 @@ static void kill_player(struct PLAYER *ply)
     case Xtank_2_e:
     case Xtank_2_s:
     case Xtank_2_w:
-      cave[x][y+1] = Xboom_bomb;
+      cave[x][y+1] = Xboom_tank;
       break;
   }
 
@@ -376,7 +378,7 @@ static void kill_player(struct PLAYER *ply)
     case Xtank_2_e:
     case Xtank_2_s:
     case Xtank_2_w:
-      cave[x-1][y] = Xboom_bomb;
+      cave[x-1][y] = Xboom_tank;
       break;
   }
 
@@ -1311,7 +1313,8 @@ static void check_player(struct PLAYER *ply)
       ply->dynamite_cnt = 0;
     }
 
-    RandomEM += 7;     /* be a bit more random if the player doesn't move */
+    /* be a bit more random if the player doesn't move */
+    game_em.random += 7;
 
     return;
   }
@@ -5563,302 +5566,482 @@ static void Lspring_fall(int x, int y)
 
 static void Lpush_emerald_e(int x, int y)
 {
+  cave[x][y] = Yemerald_eB;
+  next[x][y] = Xblank;
+
   switch (cave[x+1][y])
   {
-    case Zplayer:
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
-      cave[x][y] = Xemerald;
-      next[x][y] = Xemerald;
       return;
 
-    default:
-      cave[x][y] = Yemerald_eB;
-      next[x][y] = Xblank;
-      cave[x+1][y] = Yemerald_e;
-      next[x+1][y] = Xemerald_pause;
+#ifdef ACID_ROLL
+    case Xacid_1:
+    case Xacid_2:
+    case Xacid_3:
+    case Xacid_4:
+    case Xacid_5:
+    case Xacid_6:
+    case Xacid_7:
+    case Xacid_8:
+      if (cave[x+2][y-1] == Xblank)
+       cave[x+2][y-1] = Xsplash_e;
+      if (cave[x][y-1] == Xblank)
+       cave[x][y-1] = Xsplash_w;
+      play_element_sound(x, y, SOUND_acid, Xacid_1);
       return;
+#endif
   }
+
+  cave[x+1][y] = Yemerald_e;
+  next[x+1][y] = Xemerald_pause;
 }
 
 static void Lpush_emerald_w(int x, int y)
 {
+  cave[x][y] = Yemerald_wB;
+  next[x][y] = Xblank;
+
   switch (cave[x-1][y])
   {
-    case Zplayer:
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
-      cave[x][y] = Xemerald;
-      next[x][y] = Xemerald;
       return;
 
-    default:
-      cave[x][y] = Yemerald_wB;
-      next[x][y] = Xblank;
-      cave[x-1][y] = Yemerald_w;
-      next[x-1][y] = Xemerald_pause;
+#ifdef ACID_ROLL
+    case Xacid_1:
+    case Xacid_2:
+    case Xacid_3:
+    case Xacid_4:
+    case Xacid_5:
+    case Xacid_6:
+    case Xacid_7:
+    case Xacid_8:
+      if (cave[x][y-1] == Xblank)
+       cave[x][y-1] = Xsplash_e;
+      if (cave[x-2][y-1] == Xblank)
+       cave[x-2][y-1] = Xsplash_w;
+      play_element_sound(x, y, SOUND_acid, Xacid_1);
       return;
+#endif
   }
+
+  cave[x-1][y] = Yemerald_w;
+  next[x-1][y] = Xemerald_pause;
 }
 
 static void Lpush_diamond_e(int x, int y)
 {
+  cave[x][y] = Ydiamond_eB;
+  next[x][y] = Xblank;
+
   switch (cave[x+1][y])
   {
-    case Zplayer:
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
-      cave[x][y] = Xdiamond;
-      next[x][y] = Xdiamond;
       return;
 
-    default:
-      cave[x][y] = Ydiamond_eB;
-      next[x][y] = Xblank;
-      cave[x+1][y] = Ydiamond_e;
-      next[x+1][y] = Xdiamond_pause;
+#ifdef ACID_ROLL
+    case Xacid_1:
+    case Xacid_2:
+    case Xacid_3:
+    case Xacid_4:
+    case Xacid_5:
+    case Xacid_6:
+    case Xacid_7:
+    case Xacid_8:
+      if (cave[x+2][y-1] == Xblank)
+       cave[x+2][y-1] = Xsplash_e;
+      if (cave[x][y-1] == Xblank)
+       cave[x][y-1] = Xsplash_w;
+      play_element_sound(x, y, SOUND_acid, Xacid_1);
       return;
+#endif
   }
+
+  cave[x+1][y] = Ydiamond_e;
+  next[x+1][y] = Xdiamond_pause;
 }
 
 static void Lpush_diamond_w(int x, int y)
 {
+  cave[x][y] = Ydiamond_wB;
+  next[x][y] = Xblank;
+
   switch (cave[x-1][y])
   {
-    case Zplayer:
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
-      cave[x][y] = Xdiamond;
-      next[x][y] = Xdiamond;
       return;
 
-    default:
-      cave[x][y] = Ydiamond_wB;
-      next[x][y] = Xblank;
-      cave[x-1][y] = Ydiamond_w;
-      next[x-1][y] = Xdiamond_pause;
+#ifdef ACID_ROLL
+    case Xacid_1:
+    case Xacid_2:
+    case Xacid_3:
+    case Xacid_4:
+    case Xacid_5:
+    case Xacid_6:
+    case Xacid_7:
+    case Xacid_8:
+      if (cave[x][y-1] == Xblank)
+       cave[x][y-1] = Xsplash_e;
+      if (cave[x-2][y-1] == Xblank)
+       cave[x-2][y-1] = Xsplash_w;
+      play_element_sound(x, y, SOUND_acid, Xacid_1);
       return;
+#endif
   }
+
+  cave[x-1][y] = Ydiamond_w;
+  next[x-1][y] = Xdiamond_pause;
 }
 
 static void Lpush_stone_e(int x, int y)
 {
+  cave[x][y] = Ystone_eB;
+  next[x][y] = Xblank;
+
   switch (cave[x+1][y])
   {
-    case Zplayer:
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
-      cave[x][y] = Xstone;
-      next[x][y] = Xstone;
       return;
 
-    default:
-      cave[x][y] = Ystone_eB;
-      next[x][y] = Xblank;
-      cave[x+1][y] = Ystone_e;
-      next[x+1][y] = Xstone_pause;
+#ifdef ACID_ROLL
+    case Xacid_1:
+    case Xacid_2:
+    case Xacid_3:
+    case Xacid_4:
+    case Xacid_5:
+    case Xacid_6:
+    case Xacid_7:
+    case Xacid_8:
+      if (cave[x+2][y-1] == Xblank)
+       cave[x+2][y-1] = Xsplash_e;
+      if (cave[x][y-1] == Xblank)
+       cave[x][y-1] = Xsplash_w;
+      play_element_sound(x, y, SOUND_acid, Xacid_1);
       return;
+#endif
   }
+
+  cave[x+1][y] = Ystone_e;
+  next[x+1][y] = Xstone_pause;
 }
 
 static void Lpush_stone_w(int x, int y)
 {
+  cave[x][y] = Ystone_wB;
+  next[x][y] = Xblank;
+
   switch (cave[x-1][y])
   {
-    case Zplayer:
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
-      cave[x][y] = Xstone;
-      next[x][y] = Xstone;
       return;
 
-    default:
-      cave[x][y] = Ystone_wB;
-      next[x][y] = Xblank;
-      cave[x-1][y] = Ystone_w;
-      next[x-1][y] = Xstone_pause;
+#ifdef ACID_ROLL
+    case Xacid_1:
+    case Xacid_2:
+    case Xacid_3:
+    case Xacid_4:
+    case Xacid_5:
+    case Xacid_6:
+    case Xacid_7:
+    case Xacid_8:
+      if (cave[x][y-1] == Xblank)
+       cave[x][y-1] = Xsplash_e;
+      if (cave[x-2][y-1] == Xblank)
+       cave[x-2][y-1] = Xsplash_w;
+      play_element_sound(x, y, SOUND_acid, Xacid_1);
       return;
+#endif
   }
+
+  cave[x-1][y] = Ystone_w;
+  next[x-1][y] = Xstone_pause;
 }
 
 static void Lpush_bomb_e(int x, int y)
 {
+  cave[x][y] = Ybomb_eB;
+  next[x][y] = Xblank;
+
   switch (cave[x+1][y])
   {
-    case Zplayer:
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
-      cave[x][y] = Xbomb;
-      next[x][y] = Xbomb;
       return;
 
-    default:
-      cave[x][y] = Ybomb_eB;
-      next[x][y] = Xblank;
-      cave[x+1][y] = Ybomb_e;
-      next[x+1][y] = Xbomb_pause;
+#ifdef ACID_ROLL
+    case Xacid_1:
+    case Xacid_2:
+    case Xacid_3:
+    case Xacid_4:
+    case Xacid_5:
+    case Xacid_6:
+    case Xacid_7:
+    case Xacid_8:
+      if (cave[x+2][y-1] == Xblank)
+       cave[x+2][y-1] = Xsplash_e;
+      if (cave[x][y-1] == Xblank)
+       cave[x][y-1] = Xsplash_w;
+      play_element_sound(x, y, SOUND_acid, Xacid_1);
       return;
+#endif
   }
+
+  cave[x+1][y] = Ybomb_e;
+  next[x+1][y] = Xbomb_pause;
 }
 
 static void Lpush_bomb_w(int x, int y)
 {
+  cave[x][y] = Ybomb_wB;
+  next[x][y] = Xblank;
+
   switch (cave[x-1][y])
   {
-    case Zplayer:
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
-      cave[x][y] = Xbomb;
-      next[x][y] = Xbomb;
       return;
 
-    default:
-      cave[x][y] = Ybomb_wB;
-      next[x][y] = Xblank;
-      cave[x-1][y] = Ybomb_w;
-      next[x-1][y] = Xbomb_pause;
+#ifdef ACID_ROLL
+    case Xacid_1:
+    case Xacid_2:
+    case Xacid_3:
+    case Xacid_4:
+    case Xacid_5:
+    case Xacid_6:
+    case Xacid_7:
+    case Xacid_8:
+      if (cave[x][y-1] == Xblank)
+       cave[x][y-1] = Xsplash_e;
+      if (cave[x-2][y-1] == Xblank)
+       cave[x-2][y-1] = Xsplash_w;
+      play_element_sound(x, y, SOUND_acid, Xacid_1);
       return;
+#endif
   }
+
+  cave[x-1][y] = Ybomb_w;
+  next[x-1][y] = Xbomb_pause;
 }
 
 static void Lpush_nut_e(int x, int y)
 {
+  cave[x][y] = Ynut_eB;
+  next[x][y] = Xblank;
+
   switch (cave[x+1][y])
   {
-    case Zplayer:
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
-      cave[x][y] = Xnut;
-      next[x][y] = Xnut;
       return;
 
-    default:
-      cave[x][y] = Ynut_eB;
-      next[x][y] = Xblank;
-      cave[x+1][y] = Ynut_e;
-      next[x+1][y] = Xnut_pause;
+#ifdef ACID_ROLL
+    case Xacid_1:
+    case Xacid_2:
+    case Xacid_3:
+    case Xacid_4:
+    case Xacid_5:
+    case Xacid_6:
+    case Xacid_7:
+    case Xacid_8:
+      if (cave[x+2][y-1] == Xblank)
+       cave[x+2][y-1] = Xsplash_e;
+      if (cave[x][y-1] == Xblank)
+       cave[x][y-1] = Xsplash_w;
+      play_element_sound(x, y, SOUND_acid, Xacid_1);
       return;
+#endif
   }
+
+  cave[x+1][y] = Ynut_e;
+  next[x+1][y] = Xnut_pause;
 }
 
 static void Lpush_nut_w(int x, int y)
 {
+  cave[x][y] = Ynut_wB;
+  next[x][y] = Xblank;
+
   switch (cave[x-1][y])
   {
-    case Zplayer:
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
-      cave[x][y] = Xnut;
-      next[x][y] = Xnut;
       return;
 
-    default:
-      cave[x][y] = Ynut_wB;
-      next[x][y] = Xblank;
-      cave[x-1][y] = Ynut_w;
-      next[x-1][y] = Xnut_pause;
+#ifdef ACID_ROLL
+    case Xacid_1:
+    case Xacid_2:
+    case Xacid_3:
+    case Xacid_4:
+    case Xacid_5:
+    case Xacid_6:
+    case Xacid_7:
+    case Xacid_8:
+      if (cave[x][y-1] == Xblank)
+       cave[x][y-1] = Xsplash_e;
+      if (cave[x-2][y-1] == Xblank)
+       cave[x-2][y-1] = Xsplash_w;
+      play_element_sound(x, y, SOUND_acid, Xacid_1);
       return;
+#endif
   }
+
+  cave[x-1][y] = Ynut_w;
+  next[x-1][y] = Xnut_pause;
 }
 
 static void Lpush_spring_e(int x, int y)
 {
+  cave[x][y] = Yspring_eB;
+  next[x][y] = Xblank;
+
   switch (cave[x+1][y])
   {
-    case Zplayer:
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
-      cave[x][y] = Xspring;
-      next[x][y] = Xspring;
       return;
 
-    default:
-      cave[x][y] = Yspring_eB;
-      next[x][y] = Xblank;
-      cave[x+1][y] = Yspring_e;
-      next[x+1][y] = Xspring_e;
+#ifdef ACID_ROLL
+    case Xacid_1:
+    case Xacid_2:
+    case Xacid_3:
+    case Xacid_4:
+    case Xacid_5:
+    case Xacid_6:
+    case Xacid_7:
+    case Xacid_8:
+      if (cave[x+2][y-1] == Xblank)
+       cave[x+2][y-1] = Xsplash_e;
+      if (cave[x][y-1] == Xblank)
+       cave[x][y-1] = Xsplash_w;
+      play_element_sound(x, y, SOUND_acid, Xacid_1);
       return;
+#endif
   }
+
+  cave[x+1][y] = Yspring_e;
+  next[x+1][y] = Xspring_e;
 }
 
 static void Lpush_spring_w(int x, int y)
 {
+  cave[x][y] = Yspring_wB;
+  next[x][y] = Xblank;
+
   switch (cave[x-1][y])
   {
-    case Zplayer:
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
-      cave[x][y] = Xspring;
-      next[x][y] = Xspring;
       return;
 
-    default:
-      cave[x][y] = Yspring_wB;
-      next[x][y] = Xblank;
-      cave[x-1][y] = Yspring_w;
-      next[x-1][y] = Xspring_w;
+#ifdef ACID_ROLL
+    case Xacid_1:
+    case Xacid_2:
+    case Xacid_3:
+    case Xacid_4:
+    case Xacid_5:
+    case Xacid_6:
+    case Xacid_7:
+    case Xacid_8:
+      if (cave[x][y-1] == Xblank)
+       cave[x][y-1] = Xsplash_e;
+      if (cave[x-2][y-1] == Xblank)
+       cave[x-2][y-1] = Xsplash_w;
+      play_element_sound(x, y, SOUND_acid, Xacid_1);
       return;
+#endif
   }
+
+  cave[x-1][y] = Yspring_w;
+  next[x-1][y] = Xspring_w;
 }
 
 static void Ldynamite_1(int x, int y)
@@ -6628,10 +6811,12 @@ static void Lboom_one(int x, int y, boolean by_dynamite)
   switch (cave[x][y])
   {
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xacid_1:
     case Xacid_2:
@@ -6697,7 +6882,7 @@ static void Lboom_one(int x, int y, boolean by_dynamite)
     case Xbomb:
     case Xbomb_pause:
     case Xbomb_fall:
-      cave[x][y] = Xboom_bomb;
+      cave[x][y] = Xboom_tank;
       return;
 
     default:
@@ -6724,7 +6909,15 @@ static void Lexplode(int x, int y)
 {
   switch (cave[x][y])
   {
-    case Znormal:
+    case Zbug:
+      Lboom_nine(x, y, FALSE);
+      break;
+
+    case Ztank:
+      Lboom_nine(x, y, FALSE);
+      break;
+
+    case Zeater:
       Lboom_nine(x, y, FALSE);
       break;
 
@@ -6919,7 +7112,7 @@ static void handle_tile(int x, int y)
     case Xpause:               Lpause(x, y);                   break;
 
     case Xboom_bug:            Lboom_bug(x, y, Xboom_bug);     break;
-    case Xboom_bomb:           Lboom_tank(x, y, Xboom_bomb);   break;
+    case Xboom_tank:           Lboom_tank(x, y, Xboom_tank);   break;
     case Xboom_android:                Lboom_android(x, y);            break;
     case Xboom_1:              Lboom_1(x, y);                  break;
     case Xboom_2:              Lboom_2(x, y);                  break;
@@ -6965,7 +7158,8 @@ void logic_players(void)
     ply[i].anim = PLY_still;
   }
 
-  start_check_nr = (RandomEM & 128 ? 0 : 1) * 2 + (RandomEM & 256 ? 0 : 1);
+  start_check_nr = ((game_em.random & 128 ? 0 : 1) * 2 +
+                   (game_em.random & 256 ? 0 : 1));
 
   for (i = 0; i < MAX_PLAYERS; i++)
   {
@@ -7002,7 +7196,7 @@ void logic_objects(void)
   next = lev.next;
   boom = lev.boom;
 
-  seed = RandomEM;
+  seed = game_em.random;
   score = 0;
 
   for (y = lev.top; y < lev.bottom; y++)
@@ -7014,7 +7208,7 @@ void logic_objects(void)
   else
     game_em.game_over = TRUE;
 
-  RandomEM = seed;
+  game_em.random = seed;
 
   /* triple buffering */
   void *temp = lev.cave;
@@ -7062,7 +7256,7 @@ void logic_globals(void)
 
   /* grow amoeba */
 
-  random = RandomEM;
+  random = game_em.random;
 
   for (count = lev.amoeba_time; count--;)
   {
@@ -7076,7 +7270,7 @@ void logic_globals(void)
     random = random * 129 + 1;
   }
 
-  RandomEM = random;
+  game_em.random = random;
 
   /* handle explosions */