Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CR] Hordes don't wander to 0,0 #74053

Merged
merged 4 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions data/json/monstergroups/misc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] } ]
}
]
13 changes: 13 additions & 0 deletions src/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down Expand Up @@ -198,6 +200,7 @@ std::string enum_to_string<debug_menu::debug_menu_index>( 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";
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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<coords::sm>( player_abs_ms );
horde_dest = horde_dest + point{0, -20}; // 20 submaps to the north
overmap &om = overmap_buffer.get( project_to<coords::om>( 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;
Expand Down
1 change: 1 addition & 0 deletions src/debug_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum class debug_menu_index : int {
CONTROL_NPC,
SPAWN_ARTIFACT,
SPAWN_CLAIRVOYANCE,
SPAWN_HORDE,
MAP_EDITOR,
CHANGE_WEATHER,
WIND_DIRECTION,
Expand Down
3 changes: 2 additions & 1 deletion src/mongroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) :
Expand Down
5 changes: 5 additions & 0 deletions src/overmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
RenechCDDA marked this conversation as resolved.
Show resolved Hide resolved
{
add_mon_group( group, 1 );
RenechCDDA marked this conversation as resolved.
Show resolved Hide resolved
}

void overmap::add_mon_group( const mongroup &group )
{
zg.emplace( group.rel_pos(), group );
Expand Down
3 changes: 3 additions & 0 deletions src/overmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ class overmap
std::vector<tripoint_om_omt> 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.
Expand Down
7 changes: 7 additions & 0 deletions src/savegame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down
Loading