Fix original cutscene music lifecycle and verify walking lab route
This commit is contained in:
1 parent
c929f942e1
commit
b58138d7ba
16 files changed
+282
-18
No files matched your search
@@ -10,12 +10,19 @@ var save = OriginalSave.Load(AssetPath.Resolve(root,"NewGame.tsk"));
|
||||
var tasks = new TaskStates(save.Tasks);
|
||||
var director = new SceneDirector(level,tasks,(_,_)=>.1);
|
||||
var cues = 0;
|
||||
director.Speech += (_,_)=>cues++;
|
||||
var musicPlaying = true;
|
||||
var musicRestarts = 0;
|
||||
director.MusicStopped += () => musicPlaying = false;
|
||||
director.MusicRestarted += () => { musicPlaying = true; musicRestarts++; };
|
||||
director.Speech += (_,_)=>{ Check(!musicPlaying,"Lab cutscene music must stop before speech and stay stopped between shots"); cues++; };
|
||||
director.Begin(level.FindStart()!);
|
||||
Check(!director.Controlled && director.CurrentTag == "LABEXP1", "STRT must freeze into original first camera");
|
||||
for(var i=0;i<200 && !director.Controlled;i++) director.Step(.1f);
|
||||
Check(director.Controlled && !director.Blocked && cues>10, "Complete original intro trigger/camera chain");
|
||||
Check(tasks.Get("SCENE")==30, "Intro must not invent a progression/task advance");
|
||||
Check(musicPlaying && musicRestarts == 1,"DEFAULT must restart selected music after natural intro completion");
|
||||
director.Trigger("default");
|
||||
Check(musicRestarts == 1,"DEFAULT with Jimmy already controlled must not restart music");
|
||||
var endGoddard = director.FindActor("C3DGODDARD")!.Position;
|
||||
Check(endGoddard==director.FindActor("phone2")!.Position,"AI teleport position actions must execute");
|
||||
Check(director.Issues.Any(x=>x.Detail.Contains("Patrol")),"Unsupported patrol must remain explicit");
|
||||
@@ -23,10 +30,15 @@ Console.WriteLine($"PASS original lab sequence: {cues} original speech cues, cor
|
||||
|
||||
var skip = new SceneDirector(level,new TaskStates(save.Tasks),(_,_)=>10);
|
||||
var skipCues=0;
|
||||
var skipMusicPlaying=true;
|
||||
skip.MusicStopped+=()=>skipMusicPlaying=false;
|
||||
skip.MusicRestarted+=()=>skipMusicPlaying=true;
|
||||
skip.Speech += (_,_)=>skipCues++;
|
||||
skip.Begin(level.FindStart()!);
|
||||
Check(!skipMusicPlaying,"First CAM must stop gameplay music");
|
||||
skip.Skip();
|
||||
Check(skip.Controlled && !skip.Blocked && skipCues==1,"Skip must fast-forward voices and return control");
|
||||
Check(skipMusicPlaying,"Skipping must restore selected gameplay music");
|
||||
Check(skip.FindActor("C3DGODDARD")!.Position==endGoddard,"Skip must preserve AI/toggle actions");
|
||||
Console.WriteLine("PASS original intro skip preserves action sequence");
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net10.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable><EnableDefaultCompileItems>false</EnableDefaultCompileItems></PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs"/>
|
||||
<Compile Include="../../src/GamePort/Assets/*.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/*.cs"/>
|
||||
<Compile Include="../../src/GamePort/Application/StaticSceneVisuals.cs"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,104 @@
|
||||
using System.Numerics;
|
||||
using GamePort.Assets;
|
||||
using GamePort.Game;
|
||||
using GamePort.Application;
|
||||
|
||||
// An explicit modern input replay, not recovered original navigation/AI. The
|
||||
// player is never repositioned and all contacts use the live collision result.
|
||||
var original = Path.GetFullPath(args.Length == 1 ? args[0] : "../Original");
|
||||
var prepared = Path.GetFullPath("artifacts/extracted");
|
||||
var level = GamLevel.Load(AssetPath.Resolve(original, "gam/level1b.gam"));
|
||||
var start = level.FindStart()!;
|
||||
var world = Mesh.LoadSceneJson(Path.Combine(prepared, "level1b/scene.json"));
|
||||
var save = OriginalSave.Load(Path.Combine(original, "NewGame.tsk"));
|
||||
var tasks = new TaskStates(save.Tasks);
|
||||
var resources = new PreparedEntityResources(Path.Combine(prepared, "level1b/entities/entities.json"));
|
||||
var director = new SceneDirector(level, tasks, resources.Duration);
|
||||
var interactions = new SceneInteractions(director, tasks, save, level.Code);
|
||||
var mechanisms = new SceneMechanisms(director);
|
||||
var visuals = new StaticSceneVisuals(world, director, original, Path.Combine(prepared, "level1b/models"));
|
||||
var simulation = new LabSimulation(new SceneCollision(world), AseMesh.Load(AssetPath.Resolve(original, "ASE/jimstop.ase")),
|
||||
start.Position, start.Rotation.Y) { JetpackInventoryState = () => interactions.Inventory.State(0, 3) };
|
||||
simulation.DynamicRootResolver = (before, after, radius) => DynamicBodyResponse.Resolve(visuals.DoorColliders(), before, after, radius);
|
||||
var patrols = new List<ActorPatrol>();
|
||||
foreach (var actor in director.Actors.Where(a => a.Kind is "3DOG" or "3CAR"))
|
||||
{
|
||||
var physics = new OriginalScenePhysics(world);
|
||||
var grounded = false;
|
||||
var patrol = new ActorPatrol(actor, director.FindActor, (body, dt) =>
|
||||
{
|
||||
var step = physics.Step(body.Position, body.Velocity, actor.Kind == "3DOG" ? 130 : 100,
|
||||
actor.Kind == "3DOG" ? .3f : .75f, grounded, dt);
|
||||
grounded = step.Supported;
|
||||
return new(step.Body.Position, step.Body.Velocity);
|
||||
});
|
||||
patrols.Add(patrol);
|
||||
director.RegisterPatrolConsumer(actor.Tag);
|
||||
director.ActorChanged += changed => { if (ReferenceEquals(changed, actor)) patrol.SynchronizeAuthoredState(); };
|
||||
}
|
||||
var practice = new PracticePrompt();
|
||||
interactions.PracticeRequested += practice.Show;
|
||||
var prompts = 0;
|
||||
LevelTransition? destination = null;
|
||||
interactions.Transition += request => destination ??= request;
|
||||
director.Begin(start);
|
||||
interactions.Reset(); mechanisms.Reset(); director.Skip();
|
||||
|
||||
Vector2 Point(string tag)
|
||||
{
|
||||
var p = director.FindActor(tag)!.Position;
|
||||
return new(p.X, p.Z);
|
||||
}
|
||||
// Source trigger/item/marker/exit locations plus an explicit doorway approach.
|
||||
// The approach avoids the wall outside the authored exit opening.
|
||||
var exit = Point("LABTONEIGH");
|
||||
var route = new[] { Point("teleportexplanation"), Point("shrinkray"), Point("CARLESC3"),
|
||||
new Vector2(exit.X, 500), exit };
|
||||
var sceneStates = new[] { 35, 50, 60, 60, 60 };
|
||||
for (var leg = 0; leg < route.Length && destination == null; leg++)
|
||||
{
|
||||
var arrived = false;
|
||||
for (var tick = 0; tick < 2400; tick++)
|
||||
{
|
||||
if (practice.Active)
|
||||
{
|
||||
Require(practice.Mode == 0, "Wrong lab practice mode");
|
||||
practice.Key(17, Vector2.Zero); // N resumes; no direct task/pickup mutation.
|
||||
prompts++;
|
||||
}
|
||||
var difference = route[leg] - new Vector2(simulation.Position.X, simulation.Position.Z);
|
||||
if (difference.Length() < 90) { arrived = true; break; }
|
||||
var desiredYaw = MathF.Atan2(-difference.X, difference.Y) * 180 / MathF.PI;
|
||||
var error = MathF.IEEERemainder(desiredYaw - simulation.Yaw, 360);
|
||||
if (director.Controlled)
|
||||
{
|
||||
var previous = simulation.ActorRoot;
|
||||
simulation.Step(new(MathF.Abs(error) < 30, false, error > 1, error < -1, false));
|
||||
Require(Vector3.Distance(previous, simulation.ActorRoot) < 100, "Player warped during input replay");
|
||||
director.SyncActor(level.Player!.Tag!, simulation.ActorRoot, new(0, simulation.Yaw, 0));
|
||||
director.Touch(level.Player!.Tag!, simulation.ActorRoot);
|
||||
interactions.Update(simulation.ActorRoot, simulation.InteractionRadius);
|
||||
if (practice.Active) continue; // Same modal activation boundary as Program.
|
||||
mechanisms.Update(simulation.ActorRoot, simulation.InteractionRadius);
|
||||
}
|
||||
mechanisms.Step(FixedStepClock.Step);
|
||||
foreach (var patrol in patrols) patrol.Step(FixedStepClock.Step);
|
||||
director.Step(FixedStepClock.Step);
|
||||
if (destination != null) break;
|
||||
}
|
||||
Require(arrived || destination != null, $"Input route blocked at leg{leg}: {simulation.ActorRoot}");
|
||||
Require(tasks.Get("SCENE") == sceneStates[leg], $"Wrong task state after walking leg{leg}");
|
||||
Console.WriteLine($"PASS walked leg{leg}: SCENE={tasks.Get("SCENE")}, root={simulation.ActorRoot}");
|
||||
}
|
||||
Require(destination is { LevelFile: "level1.gam", StartPoint: "level1" }, "Walking did not enter the source outside LOAD");
|
||||
Require(interactions.Score == 150 && interactions.Inventory.State(0, 3) == 1 && prompts == 1,
|
||||
"Walking route did not preserve jetpack/Carl score, inventory and practice dispatch");
|
||||
Require(simulation.Steps > 500 && simulation.Travel > 5000 && simulation.Jumps == 0, "Walking route did not exercise actual movement");
|
||||
Require(!director.Blocked, "Source director blocked during the walking route");
|
||||
Console.WriteLine($"PASS input-only lab route ->level1.gam, score150, jetpack owned, practice declined once. {simulation.Report}");
|
||||
Console.WriteLine("This verifies port navigation through the lab; original collision/cadence/behavior fidelity remains unverified.");
|
||||
|
||||
static void Require(bool condition, string message)
|
||||
{
|
||||
if (!condition) throw new InvalidOperationException(message);
|
||||
}
|
||||
@@ -48,6 +48,20 @@ class SoundBankTests(unittest.TestCase):
|
||||
self.assertEqual(exe[0x589de:0x589e3], bytes.fromhex('e8 5d 4c 02 00'))
|
||||
self.assertEqual(exe[0x7d3bc:0x7d3c2], bytes.fromhex('56 68 65 76 61 57'))
|
||||
|
||||
def test_cutscene_stops_music_and_default_restarts_original_handle(self):
|
||||
exe = (ORIGINAL/'Neutron.exe').read_bytes()
|
||||
for offset, expected in [
|
||||
(0x16776, 'a1 04 60 69 00'), # CAM current music database.
|
||||
(0x16790, '8b 90 38 0a 00 00'), # Jimmy music handle.
|
||||
(0x16796, '53 52 e8 03 70 06 00'), # Stop(handle,0).
|
||||
(0x167e1, '89 1d 04 60 69 00'), # Clear current music DB.
|
||||
(0x47d5c, '3b c6 75 3f'), # DEFAULT skips restart when Jimmy owns control.
|
||||
(0x47f20, 'a3 04 60 69 00'), # Restore selected music DB.
|
||||
(0x47f37, '53 6a 00 6a ff 50 e8 ce 57 03 00'), # Wave0,loop.
|
||||
]:
|
||||
raw = bytes.fromhex(expected)
|
||||
self.assertEqual(exe[offset:offset+len(raw)], raw, hex(offset+0x400000))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user