added support for slime settings in BD engine to level editor
authorHolger Schemel <info@artsoft.org>
Sun, 17 Mar 2024 22:57:16 +0000 (23:57 +0100)
committerHolger Schemel <info@artsoft.org>
Sun, 17 Mar 2024 22:57:16 +0000 (23:57 +0100)
src/editor.c
src/files.c
src/main.h

index 0a682af53a6409a2b5cbccc7c68e3dd9a48b8258..025de3a70c1fb5d643c6bdeb8d0c7ea55fd83ea6 100644 (file)
@@ -724,6 +724,7 @@ enum
   GADGET_ID_BD_VOODOO_HURT_KILLS_PLAYER,
   GADGET_ID_BD_VOODOO_DIES_BY_ROCK,
   GADGET_ID_BD_VOODOO_VANISH_BY_EXPLOSION,
+  GADGET_ID_BD_SLIME_IS_PREDICTABLE,
   GADGET_ID_ENVELOPE_AUTOWRAP,
   GADGET_ID_ENVELOPE_CENTERED,
   GADGET_ID_MM_LASER_RED,
@@ -1068,6 +1069,7 @@ enum
   ED_CHECKBUTTON_ID_BD_VOODOO_HURT_KILLS_PLAYER,
   ED_CHECKBUTTON_ID_BD_VOODOO_DIES_BY_ROCK,
   ED_CHECKBUTTON_ID_BD_VOODOO_VANISH_BY_EXPLOSION,
+  ED_CHECKBUTTON_ID_BD_SLIME_IS_PREDICTABLE,
   ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
   ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
   ED_CHECKBUTTON_ID_MM_LASER_RED,
@@ -3792,6 +3794,14 @@ static struct
     NULL, NULL,
     "disappears in explosions",                "can be destroyed by explosions"
   },
+  {
+    ED_CHECKBUTTON_ID_BD_SLIME_IS_PREDICTABLE,
+    ED_ELEMENT_SETTINGS_XPOS(0),       ED_ELEMENT_SETTINGS_YPOS(0),
+    GADGET_ID_BD_SLIME_IS_PREDICTABLE, GADGET_ID_NONE,
+    &level.bd_slime_is_predictable,
+    NULL, NULL,
+    "slime is predictable",            "use predictable random numbers"
+  },
   {
     ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
     ED_ELEMENT_SETTINGS_XPOS(0),       ED_ELEMENT_SETTINGS_YPOS(1),
@@ -10841,6 +10851,9 @@ static void DrawPropertiesInfo(void)
 #define TEXT_GAME_OF_LIFE_4    "Max neighbours to create"
 #define TEXT_TIME_BONUS                "Extra time to solve level"
 #define TEXT_TIME_PENALTY      "Time penalty if destroyed"
+#define TEXT_PERMEABILITY_RATE "slime permeability rate"
+#define TEXT_PERMEABILITY_BITS "slime permeability bits"
+#define TEXT_RANDOM_SEED       "slime random number seed"
 
 static struct
 {
@@ -10957,6 +10970,12 @@ static struct
                                -100, 100                                                       },
   { EL_BD_VOODOO_DOLL,         &level.bd_voodoo_penalty_time,          TEXT_TIME_PENALTY,
                                0, 100                                                          },
+  { EL_BD_SLIME,               &level.bd_slime_permeability_rate,      TEXT_PERMEABILITY_RATE,
+                               0, 100                                                          },
+  { EL_BD_SLIME,               &level.bd_slime_permeability_bits_c64,  TEXT_PERMEABILITY_BITS,
+                               0, 255                                                          },
+  { EL_BD_SLIME,               &level.bd_slime_random_seed_c64,        TEXT_RANDOM_SEED,
+                               -1, 65535                                                       },
   { 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 },
@@ -11138,6 +11157,7 @@ static void DrawPropertiesConfig(void)
                               (COULD_MOVE_INTO_ACID(properties_element)    ? 1 : 0) +
                               (MAYBE_DONT_COLLIDE_WITH(properties_element) ? 1 : 0) +
                               (properties_element == EL_BD_VOODOO_DOLL     ? 4 : 0) +
+                              (properties_element == EL_BD_SLIME           ? 1 : 0) +
                               (properties_element == EL_EMC_MAGIC_BALL     ? 2 : 0) +
                               num_element_counters);
 
