From c44a9092d33235e035cc6b44b476a7efd5547393 Mon Sep 17 00:00:00 2001 From: jiminycrick Date: Wed, 11 Nov 2020 19:55:40 -0800 Subject: [PATCH] Biome definition tweaks and more sfx --- assets/voxygen/audio/sfx.ron | 22 +++++++ .../audio/sfx/abilities/flame_thrower.wav | 2 +- .../audio/sfx/abilities/staff_channeling.wav | 4 +- assets/voxygen/audio/soundtrack.ron | 22 ++++--- voxygen/src/audio/music.rs | 21 +------ voxygen/src/audio/sfx/mod.rs | 13 +++-- voxygen/src/audio/wind.rs | 57 ++++--------------- voxygen/src/main.rs | 2 +- voxygen/src/scene/mod.rs | 4 +- world/src/block/mod.rs | 7 ++- world/src/sim/mod.rs | 14 ++--- 11 files changed, 77 insertions(+), 91 deletions(-) diff --git a/assets/voxygen/audio/sfx.ron b/assets/voxygen/audio/sfx.ron index 9feadcc507..a2a2b9f168 100644 --- a/assets/voxygen/audio/sfx.ron +++ b/assets/voxygen/audio/sfx.ron @@ -366,6 +366,28 @@ threshold: 0.3, ), + // + // Sceptre + // + Wield(Sceptre): ( + files: [ + "voxygen.audio.sfx.weapon.sword_out", + ], + threshold: 0.5, + ), + Unwield(Sceptre): ( + files: [ + "voxygen.audio.sfx.weapon.sword_in", + ], + threshold: 0.5, + ), + Attack(BasicBeam, Sceptre): ( + files: [ + "voxygen.audio.sfx.abilities.staff_channeling", + ], + threshold: 0.6, + ), + // // Dagger // diff --git a/assets/voxygen/audio/sfx/abilities/flame_thrower.wav b/assets/voxygen/audio/sfx/abilities/flame_thrower.wav index 306420695b..1f6b029d6d 100644 --- a/assets/voxygen/audio/sfx/abilities/flame_thrower.wav +++ b/assets/voxygen/audio/sfx/abilities/flame_thrower.wav @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:507a78da5d8e3d8a01133640803b7bda101c763c14270b6486b948c23ca75eff +oid sha256:b54842c0b98562ffc6f609f7f947544bee28269da0bab5ff2562b12cd2ae3aad size 77368 diff --git a/assets/voxygen/audio/sfx/abilities/staff_channeling.wav b/assets/voxygen/audio/sfx/abilities/staff_channeling.wav index 3cf52abb56..768b9049f9 100644 --- a/assets/voxygen/audio/sfx/abilities/staff_channeling.wav +++ b/assets/voxygen/audio/sfx/abilities/staff_channeling.wav @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7029cf7dccedbf6593c135964c45b9aacaa9d5bd11af577695b73851ce2efbd1 -size 636950 +oid sha256:cbc64e9c923f80192a8cb6720335d6927824914a44c948b0915d09f00367eeac +size 156072 diff --git a/assets/voxygen/audio/soundtrack.ron b/assets/voxygen/audio/soundtrack.ron index 5abdb84d9b..2cb39fe157 100644 --- a/assets/voxygen/audio/soundtrack.ron +++ b/assets/voxygen/audio/soundtrack.ron @@ -1,8 +1,10 @@ // TODO: Re-add tunes that are not fitting general outside day/night situations // TODO: Add an ambient-soundtrack that runs independently from the musical soundtrack -//Times: Some(Day), Some(Night), None -//List of biomes currently: Grassland, Forest, Jungle, Desert, Snowland, Lake, Mountain -//Sites: Cave, Dungeon +// Times: Some(Day), Some(Night), None +// List of biomes currently: Grassland, Forest, Desert, Snowland, Lake, Mountain, Ocean +// Also Jungle and Swamp but these are not defined currently as the worldgen around +// them is changing and not stable +// Sites: Cave, Dungeon ( tracks: [ @@ -12,7 +14,6 @@ length: 206.0, timing: Some(Night), biomes: [ - (Jungle, 1), (Desert, 1), (Grassland, 1), (Snowland, 1), @@ -29,7 +30,6 @@ timing: Some(Night), biomes: [ (Forest, 1), - (Jungle, 1), ], site: Some(Void), artist: "Aeronic", @@ -75,6 +75,15 @@ site: Some(Cave), artist: "Aeronic", ), + ( //Repeat for other site + title: "Mineral Deposits", + path: "voxygen.audio.soundtrack.mineral_deposits", + length: 148.0, + timing: None, + biomes: [], + site: Some(Dungeon), + artist: "Aeronic", + ), ( title: "Moonbeams", path: "voxygen.audio.soundtrack.moonbeams", @@ -90,7 +99,6 @@ length: 173.0, timing: Some(Night), biomes: [ - (Forest, 1), (Grassland, 1), ], site: Some(Void), @@ -148,7 +156,7 @@ site: Some(Cave), artist: "badbbad", ), - ( //Repeat for other site + ( //Repeat for other site title: "Down The Rabbit Hole", path: "voxygen.audio.soundtrack.down_the_rabbit_hole", length: 244.0, diff --git a/voxygen/src/audio/music.rs b/voxygen/src/audio/music.rs index 8130b7d438..b8b7c18bc2 100644 --- a/voxygen/src/audio/music.rs +++ b/voxygen/src/audio/music.rs @@ -26,7 +26,7 @@ //! path: "voxygen.audio.soundtrack.sleepy", //! length: 400.0, //! timing: Some(Night), -//! biome: [ +//! biomes: [ //! (Forest, 1), //! (Grassland, 2), //! ], @@ -132,29 +132,12 @@ impl MusicMgr { //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_pos: {:?}", position); //} - //let player_position = match client.current_position() { - // Some(pos) => pos, - // None => Vec3::default(), - //}; - //let block_position = Vec3::new( - // player_position[0], - // player_position[1], - // player_position[2] - 1.0, - //) - //.map(|x| x as i32); - //let block_kind = match state.get_block(block_position) { - // Some(block) => block.kind(), - // None => BlockKind::Air, - //}; - //println!("BlockKind: {:?}", block_kind); if audio.music_enabled() && !self.soundtrack.tracks.is_empty() @@ -226,7 +209,7 @@ impl MusicMgr { }); if let Ok(track) = new_maybe_track { - println!("Now playing {:?}", track.title); + //println!("Now playing {:?}", track.title); self.last_track = String::from(&track.title); self.began_playing = Instant::now(); self.next_track_change = track.length + silence_between_tracks_seconds; diff --git a/voxygen/src/audio/sfx/mod.rs b/voxygen/src/audio/sfx/mod.rs index 55d40531cc..c060e8c8d0 100644 --- a/voxygen/src/audio/sfx/mod.rs +++ b/voxygen/src/audio/sfx/mod.rs @@ -244,15 +244,16 @@ pub struct SfxMgr { event_mapper: SfxEventMapper, } -impl SfxMgr { - #[allow(clippy::new_without_default)] // TODO: Pending review in #587 - pub fn new() -> Self { +impl Default for SfxMgr { + fn default() -> Self { Self { triggers: Self::load_sfx_items(), event_mapper: SfxEventMapper::new(), } } +} +impl SfxMgr { pub fn maintain( &mut self, audio: &mut AudioFrontend, @@ -360,7 +361,11 @@ impl SfxMgr { audio.play_sfx(file_ref, *pos, None); }, - Body::Object(object::Body::BoltFire | object::Body::BoltFireBig) => { + Body::Object( + object::Body::BoltFire + | object::Body::BoltFireBig + | object::Body::BoltNature, + ) => { let file_ref = vec![ "voxygen.audio.sfx.abilities.fire_shot_1", "voxygen.audio.sfx.abilities.fire_shot_2", diff --git a/voxygen/src/audio/wind.rs b/voxygen/src/audio/wind.rs index 2544dceaf5..ca739c3d45 100644 --- a/voxygen/src/audio/wind.rs +++ b/voxygen/src/audio/wind.rs @@ -6,10 +6,6 @@ use serde::Deserialize; use std::time::Instant; use tracing::warn; -// For if we want wind to vary strength by time of day -//const DAY_START_SECONDS: u32 = 28800; // 8:00 -//const DAY_END_SECONDS: u32 = 70200; // 19:30 - #[derive(Debug, Default, Deserialize)] struct WindCollection { tracks: Vec, @@ -21,19 +17,8 @@ pub struct WindItem { path: String, /// Length of the track in seconds length: f32, - /* Whether this track should play during day or night - * timing: Option, */ } -///// Allows control over when a track should play based on in-game time of day -//#[derive(Debug, Deserialize, PartialEq)] -//enum DayPeriod { -// /// 8:00 AM to 7:30 PM -// Day, -// /// 7:31 PM to 6:59 AM -// Night, -//} - pub struct WindMgr { soundtrack: WindCollection, began_playing: Instant, @@ -42,9 +27,8 @@ pub struct WindMgr { tree_multiplier: f32, } -impl WindMgr { - #[allow(clippy::new_without_default)] // TODO: Pending review in #587 - pub fn new() -> Self { +impl Default for WindMgr { + fn default() -> Self { Self { soundtrack: Self::load_soundtrack_items(), began_playing: Instant::now(), @@ -53,7 +37,9 @@ impl WindMgr { tree_multiplier: 0.0, } } +} +impl WindMgr { /// Checks whether the previous track has completed. If so, sends a /// request to play the next (random) track pub fn maintain( @@ -64,15 +50,18 @@ impl WindMgr { camera: &Camera, ) { if audio.sfx_enabled() && !self.soundtrack.tracks.is_empty() { - let player_alt = Self::get_current_alt(client); + let focus_off = camera.get_focus_pos().map(f32::trunc); + let cam_pos = camera.dependents().cam_pos + focus_off; + + let cam_alt = cam_pos.z; let terrain_alt = Self::get_current_terrain_alt(client); - let alt_multiplier = (player_alt / 1200.0).abs(); + let alt_multiplier = (cam_alt / 1200.0).abs(); // Tree density factors into wind volume. The more trees, // the less wind let mut tree_multiplier = self.tree_multiplier; - let new_tree_multiplier = if (player_alt - terrain_alt) < 150.0 { + let new_tree_multiplier = if (cam_alt - terrain_alt) < 150.0 { 1.0 - Self::get_current_tree_density(client) } else { 1.0 @@ -88,9 +77,6 @@ impl WindMgr { let mut volume_multiplier = alt_multiplier * self.tree_multiplier; - let focus_off = camera.get_focus_pos().map(f32::trunc); - let cam_pos = camera.dependents().cam_pos + focus_off; - // Checks if the camera is underwater to stop wind sounds if state .terrain() @@ -99,17 +85,13 @@ impl WindMgr { .unwrap_or(BlockKind::Air) == BlockKind::Water { - volume_multiplier *= volume_multiplier; + volume_multiplier *= 0.1; } if cam_pos.z < Self::get_current_terrain_alt(client) - 10.0 { volume_multiplier = 0.0; } - if volume_multiplier > 1.0 { - volume_multiplier = 1.0 - } - - let target_volume = volume_multiplier; + let target_volume = volume_multiplier.max(0.0).min(1.0); // Transitions the wind smoothly self.volume = audio.get_wind_volume(); @@ -132,21 +114,6 @@ impl WindMgr { } } - //fn get_current_day_period(game_time: u32) -> DayPeriod { - // if game_time > DAY_START_SECONDS && game_time < DAY_END_SECONDS { - // DayPeriod::Day - // } else { - // DayPeriod::Night - // } - //} - - fn get_current_alt(client: &Client) -> f32 { - match client.current_position() { - Some(pos) => pos.z, - None => 0.0, - } - } - fn get_current_terrain_alt(client: &Client) -> f32 { if let Some(chunk) = client.current_chunk() { chunk.meta().alt() diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index 5bb028a9f1..e4c5b60a42 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -4,7 +4,7 @@ #![recursion_limit = "2048"] use veloren_voxygen::{ - audio::{self, AudioFrontend}, + audio::AudioFrontend, i18n::{self, i18n_asset_key, Localization}, logging, profile::Profile, diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 53385c14e8..cd0b3db87d 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -307,9 +307,9 @@ impl Scene { light_data: Vec::new(), particle_mgr: ParticleMgr::new(renderer), figure_mgr: FigureMgr::new(renderer), - sfx_mgr: SfxMgr::new(), + sfx_mgr: SfxMgr::default(), music_mgr: MusicMgr::default(), - ambient_mgr: WindMgr::new(), + ambient_mgr: WindMgr::default(), } } diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index e543f6e00e..b3977419d1 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -1,7 +1,7 @@ use crate::{ column::{ColumnGen, ColumnSample}, util::{RandomField, Sampler, SmallCache}, - IndexRef, CONFIG, + IndexRef, }; use common::terrain::{ structure::{self, StructureBlock}, @@ -67,9 +67,9 @@ impl<'a> BlockGen<'a> { // marble_small, rock, // temp, - temp, // humidity, stone_col, + snow_cover, .. } = sample; @@ -129,7 +129,8 @@ impl<'a> BlockGen<'a> { let col = Lerp::lerp(sub_surface_color, surface_color, grass_factor); // Surface Some(Block::new( - if temp < CONFIG.snow_temp + 0.031 { + if snow_cover { + //if temp < CONFIG.snow_temp + 0.031 { BlockKind::Snow } else if grass_factor > 0.7 { BlockKind::Grass diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index d587ba4106..67905b01c9 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -2303,20 +2303,20 @@ impl SimChunk { pub fn get_biome(&self) -> BiomeKind { if self.alt < CONFIG.sea_level { BiomeKind::Ocean - } else if self.humidity == 0.5 { + } else if (self.temp - 0.5) < 0.005 && self.humidity < 0.1 { BiomeKind::Lake } else if self.temp < CONFIG.snow_temp { BiomeKind::Snowland - } else if self.alt > 450.0 && self.chaos > 0.35 && self.tree_density < 0.7 { + } else if self.alt > 450.0 && self.chaos > 0.3 && self.tree_density < 0.6 { BiomeKind::Mountain } else if self.temp > CONFIG.desert_temp && self.humidity < 0.6 { BiomeKind::Desert - } else if self.tree_density > 0.65 && self.humidity > 0.7 && self.temp > 0.8 { - BiomeKind::Jungle - } else if self.tree_density > 0.65 { + //} else if self.tree_density > 0.65 && self.humidity > 0.7 && self.temp > 0.8 { + // BiomeKind::Jungle + } else if self.tree_density > 0.5 { BiomeKind::Forest - } else if self.humidity > 0.8 { - BiomeKind::Swamp + //} else if self.humidity > 0.8 { + // BiomeKind::Swamp } else { BiomeKind::Grassland }