Introduce AirAttackType
Aircraft attack behavior (currently FlyBy or Hover) is now controlled via this instead of the CanHover boolean.
This commit is contained in:
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (!isAirborne)
|
if (!isAirborne)
|
||||||
QueueChild(self, new TakeOff(self), true);
|
QueueChild(self, new TakeOff(self), true);
|
||||||
|
|
||||||
if (!aircraft.Info.CanHover)
|
if (attackAircraft.Info.AttackType == AirAttackType.Strafe)
|
||||||
{
|
{
|
||||||
if (target.IsInRange(pos, attackAircraft.GetMinimumRange()))
|
if (target.IsInRange(pos, attackAircraft.GetMinimumRange()))
|
||||||
QueueChild(self, new FlyTimed(ticksUntilTurn, self), true);
|
QueueChild(self, new FlyTimed(ticksUntilTurn, self), true);
|
||||||
|
|||||||
@@ -15,9 +15,15 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
|
// TODO: Add CurleyShuffle (TD, TS), Circle (Generals Gunship-style)
|
||||||
|
public enum AirAttackType { Hover, Strafe }
|
||||||
|
|
||||||
public class AttackAircraftInfo : AttackFollowInfo, Requires<AircraftInfo>
|
public class AttackAircraftInfo : AttackFollowInfo, Requires<AircraftInfo>
|
||||||
{
|
{
|
||||||
[Desc("Delay, in game ticks, before non-hovering aircraft turns to attack.")]
|
[Desc("Attack behavior. Currently supported types are Strafe (default) and Hover.")]
|
||||||
|
public readonly AirAttackType AttackType = AirAttackType.Strafe;
|
||||||
|
|
||||||
|
[Desc("Delay, in game ticks, before strafing aircraft turns to attack.")]
|
||||||
public readonly int AttackTurnDelay = 50;
|
public readonly int AttackTurnDelay = 50;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new AttackAircraft(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new AttackAircraft(init.Self, this); }
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2019 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||||
|
{
|
||||||
|
public class AddAirAttackTypes : UpdateRule
|
||||||
|
{
|
||||||
|
public override string Name { get { return "Add AttackType field to AttackAircraft"; } }
|
||||||
|
public override string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Aircraft attack behavior now depends on AttackAircraft.AttackType\n"
|
||||||
|
+ "instead of Aircraft.CanHover.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly List<Tuple<string, string>> hoveringActors = new List<Tuple<string, string>>();
|
||||||
|
|
||||||
|
public override IEnumerable<string> AfterUpdate(ModData modData)
|
||||||
|
{
|
||||||
|
var message = "Aircraft attack behavior (Hover or Strafe) is now controlled via AttackAircraft.AttackType.\n"
|
||||||
|
+ "Aircraft with CanHover: true will now also need AttackType: Hover on AttackAircraft\n"
|
||||||
|
+ "to maintain position while attacking as before.\n"
|
||||||
|
+ "The following places might need manual changes:\n"
|
||||||
|
+ UpdateUtils.FormatMessageList(hoveringActors.Select(n => n.Item1 + " (" + n.Item2 + ")"));
|
||||||
|
|
||||||
|
if (hoveringActors.Any())
|
||||||
|
yield return message;
|
||||||
|
|
||||||
|
hoveringActors.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||||
|
{
|
||||||
|
var aircraftTraits = actorNode.ChildrenMatching("Aircraft");
|
||||||
|
var attackAircraftTraits = actorNode.ChildrenMatching("AttackAircraft");
|
||||||
|
foreach (var attackAircraft in attackAircraftTraits)
|
||||||
|
{
|
||||||
|
var isHover = false;
|
||||||
|
foreach (var aircraft in aircraftTraits)
|
||||||
|
{
|
||||||
|
var canHoverNode = aircraft.LastChildMatching("CanHover");
|
||||||
|
if (canHoverNode != null)
|
||||||
|
isHover = canHoverNode.NodeValue<bool>();
|
||||||
|
|
||||||
|
if (isHover)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// It's still possible that CanHover: true is inherited, so let modders check manually if 'false',
|
||||||
|
// otherwise add AttackType: Hover.
|
||||||
|
if (!isHover)
|
||||||
|
hoveringActors.Add(Tuple.Create(actorNode.Key, actorNode.Location.Filename));
|
||||||
|
else
|
||||||
|
attackAircraft.AddNode("AttackType", "Hover");
|
||||||
|
}
|
||||||
|
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -128,6 +128,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
|||||||
new RenameAttackMoveConditions(),
|
new RenameAttackMoveConditions(),
|
||||||
new RemovePlaceBuildingPalettes(),
|
new RemovePlaceBuildingPalettes(),
|
||||||
new RenameHoversOffsetModifier(),
|
new RenameHoversOffsetModifier(),
|
||||||
|
new AddAirAttackTypes(),
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ HELI:
|
|||||||
FacingTolerance: 20
|
FacingTolerance: 20
|
||||||
OpportunityFire: false
|
OpportunityFire: false
|
||||||
PersistentTargeting: false
|
PersistentTargeting: false
|
||||||
|
AttackType: Hover
|
||||||
AmmoPool:
|
AmmoPool:
|
||||||
Ammo: 10
|
Ammo: 10
|
||||||
PipCount: 5
|
PipCount: 5
|
||||||
@@ -154,6 +155,7 @@ ORCA:
|
|||||||
FacingTolerance: 20
|
FacingTolerance: 20
|
||||||
OpportunityFire: false
|
OpportunityFire: false
|
||||||
PersistentTargeting: false
|
PersistentTargeting: false
|
||||||
|
AttackType: Hover
|
||||||
AmmoPool:
|
AmmoPool:
|
||||||
Ammo: 6
|
Ammo: 6
|
||||||
PipCount: 6
|
PipCount: 6
|
||||||
|
|||||||
@@ -305,6 +305,7 @@ HELI:
|
|||||||
AttackAircraft:
|
AttackAircraft:
|
||||||
FacingTolerance: 20
|
FacingTolerance: 20
|
||||||
PersistentTargeting: false
|
PersistentTargeting: false
|
||||||
|
AttackType: Hover
|
||||||
Aircraft:
|
Aircraft:
|
||||||
LandWhenIdle: false
|
LandWhenIdle: false
|
||||||
TurnSpeed: 4
|
TurnSpeed: 4
|
||||||
@@ -373,6 +374,7 @@ HIND:
|
|||||||
AttackAircraft:
|
AttackAircraft:
|
||||||
FacingTolerance: 20
|
FacingTolerance: 20
|
||||||
PersistentTargeting: false
|
PersistentTargeting: false
|
||||||
|
AttackType: Hover
|
||||||
Aircraft:
|
Aircraft:
|
||||||
LandWhenIdle: false
|
LandWhenIdle: false
|
||||||
TurnSpeed: 4
|
TurnSpeed: 4
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ ORCA:
|
|||||||
PersistentTargeting: false
|
PersistentTargeting: false
|
||||||
Voice: Attack
|
Voice: Attack
|
||||||
PauseOnCondition: empdisable
|
PauseOnCondition: empdisable
|
||||||
|
AttackType: Hover
|
||||||
AmmoPool:
|
AmmoPool:
|
||||||
Ammo: 5
|
Ammo: 5
|
||||||
PipCount: 5
|
PipCount: 5
|
||||||
@@ -352,6 +353,7 @@ APACHE:
|
|||||||
PersistentTargeting: false
|
PersistentTargeting: false
|
||||||
Voice: Attack
|
Voice: Attack
|
||||||
PauseOnCondition: empdisable
|
PauseOnCondition: empdisable
|
||||||
|
AttackType: Hover
|
||||||
AmmoPool:
|
AmmoPool:
|
||||||
Ammo: 12
|
Ammo: 12
|
||||||
PipCount: 4
|
PipCount: 4
|
||||||
@@ -391,6 +393,7 @@ HUNTER:
|
|||||||
VTOL: true
|
VTOL: true
|
||||||
AttackAircraft:
|
AttackAircraft:
|
||||||
FacingTolerance: 128
|
FacingTolerance: 128
|
||||||
|
AttackType: Hover
|
||||||
Armament@PRIMARY:
|
Armament@PRIMARY:
|
||||||
Weapon: SuicideBomb
|
Weapon: SuicideBomb
|
||||||
GrantConditionOnAttack:
|
GrantConditionOnAttack:
|
||||||
|
|||||||
Reference in New Issue
Block a user