aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/audio
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-01 20:55:38 +0300
committerValentin Popov <valentin@popov.link>2026-12-01 20:55:38 +0300
commitd154efdd050e730c4072e5f53843cf3610651d00 (patch)
treefdd0c56d5232dd958f529d6faefb0f585944057e /apps/fparkan-game/src/audio
parent697241b84fb0446af5feba8eb1f78b3b04cdd5a4 (diff)
downloadfparkan-d154efdd050e730c4072e5f53843cf3610651d00.tar.xz
fparkan-d154efdd050e730c4072e5f53843cf3610651d00.zip
feat(player): announce vehicle capture when the hero stays outside
Restore the original warbot and mobile command centre acknowledgement bank. A capture that also seats the hero remains silent. The bank and non-repeat selection were checked against the native DLL, and a walk from the normal Teleport start queued the authored voice before the objective notice.
Diffstat (limited to 'apps/fparkan-game/src/audio')
-rw-r--r--apps/fparkan-game/src/audio/capture_voice.rs52
1 files changed, 52 insertions, 0 deletions
diff --git a/apps/fparkan-game/src/audio/capture_voice.rs b/apps/fparkan-game/src/audio/capture_voice.rs
new file mode 100644
index 00000000..86ecee63
--- /dev/null
+++ b/apps/fparkan-game/src/audio/capture_voice.rs
@@ -0,0 +1,52 @@
+use super::{GameAudio, VariationRng};
+
+// iron3d+0x8ecc0 selects bank 3 for warbots and mobile command centres.
+const ACKNOWLEDGEMENTS: [&str; 5] = [
+ "VOICE_ACKNOWLEDGE_B",
+ "VOICE_AFFIRMATIVE_B",
+ "VOICE_OK_B",
+ "VOICE_YES_SIR_B",
+ "VOICE_EXECUTE_B",
+];
+
+pub(super) struct VehicleCaptureVoice {
+ rng: VariationRng,
+ previous: i32,
+}
+
+impl VehicleCaptureVoice {
+ pub(super) fn new(seed: u32) -> Self {
+ Self {
+ rng: VariationRng::from_clock(seed),
+ previous: -1,
+ }
+ }
+
+ fn next(&mut self) -> &'static str {
+ let index = self
+ .rng
+ .choose(ACKNOWLEDGEMENTS.len(), &mut self.previous)
+ .expect("non-empty acknowledgement bank");
+ ACKNOWLEDGEMENTS[index]
+ }
+}
+
+impl GameAudio {
+ pub(crate) fn queue_vehicle_capture_voice(&mut self) -> Result<String, String> {
+ let symbol = self.vehicle_capture_voice.next();
+ self.queue_game_voice(symbol)
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::{VehicleCaptureVoice, ACKNOWLEDGEMENTS};
+
+ #[test]
+ fn capture_acknowledgements_follow_the_native_bank_order_and_skip_repeats() {
+ let mut voice = VehicleCaptureVoice::new(0x156a_e3bf);
+ let expected = [2, 3, 2, 3, 2, 4, 3, 4, 3, 0].map(|i| ACKNOWLEDGEMENTS[i]);
+ let actual = std::array::from_fn::<_, 10, _>(|_| voice.next());
+ assert_eq!(actual, expected);
+ }
+}