added support for biter settings in BD engine to level editor
authorHolger Schemel <info@artsoft.org>
Wed, 20 Mar 2024 23:14:20 +0000 (00:14 +0100)
committerHolger Schemel <info@artsoft.org>
Wed, 20 Mar 2024 23:14:20 +0000 (00:14 +0100)
src/editor.c
src/files.c
src/init.c
src/main.h

index 2837433467cc8e95e2005bfa87e06a5fd6f496a0..4411b1996cc7a8f802395696869bf2f82558ab33 100644 (file)
@@ -565,6 +565,7 @@ enum
   GADGET_ID_BD_AMOEBA_2_CONTENT_LOOKS_LIKE,
   GADGET_ID_BD_ACID_EATS_ELEMENT,
   GADGET_ID_BD_ACID_TURNS_TO_ELEMENT,
+  GADGET_ID_BD_BITER_EATS_ELEMENT,
   GADGET_ID_START_ELEMENT,
   GADGET_ID_ARTWORK_ELEMENT,
   GADGET_ID_EXPLOSION_ELEMENT,
@@ -1176,6 +1177,7 @@ enum
   ED_DRAWING_ID_BD_AMOEBA_2_CONTENT_LOOKS_LIKE,
   ED_DRAWING_ID_BD_ACID_EATS_ELEMENT,
   ED_DRAWING_ID_BD_ACID_TURNS_TO_ELEMENT,
+  ED_DRAWING_ID_BD_BITER_EATS_ELEMENT,
   ED_DRAWING_ID_START_ELEMENT,
   ED_DRAWING_ID_ARTWORK_ELEMENT,
   ED_DRAWING_ID_EXPLOSION_ELEMENT,
@@ -4357,6 +4359,14 @@ static struct
     &level.bd_acid_turns_to_element,   1, 1,
     "Can leave behind:", NULL, NULL, NULL,     "Turns to this element after spreading"
   },
+  {
+    ED_DRAWING_ID_BD_BITER_EATS_ELEMENT,
+    ED_AREA_1X1_SETTINGS_XPOS(0),      ED_AREA_1X1_SETTINGS_YPOS(2),
+    ED_AREA_1X1_SETTINGS_XOFF,         ED_AREA_1X1_SETTINGS_YOFF,
+    GADGET_ID_BD_BITER_EATS_ELEMENT,   GADGET_ID_NONE,
+    &level.bd_biter_eats_element,      1, 1,
+    "Can eat:", NULL, NULL, NULL,      "Eats this element when moving"
+  },
 
   // ---------- level start element -------------------------------------------
 
@@ -10876,6 +10886,7 @@ static void DrawPropertiesInfo(void)
 #define TEXT_PERMEABILITY_BITS "slime permeability bits"
 #define TEXT_RANDOM_SEED       "slime random number seed"
 #define TEXT_ACID_SPREAD_RATE  "Spread rate (percent)"
+#define TEXT_BITER_MOVE_DELAY  "Move delay (BD frames)"
 
 static struct
 {
@@ -11000,6 +11011,16 @@ static struct
                                -1, 65535                                                       },
   { EL_BD_ACID,                        &level.bd_acid_spread_rate,             TEXT_ACID_SPREAD_RATE,
                                0, 100                                                          },
+  { EL_BD_BITER,               &level.bd_biter_move_delay,             TEXT_BITER_MOVE_DELAY,
+                               0, 3                                                            },
+  { EL_BD_BITER_RIGHT,         &level.bd_biter_move_delay,             TEXT_BITER_MOVE_DELAY,
+                               0, 3                                                            },
+  { EL_BD_BITER_UP,            &level.bd_biter_move_delay,             TEXT_BITER_MOVE_DELAY,
+                               0, 3                                                            },
+  { EL_BD_BITER_LEFT,          &level.bd_biter_move_delay,             TEXT_BITER_MOVE_DELAY,
+                               0, 3                                                            },
+  { EL_BD_BITER_DOWN,          &level.bd_biter_move_delay,             TEXT_BITER_MOVE_DELAY,
+                               0, 3                                                            },
   { EL_EXTRA_TIME,             &level.extra_time,                      TEXT_TIME_BONUS         },
   { EL_TIME_ORB_FULL,          &level.time_orb_time,                   TEXT_TIME_BONUS         },
   { EL_GAME_OF_LIFE,           &level.game_of_life[0],                 TEXT_GAME_OF_LIFE_1,0,8 },
