extended support for rock/diamond settings in BD engine to level editor
authorHolger Schemel <info@artsoft.org>
Mon, 25 Mar 2024 14:33:38 +0000 (15:33 +0100)
committerHolger Schemel <info@artsoft.org>
Mon, 25 Mar 2024 14:41:22 +0000 (15:41 +0100)
src/editor.c
src/files.c
src/main.h

index afd58ff71e95ae4a7c840d67a832edb98cb34842..2e6373968240854e83ee1da1cffd6b55b5256f49 100644 (file)
@@ -583,6 +583,10 @@ enum
   GADGET_ID_BD_NUT_CONTENT,
   GADGET_ID_BD_EXPANDING_WALL_LOOKS_LIKE,
   GADGET_ID_BD_SAND_LOOKS_LIKE,
+  GADGET_ID_BD_ROCK_TURNS_TO_ON_FALLING,
+  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_START_ELEMENT,
   GADGET_ID_ARTWORK_ELEMENT,
   GADGET_ID_EXPLOSION_ELEMENT,
@@ -1232,6 +1236,10 @@ enum
   ED_DRAWING_ID_BD_NUT_CONTENT,
   ED_DRAWING_ID_BD_EXPANDING_WALL_LOOKS_LIKE,
   ED_DRAWING_ID_BD_SAND_LOOKS_LIKE,
+  ED_DRAWING_ID_BD_ROCK_TURNS_TO_ON_FALLING,
+  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_START_ELEMENT,
   ED_DRAWING_ID_ARTWORK_ELEMENT,
   ED_DRAWING_ID_EXPLOSION_ELEMENT,
@@ -4651,6 +4659,38 @@ static struct
     &level.bd_sand_looks_like,                 1, 1,
     "Use graphic of element:", NULL, NULL, NULL, "Sand looks like this element"
   },
+  {
+    ED_DRAWING_ID_BD_ROCK_TURNS_TO_ON_FALLING,
+    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_ROCK_TURNS_TO_ON_FALLING,     GADGET_ID_NONE,
+    &level.bd_rock_turns_to_on_falling,                1, 1,
+    "Turns to when falling:", NULL, NULL, NULL,        "Changes to this when falling starts"
+  },
+  {
+    ED_DRAWING_ID_BD_ROCK_TURNS_TO_ON_IMPACT,
+    ED_AREA_1X1_SETTINGS_XPOS(0),              ED_AREA_1X1_SETTINGS_YPOS(3),
+    ED_AREA_1X1_SETTINGS_XOFF,                 ED_AREA_1X1_SETTINGS_YOFF,
+    GADGET_ID_BD_ROCK_TURNS_TO_ON_IMPACT,      GADGET_ID_NONE,
+    &level.bd_rock_turns_to_on_impact,         1, 1,
+    "Turns to on impact:", NULL, NULL, NULL,   "Changes to this when falling stops"
+  },
+  {
+    ED_DRAWING_ID_BD_DIAMOND_TURNS_TO_ON_FALLING,
+    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_DIAMOND_TURNS_TO_ON_FALLING,  GADGET_ID_NONE,
+    &level.bd_diamond_turns_to_on_falling,     1, 1,
+    "Turns to when falling:", NULL, NULL, NULL,        "Changes to this when falling starts"
+  },
+  {
+    ED_DRAWING_ID_BD_DIAMOND_TURNS_TO_ON_IMPACT,
+    ED_AREA_1X1_SETTINGS_XPOS(0),              ED_AREA_1X1_SETTINGS_YPOS(3),
+    ED_AREA_1X1_SETTINGS_XOFF,                 ED_AREA_1X1_SETTINGS_YOFF,
+    GADGET_ID_BD_DIAMOND_TURNS_TO_ON_IMPACT,   GADGET_ID_NONE,
+    &level.bd_diamond_turns_to_on_impact,      1, 1,
+    "Turns to on impact:", NULL, NULL, NULL,   "Changes to this when falling stops"
+  },
 
   // ---------- level start element -------------------------------------------
 
