From 38bf6dfccb890d9de0f0d4aa27f0eae124f2c71c Mon Sep 17 00:00:00 2001 From: RenechCDDA <84619419+RenechCDDA@users.noreply.github.com> Date: Fri, 24 May 2024 12:59:35 -0400 Subject: [PATCH 1/4] debug infrastructure to force a horde to spawn --- data/json/monstergroups/misc.json | 6 ++++++ src/debug_menu.cpp | 13 +++++++++++++ src/debug_menu.h | 1 + src/overmap.cpp | 5 +++++ src/overmap.h | 3 +++ 5 files changed, 28 insertions(+) diff --git a/data/json/monstergroups/misc.json b/data/json/monstergroups/misc.json index 44c2175aa3ce4..269929daa1953 100644 --- a/data/json/monstergroups/misc.json +++ b/data/json/monstergroups/misc.json @@ -556,5 +556,11 @@ { "monster": "mon_moose", "weight": 1 }, { "monster": "mon_pig", "weight": 1 } ] + }, + { + "type": "monstergroup", + "name": "GROUP_DEBUG_EXACTLY_ONE", + "//": "Hardcoded reference in debug() (debug_menu.cpp). Used for debugging, duh.", + "monsters": [ { "monster": "mon_zombie", "weight": 1, "cost_multiplier": 1, "pack_size": [ 1, 1 ] } ] } ] diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 6e1b7782761a5..7c5d6828da16c 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -144,6 +144,8 @@ static const faction_id faction_your_followers( "your_followers" ); static const matype_id style_none( "style_none" ); +static const mongroup_id GROUP_DEBUG_EXACTLY_ONE( "GROUP_DEBUG_EXACTLY_ONE" ); + static const mtype_id mon_generator( "mon_generator" ); static const trait_id trait_ASTHMA( "ASTHMA" ); @@ -198,6 +200,7 @@ std::string enum_to_string( debug_menu::debug_menu case debug_menu::debug_menu_index::CONTROL_NPC: return "CONTROL_NPC"; case debug_menu::debug_menu_index::SPAWN_ARTIFACT: return "SPAWN_ARTIFACT"; case debug_menu::debug_menu_index::SPAWN_CLAIRVOYANCE: return "SPAWN_CLAIRVOYANCE"; + case debug_menu::debug_menu_index::SPAWN_HORDE: return "SPAWN_HORDE"; case debug_menu::debug_menu_index::MAP_EDITOR: return "MAP_EDITOR"; case debug_menu::debug_menu_index::CHANGE_WEATHER: return "CHANGE_WEATHER"; case debug_menu::debug_menu_index::WIND_DIRECTION: return "WIND_DIRECTION"; @@ -808,6 +811,7 @@ static int spawning_uilist() { uilist_entry( debug_menu_index::SPAWN_VEHICLE, true, 'v', _( "Spawn a vehicle" ) ) }, { uilist_entry( debug_menu_index::SPAWN_ARTIFACT, true, 'a', _( "Spawn artifact" ) ) }, { uilist_entry( debug_menu_index::SPAWN_CLAIRVOYANCE, true, 'c', _( "Spawn clairvoyance artifact" ) ) }, + { uilist_entry( debug_menu_index::SPAWN_HORDE, true, 'H', _( "Spawn a dummy horde twenty submaps(10 OMTs) to the north" ) ) }, }; return uilist( _( "Spawning…" ), uilist_initializer ); @@ -3679,6 +3683,15 @@ void debug() } break; + case debug_menu_index::SPAWN_HORDE: { + const tripoint_abs_ms &player_abs_ms = get_player_character().get_location(); + tripoint_abs_sm horde_dest = project_to( player_abs_ms ); + horde_dest = horde_dest + point{0, -20}; // 20 submaps to the north + overmap &om = overmap_buffer.get( project_to( player_abs_ms ).xy() ); + om.debug_force_add_group( mongroup( GROUP_DEBUG_EXACTLY_ONE, horde_dest, 1 ) ); + } + break; + case debug_menu_index::SPAWN_MON: debug_menu::wishmonster( std::nullopt ); break; diff --git a/src/debug_menu.h b/src/debug_menu.h index be80560b6168c..00796b40e1cb4 100644 --- a/src/debug_menu.h +++ b/src/debug_menu.h @@ -44,6 +44,7 @@ enum class debug_menu_index : int { CONTROL_NPC, SPAWN_ARTIFACT, SPAWN_CLAIRVOYANCE, + SPAWN_HORDE, MAP_EDITOR, CHANGE_WEATHER, WIND_DIRECTION, diff --git a/src/overmap.cpp b/src/overmap.cpp index da860f93a491a..1415413221f98 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -7243,6 +7243,11 @@ void overmap::spawn_mon_group( const mongroup &group, int radius ) add_mon_group( group, radius ); } +void overmap::debug_force_add_group(const mongroup & group) +{ + add_mon_group( group, 1 ); +} + void overmap::add_mon_group( const mongroup &group ) { zg.emplace( group.rel_pos(), group ); diff --git a/src/overmap.h b/src/overmap.h index 149ba7b0884dd..566bb34250f68 100644 --- a/src/overmap.h +++ b/src/overmap.h @@ -510,6 +510,9 @@ class overmap std::vector place_special( const overmap_special &special, const tripoint_om_omt &p, om_direction::type dir, const city &cit, bool must_be_unexplored, bool force ); + + // DEBUG ONLY! + void debug_force_add_group( const mongroup &group ); private: /** * Iterate over the overmap and place the quota of specials. From 1d5a3e03341b24a67fdafbc69c0bcd5eb81e2735 Mon Sep 17 00:00:00 2001 From: RenechCDDA <84619419+RenechCDDA@users.noreply.github.com> Date: Fri, 24 May 2024 13:03:36 -0400 Subject: [PATCH 2/4] Don't initialize hordes with target of 0,0 --- src/mongroup.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mongroup.h b/src/mongroup.h index e5e1e4120c921..9a30e9b896d7c 100644 --- a/src/mongroup.h +++ b/src/mongroup.h @@ -136,7 +136,8 @@ struct mongroup { unsigned int ppop ) : type( ptype ) , abs_pos( ppos ) - , population( ppop ) { + , population( ppop ) + , target( abs_pos.xy() ) { } mongroup( const std::string &ptype, const tripoint_abs_sm &ppos, unsigned int ppop, point_abs_sm ptarget, int pint, bool pdie, bool phorde ) : From 20b7841e362f4c08edea3c9e5d0ee764ad2fdb47 Mon Sep 17 00:00:00 2001 From: RenechCDDA <84619419+RenechCDDA@users.noreply.github.com> Date: Fri, 24 May 2024 14:56:43 -0400 Subject: [PATCH 3/4] Reset existing monster groups with bad destinations --- src/savegame.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/savegame.cpp b/src/savegame.cpp index 9ab7dc6f55fdb..562abee000f50 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -368,12 +368,19 @@ void overmap::load_monster_groups( const JsonArray &jsin ) for( JsonArray mongroup_with_tripoints : jsin ) { mongroup new_group; new_group.deserialize( mongroup_with_tripoints.next_object() ); + bool reset_target = false; + if( new_group.target == point_abs_sm() ) { // Remove after 0.I + reset_target = true; + } JsonArray tripoints_json = mongroup_with_tripoints.next_array(); tripoint_om_sm temp; for( JsonValue tripoint_json : tripoints_json ) { temp.deserialize( tripoint_json ); new_group.abs_pos = project_combine( pos(), temp ); + if( reset_target ) { // Remove after 0.I + new_group.set_target( new_group.abs_pos.xy() ); + } add_mon_group( new_group ); } From e6c6a9683bcbc6dc577fb3603c54152a07e02f1e Mon Sep 17 00:00:00 2001 From: RenechCDDA <84619419+RenechCDDA@users.noreply.github.com> Date: Fri, 24 May 2024 16:46:37 -0400 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/overmap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/overmap.cpp b/src/overmap.cpp index 1415413221f98..22ad9ce05de7d 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -7243,9 +7243,9 @@ void overmap::spawn_mon_group( const mongroup &group, int radius ) add_mon_group( group, radius ); } -void overmap::debug_force_add_group(const mongroup & group) +void overmap::debug_force_add_group( const mongroup &group ) { - add_mon_group( group, 1 ); + add_mon_group( group, 1 ); } void overmap::add_mon_group( const mongroup &group )