Oreshnik with MIRV, impact power tiers, far missile glow, SAM cameras and command post grid
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+59
-13
@@ -18,7 +18,7 @@ mod radar;
|
||||
mod sim;
|
||||
use sim::{Class, DroneKind, Ground, Out, Sam, SamKind, Sim};
|
||||
|
||||
const ITEMS: [&str; 16] = [
|
||||
const ITEMS: [&str; 17] = [
|
||||
"airdef:designator",
|
||||
"airdef:launch_shahed",
|
||||
"airdef:launch_geran3",
|
||||
@@ -29,6 +29,7 @@ const ITEMS: [&str; 16] = [
|
||||
"airdef:launch_zircon",
|
||||
"airdef:launch_iskander",
|
||||
"airdef:launch_kinzhal",
|
||||
"airdef:launch_oreshnik",
|
||||
"airdef:deploy_patriot",
|
||||
"airdef:deploy_gepard",
|
||||
"airdef:deploy_pantsir",
|
||||
@@ -45,6 +46,8 @@ struct AirDef {
|
||||
/// The system the monitor shows (K cycles), none: hidden.
|
||||
monitor: Option<usize>,
|
||||
monitor_shown: bool,
|
||||
/// Every system's monitor in a grid (J).
|
||||
grid: bool,
|
||||
/// The menu's page while it is open.
|
||||
menu: Option<Page>,
|
||||
/// Where the player is, for the sounds' delay and far variants.
|
||||
@@ -75,6 +78,7 @@ const BTN_HOLD: u32 = 10;
|
||||
const BTN_SHADER: u32 = 11;
|
||||
const BTN_DAMAGE: u32 = 12;
|
||||
const BTN_MONITOR: u32 = 13;
|
||||
const BTN_GRID: u32 = 14;
|
||||
const BTN_CLASS: u32 = 100;
|
||||
const BTN_ALL: u32 = 120;
|
||||
const BTN_DEFAULT: u32 = 121;
|
||||
@@ -198,6 +202,7 @@ impl AirDef {
|
||||
"airdef:flash" => (1.0, 0.85, 0.5, 2.0),
|
||||
"airdef:target" => (1.0, 0.1, 0.1, 0.5),
|
||||
"airdef:tracer" => (1.0, 0.12, 0.05, 0.9),
|
||||
"airdef:reentry" => (1.0, 0.6, 0.3, 1.4),
|
||||
_ => continue,
|
||||
};
|
||||
p.extend([m.at.x as f32, m.at.y as f32, m.at.z as f32, m.scale * 1.6]);
|
||||
@@ -290,7 +295,8 @@ impl AirDef {
|
||||
|
||||
fn draw_hud(&mut self, player: DVec3, yaw: f32) {
|
||||
let air: Vec<&sim::Drone> = self.sim.drones.iter().filter(|d| d.alive()).collect();
|
||||
if air.is_empty() && self.sim.sams.is_empty() && self.sim.missiles.is_empty() {
|
||||
// The command post's grid covers the screen: the other panels wait under it.
|
||||
if self.grid || (air.is_empty() && self.sim.sams.is_empty() && self.sim.missiles.is_empty()) {
|
||||
if self.hud_shown {
|
||||
hud::clear();
|
||||
render::clear_corner();
|
||||
@@ -401,6 +407,7 @@ impl AirDef {
|
||||
None => "скрыт".into(),
|
||||
};
|
||||
widgets.push(Widget::Button(ButtonWidget { id: BTN_MONITOR, label: format!("Монитор: {monitor}") }));
|
||||
widgets.push(Widget::Button(ButtonWidget { id: BTN_GRID, label: "Командный пункт: все комплексы (J)".into() }));
|
||||
widgets.push(Widget::Button(ButtonWidget { id: BTN_SHADER, label: format!("Эффекты: {}", onoff(self.sim.shader)) }));
|
||||
widgets.push(Widget::Button(ButtonWidget { id: BTN_DAMAGE, label: format!("Разрушения: {}", onoff(self.sim.damage)) }));
|
||||
}
|
||||
@@ -442,7 +449,7 @@ impl AirDef {
|
||||
}
|
||||
}
|
||||
|
||||
const HELP: &str = "/airdef menu | monitor | give | wave <тип|mix> [кол-во] [дальность] | clear | targets clear | damage on|off | shader on|off | hold on|off | roles [комплекс классы] | stats";
|
||||
const HELP: &str = "/airdef menu | monitor | grid | give | deploy <комплекс> | wave <тип|mix> [кол-во] [дальность] | clear | targets clear | damage on|off | shader on|off | hold on|off | roles [комплекс классы] | stats";
|
||||
|
||||
impl Mod for AirDef {
|
||||
fn init() -> Result<(Self, Registration), String> {
|
||||
@@ -454,12 +461,14 @@ impl Mod for AirDef {
|
||||
hud_shown: false,
|
||||
monitor: None,
|
||||
monitor_shown: false,
|
||||
grid: false,
|
||||
menu: None,
|
||||
listener: DVec3::ZERO,
|
||||
pending: Vec::new(),
|
||||
};
|
||||
let _ = input::register_key("menu", "Меню AirDef", "key.keyboard.n");
|
||||
let _ = input::register_key("monitor", "Монитор ПВО: следующий комплекс", "key.keyboard.k");
|
||||
let _ = input::register_key("grid", "Командный пункт: все комплексы", "key.keyboard.j");
|
||||
me.load();
|
||||
input::claim_items(&ITEMS.map(String::from));
|
||||
render::set_post(include_str!("../shaders/effects.wgsl"));
|
||||
@@ -474,6 +483,7 @@ impl Mod for AirDef {
|
||||
Event::UseStart(u) => self.use_item(&u.item.id),
|
||||
Event::KeyDown(k) if k == "menu" => self.open_menu(Page::Main),
|
||||
Event::KeyDown(k) if k == "monitor" => self.cycle_monitor(),
|
||||
Event::KeyDown(k) if k == "grid" => self.grid = !self.grid,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -488,15 +498,25 @@ impl Mod for AirDef {
|
||||
}
|
||||
self.emit(out);
|
||||
self.draw_hud(DVec3::new(p.x, p.y, p.z), p.yaw);
|
||||
match self.monitor {
|
||||
Some(i) if i < self.sim.sams.len() => {
|
||||
render::set_hud(&monitor::draw(&self.sim, i));
|
||||
self.monitor_shown = true;
|
||||
}
|
||||
_ => {
|
||||
if self.monitor_shown {
|
||||
render::set_hud(&[]);
|
||||
self.monitor_shown = false;
|
||||
// The monitors and the cameras they show.
|
||||
if self.grid {
|
||||
render::set_hud(&monitor::grid(&self.sim, render::gui_size()));
|
||||
let views: Vec<_> = self.sim.sams.iter().take(8).map(|s| monitor::camera(&self.sim, s)).collect();
|
||||
render::set_views(&views);
|
||||
self.monitor_shown = true;
|
||||
} else {
|
||||
match self.monitor {
|
||||
Some(i) if i < self.sim.sams.len() => {
|
||||
render::set_hud(&monitor::draw(&self.sim, i));
|
||||
render::set_views(&[monitor::camera(&self.sim, &self.sim.sams[i])]);
|
||||
self.monitor_shown = true;
|
||||
}
|
||||
_ => {
|
||||
if self.monitor_shown {
|
||||
render::set_hud(&[]);
|
||||
render::set_views(&[]);
|
||||
self.monitor_shown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -516,6 +536,12 @@ impl Mod for AirDef {
|
||||
}
|
||||
(Page::Main, BTN_HOLD) => self.sim.hold = !self.sim.hold,
|
||||
(Page::Main, BTN_MONITOR) => self.cycle_monitor(),
|
||||
(Page::Main, BTN_GRID) => {
|
||||
self.grid = true;
|
||||
self.menu = None;
|
||||
ui::close_screen();
|
||||
return;
|
||||
}
|
||||
(Page::Main, BTN_SHADER) => {
|
||||
self.sim.shader = !self.sim.shader;
|
||||
if self.sim.shader {
|
||||
@@ -560,10 +586,30 @@ impl Mod for AirDef {
|
||||
self.cycle_monitor();
|
||||
None
|
||||
}
|
||||
["grid"] => {
|
||||
self.grid = !self.grid;
|
||||
None
|
||||
}
|
||||
["give"] => {
|
||||
self.give();
|
||||
None
|
||||
}
|
||||
["deploy", kind] => {
|
||||
// A system where the player stands, a few blocks ahead.
|
||||
let kind = SamKind::from_key(kind).ok_or("Комплексы: patriot, gepard, pantsir, s400, s500")?;
|
||||
let p = player().ok_or("Нет игрока")?;
|
||||
let d = view(&p);
|
||||
let flat = DVec3::new(d.x, 0.0, d.z).normalize_or(DVec3::NEG_Z);
|
||||
let at = DVec3::new(p.x, p.y, p.z) + flat * 8.0;
|
||||
let sid = self.sim.id();
|
||||
let mut sam = Sam::new(sid, kind, at, (-flat.x).atan2(-flat.z));
|
||||
if let Some(r) = self.sim.roles.get(&kind) {
|
||||
sam.roles = *r;
|
||||
}
|
||||
self.sim.sams.push(sam);
|
||||
self.dirty = true;
|
||||
Some(format!("{} развёрнут", kind.name()))
|
||||
}
|
||||
["wave", kind, rest @ ..] => {
|
||||
let count = rest.first().and_then(|v| v.parse().ok()).unwrap_or(5u32).clamp(1, 80);
|
||||
let dist = rest.get(1).and_then(|v| v.parse().ok()).unwrap_or(260.0f64).clamp(60.0, 800.0);
|
||||
@@ -571,7 +617,7 @@ impl Mod for AirDef {
|
||||
let target = self
|
||||
.sim
|
||||
.nearest_target(DVec3::new(p.x, p.y, p.z))
|
||||
.ok_or("Сначала отметьте цель Целеуказателем")?;
|
||||
.unwrap_or(DVec3::new(p.x, p.y, p.z));
|
||||
if *kind == "mix" {
|
||||
// A combined strike: decoys first, then Shaheds, jets and cruise missiles.
|
||||
let n = count.max(4);
|
||||
|
||||
Reference in New Issue
Block a user