@@ -11939,6 +11979,15 @@ static void DrawPropertiesConfig(void)
 
     MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB);
     MapCounterButtons(ED_COUNTER_ID_BD_PUSHING_PROB_WITH_SWEET);
+
+    MapDrawingArea(ED_DRAWING_ID_BD_ROCK_TURNS_TO_ON_FALLING);
+    MapDrawingArea(ED_DRAWING_ID_BD_ROCK_TURNS_TO_ON_IMPACT);
+  }
+
+  if (properties_element == EL_BD_DIAMOND && level.game_engine_type == GAME_ENGINE_TYPE_BD)
+  {
+    MapDrawingArea(ED_DRAWING_ID_BD_DIAMOND_TURNS_TO_ON_FALLING);
+    MapDrawingArea(ED_DRAWING_ID_BD_DIAMOND_TURNS_TO_ON_IMPACT);
   }
 
   if (properties_element == EL_BD_MEGA_ROCK ||
index 92dfbcea9b7ebc18830aa2628c37e3574a3ab752..67f3f3e1bb55a4f5f110975b00b2168049d9ac43 100644 (file)
@@ -634,11 +634,32 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] =
     &li.bd_snap_element,               EL_EMPTY
   },
 
+  {
+    EL_BD_ROCK,                                -1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.bd_rock_turns_to_on_falling,   EL_BD_ROCK_FALLING
+  },
+  {
+    EL_BD_ROCK,                                -1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(2),
+    &li.bd_rock_turns_to_on_impact,    EL_BD_ROCK
+  },
+
   {
     EL_BD_DIAMOND,                     -1,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
     &li.score[SC_DIAMOND_EXTRA],       20
   },
+  {
+    EL_BD_DIAMOND,                     -1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(2),
+    &li.bd_diamond_turns_to_on_falling,        EL_BD_DIAMOND_FALLING
+  },
+  {
+    EL_BD_DIAMOND,                     -1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(3),
+    &li.bd_diamond_turns_to_on_impact, EL_BD_DIAMOND
+  },
 
   {
     EL_BD_MAGIC_WALL,                  -1,
@@ -4260,6 +4281,11 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level)
   cave->gravity_change_time            = level->bd_gravity_switch_delay;
   cave->gravity_affects_all            = level->bd_gravity_affects_all;
 
+  cave->stone_falling_effect           = LEVEL_TO_CAVE(level->bd_rock_turns_to_on_falling);
+  cave->stone_bouncing_effect          = LEVEL_TO_CAVE(level->bd_rock_turns_to_on_impact);
+  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);
+
   // level name
   strncpy(cave->name, level->name, sizeof(GdString));
   cave->name[sizeof(GdString) - 1] = '\0';
@@ -4404,6 +4430,11 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level)
   level->bd_gravity_switch_delay       = cave->gravity_change_time;
   level->bd_gravity_affects_all                = cave->gravity_affects_all;
 
+  level->bd_rock_turns_to_on_falling   = CAVE_TO_LEVEL(cave->stone_falling_effect);
+  level->bd_rock_turns_to_on_impact    = CAVE_TO_LEVEL(cave->stone_bouncing_effect);
+  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 name
   char *cave_name = getStringPrint("%s / %d", cave->name, bd_level_nr + 1);
 
index 0a5f1471e5790d1aa7331a2dbe26f2a2d7ebcc13..f9624fb872cb31f2a1878c59a63b6a0a01556d77 100644 (file)
@@ -3690,6 +3690,10 @@ struct LevelInfo
   boolean bd_gravity_switch_active;    // BD engine gravity switch starts in active state
   int bd_gravity_switch_delay;         // BD engine gravity change delay for switch (in seconds)
   boolean bd_gravity_affects_all;      // BD engine gravity affects all falling objects
+  int bd_rock_turns_to_on_falling;     // BD rock changes to specified element when falling
+  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
 
   boolean em_slippery_gems;            // EM style "gems slip from wall" behaviour
   boolean em_explodes_by_fire;         // EM style chain explosion behaviour