From 5872cb5b5cac159e4e69b6c065f9619a1f106ead Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 16 Sep 2024 21:00:53 +0200 Subject: [PATCH] added support for explosion stage 3 target element to BD engine --- src/editor.c | 13 +++++++++++++ src/files.c | 7 +++++++ src/game_bd/bd_bdcff.c | 2 +- src/game_bd/bd_c64import.c | 6 ++---- src/game_bd/bd_cave.c | 1 + src/game_bd/bd_cave.h | 2 ++ src/game_bd/bd_cavedb.c | 6 ++++++ src/game_bd/bd_caveengine.c | 6 +++++- src/main.h | 1 + 9 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/editor.c b/src/editor.c index 3008be7a..61a8e408 100644 --- a/src/editor.c +++ b/src/editor.c @@ -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) { diff --git a/src/files.c b/src/files.c index 2edc3157..9e3c25e5 100644 --- a/src/files.c +++ b/src/files.c @@ -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; diff --git a/src/game_bd/bd_bdcff.c b/src/game_bd/bd_bdcff.c index 1f7f3723..11456714 100644 --- a/src/game_bd/bd_bdcff.c +++ b/src/game_bd/bd_bdcff.c @@ -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) diff --git a/src/game_bd/bd_c64import.c b/src/game_bd/bd_c64import.c index 47fea7e1..a0978476 100644 --- a/src/game_bd/bd_c64import.c +++ b/src/game_bd/bd_c64import.c @@ -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. diff --git a/src/game_bd/bd_cave.c b/src/game_bd/bd_cave.c index 44f20c40..fe1cc2d3 100644 --- a/src/game_bd/bd_cave.c +++ b/src/game_bd/bd_cave.c @@ -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); } diff --git a/src/game_bd/bd_cave.h b/src/game_bd/bd_cave.h index 3ba7824b..66be782c 100644 --- a/src/game_bd/bd_cave.h +++ b/src/game_bd/bd_cave.h @@ -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). diff --git a/src/game_bd/bd_cavedb.c b/src/game_bd/bd_cavedb.c index 87ebd47a..87347c45 100644 --- a/src/game_bd/bd_cavedb.c +++ b/src/game_bd/bd_cavedb.c @@ -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 }, diff --git a/src/game_bd/bd_caveengine.c b/src/game_bd/bd_caveengine.c index 1b8be043..71e8bc59 100644 --- a/src/game_bd/bd_caveengine.c +++ b/src/game_bd/bd_caveengine.c @@ -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: diff --git a/src/main.h b/src/main.h index 679832f1..8e1d35ea 100644 --- a/src/main.h +++ b/src/main.h @@ -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) -- 2.34.1