added support for explosion settings in BD engine to level editor
authorHolger Schemel <info@artsoft.org>
Mon, 25 Mar 2024 15:32:51 +0000 (16:32 +0100)
committerHolger Schemel <info@artsoft.org>
Mon, 25 Mar 2024 15:33:05 +0000 (16:33 +0100)
src/editor.c
src/files.c
src/main.h

index 2e6373968240854e83ee1da1cffd6b55b5256f49..f2b1485e6065f49e90bb512f52b1db2dcf3c811f 100644 (file)
@@ -587,6 +587,12 @@ enum
   GADGET_ID_BD_ROCK_TURNS_TO_ON_IMPACT,
   GADGET_ID_BD_DIAMOND_TURNS_TO_ON_FALLING,
   GADGET_ID_BD_DIAMOND_TURNS_TO_ON_IMPACT,
+  GADGET_ID_BD_FIREFLY_EXPLODES_TO,
+  GADGET_ID_BD_FIREFLY_2_EXPLODES_TO,
+  GADGET_ID_BD_BUTTERFLY_EXPLODES_TO,
+  GADGET_ID_BD_BUTTERFLY_2_EXPLODES_TO,
+  GADGET_ID_BD_STONEFLY_EXPLODES_TO,
+  GADGET_ID_BD_DRAGONFLY_EXPLODES_TO,
   GADGET_ID_START_ELEMENT,
   GADGET_ID_ARTWORK_ELEMENT,
   GADGET_ID_EXPLOSION_ELEMENT,
@@ -1240,6 +1246,12 @@ enum
   ED_DRAWING_ID_BD_ROCK_TURNS_TO_ON_IMPACT,
   ED_DRAWING_ID_BD_DIAMOND_TURNS_TO_ON_FALLING,
   ED_DRAWING_ID_BD_DIAMOND_TURNS_TO_ON_IMPACT,
+  ED_DRAWING_ID_BD_FIREFLY_EXPLODES_TO,
+  ED_DRAWING_ID_BD_FIREFLY_2_EXPLODES_TO,
+  ED_DRAWING_ID_BD_BUTTERFLY_EXPLODES_TO,
+  ED_DRAWING_ID_BD_BUTTERFLY_2_EXPLODES_TO,
+  ED_DRAWING_ID_BD_STONEFLY_EXPLODES_TO,
+  ED_DRAWING_ID_BD_DRAGONFLY_EXPLODES_TO,
   ED_DRAWING_ID_START_ELEMENT,
   ED_DRAWING_ID_ARTWORK_ELEMENT,
   ED_DRAWING_ID_EXPLOSION_ELEMENT,
@@ -4691,6 +4703,54 @@ static struct
     &level.bd_diamond_turns_to_on_impact,      1, 1,
     "Turns to on impact:", NULL, NULL, NULL,   "Changes to this when falling stops"
   },
