Fix RCS1061
This commit is contained in:
@@ -94,9 +94,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var pos = self.CenterPosition;
|
||||
var armaments = ChooseArmamentsForTarget(target, forceAttack);
|
||||
foreach (var a in armaments)
|
||||
if (target.IsInRange(pos, a.MaxRange()) && (a.Weapon.MinRange == WDist.Zero || !target.IsInRange(pos, a.Weapon.MinRange)))
|
||||
if (TargetInFiringArc(self, target, Info.FacingTolerance))
|
||||
return true;
|
||||
if (target.IsInRange(pos, a.MaxRange()) &&
|
||||
(a.Weapon.MinRange == WDist.Zero || !target.IsInRange(pos, a.Weapon.MinRange)) &&
|
||||
TargetInFiringArc(self, target, Info.FacingTolerance))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -247,13 +247,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
a => a.TraitInfos<PowerInfo>().Where(i => i.EnabledByDefault).Sum(p => p.Amount));
|
||||
|
||||
// First priority is to get out of a low power situation
|
||||
if (playerPower != null && playerPower.ExcessPower < minimumExcessPower)
|
||||
if (playerPower != null && playerPower.ExcessPower < minimumExcessPower &&
|
||||
power != null && power.TraitInfos<PowerInfo>().Where(i => i.EnabledByDefault).Sum(p => p.Amount) > 0)
|
||||
{
|
||||
if (power != null && power.TraitInfos<PowerInfo>().Where(i => i.EnabledByDefault).Sum(p => p.Amount) > 0)
|
||||
{
|
||||
AIUtils.BotDebug("{0} decided to build {1}: Priority override (low power)", queue.Actor.Owner, power.Name);
|
||||
return power;
|
||||
}
|
||||
AIUtils.BotDebug("{0} decided to build {1}: Priority override (low power)", queue.Actor.Owner, power.Name);
|
||||
return power;
|
||||
}
|
||||
|
||||
// Next is to build up a strong economy
|
||||
|
||||
@@ -34,14 +34,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
var rb = self.TraitOrDefault<RepairableBuilding>();
|
||||
if (rb != null)
|
||||
if (rb != null && e.DamageState > DamageState.Light && e.PreviousDamageState <= DamageState.Light && !rb.RepairActive)
|
||||
{
|
||||
if (e.DamageState > DamageState.Light && e.PreviousDamageState <= DamageState.Light && !rb.RepairActive)
|
||||
{
|
||||
AIUtils.BotDebug("{0} noticed damage {1} {2}->{3}, repairing.",
|
||||
self.Owner, self, e.PreviousDamageState, e.DamageState);
|
||||
bot.QueueOrder(new Order("RepairBuilding", self.Owner.PlayerActor, Target.FromActor(self), false));
|
||||
}
|
||||
AIUtils.BotDebug("{0} noticed damage {1} {2}->{3}, repairing.",
|
||||
self.Owner, self, e.PreviousDamageState, e.DamageState);
|
||||
bot.QueueOrder(new Order("RepairBuilding", self.Owner.PlayerActor, Target.FromActor(self), false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,11 +75,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Timed tokens do not count towards the source cap: the condition with the shortest
|
||||
// remaining duration can always be revoked to make room.
|
||||
if (Info.SourceCap > 0)
|
||||
if (permanentTokens.TryGetValue(source, out var permanentTokensForSource) && permanentTokensForSource.Count >= Info.SourceCap)
|
||||
return false;
|
||||
if (Info.SourceCap > 0 &&
|
||||
permanentTokens.TryGetValue(source, out var permanentTokensForSource) &&
|
||||
permanentTokensForSource.Count >= Info.SourceCap)
|
||||
return false;
|
||||
|
||||
if (Info.TotalCap > 0 && permanentTokens.Values.Sum(t => t.Count) >= Info.TotalCap)
|
||||
if (Info.TotalCap > 0 &&
|
||||
permanentTokens.Values.Sum(t => t.Count) >= Info.TotalCap)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -93,29 +93,34 @@ namespace OpenRA.Mods.Common.Traits
|
||||
static bool TargetChanged(in Target lastTarget, in Target target)
|
||||
{
|
||||
// Invalidate reveal changing the target.
|
||||
if (lastTarget.Type == TargetType.FrozenActor && target.Type == TargetType.Actor)
|
||||
if (lastTarget.FrozenActor.Actor == target.Actor)
|
||||
return false;
|
||||
if (lastTarget.Type == TargetType.FrozenActor &&
|
||||
target.Type == TargetType.Actor &&
|
||||
lastTarget.FrozenActor.Actor == target.Actor)
|
||||
return false;
|
||||
|
||||
if (lastTarget.Type == TargetType.Actor && target.Type == TargetType.FrozenActor)
|
||||
if (target.FrozenActor.Actor == lastTarget.Actor)
|
||||
return false;
|
||||
if (lastTarget.Type == TargetType.Actor &&
|
||||
target.Type == TargetType.FrozenActor &&
|
||||
target.FrozenActor.Actor == lastTarget.Actor)
|
||||
return false;
|
||||
|
||||
if (lastTarget.Type != target.Type)
|
||||
return true;
|
||||
|
||||
// Invalidate attacking different targets with shared target types.
|
||||
if (lastTarget.Type == TargetType.Actor && target.Type == TargetType.Actor)
|
||||
if (lastTarget.Actor != target.Actor)
|
||||
return true;
|
||||
if (lastTarget.Type == TargetType.Actor &&
|
||||
target.Type == TargetType.Actor &&
|
||||
lastTarget.Actor != target.Actor)
|
||||
return true;
|
||||
|
||||
if (lastTarget.Type == TargetType.FrozenActor && target.Type == TargetType.FrozenActor)
|
||||
if (lastTarget.FrozenActor != target.FrozenActor)
|
||||
return true;
|
||||
if (lastTarget.Type == TargetType.FrozenActor &&
|
||||
target.Type == TargetType.FrozenActor &&
|
||||
lastTarget.FrozenActor != target.FrozenActor)
|
||||
return true;
|
||||
|
||||
if (lastTarget.Type == TargetType.Terrain && target.Type == TargetType.Terrain)
|
||||
if (lastTarget.CenterPosition != target.CenterPosition)
|
||||
return true;
|
||||
if (lastTarget.Type == TargetType.Terrain &&
|
||||
target.Type == TargetType.Terrain &&
|
||||
lastTarget.CenterPosition != target.CenterPosition)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -48,17 +48,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void INotifyDockClient.Docked(Actor self, Actor host)
|
||||
{
|
||||
if (info.Condition != null && (info.DockHostNames == null || info.DockHostNames.Contains(host.Info.Name)))
|
||||
if (info.Condition != null &&
|
||||
(info.DockHostNames == null || info.DockHostNames.Contains(host.Info.Name)) &&
|
||||
token == Actor.InvalidConditionToken)
|
||||
{
|
||||
if (token == Actor.InvalidConditionToken)
|
||||
if (delayedtoken == Actor.InvalidConditionToken)
|
||||
token = self.GrantCondition(info.Condition);
|
||||
else
|
||||
{
|
||||
if (delayedtoken == Actor.InvalidConditionToken)
|
||||
token = self.GrantCondition(info.Condition);
|
||||
else
|
||||
{
|
||||
token = delayedtoken;
|
||||
delayedtoken = Actor.InvalidConditionToken;
|
||||
}
|
||||
token = delayedtoken;
|
||||
delayedtoken = Actor.InvalidConditionToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,17 +48,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void INotifyDockHost.Docked(Actor self, Actor client)
|
||||
{
|
||||
if (info.Condition != null && (info.DockClientNames == null || info.DockClientNames.Contains(client.Info.Name)))
|
||||
if (info.Condition != null &&
|
||||
(info.DockClientNames == null || info.DockClientNames.Contains(client.Info.Name)) &&
|
||||
token == Actor.InvalidConditionToken)
|
||||
{
|
||||
if (token == Actor.InvalidConditionToken)
|
||||
if (delayedtoken == Actor.InvalidConditionToken)
|
||||
token = self.GrantCondition(info.Condition);
|
||||
else
|
||||
{
|
||||
if (delayedtoken == Actor.InvalidConditionToken)
|
||||
token = self.GrantCondition(info.Condition);
|
||||
else
|
||||
{
|
||||
token = delayedtoken;
|
||||
delayedtoken = Actor.InvalidConditionToken;
|
||||
}
|
||||
token = delayedtoken;
|
||||
delayedtoken = Actor.InvalidConditionToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user