@@ -11340,6 +11360,11 @@ static void DrawPropertiesConfig(void)
     MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_VOODOO_VANISH_BY_EXPLOSION);
   }
 
+  if (properties_element == EL_BD_SLIME)
+  {
+    MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_SLIME_IS_PREDICTABLE);
+  }
+
   if (properties_element == EL_BD_MAGIC_WALL)
   {
     MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_MAGIC_WALL_WAIT_HATCHING);
index 6bc53e5651a273a4ff3dd59942b232ff053c460b..d51d8f10d1b0bd5312eae65a1f2477b58931cae5 100644 (file)
@@ -683,6 +683,26 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] =
     &li.bd_voodoo_penalty_time,                30
   },
 
+  {
+    EL_BD_SLIME,                       -1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(1),
+    &li.bd_slime_is_predictable,       TRUE
+  },
+  {
+    EL_BD_SLIME,                       -1,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(2),
+    &li.bd_slime_permeability_rate,    100
+  },
+  {
+    EL_BD_SLIME,                       -1,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(3),
+    &li.bd_slime_permeability_bits_c64,        0
+  },
+  {
+    EL_BD_SLIME,                       -1,
+    TYPE_INTEGER,                      CONF_VALUE_32_BIT(1),
+    &li.bd_slime_random_seed_c64,      -1
+  },
 
   // (the following values are related to various game elements)
 
@@ -3963,6 +3983,11 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level)
   cave->amoeba_2_explosion_effect   = map_element_RND_to_BD(level->bd_amoeba_2_content_exploding);
   cave->amoeba_2_looks_like        = map_element_RND_to_BD(level->bd_amoeba_2_content_looks_like);
 
+  cave->slime_predictable              = level->bd_slime_is_predictable;
+  cave->level_slime_permeability[0]    = level->bd_slime_permeability_rate * 10000;
+  cave->level_slime_permeability_c64[0]        = level->bd_slime_permeability_bits_c64;
+  cave->level_slime_seed_c64[0]                = level->bd_slime_random_seed_c64;
+
   // level name
   strncpy(cave->name, level->name, sizeof(GdString));
   cave->name[sizeof(GdString) - 1] = '\0';
@@ -4046,6 +4071,11 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level)
   level->bd_amoeba_2_content_exploding = map_element_BD_to_RND(cave->amoeba_2_explosion_effect);
   level->bd_amoeba_2_content_looks_like        = map_element_BD_to_RND(cave->amoeba_2_looks_like);
 
+  level->bd_slime_is_predictable       = cave->slime_predictable;
+  level->bd_slime_permeability_rate    = cave->level_slime_permeability[0] / 10000;
+  level->bd_slime_permeability_bits_c64        = cave->level_slime_permeability_c64[0];
+  level->bd_slime_random_seed_c64      = cave->level_slime_seed_c64[0];
+
   // level name
   char *cave_name = getStringPrint("%s / %d", cave->name, bd_level_nr + 1);
 
index d650a5f78f3d1dde005523d83b4f251c0b3157dd..96c72b29f9c66cdc28196a59d78c1a1657d29e06 100644 (file)
@@ -3522,6 +3522,10 @@ struct LevelInfo
   boolean bd_voodoo_dies_by_rock;      // BD voodoo doll can be killed by a falling rock
   boolean bd_voodoo_vanish_by_explosion;// BD voodoo doll can be destroyed by explosions
   int bd_voodoo_penalty_time;          // BD engine penalty time when voodoo doll destroyed
+  boolean bd_slime_is_predictable;     // BD slime uses predictable random number generator
+  int bd_slime_permeability_rate;      // BD slime permeability rate for unpredictable slime
+  int bd_slime_permeability_bits_c64;  // BD slime permeability bits for predictable slime
+  int bd_slime_random_seed_c64;                // BD slime random number seed for predictable slime
   boolean em_slippery_gems;            // EM style "gems slip from wall" behaviour
   boolean em_explodes_by_fire;         // EM style chain explosion behaviour
   boolean use_spring_bug;              // for compatibility with old levels