+  {
+    ED_DRAWING_ID_BD_FIREFLY_EXPLODES_TO,
+    ED_AREA_1X1_SETTINGS_XPOS(0),              ED_AREA_1X1_SETTINGS_YPOS(0),
+    ED_AREA_1X1_SETTINGS_XOFF,                 ED_AREA_1X1_SETTINGS_YOFF,
+    GADGET_ID_BD_FIREFLY_EXPLODES_TO,          GADGET_ID_NONE,
+    &level.bd_firefly_explodes_to,             1, 1,
+    "Explodes to:", NULL, NULL, NULL,          "Changes to this when exploding"
+  },
+  {
+    ED_DRAWING_ID_BD_FIREFLY_2_EXPLODES_TO,
+    ED_AREA_1X1_SETTINGS_XPOS(0),              ED_AREA_1X1_SETTINGS_YPOS(0),
+    ED_AREA_1X1_SETTINGS_XOFF,                 ED_AREA_1X1_SETTINGS_YOFF,
+    GADGET_ID_BD_FIREFLY_2_EXPLODES_TO,                GADGET_ID_NONE,
+    &level.bd_firefly_2_explodes_to,           1, 1,
+    "Explodes to:", NULL, NULL, NULL,          "Changes to this when exploding"
+  },
+  {
+    ED_DRAWING_ID_BD_BUTTERFLY_EXPLODES_TO,
+    ED_AREA_1X1_SETTINGS_XPOS(0),              ED_AREA_1X1_SETTINGS_YPOS(0),
+    ED_AREA_1X1_SETTINGS_XOFF,                 ED_AREA_1X1_SETTINGS_YOFF,
+    GADGET_ID_BD_BUTTERFLY_EXPLODES_TO,                GADGET_ID_NONE,
+    &level.bd_butterfly_explodes_to,           1, 1,
+    "Explodes to:", NULL, NULL, NULL,          "Changes to this when exploding"
+  },
+  {
+    ED_DRAWING_ID_BD_BUTTERFLY_2_EXPLODES_TO,
+    ED_AREA_1X1_SETTINGS_XPOS(0),              ED_AREA_1X1_SETTINGS_YPOS(0),
+    ED_AREA_1X1_SETTINGS_XOFF,                 ED_AREA_1X1_SETTINGS_YOFF,
+    GADGET_ID_BD_BUTTERFLY_2_EXPLODES_TO,      GADGET_ID_NONE,
+    &level.bd_butterfly_2_explodes_to,         1, 1,
+    "Explodes to:", NULL, NULL, NULL,          "Changes to this when exploding"
+  },
+  {
+    ED_DRAWING_ID_BD_STONEFLY_EXPLODES_TO,
+    ED_AREA_1X1_SETTINGS_XPOS(0),              ED_AREA_1X1_SETTINGS_YPOS(0),
+    ED_AREA_1X1_SETTINGS_XOFF,                 ED_AREA_1X1_SETTINGS_YOFF,
+    GADGET_ID_BD_STONEFLY_EXPLODES_TO,         GADGET_ID_NONE,
+    &level.bd_stonefly_explodes_to,            1, 1,
+    "Explodes to:", NULL, NULL, NULL,          "Changes to this when exploding"
+  },
+  {
+    ED_DRAWING_ID_BD_DRAGONFLY_EXPLODES_TO,
+    ED_AREA_1X1_SETTINGS_XPOS(0),              ED_AREA_1X1_SETTINGS_YPOS(0),
+    ED_AREA_1X1_SETTINGS_XOFF,                 ED_AREA_1X1_SETTINGS_YOFF,
+    GADGET_ID_BD_DRAGONFLY_EXPLODES_TO,                GADGET_ID_NONE,
+    &level.bd_dragonfly_explodes_to,           1, 1,
+    "Explodes to:", NULL, NULL, NULL,          "Changes to this when exploding"
+  },
 
   // ---------- level start element -------------------------------------------
 
@@ -11615,6 +11675,12 @@ static boolean checkPropertiesConfig(int element)
       IS_DF_LASER(element) ||
       IS_PLAYER_ELEMENT(element) ||
       IS_BD_PLAYER_ELEMENT(element) ||
+      IS_BD_FIREFLY(properties_element) ||
+      IS_BD_FIREFLY_2(properties_element) ||
+      IS_BD_BUTTERFLY(properties_element) ||
+      IS_BD_BUTTERFLY_2(properties_element) ||
+      IS_BD_STONEFLY(properties_element) ||
+      IS_BD_DRAGONFLY(properties_element) ||
       IS_BD_EXPANDABLE_WALL(properties_element) ||
       IS_BD_EXPANDABLE_STEELWALL(properties_element) ||
       IS_BD_CONVEYOR_BELT(properties_element) ||
@@ -11737,6 +11803,14 @@ static void DrawPropertiesConfig(void)
        level.game_engine_type != GAME_ENGINE_TYPE_BD)
       continue;
 
+    // special case: score for smashing only available in R'n'D game engine
+    if ((IS_BD_FIREFLY(elements_with_counter[i].element) ||
+        IS_BD_BUTTERFLY(elements_with_counter[i].element)) &&
+       (elements_with_counter[i].value == &level.score[SC_BUG] ||
+        elements_with_counter[i].value == &level.score[SC_SPACESHIP]) &&
+       level.game_engine_type == GAME_ENGINE_TYPE_BD)
+      continue;
+
     // special case: some amoeba counters only available in R'n'D game engine
     if (elements_with_counter[i].element == EL_BD_AMOEBA &&
        elements_with_counter[i].value == &level.amoeba_speed &&
@@ -11990,6 +12064,22 @@ static void DrawPropertiesConfig(void)
     MapDrawingArea(ED_DRAWING_ID_BD_DIAMOND_TURNS_TO_ON_IMPACT);
   }
 
