added support for explosion stage 3 target element to BD engine
authorHolger Schemel <holger.schemel@virtion.de>
Mon, 16 Sep 2024 19:00:53 +0000 (21:00 +0200)
committerHolger Schemel <holger.schemel@virtion.de>
Mon, 16 Sep 2024 19:00:56 +0000 (21:00 +0200)
src/editor.c
src/files.c
src/game_bd/bd_bdcff.c
src/game_bd/bd_c64import.c
src/game_bd/bd_cave.c
src/game_bd/bd_cave.h
src/game_bd/bd_cavedb.c
src/game_bd/bd_caveengine.c
src/main.h

index 3008be7a2c7744667056df42e8e61651931efb64..61a8e408ccbbb734d8131900ffe58af530fd2687 100644 (file)
@@ -658,6 +658,7 @@ enum
   GADGET_ID_BD_BOMB_EXPLOSION_TURNS_TO,
   GADGET_ID_BD_NITRO_EXPLOSION_TURNS_TO,
   GADGET_ID_BD_EXPLOSION_TURNS_TO,
+  GADGET_ID_BD_EXPLOSION_3_TURNS_TO,
   GADGET_ID_START_ELEMENT,
   GADGET_ID_ARTWORK_ELEMENT,
   GADGET_ID_EXPLOSION_ELEMENT,
@@ -1374,6 +1375,7 @@ enum
   ED_DRAWING_ID_BD_BOMB_EXPLOSION_TURNS_TO,
   ED_DRAWING_ID_BD_NITRO_EXPLOSION_TURNS_TO,
   ED_DRAWING_ID_BD_EXPLOSION_TURNS_TO,
+  ED_DRAWING_ID_BD_EXPLOSION_3_TURNS_TO,
   ED_DRAWING_ID_START_ELEMENT,
   ED_DRAWING_ID_ARTWORK_ELEMENT,
   ED_DRAWING_ID_EXPLOSION_ELEMENT,
@@ -5162,6 +5164,14 @@ static struct
     &level.bd_explosion_turns_to,              1, 1,
     "Explosion ends in:", NULL, NULL, NULL,    "Changes to this after explosion"
   },
+  {
+    ED_DRAWING_ID_BD_EXPLOSION_3_TURNS_TO,
+    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_EXPLOSION_3_TURNS_TO,         GADGET_ID_NONE,
+    &level.bd_explosion_3_turns_to,            1, 1,
+    "Explosion (3) ends in:", NULL, NULL, NULL,        "Changes to this after explosion (3)"
+  },
 
   // ---------- level start element -------------------------------------------
 
@@ -12788,11 +12798,13 @@ static void DrawPropertiesConfig(void)
     {
       MapDrawingArea(ED_DRAWING_ID_BD_FIREFLY_1_EXPLODES_TO);
       MapDrawingArea(ED_DRAWING_ID_BD_EXPLOSION_TURNS_TO);
+      MapDrawingArea(ED_DRAWING_ID_BD_EXPLOSION_3_TURNS_TO);
     }
     else if (IS_BDX_FIREFLY_2(properties_element))
     {
       MapDrawingArea(ED_DRAWING_ID_BD_FIREFLY_2_EXPLODES_TO);
       MapDrawingArea(ED_DRAWING_ID_BD_EXPLOSION_TURNS_TO);
+      MapDrawingArea(ED_DRAWING_ID_BD_EXPLOSION_3_TURNS_TO);
     }
     else if (IS_BDX_BUTTERFLY_1(properties_element))
     {
@@ -12812,6 +12824,7 @@ static void DrawPropertiesConfig(void)
     {
       MapDrawingArea(ED_DRAWING_ID_BD_DRAGONFLY_EXPLODES_TO);
       MapDrawingArea(ED_DRAWING_ID_BD_EXPLOSION_TURNS_TO);
+      MapDrawingArea(ED_DRAWING_ID_BD_EXPLOSION_3_TURNS_TO);
     }
     else if (properties_element == EL_BDX_BOMB)
     {
index 2edc3157bcc9bff4ea7ed1ed20d359f727d8af99..9e3c25e59282e3bc637c8b326825478e6e46ac6f 100644 (file)
@@ -762,6 +762,11 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] =
     &li.bd_nitro_explosion_turns_to,   EL_EMPTY
   },
 
