diff --git a/CHANGELOG.md b/CHANGELOG.md index c12d5a7fee..8ec4aae115 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,9 +21,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed ### Fixed -- Fixed bug that would sometimes cause taking a screenshot to panic because a buffer was mapped a the wrong time. +- Fixed bug that would sometimes cause taking a screenshot to panic because a buffer was mapped at the wrong time. - Players can no longer push waypoints around - Sites will now also be placed near the edge of the map +- Fix a bug causing NPCs to jitter on interaction and randomly run away. ## [0.12.0] - 2022-02-19 diff --git a/common/src/comp/agent.rs b/common/src/comp/agent.rs index b79fec525a..e7ff1ca1f8 100644 --- a/common/src/comp/agent.rs +++ b/common/src/comp/agent.rs @@ -347,13 +347,13 @@ impl Sound { #[derive(Copy, Clone, Debug)] pub enum SoundKind { Unknown, + Utterance(UtteranceKind, Body), Movement, Melee, Projectile, Explosion, Beam, Shockwave, - Utterance(UtteranceKind, Body), } #[derive(Clone, Copy, Debug)] diff --git a/common/systems/src/beam.rs b/common/systems/src/beam.rs index 55010f688e..b073472910 100644 --- a/common/systems/src/beam.rs +++ b/common/systems/src/beam.rs @@ -100,13 +100,12 @@ impl<'a> System<'a> for Sys { let mut rng = thread_rng(); if rng.gen_bool(0.005) { server_events.push(ServerEvent::Sound { - sound: Sound::new(SoundKind::Beam, pos.0, 7.0, time), + sound: Sound::new(SoundKind::Beam, pos.0, 13.0, time), }); } // If beam segment is out of time emit destroy event but still continue since it - // may have traveled and produced effects a bit before reaching its - // end point + // may have traveled and produced effects a bit before reaching its end point if end_time < time { server_events.push(ServerEvent::Delete(entity)); } diff --git a/common/systems/src/melee.rs b/common/systems/src/melee.rs index 8c4be6bc4a..fe84701bc4 100644 --- a/common/systems/src/melee.rs +++ b/common/systems/src/melee.rs @@ -73,7 +73,7 @@ impl<'a> System<'a> for Sys { continue; } server_emitter.emit(ServerEvent::Sound { - sound: Sound::new(SoundKind::Melee, pos.0, 3.0, read_data.time.0), + sound: Sound::new(SoundKind::Melee, pos.0, 2.0, read_data.time.0), }); melee_attack.applied = true; diff --git a/common/systems/src/projectile.rs b/common/systems/src/projectile.rs index 3c3f204902..d3be470e66 100644 --- a/common/systems/src/projectile.rs +++ b/common/systems/src/projectile.rs @@ -81,7 +81,7 @@ impl<'a> System<'a> for Sys { let mut rng = thread_rng(); if physics.on_surface().is_none() && rng.gen_bool(0.05) { server_emitter.emit(ServerEvent::Sound { - sound: Sound::new(SoundKind::Projectile, pos.0, 2.0, read_data.time.0), + sound: Sound::new(SoundKind::Projectile, pos.0, 4.0, read_data.time.0), }); } diff --git a/common/systems/src/shockwave.rs b/common/systems/src/shockwave.rs index 259756ea72..04ade59559 100644 --- a/common/systems/src/shockwave.rs +++ b/common/systems/src/shockwave.rs @@ -94,7 +94,7 @@ impl<'a> System<'a> for Sys { let mut rng = thread_rng(); if rng.gen_bool(0.05) { server_emitter.emit(ServerEvent::Sound { - sound: Sound::new(SoundKind::Shockwave, pos.0, 16.0, time), + sound: Sound::new(SoundKind::Shockwave, pos.0, 40.0, time), }); } diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 9f799aa8fd..4f373b62ac 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -597,7 +597,7 @@ pub fn handle_explosion(server: &Server, pos: Vec3, explosion: Explosion, o .retrieve_entity_internal(uid.into()) }); - let explosion_volume = 2.5 * explosion.radius; + let explosion_volume = 6.25 * explosion.radius; let mut emitter = server_eventbus.emitter(); emitter.emit(ServerEvent::Sound { sound: Sound::new(SoundKind::Explosion, pos, explosion_volume, time.0), diff --git a/server/src/sys/agent.rs b/server/src/sys/agent.rs index d339e87fb7..b1e202de7f 100644 --- a/server/src/sys/agent.rs +++ b/server/src/sys/agent.rs @@ -524,7 +524,7 @@ impl<'a> AgentData<'a> { match sound { Some(AgentEvent::ServerSound(sound)) => { agent.sounds_heard.push(sound); - agent.awareness += sound.vol; + agent.awareness += sound.vol / 2.0; }, Some(AgentEvent::Hurt) => { // Hurt utterances at random upon receiving damage @@ -2165,36 +2165,23 @@ impl<'a> AgentData<'a> { if let Some(agent_stats) = read_data.stats.get(*self.entity) { let sound_pos = Pos(sound.pos); let dist_sqrd = self.pos.0.distance_squared(sound_pos.0); + let close_enough_to_react = dist_sqrd < 35.0_f32.powi(2); + let too_far_to_investigate = dist_sqrd > 10.0_f32.powi(2); // FIXME: We need to be able to change the name of a guard without breaking this - // logic The `Mark` enum from common::agent could be used to + // logic. The `Mark` enum from common::agent could be used to // match with `agent::Mark::Guard` let is_village_guard = agent_stats.name == *"Guard".to_string(); let is_enemy = matches!(self.alignment, Some(Alignment::Enemy)); - if is_enemy { - let far_enough = dist_sqrd > 10.0_f32.powi(2); + let sound_was_loud = sound.vol >= 10.0; + let sound_was_threatening = sound_was_loud + || matches!(sound.kind, SoundKind::Utterance(UtteranceKind::Scream, _)); - if far_enough { - self.follow(agent, controller, &read_data.terrain, &sound_pos); - } else { - // TODO: Change this to a search action instead of idle - self.idle(agent, controller, read_data, rng); - } - } else if is_village_guard { + if (is_enemy || is_village_guard) && too_far_to_investigate { self.follow(agent, controller, &read_data.terrain, &sound_pos); - } else if !is_village_guard { - let flee_health = agent.psyche.flee_health; - let close_enough = dist_sqrd < 35.0_f32.powi(2); - let sound_was_loud = sound.vol >= 10.0; - - if close_enough - && (flee_health <= 0.7 || (flee_health <= 0.5 && sound_was_loud)) - { - self.flee(agent, controller, &read_data.terrain, &sound_pos); - } else { - self.idle(agent, controller, read_data, rng); - } + } else if sound_was_threatening && close_enough_to_react { + self.flee(agent, controller, &read_data.terrain, &sound_pos); } else { // TODO: Change this to a search action instead of idle self.idle(agent, controller, read_data, rng); @@ -2354,7 +2341,7 @@ impl<'a> AgentData<'a> { sound: Sound::new( SoundKind::Utterance(UtteranceKind::Scream, *body), self.pos.0, - 100.0, + 13.0, time, ), });