Remove TargetActor and TargetLocation from order issuing.

This commit is contained in:
Paul Chote
2017-10-15 16:45:16 +00:00
committed by reaperrr
parent 4896a90b8d
commit d967c564a2
45 changed files with 104 additions and 144 deletions

View File

@@ -157,11 +157,13 @@ namespace OpenRA.Mods.Common.AI
else
{
failCount = 0;
ai.QueueOrder(new Order("PlaceBuilding", player.PlayerActor, false)
ai.QueueOrder(new Order("PlaceBuilding", player.PlayerActor, Target.FromCell(world, location.Value), false)
{
TargetLocation = location.Value,
// Building to place
TargetString = currentBuilding.Item,
TargetActor = queue.Actor,
// Actor ID to associate the placement with
ExtraData = queue.Actor.ActorID,
SuppressVisualFeedback = true
});

View File

@@ -757,7 +757,7 @@ namespace OpenRA.Mods.Common.AI
if (target.Actor == null)
return;
QueueOrder(new Order(target.OrderString, capturer, true) { TargetActor = target.Actor });
QueueOrder(new Order(target.OrderString, capturer, Target.FromActor(target.Actor), true));
BotDebug("AI ({0}): Ordered {1} to capture {2}", Player.ClientIndex, capturer, target.Actor);
activeUnits.Remove(capturer);
}
@@ -813,7 +813,7 @@ namespace OpenRA.Mods.Common.AI
// Tell the idle harvester to quit slacking:
var newSafeResourcePatch = FindNextResource(harvester, harv);
BotDebug("AI: Harvester {0} is idle. Ordering to {1} in search for new resources.".F(harvester, newSafeResourcePatch));
QueueOrder(new Order("Harvest", harvester, false) { TargetLocation = newSafeResourcePatch });
QueueOrder(new Order("Harvest", harvester, Target.FromCell(World, newSafeResourcePatch), false));
}
}
@@ -927,13 +927,16 @@ namespace OpenRA.Mods.Common.AI
void SetRallyPointsForNewProductionBuildings(Actor self)
{
foreach (var rp in self.World.ActorsWithTrait<RallyPoint>())
{
if (rp.Actor.Owner == Player &&
!IsRallyPointValid(rp.Trait.Location, rp.Actor.Info.TraitInfoOrDefault<BuildingInfo>()))
QueueOrder(new Order("SetRallyPoint", rp.Actor, false)
{
QueueOrder(new Order("SetRallyPoint", rp.Actor, Target.FromCell(World, ChooseRallyLocationNear(rp.Actor)), false)
{
TargetLocation = ChooseRallyLocationNear(rp.Actor),
SuppressVisualFeedback = true
});
}
}
}
// Won't work for shipyards...
@@ -992,7 +995,7 @@ namespace OpenRA.Mods.Common.AI
if (desiredLocation == null)
continue;
QueueOrder(new Order("Move", mcv, true) { TargetLocation = desiredLocation.Value });
QueueOrder(new Order("Move", mcv, Target.FromCell(World, desiredLocation.Value), true));
QueueOrder(new Order("DeployTransform", mcv, true));
}
}
@@ -1047,7 +1050,7 @@ namespace OpenRA.Mods.Common.AI
// Valid target found, delay by a few ticks to avoid rescanning before power fires via order
BotDebug("AI: {2} found new target location {0} for support power {1}.", attackLocation, sp.Info.OrderName, Player.PlayerName);
waitingPowers[sp] += 10;
QueueOrder(new Order(sp.Key, supportPowerMngr.Self, false) { TargetLocation = attackLocation.Value, SuppressVisualFeedback = true });
QueueOrder(new Order(sp.Key, supportPowerMngr.Self, Target.FromCell(World, attackLocation.Value), false) { SuppressVisualFeedback = true });
}
}
}
@@ -1199,7 +1202,7 @@ namespace OpenRA.Mods.Common.AI
{
BotDebug("Bot noticed damage {0} {1}->{2}, repairing.",
self, e.PreviousDamageState, e.DamageState);
QueueOrder(new Order("RepairBuilding", self.Owner.PlayerActor, false) { TargetActor = self });
QueueOrder(new Order("RepairBuilding", self.Owner.PlayerActor, Target.FromActor(self), false));
}
}

View File