+  {
+    EL_BDX_EXPLODING_3,                        -1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.bd_explosion_3_turns_to,       EL_BDX_EXPLODING_4
+  },
   {
     EL_BDX_EXPLODING_5,                        -1,
     TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
@@ -4452,6 +4457,7 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level)
   cave->bomb_explosion_effect          = LEVEL_TO_CAVE(level->bd_bomb_explosion_turns_to);
   cave->nitro_explosion_effect         = LEVEL_TO_CAVE(level->bd_nitro_explosion_turns_to);
   cave->explosion_effect               = LEVEL_TO_CAVE(level->bd_explosion_turns_to);
+  cave->explosion_3_effect             = LEVEL_TO_CAVE(level->bd_explosion_3_turns_to);
 
   cave->colorb                         = level->bd_color_b;
   cave->color0                         = level->bd_color_0;
@@ -4635,6 +4641,7 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level)
   level->bd_bomb_explosion_turns_to    = CAVE_TO_LEVEL(cave->bomb_explosion_effect);
   level->bd_nitro_explosion_turns_to   = CAVE_TO_LEVEL(cave->nitro_explosion_effect);
   level->bd_explosion_turns_to         = CAVE_TO_LEVEL(cave->explosion_effect);
+  level->bd_explosion_3_turns_to       = CAVE_TO_LEVEL(cave->explosion_3_effect);
 
   level->bd_color_b                    = cave->colorb;
   level->bd_color_0                    = cave->color0;
index 1f7f3723372a9644293077fe2ed1eb776a588fbe..1145671441d089fd4346a26b8cb28845f95f8e1e 100644 (file)
@@ -1131,7 +1131,7 @@ boolean gd_caveset_load_from_bdcff(const char *contents)
              cave->stone_bouncing_effect =
                 non_scanned_pair(gd_get_element_from_string(params[1]));
            else if (strcasecmp(params[0], "EXPLOSION3S") == 0)
-             cave->explosion_effect =
+             cave->explosion_3_effect =
                 non_scanned_pair(gd_get_element_from_string(params[1]));
            // falling with one l...
            else if (strcasecmp(params[0], "STARTING_FALING_DIAMOND") == 0)
