From e00de807ff07959c012a358933f66018f4e7ee3c Mon Sep 17 00:00:00 2001 From: Hirmuolio Date: Thu, 26 Dec 2019 02:15:27 +0200 Subject: [PATCH 1/2] move no spawn condition --- src/mapgen.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mapgen.cpp b/src/mapgen.cpp index dcb2210f5c8c9..1e420957458b5 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -1197,17 +1197,13 @@ class jmapgen_monster : public jmapgen_piece // Instead, apply a multipler to the number of monsters for really high densities. // For example, a 50% chance at spawn density 4 becomes a 75% chance of ~2.7 monsters. int odds_after_density = raw_odds * get_option( "SPAWN_DENSITY" ) ; - int max_odds = 100 - ( 100 - raw_odds ) / 2; + int max_odds = ( 100 + raw_odds ) / 2; float density_multiplier = 1; if( odds_after_density > max_odds ) { density_multiplier = 1.0f * odds_after_density / max_odds; odds_after_density = max_odds; } - if( !x_in_y( odds_after_density, 100 ) ) { - return; - } - int mission_id = -1; if( dat.mission() && target ) { mission_id = dat.mission()->get_id(); @@ -1226,6 +1222,10 @@ class jmapgen_monster : public jmapgen_piece } if( raw_odds == 100 ) { // don't spawn less than 1 if odds were 100%, even with low spawn density. spawn_count = std::max( spawn_count, 1 ); + } else { + if( !x_in_y( odds_after_density, 100 ) ) { + return; + } } dat.m.add_spawn( *( ids.pick() ), spawn_count * pack_size.get(), point( x.get(), y.get() ), From cf246315fc0d9706b500fbe0a41de8299db6e331 Mon Sep 17 00:00:00 2001 From: Hirmuolio Date: Thu, 26 Dec 2019 14:50:16 +0200 Subject: [PATCH 2/2] reworked spawning from group --- src/mapgen.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 1e420957458b5..667a6a901b43b 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -1127,8 +1127,8 @@ class jmapgen_monster_group : public jmapgen_piece } }; /** - * Place spawn points for a specific monster (not a group). - * "monster": id of the monster. + * Place spawn points for a specific monster. + * "monster": id of the monster. or "group": id of the monster group. * "friendly": whether the new monster is friendly to the player character. * "name": the name of the monster (if it has one). * "chance": the percentage chance of a monster, affected by spawn density @@ -1209,25 +1209,26 @@ class jmapgen_monster : public jmapgen_piece mission_id = dat.mission()->get_id(); } - if( m_id != mongroup_id::NULL_ID() ) { - // Spawn single monster from a group - dat.m.place_spawns( m_id, 1, point( x.get(), y.get() ), point( x.get(), y.get() ), 1.0f, true, - false, - name, mission_id ); - } else { - int spawn_count = roll_remainder( density_multiplier ); - if( one_or_none ) { // don't let high spawn density alone cause more than 1 to spawn. - spawn_count = std::min( spawn_count, 1 ); - } - if( raw_odds == 100 ) { // don't spawn less than 1 if odds were 100%, even with low spawn density. - spawn_count = std::max( spawn_count, 1 ); - } else { - if( !x_in_y( odds_after_density, 100 ) ) { - return; - } + + int spawn_count = roll_remainder( density_multiplier ); + + if( one_or_none ) { // don't let high spawn density alone cause more than 1 to spawn. + spawn_count = std::min( spawn_count, 1 ); + } + if( raw_odds == 100 ) { // don't spawn less than 1 if odds were 100%, even with low spawn density. + spawn_count = std::max( spawn_count, 1 ); + } else { + if( !x_in_y( odds_after_density, 100 ) ) { + return; } + } + if( m_id != mongroup_id::NULL_ID() ) { + MonsterGroupResult spawn_details = MonsterGroupManager::GetResultFromGroup( m_id ); + dat.m.add_spawn( spawn_details.name, spawn_count * pack_size.get(), point( x.get(), y.get() ), + friendly, -1, mission_id, name ); + } else { dat.m.add_spawn( *( ids.pick() ), spawn_count * pack_size.get(), point( x.get(), y.get() ), friendly, -1, mission_id, name ); }