+  if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
+  {
+    if (IS_BD_FIREFLY(properties_element))
+      MapDrawingArea(ED_DRAWING_ID_BD_FIREFLY_EXPLODES_TO);
+    else if (IS_BD_FIREFLY_2(properties_element))
+      MapDrawingArea(ED_DRAWING_ID_BD_FIREFLY_2_EXPLODES_TO);
+    else if (IS_BD_BUTTERFLY(properties_element))
+      MapDrawingArea(ED_DRAWING_ID_BD_BUTTERFLY_EXPLODES_TO);
+    else if (IS_BD_BUTTERFLY_2(properties_element))
+      MapDrawingArea(ED_DRAWING_ID_BD_BUTTERFLY_2_EXPLODES_TO);
+    else if (IS_BD_STONEFLY(properties_element))
+      MapDrawingArea(ED_DRAWING_ID_BD_STONEFLY_EXPLODES_TO);
+    else if (IS_BD_DRAGONFLY(properties_element))
+      MapDrawingArea(ED_DRAWING_ID_BD_DRAGONFLY_EXPLODES_TO);
+  }
+
   if (properties_element == EL_BD_MEGA_ROCK ||
       properties_element == EL_BD_SWEET)
   {
@@ -12079,7 +12169,8 @@ static void DrawPropertiesConfig(void)
   if (properties_element == EL_EM_DYNAMITE)
     MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE);
 
-  if (COULD_MOVE_INTO_ACID(properties_element) &&
+  if (level.game_engine_type == GAME_ENGINE_TYPE_RND &&
+      COULD_MOVE_INTO_ACID(properties_element) &&
       !IS_PLAYER_ELEMENT(properties_element) &&
       (!IS_CUSTOM_ELEMENT(properties_element) ||
        edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2))
index 4967317e9c1eb2778da3644d6ab35c2a910b8a27..71c2c52d857b98200f7c427db7daeedfc56ace6a 100644 (file)
@@ -667,6 +667,42 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] =
     &li.bd_diamond_turns_to_on_impact, EL_BD_DIAMOND
   },
 
+  {
+    EL_BD_FIREFLY,                     -1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.bd_firefly_explodes_to,                EL_BD_EXPLODING_1
+  },
+
+  {
+    EL_BD_FIREFLY_2,                   -1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.bd_firefly_2_explodes_to,      EL_BD_EXPLODING_1
+  },
+
+  {
+    EL_BD_BUTTERFLY,                   -1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.bd_butterfly_explodes_to,      EL_BD_DIAMOND_GROWING_1
+  },
+
+  {
+    EL_BD_BUTTERFLY_2,                 -1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.bd_butterfly_2_explodes_to,    EL_BD_DIAMOND_GROWING_1
+  },
+
+  {
+    EL_BD_STONEFLY,                    -1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.bd_stonefly_explodes_to,       EL_BD_ROCK_GROWING_1
+  },
+
+  {
+    EL_BD_DRAGONFLY,                   -1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.bd_dragonfly_explodes_to,      EL_BD_EXPLODING_1
+  },
+
   {
     EL_BD_MAGIC_WALL,                  -1,
     TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(1),
@@ -4286,6 +4322,13 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level)
   cave->diamond_falling_effect         = LEVEL_TO_CAVE(level->bd_diamond_turns_to_on_falling);
   cave->diamond_bouncing_effect                = LEVEL_TO_CAVE(level->bd_diamond_turns_to_on_impact);
 
+  cave->firefly_explode_to             = LEVEL_TO_CAVE(level->bd_firefly_explodes_to);
+  cave->alt_firefly_explode_to         = LEVEL_TO_CAVE(level->bd_firefly_2_explodes_to);
+  cave->butterfly_explode_to           = LEVEL_TO_CAVE(level->bd_butterfly_explodes_to);
+  cave->alt_butterfly_explode_to       = LEVEL_TO_CAVE(level->bd_butterfly_2_explodes_to);
+  cave->stonefly_explode_to            = LEVEL_TO_CAVE(level->bd_stonefly_explodes_to);
+  cave->dragonfly_explode_to           = LEVEL_TO_CAVE(level->bd_dragonfly_explodes_to);
+
   // level name
   strncpy(cave->name, level->name, sizeof(GdString));
   cave->name[sizeof(GdString) - 1] = '\0';
@@ -4435,6 +4478,13 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level)
   level->bd_diamond_turns_to_on_falling        = CAVE_TO_LEVEL(cave->diamond_falling_effect);
   level->bd_diamond_turns_to_on_impact = CAVE_TO_LEVEL(cave->diamond_bouncing_effect);
 