index 47fea7e1f37abe2aadf6198d41c0ee3f3cb6fce4..a09784762447e83c75eced1f2c10a9439bb0ae33 100644 (file)
@@ -1340,10 +1340,8 @@ static int cave_copy_from_plck(GdCave *cave, const byte *data,
     cave->stone_bouncing_effect = bd1_import(data[0x1ea], 0x1ea);
     cave->diamond_falling_effect = bd1_import(data[0x1eb], 0x1eb);
 
-    // explosions: 0x1e was explosion 5, if this is set to default, we also do not read it,
-    // as in our engine this would cause an O_EXPLODE_5 to stay there.
-    if (data[0x1ec] != 0x1e)
-      cave->explosion_effect = bd1_import(data[0x1ec], 0x1ec);
+    // explosions: 0x1e was explosion 4.
+    cave->explosion_3_effect = bd1_import(data[0x1ec], 0x1ec);
 
     /*
       pointer to element graphic.
index 44f20c40a88d0eb5ad2839eb0a5b7d7a9ddf0a97..fe1cc2d311bbcc1d3436804f5934b9981c28e2cf 100644 (file)
@@ -1790,4 +1790,5 @@ void unscan_cave(GdCave *cave)
   cave->bomb_explosion_effect          = non_scanned_pair(cave->bomb_explosion_effect);
   cave->nitro_explosion_effect         = non_scanned_pair(cave->nitro_explosion_effect);
   cave->explosion_effect               = non_scanned_pair(cave->explosion_effect);
+  cave->explosion_3_effect             = non_scanned_pair(cave->explosion_3_effect);
 }
index 3ba7824b49cc16a608804226b16848c456d3750e..66be782c6dc8e52bee719690116a3013b3a5be90 100644 (file)
@@ -495,6 +495,8 @@ typedef struct _gd_cave
   // effects
   GdElement explosion_effect;           // explosion converts to this element after its last stage.
                                         // diego effect.
+  GdElement explosion_3_effect;         // O_EXPLODE_3 converts to this element
+                                        // diego effect, for compatibility.
   GdElement diamond_birth_effect;       // a diamond birth converts to this element after its last
                                         // stage. diego effect.
   GdElement bomb_explosion_effect;      // bombs explode to this element. diego effect (almost).
index 87ebd47a3b0a460cfabdb5bc5a749e64377f2b44..87347c457deb65e6a9ab6dc19dffcb02ffc9b547 100644 (file)
@@ -2762,6 +2762,11 @@ const GdStructDescriptor gd_cave_properties[] =
     N_("Explosions end in"), CAVE_OFFSET(explosion_effect), 1,
     N_("This element appears in places where an explosion finishes.")
   },
+  {
+    "EXPLOSION3S", GD_TYPE_EFFECT, 0,
+    N_("Explosion stage 3 to"), CAVE_OFFSET(explosion_3_effect), 1,
+    N_("This element appears as the next stage of explosion 3. Not recommended to change. Check explosion effects on the effects page for a better alternative.")
+  },
   {
     "DIAMONDBIRTHEffect", GD_TYPE_EFFECT, 0,
     N_("Diamond births end in"), CAVE_OFFSET(diamond_birth_effect), 1,
@@ -3206,6 +3211,7 @@ GdPropertyDefault gd_cave_defaults_gdash[] =
 
   // cave effects
   { CAVE_OFFSET(explosion_effect),                             O_SPACE                         },
+  { CAVE_OFFSET(explosion_3_effect),                           O_EXPLODE_4                     },
   { CAVE_OFFSET(diamond_birth_effect),                         O_DIAMOND                       },
   { CAVE_OFFSET(bomb_explosion_effect),                                O_BRICK                         },
   { CAVE_OFFSET(nitro_explosion_effect),                       O_SPACE                         },
index 1b8be0431136ac00ac7756ea55624d691763d996..71e8bc5982c6c88e834739af4b5a558b28e2396b 100644 (file)
@@ -3727,6 +3727,10 @@ void gd_cave_iterate(GdCave *cave, GdDirection player_move, boolean player_fire,
          //    S I M P L E   C H A N G I N G;   E X P L O S I O N S
          // ======================================================================================
 
+       case O_EXPLODE_3:
+         store(cave, x, y, cave->explosion_3_effect);
+         break;
+
        case O_EXPLODE_5:
          store(cave, x, y, cave->explosion_effect);
          break;
@@ -3844,7 +3848,7 @@ void gd_cave_iterate(GdCave *cave, GdDirection player_move, boolean player_fire,
        case O_GHOST_EXPL_3:
        case O_EXPLODE_1:
        case O_EXPLODE_2:
-       case O_EXPLODE_3:
+         // O_EXPLODE_3 is "effected"
        case O_EXPLODE_4:
        case O_PRE_CLOCK_1:
        case O_PRE_CLOCK_2:
index 679832f15adc72b5d76dbf9acc082912b3ca1420..8e1d35eaad7eb08a761d486d413c2cb9518dd0f7 100644 (file)
@@ -3887,6 +3887,7 @@ struct LevelInfo
   int bd_bomb_explosion_turns_to;      // BD bomb explosion changes to specified element
   int bd_nitro_explosion_turns_to;     // BD nitro pack explosion changes to specified element
   int bd_explosion_turns_to;           // BD other explosions change to specified element
+  int bd_explosion_3_turns_to;         // BD other explosions change to specified element, stage 3
   int bd_color_b;                      // BD engine C64-style cave color (border)
   int bd_color_0;                      // BD engine C64-style cave color (background)
   int bd_color_1;                      // BD engine C64-style cave color (sand)