Run body and fire phases during scripted control locks
This commit is contained in:
1 parent
5876da112c
commit
c285b57091
35 files changed
+1503
-45
No files matched your search
@@ -37,6 +37,7 @@ public sealed class DirectorActor
|
||||
}
|
||||
|
||||
public sealed record DirectorIssue(string Tag, string Kind, string Detail);
|
||||
public enum ScriptPreparation { StopMotion, ReleaseGadget, FlattenOrientation }
|
||||
|
||||
/// <summary>
|
||||
/// Recovered synchronous AI-trigger dispatch and audio-duration-driven CAM/MCA
|
||||
@@ -71,6 +72,7 @@ public sealed class SceneDirector
|
||||
public List<DirectorActor> Actors { get; } = [];
|
||||
public IReadOnlyList<DirectorIssue> Issues => issues;
|
||||
private string? controlledTag;
|
||||
public string? AuthoredControlledTag => controlledTag;
|
||||
/// <summary>Modern debug override; leaves authored control/camera transitions intact.</summary>
|
||||
public bool DebugForceControl { get; set; }
|
||||
public bool Controlled => Equal(ControlledTag, level.Player?.Tag);
|
||||
@@ -90,6 +92,8 @@ public sealed class SceneDirector
|
||||
public event Action? MusicStopped;
|
||||
public event Action? MusicRestarted;
|
||||
public event Action<DirectorActor>? ActorChanged;
|
||||
public event Action<DirectorActor, ScriptPreparation>? ActorPreparing;
|
||||
public event Action<DirectorActor>? AuthoredTransformChanged;
|
||||
public event Action<string, string>? Unsupported;
|
||||
|
||||
public SceneDirector(GamLevel level, TaskStates tasks, Func<string, int, double> soundDuration)
|
||||
@@ -277,7 +281,7 @@ public sealed class SceneDirector
|
||||
var number = activations.GetValueOrDefault(entity.Offset) + 1;
|
||||
activations[entity.Offset] = number;
|
||||
if (times != -1 && number > times) return;
|
||||
SetControl(entity);
|
||||
SetControl(entity, prepareOwner: true);
|
||||
|
||||
var targetTag = entity.Text("AITarget");
|
||||
if (!IsNone(targetTag))
|
||||
@@ -286,12 +290,13 @@ public sealed class SceneDirector
|
||||
Report(entity.Tag!, entity.Kind, $"AI target {targetTag} absent");
|
||||
else
|
||||
{
|
||||
var transformed = false;
|
||||
var hide = entity.Integer("AIHideObj", -1);
|
||||
if (hide != -1) target.Visible = hide == 0;
|
||||
var positionTag = entity.Text("AINewPos");
|
||||
if (!IsNone(positionTag))
|
||||
{
|
||||
if (actors.TryGetValue(positionTag!, out var marker)) target.Position = marker.Position;
|
||||
if (actors.TryGetValue(positionTag!, out var marker)) { target.Position = marker.Position; transformed = true; }
|
||||
else Report(entity.Tag!, entity.Kind, $"AINewPos {positionTag} absent");
|
||||
}
|
||||
var animation = entity.Text("AIAnim");
|
||||
@@ -302,7 +307,8 @@ public sealed class SceneDirector
|
||||
var patrol = entity.Text("AIPatrol");
|
||||
if (!IsNone(patrol)) target.Patrol = patrol;
|
||||
var yaw = entity.Number("AINewRotY", -1);
|
||||
if (yaw != -1) target.Rotation = target.Rotation with { Y = yaw };
|
||||
if (yaw != -1) { target.Rotation = target.Rotation with { Y = yaw }; transformed = true; }
|
||||
if (transformed) AuthoredTransformChanged?.Invoke(target);
|
||||
ActorChanged?.Invoke(target);
|
||||
if (target.AIstate == 3 && (target.Kind is "3DOG" or "3CAR") && !patrolConsumers.Contains(target.Tag))
|
||||
Report(target.Tag, target.Kind, "Patrol motion/arrival is not yet reconstructed; actor-state callback emitted");
|
||||
@@ -331,15 +337,26 @@ public sealed class SceneDirector
|
||||
private void StartMulti(GamEntity entity)
|
||||
{
|
||||
// MCA's PlayerControlled is its completion target (4311F0), not an
|
||||
// activation grant. Each valid shot clears control at43159E..4315A7.
|
||||
// activation grant. Only initial activation clears control; later shots
|
||||
//use431750 without repeating431502..4315A7 preparation.
|
||||
Toggle(entity);
|
||||
if (IsNone(entity.Text("CameraTarget0"))) return; //431300→431668 returns, not completion.
|
||||
if (skipping) { FinishMulti(entity); return; }
|
||||
//431502 initial activation only. Subsequent431750 shots do not repeat
|
||||
//preparation or clear control. The raw owner guard ignores debug force.
|
||||
PrepareOwner(ScriptPreparation.StopMotion, ScriptPreparation.FlattenOrientation, ScriptPreparation.ReleaseGadget);
|
||||
ControlledTag = null;
|
||||
StartCamera(entity, 0, applyCommon: false);
|
||||
}
|
||||
|
||||
private void StartCamera(GamEntity entity, int index, bool applyCommon = true)
|
||||
{
|
||||
if (applyCommon) { SetControl(entity); Toggle(entity); }
|
||||
if (applyCommon)
|
||||
{
|
||||
if (Equal(entity.Text("PlayerControlled"), "NULL"))
|
||||
PrepareOwner(ScriptPreparation.ReleaseGadget, ScriptPreparation.StopMotion, ScriptPreparation.FlattenOrientation);
|
||||
SetControl(entity); Toggle(entity);
|
||||
}
|
||||
if (entity.Integer("DeactivateInv") != 0) InventoryEnabled = false;
|
||||
if (skipping)
|
||||
{
|
||||
@@ -361,7 +378,6 @@ public sealed class SceneDirector
|
||||
Block(entity, $"Camera target {targetTag} absent", entity.Text("NextTrigger"));
|
||||
return;
|
||||
}
|
||||
if (index >= 0) ControlledTag = null;
|
||||
var database = entity.Text("SoundDatabase") ?? "none";
|
||||
var duration = soundDuration(database, sound);
|
||||
if (!double.IsFinite(duration) || duration < 0)
|
||||
@@ -478,11 +494,33 @@ public sealed class SceneDirector
|
||||
return target.Position + new Vector3(x * cy - pitchedZ * sy, pitchedY, x * sy + pitchedZ * cy);
|
||||
}
|
||||
|
||||
private void SetControl(GamEntity entity)
|
||||
private void PrepareOwner(params ScriptPreparation[] actions)
|
||||
{
|
||||
if (controlledTag == null || !actors.TryGetValue(controlledTag, out var owner)) return;
|
||||
foreach (var action in actions)
|
||||
{
|
||||
// Only Jimmy's derived preparation is modeled here; other classes
|
||||
//receive the boundary without inventing their virtual side effects.
|
||||
if (action == ScriptPreparation.StopMotion && owner.Kind == "3JIM")
|
||||
owner.Speed = 0;
|
||||
else if (action == ScriptPreparation.FlattenOrientation)
|
||||
owner.Rotation = new Vector3(0, owner.Rotation.Y, 0);
|
||||
ActorPreparing?.Invoke(owner, action);
|
||||
//42AFC0 invokes43A750 before the derived STOP animation request.
|
||||
if (action == ScriptPreparation.StopMotion && owner.Kind == "3JIM")
|
||||
{ owner.Animation = "STOP"; ActorChanged?.Invoke(owner); }
|
||||
}
|
||||
}
|
||||
|
||||
private void SetControl(GamEntity entity, bool prepareOwner = false)
|
||||
{
|
||||
var control = entity.Text("PlayerControlled");
|
||||
if (IsNone(control)) return;
|
||||
if (Equal(control, "NULL")) ControlledTag = null;
|
||||
if (Equal(control, "NULL"))
|
||||
{
|
||||
if (prepareOwner) PrepareOwner(ScriptPreparation.StopMotion); //40C4AD; no438/flatten.
|
||||
ControlledTag = null;
|
||||
}
|
||||
else if (actors.ContainsKey(control!)) ControlledTag = control;
|
||||
else Report(entity.Tag!, entity.Kind, $"PlayerControlled target {control} absent");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user