From 0a271371e1df285ff6f279c0c4dcedc9be2cde0f Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Thu, 21 Mar 2024 00:14:20 +0100 Subject: [PATCH] added support for biter settings in BD engine to level editor --- src/editor.c | 25 +++++++++++++++++++++++++ src/files.c | 17 +++++++++++++++++ src/init.c | 5 +++++ src/main.h | 8 ++++++++ 4 files changed, 55 insertions(+) diff --git a/src/editor.c b/src/editor.c index 28374334..4411b199 100644 --- a/src/editor.c +++ b/src/editor.c @@ -565,6 +565,7 @@ enum GADGET_ID_BD_AMOEBA_2_CONTENT_LOOKS_LIKE, GADGET_ID_BD_ACID_EATS_ELEMENT, GADGET_ID_BD_ACID_TURNS_TO_ELEMENT, + GADGET_ID_BD_BITER_EATS_ELEMENT, GADGET_ID_START_ELEMENT, GADGET_ID_ARTWORK_ELEMENT, GADGET_ID_EXPLOSION_ELEMENT, @@ -1176,6 +1177,7 @@ enum ED_DRAWING_ID_BD_AMOEBA_2_CONTENT_LOOKS_LIKE, ED_DRAWING_ID_BD_ACID_EATS_ELEMENT, ED_DRAWING_ID_BD_ACID_TURNS_TO_ELEMENT, + ED_DRAWING_ID_BD_BITER_EATS_ELEMENT, ED_DRAWING_ID_START_ELEMENT, ED_DRAWING_ID_ARTWORK_ELEMENT, ED_DRAWING_ID_EXPLOSION_ELEMENT, @@ -4357,6 +4359,14 @@ static struct &level.bd_acid_turns_to_element, 1, 1, "Can leave behind:", NULL, NULL, NULL, "Turns to this element after spreading" }, + { + ED_DRAWING_ID_BD_BITER_EATS_ELEMENT, + 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_BITER_EATS_ELEMENT, GADGET_ID_NONE, + &level.bd_biter_eats_element, 1, 1, + "Can eat:", NULL, NULL, NULL, "Eats this element when moving" + }, // ---------- level start element ------------------------------------------- @@ -10876,6 +10886,7 @@ static void DrawPropertiesInfo(void) #define TEXT_PERMEABILITY_BITS "slime permeability bits" #define TEXT_RANDOM_SEED "slime random number seed" #define TEXT_ACID_SPREAD_RATE "Spread rate (percent)" +#define TEXT_BITER_MOVE_DELAY "Move delay (BD frames)" static struct { @@ -11000,6 +11011,16 @@ static struct -1, 65535 }, { EL_BD_ACID, &level.bd_acid_spread_rate, TEXT_ACID_SPREAD_RATE, 0, 100 }, + { EL_BD_BITER, &level.bd_biter_move_delay, TEXT_BITER_MOVE_DELAY, + 0, 3 }, + { EL_BD_BITER_RIGHT, &level.bd_biter_move_delay, TEXT_BITER_MOVE_DELAY, + 0, 3 }, + { EL_BD_BITER_UP, &level.bd_biter_move_delay, TEXT_BITER_MOVE_DELAY, + 0, 3 }, + { EL_BD_BITER_LEFT, &level.bd_biter_move_delay, TEXT_BITER_MOVE_DELAY, + 0, 3 }, + { EL_BD_BITER_DOWN, &level.bd_biter_move_delay, TEXT_BITER_MOVE_DELAY, + 0, 3 }, { 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 }, @@ -11238,6 +11259,10 @@ static void DrawPropertiesConfig(void) MapDrawingArea(ED_DRAWING_ID_BD_ACID_EATS_ELEMENT); MapDrawingArea(ED_DRAWING_ID_BD_ACID_TURNS_TO_ELEMENT); } + else if (IS_BD_BITER(properties_element)) + { + MapDrawingArea(ED_DRAWING_ID_BD_BITER_EATS_ELEMENT); + } else if (properties_element == EL_YAMYAM || properties_element == EL_YAMYAM_LEFT || properties_element == EL_YAMYAM_RIGHT || diff --git a/src/files.c b/src/files.c index 1f1bd843..3f2f69dd 100644 --- a/src/files.c +++ b/src/files.c @@ -725,6 +725,17 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] = &li.bd_acid_turns_to_element, EL_EMPTY }, + { + EL_BD_BITER, -1, + TYPE_INTEGER, CONF_VALUE_8_BIT(1), + &li.bd_biter_move_delay, 0 + }, + { + EL_BD_BITER, -1, + TYPE_ELEMENT, CONF_VALUE_16_BIT(1), + &li.bd_biter_eats_element, EL_BD_DIAMOND + }, + // (the following values are related to various game elements) { @@ -4015,6 +4026,9 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level) cave->acid_spread_ratio = level->bd_acid_spread_rate * 10000; cave->acid_turns_to = map_element_RND_to_BD(level->bd_acid_turns_to_element); + cave->biter_delay_frame = level->bd_biter_move_delay; + cave->biter_eat = map_element_RND_to_BD(level->bd_biter_eats_element); + // level name strncpy(cave->name, level->name, sizeof(GdString)); cave->name[sizeof(GdString) - 1] = '\0'; @@ -4109,6 +4123,9 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level) level->bd_acid_spread_rate = cave->acid_spread_ratio / 10000; level->bd_acid_turns_to_element = map_element_BD_to_RND(cave->acid_turns_to); + level->bd_biter_move_delay = cave->biter_delay_frame; + level->bd_biter_eats_element = map_element_BD_to_RND(cave->biter_eat); + // level name char *cave_name = getStringPrint("%s / %d", cave->name, bd_level_nr + 1); diff --git a/src/init.c b/src/init.c index 340a00db..ba509b7b 100644 --- a/src/init.c +++ b/src/init.c @@ -4280,6 +4280,11 @@ void InitElementPropertiesStatic(void) EL_BD_AMOEBA, EL_BD_AMOEBA_2, EL_BD_ACID, + EL_BD_BITER, + EL_BD_BITER_RIGHT, + EL_BD_BITER_UP, + EL_BD_BITER_LEFT, + EL_BD_BITER_DOWN, EL_EMC_MAGIC_BALL, EL_EMC_ANDROID, EL_MM_GRAY_BALL, diff --git a/src/main.h b/src/main.h index f65f53c2..cf694a78 100644 --- a/src/main.h +++ b/src/main.h @@ -905,6 +905,12 @@ (e) == EL_BD_PLAYER_GLUED || \ (e) == EL_BD_PLAYER_STIRRING) +#define IS_BD_BITER(e) ((e) == EL_BD_BITER || \ + (e) == EL_BD_BITER_RIGHT || \ + (e) == EL_BD_BITER_UP || \ + (e) == EL_BD_BITER_LEFT || \ + (e) == EL_BD_BITER_DOWN) + #define IS_SOKOBAN_OBJECT_OR_FIELD(e) ((e) == EL_SOKOBAN_OBJECT || \ (e) == EL_SOKOBAN_FIELD_EMPTY || \ (e) == EL_SOKOBAN_FIELD_FULL) @@ -3531,6 +3537,8 @@ struct LevelInfo int bd_acid_eats_element; // BD acid eats this game element when spreading int bd_acid_spread_rate; // BD acid probability of spreading (in percent) int bd_acid_turns_to_element; // BD acid target element after spreading + int bd_biter_move_delay; // BD biter delay between movements (in BD frames) + int bd_biter_eats_element; // BD biter eats this game element when moving boolean em_slippery_gems; // EM style "gems slip from wall" behaviour boolean em_explodes_by_fire; // EM style chain explosion behaviour -- 2.34.1