Playtest fixes: smoke by engine, searchlights, far launch sites that load their chunks, air defence balance, last chance and radar-cued shots, radars in smart raids, echo, Windows release build from a tag
Smoke: one rule by engine, no heat on trails, no trail on P1-SUN. Searchlights: two lamps a target, off with an empty sky. Halos fade before their reach and their sum is limited. Launch sites load chunks through the server thread, go off-map as a last resort, and reach 4000 blocks. Air defence: ranges x1.5, shots grow with urgency, claims released, /airdef lastchance, long shots on a big radar's tracks. Build: rust-toolchain.toml, airdef.py check, generator manifest and --check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+80
-34
@@ -99,30 +99,48 @@ fn blast_billows(out: &mut Vec<SmokeSegment>, blasts: &[crate::sim::Blast], tick
|
||||
}
|
||||
}
|
||||
|
||||
fn style_drone(s: &mut SmokeSegment, class: Class) {
|
||||
let (r0, r1, dens, heat, soot, clear, life): (f32, f32, f32, f32, f32, f32, f32) = match class {
|
||||
Class::Drone => (0.9, 5.0, 2.0, 0.0, 0.45, 3.0, 1200.0),
|
||||
Class::Jet | Class::Cruise => (1.1, 7.0, 2.5, 0.15, 0.35, 4.0, 1300.0),
|
||||
Class::Supersonic => (1.4, 9.0, 3.2, 0.5, 0.2, 5.0, 1300.0),
|
||||
Class::Ballistic => (2.0, 13.0, 4.0, 0.7, 0.15, 7.0, 1500.0),
|
||||
};
|
||||
s.radius_start = r0;
|
||||
s.radius_end = r1;
|
||||
s.density = dens;
|
||||
s.heat = heat;
|
||||
s.soot = soot;
|
||||
s.clear = clear;
|
||||
s.life = life;
|
||||
/// How one kind of trail looks. One rule by engine: a propeller leaves a faint short grey haze,
|
||||
/// a jet or a cruise missile a thin grey line, a rocket (supersonic, ballistic, interceptor) a white
|
||||
/// line as thick as the missile is big. No trail has heat: the flame at the nozzle is separate.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct Look {
|
||||
r0: f32,
|
||||
r1: f32,
|
||||
density: f32,
|
||||
soot: f32,
|
||||
clear: f32,
|
||||
life: f32,
|
||||
}
|
||||
|
||||
fn style_missile(s: &mut SmokeSegment) {
|
||||
s.radius_start = 0.6;
|
||||
s.radius_end = 5.0;
|
||||
s.density = 3.0;
|
||||
s.heat = 0.8;
|
||||
s.soot = 0.05;
|
||||
s.clear = 3.0;
|
||||
s.life = 1000.0;
|
||||
/// A rocket's white line, thicker for a bigger missile (`scale`: Pantsir 0.85, S-500 1.7).
|
||||
fn rocket(scale: f32, density: f32, life: f32) -> Look {
|
||||
let scale = scale.min(2.0);
|
||||
Look { r0: 0.25 * scale, r1: 1.2 + 1.6 * scale, density, soot: 0.02, clear: 0.8 + 1.2 * scale, life: life + 250.0 * scale }
|
||||
}
|
||||
|
||||
fn drone_look(class: Class, scale: f32) -> Look {
|
||||
match class {
|
||||
Class::Drone => Look { r0: 0.4, r1: 1.8, density: 0.15, soot: 0.3, clear: 0.3, life: 250.0 },
|
||||
Class::Jet => Look { r0: 0.5, r1: 2.5, density: 0.5, soot: 0.25, clear: 1.5, life: 500.0 },
|
||||
Class::Cruise => Look { r0: 0.6, r1: 3.0, density: 0.6, soot: 0.3, clear: 2.0, life: 600.0 },
|
||||
Class::Supersonic => rocket(scale, 0.9, 400.0),
|
||||
Class::Ballistic => rocket(scale, 1.1, 500.0),
|
||||
}
|
||||
}
|
||||
|
||||
/// `None`: no motor smoke at all (the electric P1-SUN).
|
||||
fn missile_look(kind: crate::sim::MissileKind) -> Option<Look> {
|
||||
kind.trail_scale().map(|k| rocket(k, 0.8, 250.0))
|
||||
}
|
||||
|
||||
fn style(s: &mut SmokeSegment, l: Look) {
|
||||
s.radius_start = l.r0;
|
||||
s.radius_end = l.r1;
|
||||
s.density = l.density;
|
||||
s.heat = 0.0;
|
||||
s.soot = l.soot;
|
||||
s.clear = l.clear;
|
||||
s.life = l.life;
|
||||
}
|
||||
|
||||
/// Points between a replay trail segment's ends (a segment every `TRAIL_GRID * STEP` ticks).
|
||||
@@ -138,15 +156,15 @@ pub fn replay_smoke(rec: &crate::sim::record::Recording, t: f64) -> Vec<SmokeSeg
|
||||
let mut out: Vec<SmokeSegment> = Vec::new();
|
||||
let stride = (TRAIL_GRID as u32 * STEP) as f64;
|
||||
for (n, tr) in rec.tracks.iter().enumerate() {
|
||||
let (life, style): (f64, Box<dyn Fn(&mut SmokeSegment)>) = match tr.what {
|
||||
let look = match tr.what {
|
||||
What::Drone(kind) => {
|
||||
let class = kind.spec().class;
|
||||
let mut probe = seg(0, DVec3::ZERO, DVec3::ZERO, 0, 0);
|
||||
style_drone(&mut probe, class);
|
||||
(probe.life as f64, Box::new(move |s| style_drone(s, class)))
|
||||
let spec = kind.spec();
|
||||
Some(drone_look(spec.class, spec.trail_scale()))
|
||||
}
|
||||
What::Missile(..) => (1000.0, Box::new(style_missile)),
|
||||
What::Missile(kind, _) => missile_look(kind),
|
||||
};
|
||||
let Some(look) = look else { continue };
|
||||
let life = look.life as f64;
|
||||
// The segments whose end point has been reached and whose life is not over.
|
||||
let lo = (((t - life - tr.first as f64) / stride).floor().max(0.0)) as usize;
|
||||
let hi = (((t - tr.first as f64) / stride).floor().max(0.0)) as usize;
|
||||
@@ -157,7 +175,7 @@ pub fn replay_smoke(rec: &crate::sim::record::Recording, t: f64) -> Vec<SmokeSeg
|
||||
continue;
|
||||
}
|
||||
let mut s = seg(0x2000_0000 | ((n as u32).wrapping_mul(7919) ^ g as u32) & 0x0fff_ffff, a, b, born, 1200);
|
||||
style(&mut s);
|
||||
style(&mut s, look);
|
||||
if (tick as f64) < born as f64 + s.life as f64 {
|
||||
out.push(s);
|
||||
}
|
||||
@@ -192,7 +210,7 @@ pub fn replay_smoke(rec: &crate::sim::record::Recording, t: f64) -> Vec<SmokeSeg
|
||||
}
|
||||
|
||||
impl Smoke {
|
||||
fn trail(&mut self, key: (u8, u32), at: DVec3, tick: u64, style: impl Fn(&mut SmokeSegment)) {
|
||||
fn trail(&mut self, key: (u8, u32), at: DVec3, tick: u64, look: Look) {
|
||||
let Some(&(from, when)) = self.last.get(&key) else {
|
||||
self.last.insert(key, (at, tick));
|
||||
return;
|
||||
@@ -204,7 +222,7 @@ impl Smoke {
|
||||
if at.distance(from) < 400.0 {
|
||||
self.next = self.next.wrapping_add(1);
|
||||
let mut s = seg(self.next, from, at, tick, 1200);
|
||||
style(&mut s);
|
||||
style(&mut s, look);
|
||||
self.trails.push(Trail { seg: s });
|
||||
}
|
||||
self.last.insert(key, (at, tick));
|
||||
@@ -219,11 +237,13 @@ impl Smoke {
|
||||
}
|
||||
self.last_tick = tick;
|
||||
for d in &sim.drones {
|
||||
let class = d.kind.spec().class;
|
||||
self.trail((0, d.id), d.pos, tick, |s| style_drone(s, class));
|
||||
let spec = d.kind.spec();
|
||||
self.trail((0, d.id), d.pos, tick, drone_look(spec.class, spec.trail_scale()));
|
||||
}
|
||||
for m in &sim.missiles {
|
||||
self.trail((1, m.id), m.pos, tick, style_missile);
|
||||
if let Some(look) = missile_look(m.kind) {
|
||||
self.trail((1, m.id), m.pos, tick, look);
|
||||
}
|
||||
}
|
||||
// Forget what is gone.
|
||||
if tick % 100 == 0 {
|
||||
@@ -258,3 +278,29 @@ impl Smoke {
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::sim::{DroneKind, MissileKind};
|
||||
|
||||
#[test]
|
||||
fn trails_follow_one_rule() {
|
||||
assert!(missile_look(MissileKind::P1sun).is_none());
|
||||
let rocket_look = missile_look(MissileKind::M77n6).unwrap();
|
||||
let pantsir = missile_look(MissileKind::M57e6).unwrap();
|
||||
assert!(pantsir.r1 < rocket_look.r1);
|
||||
let mut s = seg(0, DVec3::ZERO, DVec3::ZERO, 0, 0);
|
||||
for class in [Class::Drone, Class::Jet, Class::Cruise, Class::Supersonic, Class::Ballistic] {
|
||||
style(&mut s, drone_look(class, 1.0));
|
||||
assert_eq!(s.heat, 0.0);
|
||||
}
|
||||
for k in [MissileKind::Pac3, MissileKind::M57e6, MissileKind::M77n6, MissileKind::Amraam] {
|
||||
style(&mut s, missile_look(k).unwrap());
|
||||
assert_eq!(s.heat, 0.0);
|
||||
}
|
||||
let spec = DroneKind::Shahed.spec();
|
||||
let shahed = drone_look(Class::Drone, spec.trail_scale());
|
||||
assert!(shahed.density * 4.0 < rocket_look.density);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user