feat: attenuate indirect blast damage behind known cover
build / mod (push) Failing after 18s

Use a bounded read-only pre-destruction occupancy sample; preserve conservative damage for unresolved geometry and do not defer or repeat damage on replies.

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
2026-11-02 23:55:38 +03:00
parent a7d400ea7e
commit c96676f3e5
8 changed files with 196 additions and 19 deletions
+7 -7
View File
@@ -2386,7 +2386,7 @@ impl Sim {
out.jolt((1.0 - d / reach) as f32 * strength, [1.0, 0.8, 1.6, 2.2, 3.0][power]);
}
}
self.blast_damage(pos, power, out);
self.blast_damage(pos, power, ground, out);
if self.damage && tnt > 0 {
for i in 0..tnt {
out.commands.push(format!(
@@ -2416,17 +2416,17 @@ impl Sim {
}
/// A drone hit by the guns of system `by`.
fn shoot_down(&mut self, idx: usize, by: u32, missile: Option<u32>, out: &mut Out) -> Option<Outcome> {
fn shoot_down(&mut self, idx: usize, by: u32, missile: Option<u32>, ground: &Ground, out: &mut Out) -> Option<Outcome> {
let kind = self.sams.iter().find(|s| s.id == by).map_or(SamKind::Gepard, |s| s.kind);
let shell = kind.spec().gun.as_ref().map_or(5.0, |g| g.shell);
let at = self.drones[idx].pos;
self.shoot_down_by(idx, by, missile, Impact::gun(kind, at, shell), out)
self.shoot_down_by(idx, by, missile, Impact::gun(kind, at, shell), ground, out)
}
/// A drone brought down by `imp` from system `by`: how it ends is rolled once (combat randomness, so a
/// detonation really means no ground impact), recorded with the kill, and drawn from the visual randomness
/// only. The kill is counted here and nowhere else.
fn shoot_down_by(&mut self, idx: usize, by: u32, missile: Option<u32>, imp: Impact, out: &mut Out) -> Option<Outcome> {
fn shoot_down_by(&mut self, idx: usize, by: u32, missile: Option<u32>, imp: Impact, ground: &Ground, out: &mut Out) -> Option<Outcome> {
if !self.drones[idx].alive() {
return None;
}
@@ -2489,7 +2489,7 @@ impl Sim {
out.particles("minecraft:firework", pos, 0.6, DVec3::ZERO, 0.5, 50);
// The shock arrives after the flash (`boom` sounds travel); the warhead's blast hurts what is near.
out.sound("airdef:boom.sonic", pos, 0.8, 1.2);
self.blast_damage(pos, 0, out);
self.blast_damage(pos, 0, ground, out);
}
}
out.sound(sound, pos, gain, pitch);
@@ -2927,7 +2927,7 @@ impl Sim {
}
for (t, by) in gun_hits {
if let Some(i) = self.drones.iter().position(|d| d.id == t) {
let _ = self.shoot_down(i, by, None, out);
let _ = self.shoot_down(i, by, None, ground, out);
}
}
for i in 0..self.sams.len() {
@@ -3133,7 +3133,7 @@ impl Sim {
self.drones[t].engaged = self.drones[t].engaged.saturating_sub(1);
if kill {
let (at, closing) = (self.drones[t].pos, (m.vel - self.drones[t].vel).length());
let _ = self.shoot_down_by(t, sam, Some(mid), Impact::missile(m.kind, at, closing), out);
let _ = self.shoot_down_by(t, sam, Some(mid), Impact::missile(m.kind, at, closing), ground, out);
}
}
// A missile that lost its target frees it for others.