Sunsets, volumetric clouds and fog in HD (fork patch 23, #53); missiles and drones collide with the world through new world queries (patch 24, API level 12; #42, #43); a direct hit destroys a system, strikes scatter by kind with a small miss chance (#49, #59)
build / mod (push) Successful in 3m24s
build / mod (push) Successful in 3m24s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,72 @@ impl MissileKind {
|
||||
}
|
||||
}
|
||||
|
||||
/// A strike that ends farther than this from its aim point misses (the lethal radius of a point target).
|
||||
pub(super) const MISS_RADIUS: f64 = 3.0;
|
||||
/// A system's hull, as a cylinder: its radius (× scale) and how far above the ground it reaches (× scale).
|
||||
const HULL_RADIUS: f64 = 2.2;
|
||||
const HULL_TOP: f64 = 3.0;
|
||||
|
||||
impl DroneKind {
|
||||
/// Strike accuracy: the CEP (blocks; half the strikes land within it, the scatter is Rayleigh)
|
||||
/// and the share of strikes with a rare gross navigation fault, which lands beyond `MISS_RADIUS`.
|
||||
pub(super) fn accuracy(self) -> (f64, f64) {
|
||||
match self {
|
||||
DroneKind::Shahed => (1.2, 0.03),
|
||||
DroneKind::Geran3 => (1.0, 0.03),
|
||||
DroneKind::Lancet => (0.8, 0.02),
|
||||
DroneKind::Gerbera => (1.5, 0.04),
|
||||
DroneKind::Kh101 => (1.3, 0.05),
|
||||
DroneKind::Kalibr => (1.3, 0.05),
|
||||
DroneKind::Kh22 => (1.6, 0.06),
|
||||
DroneKind::Zircon => (1.5, 0.06),
|
||||
DroneKind::Iskander => (1.4, 0.06),
|
||||
DroneKind::Kinzhal => (1.5, 0.06),
|
||||
// The bus and its blocks: the blocks are aimed by the split, so only the bus's own error applies.
|
||||
DroneKind::Oreshnik | DroneKind::OreshnikBlock | DroneKind::OreshnikSub => (1.6, 0.08),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Sim {
|
||||
/// The aim error of a new strike: drawn once from the seed, the drone keeps it for its whole flight.
|
||||
pub(super) fn aim_error(&mut self, kind: DroneKind) -> DVec3 {
|
||||
let (cep, gross) = kind.accuracy();
|
||||
let angle = self.rng.f() * std::f64::consts::TAU;
|
||||
let r = if self.rng.chance(gross) {
|
||||
MISS_RADIUS + cep * (0.5 + 2.5 * self.rng.f())
|
||||
} else {
|
||||
// Rayleigh with its median at the CEP.
|
||||
let u = 1.0 - self.rng.f();
|
||||
cep * (-2.0 * u.ln() / (2.0 * std::f64::consts::LN_2)).sqrt()
|
||||
};
|
||||
DVec3::new(angle.cos() * r, 0.0, angle.sin() * r)
|
||||
}
|
||||
|
||||
/// An armed warhead reached `pos` (its last step was `vel`): a system whose hull it swept through is
|
||||
/// destroyed at once, whatever the blast would have done to it. A near miss is only splash.
|
||||
pub(super) fn direct_hit(&mut self, pos: DVec3, vel: DVec3, tnt: u32, out: &mut Out) {
|
||||
if !self.damage || tnt == 0 {
|
||||
return;
|
||||
}
|
||||
let from = pos - vel;
|
||||
for i in 0..self.sams.len() {
|
||||
let sam = &self.sams[i];
|
||||
if !sam.alive() {
|
||||
continue;
|
||||
}
|
||||
let s = sam.kind.spec().scale;
|
||||
let hit = (0..=8).any(|k| {
|
||||
let p = from.lerp(pos, k as f64 / 8.0);
|
||||
let across = DVec3::new(p.x - sam.pos.x, 0.0, p.z - sam.pos.z).length();
|
||||
across <= HULL_RADIUS * s && p.y >= sam.pos.y - 1.0 && p.y <= sam.pos.y + HULL_TOP * s
|
||||
});
|
||||
if hit {
|
||||
self.destroy(i, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A blast of `power` (0 to 4) at `pos`: the systems and objects round it take damage.
|
||||
pub(super) fn blast_damage(&mut self, pos: DVec3, power: usize, out: &mut Out) {
|
||||
let (reach, hit) = (REACH[power], HIT[power]);
|
||||
|
||||
Reference in New Issue
Block a user