tweak gforces, vehicle speed, ignore gforce when cheating

This commit is contained in:
yuni 2024-04-06 01:36:14 +02:00
parent a869a7704e
commit d4708c2873
4 changed files with 19 additions and 6 deletions

View file

@ -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;

View file

@ -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;
}

View file

@ -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

View file

@ -353,7 +353,7 @@ fn handle_despawn(
fn handle_cheats(
key_input: Res<ButtonInput<KeyCode>>,
mut q_player: Query<(&Transform, &mut Position, &mut LinearVelocity), With<actor::PlayerCamera>>,
mut q_life: Query<(&mut actor::LifeForm, ), With<actor::Player>>,
mut q_life: Query<(&mut actor::LifeForm, &mut actor::ExperiencesGForce), With<actor::Player>>,
mut ew_playerdies: EventWriter<actor::PlayerDiesEvent>,
settings: ResMut<settings::Settings>,
) {
@ -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;