mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed castle bug, better field RNG
This commit is contained in:
parent
41229b4665
commit
c547cdd72c
@ -1,9 +1,11 @@
|
||||
[
|
||||
(25, Velorite),
|
||||
(50, VeloriteFrag),
|
||||
(15, WhiteFlower),
|
||||
(80, ShortGrass),
|
||||
(150, Mushroom),
|
||||
(35, VeloriteFrag),
|
||||
(60, Stones),
|
||||
(15, PurpleFlower),
|
||||
(150, ShortGrass),
|
||||
(80, Mushroom),
|
||||
(8, ShinyGem),
|
||||
(5, Chest),
|
||||
(2, Crate),
|
||||
(1, Scarecrow),
|
||||
|
@ -156,6 +156,7 @@ impl Civs {
|
||||
- (site.center - pos).map(|e| e as f32).magnitude() / flatten_radius)
|
||||
* 1.25)
|
||||
.min(1.0);
|
||||
let rng = &mut ctx.rng;
|
||||
ctx.sim
|
||||
.get_mut(pos)
|
||||
// Don't disrupt chunks that are near water
|
||||
@ -166,6 +167,7 @@ impl Civs {
|
||||
chunk.basement += diff;
|
||||
chunk.rockiness = 0.0;
|
||||
chunk.warp_factor = 0.0;
|
||||
chunk.surface_veg *= 1.0 - factor * rng.gen_range(0.25, 0.9);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ pub fn apply_caves_to<'a>(
|
||||
}
|
||||
|
||||
// Scatter things in caves
|
||||
if RandomField::new(index.seed).chance(wpos2d.into(), 0.002) && cave_base < surface_z as i32 - 25 {
|
||||
if RandomField::new(index.seed).chance(wpos2d.into(), 0.001) && cave_base < surface_z as i32 - 25 {
|
||||
let kind = *assets::load_expect::<Lottery<BlockKind>>("common.cave_scatter")
|
||||
.choose_seeded(RandomField::new(index.seed + 1).get(wpos2d.into()));
|
||||
let _ = vol.set(Vec3::new(offs.x, offs.y, cave_base), Block::new(kind, Rgb::zero()));
|
||||
|
@ -202,7 +202,7 @@ impl Castle {
|
||||
for z in -5..3 {
|
||||
let pos = Vec3::new(offs.x, offs.y, surface_z + z);
|
||||
|
||||
if z >= 0 {
|
||||
if z > 0 {
|
||||
if vol.get(pos).unwrap().kind() != BlockKind::Water {
|
||||
let _ = vol.set(pos, Block::empty());
|
||||
}
|
||||
|
@ -201,6 +201,7 @@ pub struct Floor {
|
||||
hollow_depth: i32,
|
||||
#[allow(dead_code)]
|
||||
stair_tile: Vec2<i32>,
|
||||
final_level: bool,
|
||||
}
|
||||
|
||||
const FLOOR_SIZE: Vec2<i32> = Vec2::new(18, 18);
|
||||
@ -233,6 +234,7 @@ impl Floor {
|
||||
solid_depth: if level == 0 { 80 } else { 32 },
|
||||
hollow_depth: 30,
|
||||
stair_tile: new_stair_tile - tile_offset,
|
||||
final_level,
|
||||
};
|
||||
|
||||
const STAIR_ROOM_HEIGHT: i32 = 13;
|
||||
@ -632,10 +634,12 @@ impl Floor {
|
||||
empty
|
||||
};
|
||||
|
||||
let tunnel_height = if self.final_level { 16.0 } else { 8.0 };
|
||||
|
||||
move |z| match self.tiles.get(tile_pos) {
|
||||
Some(Tile::Solid) => BlockMask::nothing(),
|
||||
Some(Tile::Tunnel) => {
|
||||
if dist_to_wall >= wall_thickness && (z as f32) < 8.0 - 8.0 * tunnel_dist.powf(4.0)
|
||||
if dist_to_wall >= wall_thickness && (z as f32) < tunnel_height * (1.0 - tunnel_dist.powf(4.0))
|
||||
{
|
||||
if z == 0 { floor_sprite } else { empty }
|
||||
} else {
|
||||
|
@ -20,7 +20,22 @@ impl Sampler<'static> for RandomField {
|
||||
|
||||
fn get(&self, pos: Self::Index) -> Self::Sample {
|
||||
let pos = pos.map(|e| u32::from_le_bytes(e.to_le_bytes()));
|
||||
seed_expan::diffuse_mult(&[self.seed, pos.x, pos.y, pos.z])
|
||||
|
||||
let mut a = self.seed;
|
||||
a = (a ^ 61) ^ (a >> 16);
|
||||
a = a.wrapping_add(a << 3);
|
||||
a = a ^ pos.x;
|
||||
a = a ^ (a >> 4);
|
||||
a = a.wrapping_mul(0x27d4eb2d);
|
||||
a = a ^ (a >> 15);
|
||||
a = a ^ pos.y;
|
||||
a = (a ^ 61) ^ (a >> 16);
|
||||
a = a.wrapping_add(a << 3);
|
||||
a = a ^ (a >> 4);
|
||||
a = a ^ pos.z;
|
||||
a = a.wrapping_mul(0x27d4eb2d);
|
||||
a = a ^ (a >> 15);
|
||||
a
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user