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),
(35, VeloriteFrag),
(20, Velorite),
(30, VeloriteFrag),
(60, Stones),
(15, PurpleFlower),
(150, ShortGrass),
(80, Mushroom),
(130, ShortGrass),
(120, Mushroom),
(8, ShinyGem),
(5, Chest),
(15, Chest),
(2, Crate),
(1, Scarecrow),
(0.25, Scarecrow),
]

View File

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

View File

@ -51,9 +51,18 @@ pub fn apply_scatter_to<'a>(
None,
)
}),
(Twigs, false, |c| ((c.tree_density - 0.5).max(0.0) * 0.0025, None)),
(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)))),
(Twigs, false, |c| {
((c.tree_density - 0.5).max(0.0) * 0.0025, None)
}),
(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| {
(
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 bk = scatter.iter().enumerate().find_map(|(i, (bk, is_underwater, f))| {
let (density, patch) = f(chunk);
if density <= 0.0
|| patch
.map(|(wavelen, threshold)| {
index.noise.scatter_nz.get(
wpos2d
.map(|e| e as f64 / wavelen as f64 + i as f64 * 43.0)
.into_array(),
) < threshold as f64
})
.unwrap_or(false)
|| !RandomField::new(i as u32).chance(Vec3::new(wpos2d.x, wpos2d.y, 0), density)
|| underwater != *is_underwater
{
None
} else {
Some(*bk)
}
});
let bk = scatter
.iter()
.enumerate()
.find_map(|(i, (bk, is_underwater, f))| {
let (density, patch) = f(chunk);
if density <= 0.0
|| patch
.map(|(wavelen, threshold)| {
index.noise.scatter_nz.get(
wpos2d
.map(|e| e as f64 / wavelen as f64 + i as f64 * 43.0)
.into_array(),
) < threshold as f64
})
.unwrap_or(false)
|| !RandomField::new(i as u32)
.chance(Vec3::new(wpos2d.x, wpos2d.y, 0), density)
|| underwater != *is_underwater
{
None
} else {
Some(*bk)
}
});
if let Some(bk) = bk {
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 difficulty = cave_depth / 200.0;
let difficulty = cave_depth / 100.0;
// 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
{
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;
// 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
{
let entity = EntityInfo::at(Vec3::new(

View File

@ -230,7 +230,14 @@ impl World {
}
// 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
sim_chunk.sites.iter().for_each(|site| {