Remove TargetWhenIdle and TargetWhenDamaged from AutoTarget
This commit is contained in:
@@ -60,10 +60,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Ticks to wait until next AutoTarget: attempt.")]
|
[Desc("Ticks to wait until next AutoTarget: attempt.")]
|
||||||
public readonly int MaximumScanTimeInterval = 8;
|
public readonly int MaximumScanTimeInterval = 8;
|
||||||
|
|
||||||
public readonly bool TargetWhenIdle = true;
|
|
||||||
|
|
||||||
public readonly bool TargetWhenDamaged = true;
|
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new AutoTarget(init, this); }
|
public override object Create(ActorInitializer init) { return new AutoTarget(init, this); }
|
||||||
|
|
||||||
public override void RulesetLoaded(Ruleset rules, ActorInfo info)
|
public override void RulesetLoaded(Ruleset rules, ActorInfo info)
|
||||||
@@ -157,17 +153,18 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Damaged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (IsTraitDisabled)
|
if (IsTraitDisabled || !self.IsIdle || Stance < UnitStance.ReturnFire)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!self.IsIdle || !Info.TargetWhenDamaged)
|
// Don't retaliate against healers
|
||||||
|
if (e.Damage.Value < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var attacker = e.Attacker;
|
var attacker = e.Attacker;
|
||||||
if (attacker.Disposed || Stance < UnitStance.ReturnFire)
|
if (attacker.Disposed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!attacker.IsInWorld && !attacker.Disposed)
|
if (!attacker.IsInWorld)
|
||||||
{
|
{
|
||||||
// If the aggressor is in a transport, then attack the transport instead
|
// If the aggressor is in a transport, then attack the transport instead
|
||||||
var passenger = attacker.TraitOrDefault<Passenger>();
|
var passenger = attacker.TraitOrDefault<Passenger>();
|
||||||
@@ -175,19 +172,15 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
attacker = passenger.Transport;
|
attacker = passenger.Transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
// not a lot we can do about things we can't hurt... although maybe we should automatically run away?
|
// Not a lot we can do about things we can't hurt... although maybe we should automatically run away?
|
||||||
var attackerAsTarget = Target.FromActor(attacker);
|
var attackerAsTarget = Target.FromActor(attacker);
|
||||||
if (!activeAttackBases.Any(a => a.HasAnyValidWeapons(attackerAsTarget)))
|
if (!activeAttackBases.Any(a => a.HasAnyValidWeapons(attackerAsTarget)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// don't retaliate against own units force-firing on us. It's usually not what the player wanted.
|
// Don't retaliate against own units force-firing on us. It's usually not what the player wanted.
|
||||||
if (attacker.AppearsFriendlyTo(self))
|
if (attacker.AppearsFriendlyTo(self))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// don't retaliate against healers
|
|
||||||
if (e.Damage.Value < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Aggressor = attacker;
|
Aggressor = attacker;
|
||||||
|
|
||||||
bool allowMove;
|
bool allowMove;
|
||||||
@@ -197,10 +190,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public void TickIdle(Actor self)
|
public void TickIdle(Actor self)
|
||||||
{
|
{
|
||||||
if (IsTraitDisabled)
|
if (IsTraitDisabled || Stance < UnitStance.Defend)
|
||||||
return;
|
|
||||||
|
|
||||||
if (Stance < UnitStance.Defend || !Info.TargetWhenIdle)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool allowMove;
|
bool allowMove;
|
||||||
|
|||||||
@@ -877,6 +877,82 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TargetWhenIdle and TargetWhenDamaged were removed from AutoTarget
|
||||||
|
if (engineVersion < 20170722)
|
||||||
|
{
|
||||||
|
if (node.Key.StartsWith("AutoTarget", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
var valueNodes = node.Value.Nodes;
|
||||||
|
var targetIdle = valueNodes.FirstOrDefault(n => n.Key == "TargetWhenIdle");
|
||||||
|
var targetDamaged = valueNodes.FirstOrDefault(n => n.Key == "TargetWhenDamaged");
|
||||||
|
var hasInitialStance = valueNodes.FirstOrDefault(n => n.Key == "InitialStance") != null;
|
||||||
|
var enableStances = valueNodes.FirstOrDefault(n => n.Key == "EnableStances");
|
||||||
|
|
||||||
|
if (targetDamaged == null)
|
||||||
|
{
|
||||||
|
if (targetIdle != null)
|
||||||
|
{
|
||||||
|
if (hasInitialStance)
|
||||||
|
Console.WriteLine("'TargetWhenIdle' was removed from 'AutoTarget'. 'InitialStance' might need to be adjusted.");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
valueNodes.Add(new MiniYamlNode("InitialStance", targetIdle.Value.Value.ToLower() == "true" ? "Defend" : "ReturnFire"));
|
||||||
|
|
||||||
|
if (enableStances != null)
|
||||||
|
enableStances.Value.Value = "false";
|
||||||
|
else
|
||||||
|
valueNodes.Add(new MiniYamlNode("EnableStances", "false"));
|
||||||
|
}
|
||||||
|
|
||||||
|
valueNodes.Remove(targetIdle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (targetIdle == null)
|
||||||
|
{
|
||||||
|
if (hasInitialStance)
|
||||||
|
Console.WriteLine("'TargetWhenDamaged' was removed from 'AutoTarget'. 'InitialStance' might need to be adjusted.");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// In this case the default for "TargetWhenIdle" (true) takes effect, i.e. use the "Defend" stance
|
||||||
|
valueNodes.Add(new MiniYamlNode("InitialStance", "Defend"));
|
||||||
|
|
||||||
|
if (enableStances != null)
|
||||||
|
enableStances.Value.Value = "false";
|
||||||
|
else
|
||||||
|
valueNodes.Add(new MiniYamlNode("EnableStances", "false"));
|
||||||
|
}
|
||||||
|
|
||||||
|
valueNodes.Remove(targetDamaged);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (hasInitialStance)
|
||||||
|
Console.WriteLine("'TargetWhenDamaged' and 'TargetWhenIdle' were removed from 'AutoTarget'. 'InitialStance' might need to be adjusted.");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var idle = targetIdle.Value.Value.ToLower() == "true";
|
||||||
|
var damaged = targetDamaged.Value.Value.ToLower() == "true";
|
||||||
|
|
||||||
|
if (idle)
|
||||||
|
valueNodes.Add(new MiniYamlNode("InitialStance", "Defend"));
|
||||||
|
else
|
||||||
|
valueNodes.Add(new MiniYamlNode("InitialStance", damaged ? "ReturnFire" : "HoldFire"));
|
||||||
|
|
||||||
|
if (enableStances != null)
|
||||||
|
enableStances.Value.Value = "false";
|
||||||
|
else
|
||||||
|
valueNodes.Add(new MiniYamlNode("EnableStances", "false"));
|
||||||
|
}
|
||||||
|
|
||||||
|
valueNodes.Remove(targetIdle);
|
||||||
|
valueNodes.Remove(targetDamaged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ RMBO:
|
|||||||
MustBeDestroyed:
|
MustBeDestroyed:
|
||||||
RequiredForShortGame: true
|
RequiredForShortGame: true
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
TargetWhenIdle: false
|
EnableStances: false
|
||||||
TargetWhenDamaged: true
|
InitialStance: ReturnFire
|
||||||
Health:
|
Health:
|
||||||
HP: 150
|
HP: 150
|
||||||
|
|
||||||
|
|||||||
@@ -118,9 +118,8 @@ MIG:
|
|||||||
RepulsionSpeed: 40
|
RepulsionSpeed: 40
|
||||||
MaximumPitch: 56
|
MaximumPitch: 56
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
TargetWhenIdle: false
|
InitialStance: HoldFire
|
||||||
TargetWhenDamaged: false
|
InitialStanceAI: HoldFire
|
||||||
EnableStances: false
|
|
||||||
AmmoPool:
|
AmmoPool:
|
||||||
Ammo: 8
|
Ammo: 8
|
||||||
ReturnOnIdle:
|
ReturnOnIdle:
|
||||||
@@ -183,9 +182,8 @@ YAK:
|
|||||||
RepulsionSpeed: 40
|
RepulsionSpeed: 40
|
||||||
MaximumPitch: 56
|
MaximumPitch: 56
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
TargetWhenIdle: false
|
InitialStance: HoldFire
|
||||||
TargetWhenDamaged: false
|
InitialStanceAI: HoldFire
|
||||||
EnableStances: false
|
|
||||||
AmmoPool:
|
AmmoPool:
|
||||||
Ammo: 18
|
Ammo: 18
|
||||||
PipCount: 6
|
PipCount: 6
|
||||||
|
|||||||
Reference in New Issue
Block a user