Part of #41: the comments of `benilla-formats` (the library, its extract tools, examples and tests) are rewritten to the rule in `docs/METHOD.md`, which is what the code does and the reference fact behind it, in a line. 19,654 comment lines become 7,264. Fixes #105: the WMO collision comments now name walking's box-query leaf `0x6bca50` and the camera and line-of-sight segment-query leaf `0x6bc700`, in `models/collision.rs`, `examples/wmo_bsp.rs` and `tests/chain.rs`. - **The mechanical strip.** The citations that were only a private record number go first, and each edit is shown to be a pure removal. - **Wrong facts corrected.** The rewrite corrects the comments that stated wrong facts. Among them: - A placed doodad's material alpha reads file slot 0 on its spawn clock, while the reference reads bone 0's armed sequence, re-rolled every play window. The old text said doodads are armed once at load. - The fog end is stored ×36 and scaled once at load (`0x6d6090`). It is not raw. - The MCSH bit picks a map doodad's sun scale, 1.0 lit or 0.5 shadowed. 2.5 belongs to an entity's light node. - `SpellRec` is the row as stored, column × 4, not a translated copy. - A global sequence's clock is anchored at the instance's attach time (`0x714352`). - Particle twinkle is a gated size multiplier (`0x7b2adc`). - The blob shadow sizes from the Stand box. - Data claims are checked against the install: the weapon-trail kits' parameters and alphas, the beam rows' noise, and the maps' `field_16`. - Dozens more turned up on the way: renamed or deleted items, docs sitting on the wrong item, stale counts and links. - **Deviation labels.** "Deviation:" now marks only a choice with a reason. An unbuilt behaviour says so plainly. - **Verification.** Every file strips to identical code, and `cargo fmt --check` is clean. Four second readers compared every file old against new, restored the facts the rewrite had dropped, and checked each new citation against the reference, the code and the shipped data. String literals are untouched; they are #92. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
112 lines
3.6 KiB
Rust
112 lines
3.6 KiB
Rust
//! `WeaponImpactSounds.dbc`: the melee impact sounds, ten normal and ten critical kits per weapon
|
|
//! subclass and material (column 2; a metal weapon carries the metal parry kits), which the client
|
|
//! reads as `AUIMPACTSOUNDARRAY` (`0x587450`). Slots 7-9 are wood, stone and ethereal creatures,
|
|
//! `CreatureImpactType` 2, 1 and 3.
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use anyhow::{Context, Result};
|
|
use benilla_dbc::{FieldType, Schema, SchemaField};
|
|
|
|
use crate::dbc::{parse, u32_at};
|
|
use crate::Chain;
|
|
|
|
/// The ten target slots, as the shipped kit names pin them.
|
|
pub mod impact_slot {
|
|
pub const FLESH: usize = 0;
|
|
pub const CHAIN: usize = 1;
|
|
pub const PLATE: usize = 2;
|
|
pub const SHIELD_METAL: usize = 3;
|
|
pub const SHIELD_WOOD: usize = 4;
|
|
pub const PARRY_METAL: usize = 5;
|
|
pub const PARRY_WOOD: usize = 6;
|
|
pub const WOOD: usize = 7;
|
|
pub const STONE: usize = 8;
|
|
pub const ETHEREAL: usize = 9;
|
|
}
|
|
|
|
/// One weapon row: the normal and critical impact kits by target slot.
|
|
pub struct WeaponImpactRow {
|
|
pub impact: [u32; 10],
|
|
pub crit: [u32; 10],
|
|
}
|
|
|
|
/// `(WeaponSubClassID, metal)` → the impact kits.
|
|
pub struct WeaponImpactCatalog {
|
|
rows: HashMap<(u32, bool), WeaponImpactRow>,
|
|
}
|
|
|
|
impl WeaponImpactCatalog {
|
|
/// The row for a subclass in the given material, else in the other, as some have only one;
|
|
/// wands and thrown have none.
|
|
pub fn get(&self, subclass: u32, metal: bool) -> Option<&WeaponImpactRow> {
|
|
self.rows
|
|
.get(&(subclass, metal))
|
|
.or_else(|| self.rows.get(&(subclass, !metal)))
|
|
}
|
|
|
|
pub fn len(&self) -> usize {
|
|
self.rows.len()
|
|
}
|
|
|
|
pub fn is_empty(&self) -> bool {
|
|
self.rows.is_empty()
|
|
}
|
|
}
|
|
|
|
fn schema() -> Schema {
|
|
let mut s = Schema::new("WeaponImpactSounds");
|
|
for i in 0..23 {
|
|
s.add_field(SchemaField::new(format!("f{i}"), FieldType::UInt32));
|
|
}
|
|
s
|
|
}
|
|
|
|
/// Read `WeaponImpactSounds.dbc` off the patch chain.
|
|
pub fn load_weapon_impact_catalog(chain: &mut Chain) -> Result<WeaponImpactCatalog> {
|
|
let bytes = chain
|
|
.read_file("DBFilesClient\\WeaponImpactSounds.dbc")
|
|
.context("reading WeaponImpactSounds.dbc")?;
|
|
let rs = parse(&bytes, schema(), "WeaponImpactSounds")?;
|
|
let mut rows = HashMap::with_capacity(rs.records().len());
|
|
for r in rs.records() {
|
|
let (Some(subclass), Some(metal)) = (u32_at(r, 1), u32_at(r, 2)) else {
|
|
continue;
|
|
};
|
|
let g = |i: usize| u32_at(r, i).unwrap_or(0);
|
|
let mut impact = [0u32; 10];
|
|
let mut crit = [0u32; 10];
|
|
for s in 0..10 {
|
|
impact[s] = g(3 + s);
|
|
crit[s] = g(13 + s);
|
|
}
|
|
rows.insert((subclass, metal != 0), WeaponImpactRow { impact, crit });
|
|
}
|
|
Ok(WeaponImpactCatalog { rows })
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn real_weapon_impacts_decode() {
|
|
let data = crate::wow_data_or_skip!();
|
|
let mut chain = crate::open_chain(&data).expect("open chain");
|
|
let cat = load_weapon_impact_catalog(&mut chain).expect("load weapon impacts");
|
|
assert_eq!(cat.len(), 30);
|
|
|
|
let axe = cat.get(0, true).expect("Axe1H metal");
|
|
assert_eq!(axe.impact[impact_slot::FLESH], 171);
|
|
assert_eq!(axe.crit[impact_slot::FLESH], 172);
|
|
assert_eq!(axe.impact[impact_slot::STONE], 3206);
|
|
assert_eq!(axe.impact[impact_slot::PARRY_METAL], 1002);
|
|
|
|
let unarmed = cat.get(13, true).expect("Fist/unarmed");
|
|
assert_ne!(unarmed.impact[impact_slot::FLESH], 0);
|
|
|
|
// Bows (2) have only a non-metal row.
|
|
assert!(cat.get(2, true).is_some());
|
|
}
|
|
}
|