@@ -223,7 +223,7 @@ namespace OpenRA.Mods.Common.AI
}
if (CanAttackTarget(a, owner.TargetActor))
owner.Bot.QueueOrder(new Order("Attack", a, false) { TargetActor = owner.TargetActor });
owner.Bot.QueueOrder(new Order("Attack", a, Target.FromActor(owner.TargetActor), false));
}
}
@@ -250,7 +250,7 @@ namespace OpenRA.Mods.Common.AI
continue;
}
owner.Bot.QueueOrder(new Order("Move", a, false) { TargetLocation = RandomBuildingLocation(owner) });
owner.Bot.QueueOrder(new Order("Move", a, Target.FromCell(owner.World, RandomBuildingLocation(owner)), false));
}
owner.FuzzyStateMachine.ChangeState(owner, new AirIdleState(), true);

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.AI
if (AttackOrFleeFuzzy.Default.CanAttack(owner.Units, enemyUnits))
{
foreach (var u in owner.Units)
owner.Bot.QueueOrder(new Order("AttackMove", u, false) { TargetLocation = owner.TargetActor.Location });
owner.Bot.QueueOrder(new Order("AttackMove", u, Target.FromCell(owner.World, owner.TargetActor.Location), false));
// We have gathered sufficient units. Attack the nearest enemy unit.
owner.FuzzyStateMachine.ChangeState(owner, new GroundUnitsAttackMoveState(), true);
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.AI
// Let them regroup into tighter formation.
owner.Bot.QueueOrder(new Order("Stop", leader, false));
foreach (var unit in owner.Units.Where(a => !ownUnits.Contains(a)))
owner.Bot.QueueOrder(new Order("AttackMove", unit, false) { TargetLocation = leader.Location });
owner.Bot.QueueOrder(new Order("AttackMove", unit, Target.FromCell(owner.World, leader.Location), false));
}
else
{
@@ -114,7 +114,7 @@ namespace OpenRA.Mods.Common.AI
}
else
foreach (var a in owner.Units)
owner.Bot.QueueOrder(new Order("AttackMove", a, false) { TargetLocation = owner.TargetActor.Location });
owner.Bot.QueueOrder(new Order("AttackMove", a, Target.FromCell(owner.World, owner.TargetActor.Location), false));
}
if (ShouldFlee(owner))
@@ -147,7 +147,7 @@ namespace OpenRA.Mods.Common.AI
foreach (var a in owner.Units)
if (!BusyAttack(a))
owner.Bot.QueueOrder(new Order("Attack", a, false) { TargetActor = owner.TargetActor });
owner.Bot.QueueOrder(new Order("Attack", a, Target.FromActor(owner.TargetActor), false));
if (ShouldFlee(owner))
owner.FuzzyStateMachine.ChangeState(owner, new GroundUnitsFleeState(), true);

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.AI
if (AttackOrFleeFuzzy.Default.CanAttack(owner.Units, enemyUnits))
{
foreach (var u in owner.Units)
owner.Bot.QueueOrder(new Order("AttackMove", u, false) { TargetLocation = owner.TargetActor.Location });
owner.Bot.QueueOrder(new Order("AttackMove", u, Target.FromCell(owner.World, owner.TargetActor.Location), false));
// We have gathered sufficient units. Attack the nearest enemy unit.
owner.FuzzyStateMachine.ChangeState(owner, new NavyUnitsAttackMoveState(), true);
@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.AI
// Let them regroup into tighter formation.
owner.Bot.QueueOrder(new Order("Stop", leader, false));
foreach (var unit in owner.Units.Where(a => !ownUnits.Contains(a)))
owner.Bot.QueueOrder(new Order("AttackMove", unit, false) { TargetLocation = leader.Location });
owner.Bot.QueueOrder(new Order("AttackMove", unit, Target.FromCell(owner.World, leader.Location), false));
}
else
{
@@ -141,7 +141,7 @@ namespace OpenRA.Mods.Common.AI
}
else
foreach (var a in owner.Units)
owner.Bot.QueueOrder(new Order("AttackMove", a, false) { TargetLocation = owner.TargetActor.Location });
owner.Bot.QueueOrder(new Order("AttackMove", a, Target.FromCell(owner.World, owner.TargetActor.Location), false));
}
if (ShouldFlee(owner))
@@ -174,7 +174,7 @@ namespace OpenRA.Mods.Common.AI
foreach (var a in owner.Units)
if (!BusyAttack(a))
owner.Bot.QueueOrder(new Order("Attack", a, false) { TargetActor = owner.TargetActor });
owner.Bot.QueueOrder(new Order("Attack", a, Target.FromActor(owner.TargetActor), false));
if (ShouldFlee(owner))
owner.FuzzyStateMachine.ChangeState(owner, new NavyUnitsFleeState(), true);

View File

@@ -9,6 +9,8 @@
*/
#endregion
using OpenRA.Traits;
namespace OpenRA.Mods.Common.AI
{
class UnitsForProtectionIdleState : GroundStateBase, IState
@@ -55,7 +57,7 @@ namespace OpenRA.Mods.Common.AI
else
{
foreach (var a in owner.Units)
owner.Bot.QueueOrder(new Order("AttackMove", a, false) { TargetLocation = owner.TargetActor.Location });
owner.Bot.QueueOrder(new Order("AttackMove", a, Target.FromCell(owner.World, owner.TargetActor.Location), false));
}
}

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.AI
{
var loc = RandomBuildingLocation(squad);
foreach (var a in squad.Units)
squad.Bot.QueueOrder(new Order("Move", a, false) { TargetLocation = loc });
squad.Bot.QueueOrder(new Order("Move", a, Target.FromCell(squad.World, loc), false));
}
protected static CPos RandomBuildingLocation(Squad squad)