From a5c25a00d6c2e55a71f760101d1aab50ce9cc06c Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 5 Oct 2024 13:51:43 +0200 Subject: [PATCH] added level editor option for buggy BD style teleporter --- src/editor.c | 16 ++++++++++++++++ src/files.c | 10 ++++++++++ src/game_bd/bd_cave.h | 2 ++ src/game_bd/bd_cavedb.c | 8 ++++++++ src/game_bd/bd_caveengine.c | 6 +++--- src/main.h | 1 + 6 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/editor.c b/src/editor.c index 756dc18e..d656d3b9 100644 --- a/src/editor.c +++ b/src/editor.c @@ -870,6 +870,7 @@ enum GADGET_ID_BD_WATER_CANNOT_FLOW_DOWN, GADGET_ID_BD_HAMMER_WALLS_REAPPEAR, GADGET_ID_BD_INFINITE_ROCKETS, + GADGET_ID_BD_BUGGY_TELEPORTER, GADGET_ID_BD_CREATURES_START_BACKWARDS, GADGET_ID_BD_CREATURES_TURN_ON_HATCHING, GADGET_ID_BD_GRAVITY_SWITCH_ACTIVE, @@ -1270,6 +1271,7 @@ enum ED_CHECKBUTTON_ID_BD_WATER_CANNOT_FLOW_DOWN, ED_CHECKBUTTON_ID_BD_HAMMER_WALLS_REAPPEAR, ED_CHECKBUTTON_ID_BD_INFINITE_ROCKETS, + ED_CHECKBUTTON_ID_BD_BUGGY_TELEPORTER, ED_CHECKBUTTON_ID_BD_CREATURES_START_BACKWARDS, ED_CHECKBUTTON_ID_BD_CREATURES_TURN_ON_HATCHING, ED_CHECKBUTTON_ID_BD_GRAVITY_SWITCH_ACTIVE, @@ -4418,6 +4420,14 @@ static struct NULL, NULL, "Infinite rockets", "Rocket launcher has infinite rockets" }, + { + ED_CHECKBUTTON_ID_BD_BUGGY_TELEPORTER, + ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0), + GADGET_ID_BD_BUGGY_TELEPORTER, GADGET_ID_NONE, + &level.bd_buggy_teleporter, + NULL, NULL, + "Use buggy teleporter", "Teleporter only works from two sides" + }, { ED_CHECKBUTTON_ID_BD_CREATURES_START_BACKWARDS, ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(0), @@ -12689,6 +12699,7 @@ static boolean checkPropertiesConfig(int element) element == EL_BDX_HEAVY_ROCK || element == EL_BDX_BOMB || element == EL_BDX_ROCKET_LAUNCHER || + element == EL_BDX_TELEPORTER || element == EL_BDX_NITRO_PACK || element == EL_BDX_SWEET || element == EL_BDX_VOODOO_DOLL || @@ -13151,6 +13162,11 @@ static void DrawPropertiesConfig(void) MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_INFINITE_ROCKETS); } + if (properties_element == EL_BDX_TELEPORTER) + { + MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_BUGGY_TELEPORTER); + } + if (properties_element == EL_BDX_CREATURE_SWITCH) { MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_CREATURES_START_BACKWARDS); diff --git a/src/files.c b/src/files.c index 74fc442e..50abce3a 100644 --- a/src/files.c +++ b/src/files.c @@ -1022,6 +1022,12 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] = &li.bd_infinite_rockets, FALSE }, + { + EL_BDX_TELEPORTER, -1, + TYPE_BOOLEAN, CONF_VALUE_8_BIT(1), + &li.bd_buggy_teleporter, FALSE + }, + { EL_BDX_SKELETON, -1, TYPE_INTEGER, CONF_VALUE_8_BIT(1), @@ -4432,6 +4438,8 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level) cave->infinite_rockets = level->bd_infinite_rockets; + cave->buggy_teleporter = level->bd_buggy_teleporter; + cave->skeletons_needed_for_pot = level->bd_num_skeletons_needed_for_pot; cave->skeletons_worth_diamonds = level->bd_skeleton_worth_num_diamonds; @@ -4617,6 +4625,8 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level) level->bd_infinite_rockets = cave->infinite_rockets; + level->bd_buggy_teleporter = cave->buggy_teleporter; + level->bd_num_skeletons_needed_for_pot= cave->skeletons_needed_for_pot; level->bd_skeleton_worth_num_diamonds = cave->skeletons_worth_diamonds; diff --git a/src/game_bd/bd_cave.h b/src/game_bd/bd_cave.h index 91d46cb6..0c7300e7 100644 --- a/src/game_bd/bd_cave.h +++ b/src/game_bd/bd_cave.h @@ -561,6 +561,8 @@ typedef struct _gd_cave boolean infinite_rockets; // if true, the player which got a rocket launcher will be // able to launch an infinite number of rockets + boolean buggy_teleporter; // use old, buggy teleporter behavior + // internal variables, used during the game. private data :) // returns range corrected x/y position (points to perfect or line shifting get function) diff --git a/src/game_bd/bd_cavedb.c b/src/game_bd/bd_cavedb.c index 247ea53e..1e30fbb5 100644 --- a/src/game_bd/bd_cavedb.c +++ b/src/game_bd/bd_cavedb.c @@ -2283,6 +2283,11 @@ const GdStructDescriptor gd_cave_properties[] = N_("Infinite rockets"), CAVE_OFFSET(infinite_rockets), 1, N_("If it is true, the player is able to launch an infinite number of rockets. Otherwise every rocket launcher contains only a single rocket.") }, + { + "Teleporter.buggy", GD_TYPE_BOOLEAN, 0, + N_("Buggy teleporter"), CAVE_OFFSET(buggy_teleporter), 1, + N_("If it is true, the player can only enter a teleporter from two sides (right and bottom side). Otherwise, the teleporter works as expected, and the player can enter from all four sides.") + }, // pneumatic hammer { @@ -3210,6 +3215,9 @@ GdPropertyDefault gd_cave_defaults_gdash[] = // bladder { CAVE_OFFSET(bladder_converts_by), O_VOODOO }, + // teleporter + { CAVE_OFFSET(buggy_teleporter), TRUE }, + // SOUND { CAVE_OFFSET(amoeba_sound), TRUE }, { CAVE_OFFSET(magic_wall_sound), TRUE }, diff --git a/src/game_bd/bd_caveengine.c b/src/game_bd/bd_caveengine.c index 99880bbb..df6553dc 100644 --- a/src/game_bd/bd_caveengine.c +++ b/src/game_bd/bd_caveengine.c @@ -1183,9 +1183,9 @@ static GdElement player_eat_element(GdCave *cave, const GdElement element, int x // @return True, if the player is teleported, false, if no suitable teleporter found. static boolean do_teleporter(GdCave *cave, int px, int py, GdDirection player_move) { - // start at teleporter position (not at player position!) - int tx_start = px + gd_dx[player_move]; - int ty_start = py + gd_dy[player_move]; + // start at teleporter position (not at player position!) unless using buggy behaviour + int tx_start = px + (cave->buggy_teleporter ? 0 : gd_dx[player_move]); + int ty_start = py + (cave->buggy_teleporter ? 0 : gd_dy[player_move]); int tx = tx_start; int ty = ty_start; diff --git a/src/main.h b/src/main.h index 5a5e89fd..d7d32fbf 100644 --- a/src/main.h +++ b/src/main.h @@ -3868,6 +3868,7 @@ struct LevelInfo boolean bd_hammer_walls_reappear; // BD hammered walls are reappearing after some delay int bd_hammer_walls_reappear_delay; // BD hammer time for reappearing walls (in BD frames) boolean bd_infinite_rockets; // BD rocket launcher has infinite number of rockets + boolean bd_buggy_teleporter; // BD teleporter setting to implement buggy behaviour int bd_num_skeletons_needed_for_pot; // BD skeletons amount must be collected to use a pot int bd_skeleton_worth_num_diamonds; // BD skeleton collected is worth this number of diamonds int bd_expanding_wall_looks_like; // BD expanding wall looks like this other game element -- 2.34.1