+  level->bd_firefly_explodes_to                = CAVE_TO_LEVEL(cave->firefly_explode_to);
+  level->bd_firefly_2_explodes_to      = CAVE_TO_LEVEL(cave->alt_firefly_explode_to);
+  level->bd_butterfly_explodes_to      = CAVE_TO_LEVEL(cave->butterfly_explode_to);
+  level->bd_butterfly_2_explodes_to    = CAVE_TO_LEVEL(cave->alt_butterfly_explode_to);
+  level->bd_stonefly_explodes_to       = CAVE_TO_LEVEL(cave->stonefly_explode_to);
+  level->bd_dragonfly_explodes_to      = CAVE_TO_LEVEL(cave->dragonfly_explode_to);
+
   // level name
   char *cave_name = getStringPrint("%s / %d", cave->name, bd_level_nr + 1);
 
index f9624fb872cb31f2a1878c59a63b6a0a01556d77..e0dcb0ec5f333d00f356d0957a7226cf9e0a0139 100644 (file)
                                         (e) == EL_BD_PLAYER_GLUED ||           \
                                         (e) == EL_BD_PLAYER_STIRRING)
 
+#define IS_BD_FIREFLY(e)               ((e) == EL_BD_FIREFLY ||                \
+                                        (e) == EL_BD_FIREFLY_RIGHT ||          \
+                                        (e) == EL_BD_FIREFLY_UP ||             \
+                                        (e) == EL_BD_FIREFLY_LEFT ||           \
+                                        (e) == EL_BD_FIREFLY_DOWN)
+
+#define IS_BD_FIREFLY_2(e)             ((e) == EL_BD_FIREFLY_2 ||              \
+                                        (e) == EL_BD_FIREFLY_2_RIGHT ||        \
+                                        (e) == EL_BD_FIREFLY_2_UP ||           \
+                                        (e) == EL_BD_FIREFLY_2_LEFT ||         \
+                                        (e) == EL_BD_FIREFLY_2_DOWN)
+
+#define IS_BD_BUTTERFLY(e)             ((e) == EL_BD_BUTTERFLY ||              \
+                                        (e) == EL_BD_BUTTERFLY_RIGHT ||        \
+                                        (e) == EL_BD_BUTTERFLY_UP ||           \
+                                        (e) == EL_BD_BUTTERFLY_LEFT ||         \
+                                        (e) == EL_BD_BUTTERFLY_DOWN)
+
+#define IS_BD_BUTTERFLY_2(e)           ((e) == EL_BD_BUTTERFLY_2 ||            \
+                                        (e) == EL_BD_BUTTERFLY_2_RIGHT ||      \
+                                        (e) == EL_BD_BUTTERFLY_2_UP ||         \
+                                        (e) == EL_BD_BUTTERFLY_2_LEFT ||       \
+                                        (e) == EL_BD_BUTTERFLY_2_DOWN)
+
+#define IS_BD_STONEFLY(e)              ((e) == EL_BD_STONEFLY ||               \
+                                        (e) == EL_BD_STONEFLY_RIGHT ||         \
+                                        (e) == EL_BD_STONEFLY_UP ||            \
+                                        (e) == EL_BD_STONEFLY_LEFT ||          \
+                                        (e) == EL_BD_STONEFLY_DOWN)
+
+#define IS_BD_DRAGONFLY(e)             ((e) == EL_BD_DRAGONFLY ||              \
+                                        (e) == EL_BD_DRAGONFLY_RIGHT ||                \
+                                        (e) == EL_BD_DRAGONFLY_UP ||           \
+                                        (e) == EL_BD_DRAGONFLY_LEFT ||         \
+                                        (e) == EL_BD_DRAGONFLY_DOWN)
+
 #define IS_BD_BITER(e)                 ((e) == EL_BD_BITER ||                  \
                                         (e) == EL_BD_BITER_RIGHT ||            \
                                         (e) == EL_BD_BITER_UP ||               \
@@ -3694,6 +3730,12 @@ struct LevelInfo
   int bd_rock_turns_to_on_impact;      // BD rock changes to specified element on impact
   int bd_diamond_turns_to_on_falling;  // BD diamond changes to specified element when falling
   int bd_diamond_turns_to_on_impact;   // BD diamond changes to specified element on impact
+  int bd_firefly_explodes_to;          // BD firefly explodes to specified element
+  int bd_firefly_2_explodes_to;                // BD firefly 2 explodes to specified element
+  int bd_butterfly_explodes_to;                // BD butterfly explodes to specified element
+  int bd_butterfly_2_explodes_to;      // BD butterfly 2 explodes to specified element
+  int bd_stonefly_explodes_to;         // BD stonefly explodes to specified element
+  int bd_dragonfly_explodes_to;                // BD dragonfly explodes to specified element
 
   boolean em_slippery_gems;            // EM style "gems slip from wall" behaviour
   boolean em_explodes_by_fire;         // EM style chain explosion behaviour