diff --git a/common/src/comp/agent.rs b/common/src/comp/agent.rs index 0f21db8320..556537ed63 100644 --- a/common/src/comp/agent.rs +++ b/common/src/comp/agent.rs @@ -327,8 +327,6 @@ pub enum SoundKind { Beam, Shockwave, Utterance(UtteranceKind, Body), - // TODO: unify VillagerAlarm with Utterance - VillagerAlarm, } #[derive(Clone, Copy, Debug)] diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index 93f81a49cd..a3b9ca9076 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -104,6 +104,7 @@ pub enum UtteranceKind { Surprised, Hurt, Greeting, + Scream, /* Death, * TODO: Wait for more post-death features (i.e. animiations) before implementing death * sounds */ diff --git a/server/src/sys/agent.rs b/server/src/sys/agent.rs index 331e86e4c1..56c43c7a79 100644 --- a/server/src/sys/agent.rs +++ b/server/src/sys/agent.rs @@ -716,7 +716,7 @@ impl<'a> AgentData<'a> { // Should the agent flee? if agent.action_state.timer == 0.0 && can_speak(agent) { self.chat_general("npc.speech.villager_under_attack", event_emitter); - self.emit_villager_alarm(read_data.time.0, event_emitter); + self.emit_alarm(read_data.time.0, event_emitter); agent.action_state.timer = 0.01; } else if agent.action_state.timer < FLEE_DURATION || dist_sq < MAX_FLEE_DIST.powi(2) @@ -4355,10 +4355,12 @@ impl<'a> AgentData<'a> { ))); } - fn emit_villager_alarm(&self, time: f64, event_emitter: &mut Emitter<'_, ServerEvent>) { - event_emitter.emit(ServerEvent::Sound { - sound: Sound::new(SoundKind::VillagerAlarm, self.pos.0, 100.0, time), - }); + fn emit_alarm(&self, time: f64, event_emitter: &mut Emitter<'_, ServerEvent>) { + if let Some(body) = self.body { + event_emitter.emit(ServerEvent::Sound { + sound: Sound::new(SoundKind::Utterance(UtteranceKind::Scream, *body), self.pos.0, 100.0, time), + }); + } } }