mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Made biome probabilities neater
This commit is contained in:
parent
e880654f2e
commit
d0bd5118bf
@ -19,7 +19,6 @@
|
||||
files: [
|
||||
"voxygen.audio.sfx.ambient.birdcall_1",
|
||||
"voxygen.audio.sfx.ambient.birdcall_2",
|
||||
"voxygen.audio.sfx.ambient.birdcall_3",
|
||||
],
|
||||
threshold: 10.0,
|
||||
),
|
||||
|
BIN
assets/voxygen/audio/sfx/ambient/birdcall_3.wav
(Stored with Git LFS)
BIN
assets/voxygen/audio/sfx/ambient/birdcall_3.wav
(Stored with Git LFS)
Binary file not shown.
@ -8,18 +8,10 @@
|
||||
path: "voxygen.audio.soundtrack.a_solemn_quest",
|
||||
length: 206.0,
|
||||
timing: Some(Day),
|
||||
biomes: (
|
||||
void: 1,
|
||||
lake: 1,
|
||||
grassland: 1,
|
||||
ocean: 1,
|
||||
mountain: 1,
|
||||
snowland: 1,
|
||||
desert: 1,
|
||||
swamp: 1,
|
||||
jungle: 1,
|
||||
forest: 0,
|
||||
),
|
||||
biomes: [
|
||||
(Lake, 1),
|
||||
(Grassland, 1),
|
||||
],
|
||||
site: None,
|
||||
artist: "Eden",
|
||||
),
|
||||
@ -28,30 +20,22 @@
|
||||
path: "voxygen.audio.soundtrack.into_the_dark_forest",
|
||||
length: 184.0,
|
||||
timing: Some(Day),
|
||||
biomes: (
|
||||
void: 1,
|
||||
lake: 1,
|
||||
grassland: 1,
|
||||
ocean: 1,
|
||||
mountain: 1,
|
||||
snowland: 1,
|
||||
desert: 1,
|
||||
swamp: 1,
|
||||
jungle: 1,
|
||||
forest: 0,
|
||||
),
|
||||
biomes: [
|
||||
(Forest, 1),
|
||||
(Jungle, 1),
|
||||
],
|
||||
site: None,
|
||||
artist: "Aeronic",
|
||||
),
|
||||
(
|
||||
title: "Field Grazing",
|
||||
path: "voxygen.audio.soundtrack.field_grazing",
|
||||
length: 154.0,
|
||||
timing: Some(Day),
|
||||
biomes: [],
|
||||
site: None,
|
||||
artist: "Aeronic",
|
||||
),
|
||||
//(
|
||||
// title: "Field Grazing",
|
||||
// path: "voxygen.audio.soundtrack.field_grazing",
|
||||
// length: 154.0,
|
||||
// timing: Some(Day),
|
||||
// biome: Some(Snowland),
|
||||
// site: None,
|
||||
// artist: "Aeronic",
|
||||
//),
|
||||
//(
|
||||
// title: "Wandering Voices",
|
||||
// path: "voxygen.audio.soundtrack.wandering_voices",
|
||||
@ -124,54 +108,32 @@
|
||||
// site: None,
|
||||
// artist: "badbbad",
|
||||
//),
|
||||
//(
|
||||
// title: "Limits",
|
||||
// path: "voxygen.audio.soundtrack.limits",
|
||||
// length: 203.0,
|
||||
// timing: Some(Night),
|
||||
// biome: Some(Desert),
|
||||
// site: None,
|
||||
// artist: "badbbad",
|
||||
//),
|
||||
(
|
||||
title: "Limits",
|
||||
path: "voxygen.audio.soundtrack.limits",
|
||||
length: 203.0,
|
||||
timing: Some(Night),
|
||||
biomes: [],
|
||||
site: Some(Dungeon),
|
||||
artist: "badbbad",
|
||||
),
|
||||
( // Dungeon
|
||||
title: "Down The Rabbit Hole",
|
||||
path: "voxygen.audio.soundtrack.down_the_rabbit_hole",
|
||||
length: 244.0,
|
||||
timing: None,
|
||||
biomes: (
|
||||
void: 1,
|
||||
lake: 1,
|
||||
grassland: 1,
|
||||
ocean: 1,
|
||||
mountain: 1,
|
||||
snowland: 1,
|
||||
desert: 1,
|
||||
swamp: 1,
|
||||
jungle: 1,
|
||||
forest: 1,
|
||||
),
|
||||
biomes: [],
|
||||
site: Some(Cave),
|
||||
artist: "badbbad",
|
||||
),
|
||||
(
|
||||
title: "Between The Fairies",
|
||||
path: "voxygen.audio.soundtrack.between_the_fairies",
|
||||
length: 175.0,
|
||||
timing: None,
|
||||
biomes: (
|
||||
void: 1,
|
||||
lake: 1,
|
||||
grassland: 1,
|
||||
ocean: 1,
|
||||
mountain: 1,
|
||||
snowland: 1,
|
||||
desert: 1,
|
||||
swamp: 1,
|
||||
jungle: 1,
|
||||
forest: 1,
|
||||
),
|
||||
site: Some(Dungeon),
|
||||
artist: "badbbad",
|
||||
),
|
||||
//(
|
||||
// title: "Between The Fairies",
|
||||
// path: "voxygen.audio.soundtrack.between_the_fairies",
|
||||
// length: 175.0,
|
||||
// timing: None,
|
||||
// biomes: [],
|
||||
// site: Some(Cave),
|
||||
// artist: "badbbad",
|
||||
//),
|
||||
]
|
||||
)
|
||||
|
@ -67,24 +67,10 @@ pub struct SoundtrackItem {
|
||||
length: f64,
|
||||
/// Whether this track should play during day or night
|
||||
timing: Option<DayPeriod>,
|
||||
biomes: BiomeProbability,
|
||||
biomes: Vec<(BiomeKind, u8)>,
|
||||
site: Option<SitesKind>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct BiomeProbability {
|
||||
void: u8,
|
||||
lake: u8,
|
||||
grassland: u8,
|
||||
ocean: u8,
|
||||
mountain: u8,
|
||||
snowland: u8,
|
||||
desert: u8,
|
||||
swamp: u8,
|
||||
jungle: u8,
|
||||
forest: u8,
|
||||
}
|
||||
|
||||
/// Allows control over when a track should play based on in-game time of day
|
||||
#[derive(Debug, Deserialize, PartialEq)]
|
||||
enum DayPeriod {
|
||||
@ -107,13 +93,13 @@ enum PlayState {
|
||||
pub struct MusicMgr {
|
||||
soundtrack: SoundtrackCollection,
|
||||
began_playing: Instant,
|
||||
began_fading: Instant,
|
||||
//began_fading: Instant,
|
||||
next_track_change: f64,
|
||||
/// The title of the last track played. Used to prevent a track
|
||||
/// being played twice in a row
|
||||
last_track: String,
|
||||
last_biome: BiomeKind,
|
||||
playing: PlayState,
|
||||
/*last_biome: BiomeKind,
|
||||
*playing: PlayState, */
|
||||
}
|
||||
|
||||
impl MusicMgr {
|
||||
@ -122,11 +108,11 @@ impl MusicMgr {
|
||||
Self {
|
||||
soundtrack: Self::load_soundtrack_items(),
|
||||
began_playing: Instant::now(),
|
||||
began_fading: Instant::now(),
|
||||
//began_fading: Instant::now(),
|
||||
next_track_change: 0.0,
|
||||
last_track: String::from("None"),
|
||||
last_biome: BiomeKind::Void,
|
||||
playing: PlayState::Stopped,
|
||||
/*last_biome: BiomeKind::Void,
|
||||
*playing: PlayState::Stopped, */
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,18 +125,19 @@ impl MusicMgr {
|
||||
// _ => self.last_biome,
|
||||
//};
|
||||
|
||||
if let Some(current_chunk) = client.current_chunk() {
|
||||
println!("biome: {:?}", current_chunk.meta().biome());
|
||||
println!("chaos: {}", current_chunk.meta().chaos());
|
||||
println!("alt: {}", current_chunk.meta().alt());
|
||||
println!("temp: {}", current_chunk.meta().temp());
|
||||
println!("tree_density: {}", current_chunk.meta().tree_density());
|
||||
println!("humidity: {}", current_chunk.meta().humidity());
|
||||
println!("cave_alt: {}", current_chunk.meta().cave_alt());
|
||||
if let Some(position) = client.current_position() {
|
||||
println!("player_alt: {}", position[2]);
|
||||
}
|
||||
}
|
||||
//if let Some(current_chunk) = client.current_chunk() {
|
||||
// println!("biome: {:?}", current_chunk.meta().biome());
|
||||
// println!("chaos: {}", current_chunk.meta().chaos());
|
||||
// println!("alt: {}", current_chunk.meta().alt());
|
||||
// println!("temp: {}", current_chunk.meta().temp());
|
||||
// println!("tree_density: {}",
|
||||
// current_chunk.meta().tree_density());
|
||||
// println!("humidity: {}", current_chunk.meta().humidity());
|
||||
// println!("cave_alt: {}", current_chunk.meta().cave_alt());
|
||||
// if let Some(position) = client.current_position() {
|
||||
// println!("player_alt: {}", position[2]);
|
||||
// }
|
||||
//}
|
||||
|
||||
if audio.music_enabled()
|
||||
&& !self.soundtrack.tracks.is_empty()
|
||||
@ -198,35 +185,33 @@ impl MusicMgr {
|
||||
Some(site) => site == ¤t_site,
|
||||
None => true,
|
||||
})
|
||||
.filter(|track| match current_biome {
|
||||
BiomeKind::Void => false,
|
||||
BiomeKind::Lake => track.biomes.lake > 0,
|
||||
BiomeKind::Grassland => track.biomes.grassland > 0,
|
||||
BiomeKind::Ocean => track.biomes.ocean > 0,
|
||||
BiomeKind::Mountain => track.biomes.mountain > 0,
|
||||
BiomeKind::Snowland => track.biomes.snowland > 0,
|
||||
BiomeKind::Desert => track.biomes.desert > 0,
|
||||
BiomeKind::Swamp => track.biomes.swamp > 0,
|
||||
BiomeKind::Jungle => track.biomes.jungle > 0,
|
||||
BiomeKind::Forest => track.biomes.forest > 0,
|
||||
.filter(|track| {
|
||||
let mut result = false;
|
||||
if track.biomes.len() > 0 {
|
||||
for biome in track.biomes.iter() {
|
||||
if biome.0 == current_biome {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = true;
|
||||
}
|
||||
result
|
||||
})
|
||||
.collect::<Vec<&SoundtrackItem>>();
|
||||
|
||||
//let new_maybe_track = maybe_track
|
||||
// .choose_weighted(&mut rng, |track|
|
||||
// track.biomes.unwrap().entry(current_biome));
|
||||
|
||||
let new_maybe_track = maybe_track.choose_weighted(&mut rng, |track| match current_biome {
|
||||
BiomeKind::Void => track.biomes.void,
|
||||
BiomeKind::Lake => track.biomes.lake,
|
||||
BiomeKind::Grassland => track.biomes.grassland,
|
||||
BiomeKind::Ocean => track.biomes.ocean,
|
||||
BiomeKind::Mountain => track.biomes.mountain,
|
||||
BiomeKind::Snowland => track.biomes.snowland,
|
||||
BiomeKind::Desert => track.biomes.desert,
|
||||
BiomeKind::Swamp => track.biomes.swamp,
|
||||
BiomeKind::Jungle => track.biomes.jungle,
|
||||
BiomeKind::Forest => track.biomes.forest,
|
||||
let new_maybe_track = maybe_track.choose_weighted(&mut rng, |track| {
|
||||
let mut chance = 0;
|
||||
if track.biomes.len() > 0 {
|
||||
for biome in track.biomes.iter() {
|
||||
if biome.0 == current_biome {
|
||||
chance = biome.1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
chance = 1;
|
||||
}
|
||||
chance
|
||||
});
|
||||
|
||||
if let Ok(track) = new_maybe_track {
|
||||
@ -264,9 +249,9 @@ impl MusicMgr {
|
||||
alt = chunk.meta().alt();
|
||||
cave_alt = chunk.meta().cave_alt();
|
||||
}
|
||||
if player_alt < cave_alt && cave_alt != 0.0 {
|
||||
if player_alt < (alt - 20.0) && cave_alt != 0.0 {
|
||||
SitesKind::Cave
|
||||
} else if player_alt < (alt - 30.0) {
|
||||
} else if player_alt < (alt - 20.0) {
|
||||
SitesKind::Dungeon
|
||||
} else {
|
||||
SitesKind::None
|
||||
|
@ -86,15 +86,15 @@ impl EventMapper for BlockEventMapper {
|
||||
volume: 1.0,
|
||||
cond: |st| st.get_day_period().is_dark(),
|
||||
},
|
||||
BlockSounds {
|
||||
blocks: |boi| &boi.embers,
|
||||
range: 1,
|
||||
sfx: SfxEvent::Embers,
|
||||
volume: 0.15,
|
||||
//volume: 0.05,
|
||||
cond: |_| true,
|
||||
//cond: |st| st.get_day_period().is_dark(),
|
||||
},
|
||||
//BlockSounds {
|
||||
// blocks: |boi| &boi.embers,
|
||||
// range: 1,
|
||||
// sfx: SfxEvent::Embers,
|
||||
// volume: 0.15,
|
||||
// //volume: 0.05,
|
||||
// cond: |_| true,
|
||||
// //cond: |st| st.get_day_period().is_dark(),
|
||||
//},
|
||||
BlockSounds {
|
||||
blocks: |boi| &boi.reeds,
|
||||
range: 1,
|
||||
@ -131,7 +131,7 @@ impl EventMapper for BlockEventMapper {
|
||||
for sounds in sounds.iter() {
|
||||
if !(sounds.cond)(state) {
|
||||
continue;
|
||||
} else if sounds.sfx == SfxEvent::Birdcall && thread_rng().gen_bool(0.99) {
|
||||
} else if sounds.sfx == SfxEvent::Birdcall && thread_rng().gen_bool(0.995) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user