From d4708c2873037c4bec3e840a30881a9917750afb Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 6 Apr 2024 01:36:14 +0200 Subject: [PATCH] tweak gforces, vehicle speed, ignore gforce when cheating --- src/actor.rs | 11 +++++++++-- src/camera.rs | 2 +- src/defs.txt | 2 +- src/world.rs | 10 ++++++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/actor.rs b/src/actor.rs index ead5c1d..64367fd 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -81,13 +81,15 @@ pub struct ExperiencesGForce { pub blackout_threshold: f32, pub blackout: f32, pub last_linear_velocity: DVec3, + pub ignore_gforce_seconds: f32, } impl Default for ExperiencesGForce { fn default() -> Self { Self { gforce: 0.0, - damage_threshold: 50.0, + damage_threshold: 100.0, blackout_threshold: 20.0, blackout: 0.0, last_linear_velocity: DVec3::splat(0.0), + ignore_gforce_seconds: 0.0, }}} #[derive(Component)] pub struct Player; // Attached to the suit of the player @@ -444,6 +446,11 @@ fn handle_gforce( let dt = time.delta_seconds(); let factor = 1.0 / dt / 9.81; for (v, mut hp, mut gforce) in &mut q_actor { + if gforce.ignore_gforce_seconds > 0.0 { + gforce.ignore_gforce_seconds -= dt; + gforce.last_linear_velocity = v.0; + continue; + } gforce.gforce = factor * (v.0 - gforce.last_linear_velocity).length() as f32; gforce.last_linear_velocity = v.0; if gforce.gforce > gforce.damage_threshold { @@ -451,7 +458,7 @@ fn handle_gforce( } if gforce.blackout > 0.0001 { - gforce.blackout *= 0.998; + gforce.blackout *= 0.984; } else if gforce.blackout > 0.0 { gforce.blackout = 0.0; diff --git a/src/camera.rs b/src/camera.rs index 489b196..df3a5f6 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -105,7 +105,7 @@ pub fn update_fov( settings.is_zooming = true; } } else { - fov = (lifeform.adrenaline.powf(3.0) * 45.0 + 45.0).to_radians(); + fov = (lifeform.adrenaline.powf(3.0) * 25.0 + 45.0).to_radians(); if settings.is_zooming { settings.is_zooming = false; } diff --git a/src/defs.txt b/src/defs.txt index 55579ed..797b4b1 100644 --- a/src/defs.txt +++ b/src/defs.txt @@ -29,7 +29,7 @@ actor 10 -30 20 MeteorAceGT relativeto player scale 5 vehicle yes - thrust 35 6.85 4.7 200000 20 + thrust 24.5 4.8 3.3 200000 3 engine ion collider sphere 1.5 camdistance 50 diff --git a/src/world.rs b/src/world.rs index ec7e43f..45d3c09 100644 --- a/src/world.rs +++ b/src/world.rs @@ -353,7 +353,7 @@ fn handle_despawn( fn handle_cheats( key_input: Res>, mut q_player: Query<(&Transform, &mut Position, &mut LinearVelocity), With>, - mut q_life: Query<(&mut actor::LifeForm, ), With>, + mut q_life: Query<(&mut actor::LifeForm, &mut actor::ExperiencesGForce), With>, mut ew_playerdies: EventWriter, settings: ResMut, ) { @@ -361,33 +361,39 @@ fn handle_cheats( return; } let (trans, mut pos, mut v) = q_player.get_single_mut().unwrap(); + let (mut lifeform, mut gforce) = q_life.get_single_mut().unwrap(); let boost = if key_input.pressed(KeyCode::ShiftLeft) { 1e6 } else { 1e3 }; if key_input.just_pressed(settings.key_cheat_stop) { + gforce.ignore_gforce_seconds = 1.0; v.0 = DVec3::ZERO; } if key_input.pressed(settings.key_cheat_speed) { + gforce.ignore_gforce_seconds = 1.0; v.0 += DVec3::from(trans.rotation * Vec3::new(0.0, 0.0, boost)); } if key_input.pressed(settings.key_cheat_speed_backward) { + gforce.ignore_gforce_seconds = 1.0; v.0 += DVec3::from(trans.rotation * Vec3::new(0.0, 0.0, -boost)); } if !settings.dev_mode { return; } - let (mut lifeform, ) = q_life.get_single_mut().unwrap(); if key_input.just_pressed(settings.key_cheat_pizza) { pos.0 = DVec3::new(-303370.0, 0.0, -500000.0); + gforce.ignore_gforce_seconds = 1.0; } if key_input.just_pressed(settings.key_cheat_farview1) { pos.0 = DVec3::new(-1000.0e6, 1000.0e6, -500.0e6); + gforce.ignore_gforce_seconds = 1.0; } if key_input.just_pressed(settings.key_cheat_farview2) { pos.0 = DVec3::new(1000.0e6, 1000.0e6, -500.0e6); + gforce.ignore_gforce_seconds = 1.0; } if key_input.pressed(settings.key_cheat_adrenaline_zero) { lifeform.adrenaline = 0.0;