@@ -11238,6 +11259,10 @@ static void DrawPropertiesConfig(void)
       MapDrawingArea(ED_DRAWING_ID_BD_ACID_EATS_ELEMENT);
       MapDrawingArea(ED_DRAWING_ID_BD_ACID_TURNS_TO_ELEMENT);
     }
+    else if (IS_BD_BITER(properties_element))
+    {
+      MapDrawingArea(ED_DRAWING_ID_BD_BITER_EATS_ELEMENT);
+    }
     else if (properties_element == EL_YAMYAM ||
             properties_element == EL_YAMYAM_LEFT ||
             properties_element == EL_YAMYAM_RIGHT ||
index 1f1bd843d166f5d3f7a7ca1aa97ed9242471ffa6..3f2f69dd4aac97e027504c46031a45d7fb0b76d9 100644 (file)
@@ -725,6 +725,17 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] =
     &li.bd_acid_turns_to_element,      EL_EMPTY
   },
 
+  {
+    EL_BD_BITER,                       -1,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(1),
+    &li.bd_biter_move_delay,           0
+  },
+  {
+    EL_BD_BITER,                       -1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.bd_biter_eats_element,         EL_BD_DIAMOND
+  },
+
   // (the following values are related to various game elements)
 
   {
@@ -4015,6 +4026,9 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level)
   cave->acid_spread_ratio              = level->bd_acid_spread_rate * 10000;
   cave->acid_turns_to                  = map_element_RND_to_BD(level->bd_acid_turns_to_element);
 
+  cave->biter_delay_frame              = level->bd_biter_move_delay;
+  cave->biter_eat                      = map_element_RND_to_BD(level->bd_biter_eats_element);
+
   // level name
   strncpy(cave->name, level->name, sizeof(GdString));
   cave->name[sizeof(GdString) - 1] = '\0';
@@ -4109,6 +4123,9 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level)
   level->bd_acid_spread_rate           = cave->acid_spread_ratio / 10000;
   level->bd_acid_turns_to_element      = map_element_BD_to_RND(cave->acid_turns_to);
 
+  level->bd_biter_move_delay           = cave->biter_delay_frame;
+  level->bd_biter_eats_element         = map_element_BD_to_RND(cave->biter_eat);
+
   // level name
   char *cave_name = getStringPrint("%s / %d", cave->name, bd_level_nr + 1);
 
index 340a00db3ea9e44a170905b3a05d39e608fe6219..ba509b7ba3f09310422674e8c4709c6fd5c70c10 100644 (file)
@@ -4280,6 +4280,11 @@ void InitElementPropertiesStatic(void)
     EL_BD_AMOEBA,
     EL_BD_AMOEBA_2,
     EL_BD_ACID,
+    EL_BD_BITER,
+    EL_BD_BITER_RIGHT,
+    EL_BD_BITER_UP,
+    EL_BD_BITER_LEFT,
+    EL_BD_BITER_DOWN,
     EL_EMC_MAGIC_BALL,
     EL_EMC_ANDROID,
     EL_MM_GRAY_BALL,
index f65f53c2cd1c3b4020063c8f9949a8d39e58380e..cf694a786359b81480fb9111407055a856b702a2 100644 (file)
                                         (e) == EL_BD_PLAYER_GLUED ||           \
                                         (e) == EL_BD_PLAYER_STIRRING)
 
+#define IS_BD_BITER(e)                 ((e) == EL_BD_BITER ||                  \
+                                        (e) == EL_BD_BITER_RIGHT ||            \
+                                        (e) == EL_BD_BITER_UP ||               \
+                                        (e) == EL_BD_BITER_LEFT ||             \
+                                        (e) == EL_BD_BITER_DOWN)
+
 #define IS_SOKOBAN_OBJECT_OR_FIELD(e)  ((e) == EL_SOKOBAN_OBJECT ||            \
                                         (e) == EL_SOKOBAN_FIELD_EMPTY ||       \
                                         (e) == EL_SOKOBAN_FIELD_FULL)
@@ -3531,6 +3537,8 @@ struct LevelInfo
   int bd_acid_eats_element;            // BD acid eats this game element when spreading
   int bd_acid_spread_rate;             // BD acid probability of spreading (in percent)
   int bd_acid_turns_to_element;                // BD acid target element after spreading
+  int bd_biter_move_delay;             // BD biter delay between movements (in BD frames)
+  int bd_biter_eats_element;           // BD biter eats this game element when moving
 
   boolean em_slippery_gems;            // EM style "gems slip from wall" behaviour
   boolean em_explodes_by_fire;         // EM style chain explosion behaviour