fix(physics): restore type-four trigger response

The rewrite scored type-four targets but left ball velocity unchanged. The
reconstructed collision loop consumes two Borland random values after each
entered radius-bearing trigger and scales X and Y independently by
1.03 - Random * 0.08.

Apply that response to targets 140 through 152 and effect record 149 after their
ordered rule handling. This restores both the immediate trajectory and the
shared random-stream position used by later launcher, claw, nudge, and mechanism
choices.

Test Plan:
- `cargo test --all-targets` -- passed, 60 tests
- `cargo clippy --all-targets -- -D warnings` -- passed
- `rumdl check tdkpin-rs/CHANGELOG.md tdkpin-rs/RECONSTRUCTION.md` -- passed
- `git diff --cached --check` -- passed
This commit is contained in:
2026-08-23 17:01:44 +02:00
parent 3fa3e29ad3
commit 2f7e29b6a4
3 changed files with 22 additions and 2 deletions
+18 -1
View File
@@ -965,6 +965,7 @@ impl Game {
self.object_active[effect_index] = false;
events.push(Event::Target);
events.push(Event::Sound(2004));
self.randomize_trigger_velocity();
}
}
}
@@ -1002,9 +1003,20 @@ impl Game {
let field_id = [153, 6, 154][usize::from(sensor.id - 150)];
self.object_active[field_id] = true;
}
self.randomize_trigger_velocity();
}
}
#[allow(clippy::cast_possible_truncation)]
fn randomize_trigger_velocity(&mut self) {
let mut velocity = MilliVec::from_velocity_per_second(self.ball.velocity);
let x_factor = 1.03 - self.random.unit_interval() * 0.08;
let y_factor = 1.03 - self.random.unit_interval() * 0.08;
velocity.x = (f64::from(velocity.x) * x_factor).round() as i32;
velocity.y = (f64::from(velocity.y) * y_factor).round() as i32;
self.ball.velocity = velocity.to_velocity_per_second();
}
fn reset_ball_to_launcher(&mut self) {
self.ball = Ball::default();
self.launcher_charge = 0.0;
@@ -2053,6 +2065,7 @@ mod tests {
let mut game = Game::new_with_seed(1, 7);
game.ball.in_launcher = false;
game.ball.position = vec2(205.0, 55.0);
game.ball.velocity = vec2(100.0, 200.0);
let mut events = Vec::new();
game.check_sensor_objects(
@@ -2065,6 +2078,10 @@ mod tests {
assert!(game.object_active[153]);
assert!(!game.object_active[6]);
assert!(!game.object_active[154]);
assert_eq!(
MilliVec::from_velocity_per_second(game.ball.velocity),
MilliVec { x: 1_012, y: 1_926 }
);
let mut field_velocity = MilliVec { x: 0, y: 2_015 };
game.apply_magnetic_fields(
@@ -2074,7 +2091,7 @@ mod tests {
},
&mut field_velocity,
);
assert_eq!(field_velocity, MilliVec { x: 0, y: -3_550 });
assert_eq!(field_velocity, MilliVec { x: 0, y: -3_513 });
game.apply_magnetic_fields(
MilliVec {
x: 15_000,