Improved spawn rates of castles and cave monsters

This commit is contained in:
Joshua Barretto 2020-08-12 15:04:17 +01:00
parent 85ed5ad356
commit 9cefaaa7af
4 changed files with 56 additions and 36 deletions

View File

@ -1,12 +1,12 @@
[ [
(25, Velorite), (20, Velorite),
(35, VeloriteFrag), (30, VeloriteFrag),
(60, Stones), (60, Stones),
(15, PurpleFlower), (15, PurpleFlower),
(150, ShortGrass), (130, ShortGrass),
(80, Mushroom), (120, Mushroom),
(8, ShinyGem), (8, ShinyGem),
(5, Chest), (15, Chest),
(2, Crate), (2, Crate),
(1, Scarecrow), (0.25, Scarecrow),
] ]

View File

@ -90,9 +90,9 @@ impl Civs {
for _ in 0..INITIAL_CIV_COUNT * 3 { for _ in 0..INITIAL_CIV_COUNT * 3 {
attempt(5, || { attempt(5, || {
let (kind, size) = match ctx.rng.gen_range(0, 2) { let (kind, size) = match ctx.rng.gen_range(0, 8) {
0 => (SiteKind::Dungeon, 0), 0 => (SiteKind::Castle, 3),
_ => (SiteKind::Castle, 3), _ => (SiteKind::Dungeon, 0),
}; };
let loc = find_site_loc(&mut ctx, None, size)?; let loc = find_site_loc(&mut ctx, None, size)?;
this.establish_site(&mut ctx.reseed(), loc, |place| Site { this.establish_site(&mut ctx.reseed(), loc, |place| Site {

View File

@ -51,9 +51,18 @@ pub fn apply_scatter_to<'a>(
None, None,
) )
}), }),
(Twigs, false, |c| ((c.tree_density - 0.5).max(0.0) * 0.0025, None)), (Twigs, false, |c| {
(Stones, false, |c| ((c.rockiness - 0.5).max(0.0) * 0.005, None)), ((c.tree_density - 0.5).max(0.0) * 0.0025, None)
(ShortGrass, false, |c| (close(c.temp, 0.3, 0.4).min(close(c.humidity, 0.6, 0.35)) * 0.05, Some((48.0, 0.4)))), }),
(Stones, false, |c| {
((c.rockiness - 0.5).max(0.0) * 0.005, None)
}),
(ShortGrass, false, |c| {
(
close(c.temp, 0.3, 0.4).min(close(c.humidity, 0.6, 0.35)) * 0.05,
Some((48.0, 0.4)),
)
}),
(MediumGrass, false, |c| { (MediumGrass, false, |c| {
( (
close(c.temp, 0.0, 0.6).min(close(c.humidity, 0.6, 0.35)) * 0.05, close(c.temp, 0.0, 0.6).min(close(c.humidity, 0.6, 0.35)) * 0.05,
@ -89,26 +98,30 @@ pub fn apply_scatter_to<'a>(
let underwater = col_sample.water_level > col_sample.alt; let underwater = col_sample.water_level > col_sample.alt;
let bk = scatter.iter().enumerate().find_map(|(i, (bk, is_underwater, f))| { let bk = scatter
let (density, patch) = f(chunk); .iter()
if density <= 0.0 .enumerate()
|| patch .find_map(|(i, (bk, is_underwater, f))| {
.map(|(wavelen, threshold)| { let (density, patch) = f(chunk);
index.noise.scatter_nz.get( if density <= 0.0
wpos2d || patch
.map(|e| e as f64 / wavelen as f64 + i as f64 * 43.0) .map(|(wavelen, threshold)| {
.into_array(), index.noise.scatter_nz.get(
) < threshold as f64 wpos2d
}) .map(|e| e as f64 / wavelen as f64 + i as f64 * 43.0)
.unwrap_or(false) .into_array(),
|| !RandomField::new(i as u32).chance(Vec3::new(wpos2d.x, wpos2d.y, 0), density) ) < threshold as f64
|| underwater != *is_underwater })
{ .unwrap_or(false)
None || !RandomField::new(i as u32)
} else { .chance(Vec3::new(wpos2d.x, wpos2d.y, 0), density)
Some(*bk) || underwater != *is_underwater
} {
}); None
} else {
Some(*bk)
}
});
if let Some(bk) = bk { if let Some(bk) = bk {
let mut z = col_sample.alt as i32 - 4; let mut z = col_sample.alt as i32 - 4;
@ -287,10 +300,10 @@ pub fn apply_caves_to<'a>(
} }
let cave_depth = (col_sample.alt - cave.alt).max(0.0); let cave_depth = (col_sample.alt - cave.alt).max(0.0);
let difficulty = cave_depth / 200.0; let difficulty = cave_depth / 100.0;
// Scatter things in caves // Scatter things in caves
if RandomField::new(index.seed).chance(wpos2d.into(), 0.002 * difficulty) if RandomField::new(index.seed).chance(wpos2d.into(), 0.002 * difficulty.powf(1.5))
&& cave_base < surface_z as i32 - 25 && cave_base < surface_z as i32 - 25
{ {
let kind = *assets::load_expect::<Lottery<BlockKind>>("common.cave_scatter") let kind = *assets::load_expect::<Lottery<BlockKind>>("common.cave_scatter")
@ -343,7 +356,7 @@ pub fn apply_caves_supplement<'a>(
let difficulty = cave_depth / 200.0; let difficulty = cave_depth / 200.0;
// Scatter things in caves // Scatter things in caves
if RandomField::new(index.seed).chance(wpos2d.into(), 0.0001 * difficulty) if RandomField::new(index.seed).chance(wpos2d.into(), 0.00005 * difficulty)
&& cave_base < surface_z as i32 - 40 && cave_base < surface_z as i32 - 40
{ {
let entity = EntityInfo::at(Vec3::new( let entity = EntityInfo::at(Vec3::new(

View File

@ -230,7 +230,14 @@ impl World {
} }
// Apply layer supplement // Apply layer supplement
layer::apply_caves_supplement(&mut rng, chunk_wpos2d, sample_get, &chunk, &self.index, &mut supplement); layer::apply_caves_supplement(
&mut rng,
chunk_wpos2d,
sample_get,
&chunk,
&self.index,
&mut supplement,
);
// Apply site supplementary information // Apply site supplementary information
sim_chunk.sites.iter().for_each(|site| { sim_chunk.sites.iter().for_each(|site| {