Restore delegated combat range control
This commit is contained in:
parent
974733c10d
commit
57bda320fa
2 changed files with 78 additions and 7 deletions
|
|
@ -24,6 +24,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
SchedulerAssignsHighestPriorityCompatibleTask();
|
||||
SchedulerAssignsShortestGalaxyRoute();
|
||||
AgentTraversesGalaxyRouteBeforeExecutingTask();
|
||||
AttackAgentControlsOptimumRangeThroughMovementLever();
|
||||
AgentCompletesAttackTaskThroughTargetFireAndYmir();
|
||||
AgentCompletesHaulTaskThroughMovementAndCargoCommands();
|
||||
RejectedHaulTransferDoesNotAdvanceTask();
|
||||
|
|
@ -537,6 +538,50 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
"attack task must complete when its target dies");
|
||||
}
|
||||
|
||||
private static void AttackAgentControlsOptimumRangeThroughMovementLever()
|
||||
{
|
||||
var settings = AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault;
|
||||
var optimum = settings.AttackRange * settings.AttackHoldRatio;
|
||||
|
||||
var closing = AttackMovementAtDistance(optimum + 30);
|
||||
Require(closing.DirectionX > 0.99 && closing.ScalarValue > 0,
|
||||
"attack agent outside optimum range must close through the shared movement lever");
|
||||
|
||||
var retreating = AttackMovementAtDistance(optimum - 30);
|
||||
Require(retreating.DirectionX < -0.99 && retreating.ScalarValue > 0,
|
||||
"attack agent inside optimum range must retreat through the shared movement lever");
|
||||
|
||||
var holding = AttackMovementAtDistance(optimum);
|
||||
Require(Math.Abs(holding.DirectionX) < 0.001 && Math.Abs(holding.ScalarValue) < 0.001,
|
||||
"attack agent in the optimum band must hold range instead of charging the target");
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeDaemonCommandDocument AttackMovementAtDistance(double distance)
|
||||
{
|
||||
var agent = Entity(0, 0, "workers");
|
||||
agent.AgentTaskCapabilities = [AetheriaRuntimeAgentTaskTypes.Attack];
|
||||
agent.WeaponGroups = [new[] { 0 }];
|
||||
var target = Entity(1, distance, "raiders");
|
||||
var task = new AetheriaRuntimeAgentTaskCommit
|
||||
{
|
||||
TaskId = "range-control",
|
||||
CorporationKey = "workers",
|
||||
TaskType = AetheriaRuntimeAgentTaskTypes.Attack,
|
||||
ZoneIndex = 0,
|
||||
TargetEntityIndex = 1,
|
||||
WeaponGroup = 0
|
||||
};
|
||||
var run = new AetheriaRuntimeRunCheckpointCommit
|
||||
{
|
||||
RunId = "agent-range-control-smoke",
|
||||
Zones = [new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [agent, target] }],
|
||||
AgentTasks = [task]
|
||||
};
|
||||
|
||||
return AetheriaRuntimeAgentScheduler.AssignAndPlan(run, 1)
|
||||
.Single(command => command.Kind == AetheriaRuntimeDaemonCommandKinds.SetMoveVector);
|
||||
}
|
||||
|
||||
private static void SchedulerAssignsHighestPriorityCompatibleTask()
|
||||
{
|
||||
var agent = Entity(0, 0, "workers");
|
||||
|
|
|
|||
|
|
@ -288,6 +288,11 @@ namespace GameCult.Aetheria.State.Verse
|
|||
var dx = targetX - agent.PositionX;
|
||||
var dz = targetZ - agent.PositionZ;
|
||||
var distance = Math.Sqrt(dx * dx + dz * dz);
|
||||
if (string.Equals(task.TaskType, AetheriaRuntimeAgentTaskTypes.Attack, StringComparison.Ordinal) && target != null)
|
||||
{
|
||||
commands.AddRange(PlanAttack(run, task, agent, target, frameId, dx, dz, distance));
|
||||
continue;
|
||||
}
|
||||
if (distance <= Math.Max(0.01, task.CompletionRadius) &&
|
||||
!string.Equals(task.TaskType, AetheriaRuntimeAgentTaskTypes.Attack, StringComparison.Ordinal))
|
||||
{
|
||||
|
|
@ -298,17 +303,38 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
var magnitude = distance <= 0.0001 ? 0 : 1;
|
||||
commands.Add(Movement(task, agent, frameId, dx, dz, magnitude));
|
||||
if (string.Equals(task.TaskType, AetheriaRuntimeAgentTaskTypes.Attack, StringComparison.Ordinal) && target != null)
|
||||
{
|
||||
commands.Add(Command(task, agent, frameId, AetheriaRuntimeDaemonCommandKinds.SetTarget, "target", command =>
|
||||
command.TargetEntityKey = EntityKey(run, task.ZoneIndex, target.EntityIndex)));
|
||||
commands.Add(Command(task, agent, frameId, AetheriaRuntimeDaemonCommandKinds.FireWeaponGroup, "fire", command =>
|
||||
command.WeaponGroup = Math.Max(0, task.WeaponGroup)));
|
||||
}
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
|
||||
private static IReadOnlyList<AetheriaRuntimeDaemonCommandDocument> PlanAttack(
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
AetheriaRuntimeAgentTaskCommit task,
|
||||
AetheriaRuntimeEntitySnapshotCommit agent,
|
||||
AetheriaRuntimeEntitySnapshotCommit target,
|
||||
long frameId,
|
||||
double dx,
|
||||
double dz,
|
||||
double distance)
|
||||
{
|
||||
var settings = AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault;
|
||||
var optimum = settings.AttackRange * settings.AttackHoldRatio;
|
||||
var tolerance = Math.Max(1.0, settings.AttackRange * 0.04);
|
||||
var radial = distance > optimum + tolerance ? 1.0 : distance < optimum - tolerance ? -1.0 : 0.0;
|
||||
var thrust = radial == 0 ? 0 : Math.Min(1.0, Math.Abs(distance - optimum) / settings.AttackRange);
|
||||
task.Phase = radial > 0 ? "closing-range" : radial < 0 ? "opening-range" : "holding-range";
|
||||
var commands = new List<AetheriaRuntimeDaemonCommandDocument>
|
||||
{
|
||||
Movement(task, agent, frameId, dx * radial, dz * radial, thrust),
|
||||
Command(task, agent, frameId, AetheriaRuntimeDaemonCommandKinds.SetTarget, "target", command =>
|
||||
command.TargetEntityKey = EntityKey(run, task.ZoneIndex, target.EntityIndex))
|
||||
};
|
||||
if (distance <= settings.AttackRange)
|
||||
commands.Add(Command(task, agent, frameId, AetheriaRuntimeDaemonCommandKinds.FireWeaponGroup, "fire", command =>
|
||||
command.WeaponGroup = Math.Max(0, task.WeaponGroup)));
|
||||
return commands;
|
||||
}
|
||||
|
||||
private static (AetheriaRuntimeZoneSnapshotCommit? Zone, AetheriaRuntimeEntitySnapshotCommit? Entity) FindAssignedEntity(
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
AetheriaRuntimeAgentTaskCommit task)
|
||||
|
|
|
|||
Loading…
Reference in a new issue