Generalise AttackMove to support anything with IMove and AutoTarget.

Also removes the unnecessary JustMove parameter.
This commit is contained in:
Paul Chote
2014-01-14 21:13:44 +13:00
parent e07453bb7f
commit 99cb698424
37 changed files with 33 additions and 83 deletions

View File

@@ -153,6 +153,7 @@ namespace OpenRA.Traits
Activity MoveTo(CPos cell, int nearEnough); Activity MoveTo(CPos cell, int nearEnough);
Activity MoveTo(CPos cell, Actor ignoredActor); Activity MoveTo(CPos cell, Actor ignoredActor);
Activity MoveWithinRange(Target target, WRange range); Activity MoveWithinRange(Target target, WRange range);
CPos NearestMoveableCell(CPos target);
} }
public interface INotifyBlockingMove { void OnNotifyBlockingMove(Actor self, Actor blocking); } public interface INotifyBlockingMove { void OnNotifyBlockingMove(Actor self, Actor blocking); }

View File

@@ -152,5 +152,6 @@ namespace OpenRA.Mods.RA.Air
public Activity MoveTo(CPos cell, int nearEnough) { return new HeliFly(cell); } public Activity MoveTo(CPos cell, int nearEnough) { return new HeliFly(cell); }
public Activity MoveTo(CPos cell, Actor ignoredActor) { return new HeliFly(cell); } public Activity MoveTo(CPos cell, Actor ignoredActor) { return new HeliFly(cell); }
public Activity MoveWithinRange(Target target, WRange range) { return new HeliFly(target.CenterPosition); } public Activity MoveWithinRange(Target target, WRange range) { return new HeliFly(target.CenterPosition); }
public CPos NearestMoveableCell(CPos cell) { return cell; }
} }
} }

View File

@@ -92,5 +92,6 @@ namespace OpenRA.Mods.RA.Air
public Activity MoveTo(CPos cell, int nearEnough) { return Fly.ToCell(cell); } public Activity MoveTo(CPos cell, int nearEnough) { return Fly.ToCell(cell); }
public Activity MoveTo(CPos cell, Actor ignoredActor) { return Fly.ToCell(cell); } public Activity MoveTo(CPos cell, Actor ignoredActor) { return Fly.ToCell(cell); }
public Activity MoveWithinRange(Target target, WRange range) { return Fly.ToPos(target.CenterPosition); } public Activity MoveWithinRange(Target target, WRange range) { return Fly.ToPos(target.CenterPosition); }
public CPos NearestMoveableCell(CPos cell) { return cell; }
} }
} }

View File

@@ -17,8 +17,6 @@ namespace OpenRA.Mods.RA
{ {
class AttackMoveInfo : ITraitInfo class AttackMoveInfo : ITraitInfo
{ {
public readonly bool JustMove = false;
public object Create(ActorInitializer init) { return new AttackMove(init.self, this); } public object Create(ActorInitializer init) { return new AttackMove(init.self, this); }
} }
@@ -27,13 +25,11 @@ namespace OpenRA.Mods.RA
[Sync] public CPos _targetLocation { get { return TargetLocation.HasValue ? TargetLocation.Value : CPos.Zero; } } [Sync] public CPos _targetLocation { get { return TargetLocation.HasValue ? TargetLocation.Value : CPos.Zero; } }
public CPos? TargetLocation = null; public CPos? TargetLocation = null;
readonly Mobile mobile; readonly IMove move;
readonly AttackMoveInfo info;
public AttackMove(Actor self, AttackMoveInfo info) public AttackMove(Actor self, AttackMoveInfo info)
{ {
this.info = info; move = self.Trait<IMove>();
mobile = self.Trait<Mobile>();
} }
public string VoicePhraseForOrder(Actor self, Order order) public string VoicePhraseForOrder(Actor self, Order order)
@@ -47,7 +43,7 @@ namespace OpenRA.Mods.RA
void Activate(Actor self) void Activate(Actor self)
{ {
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(new AttackMoveActivity(self, mobile.MoveTo(TargetLocation.Value, 1))); self.QueueActivity(new AttackMoveActivity(self, move.MoveTo(TargetLocation.Value, 1)));
self.SetTargetLine(Target.FromCell(TargetLocation.Value), Color.Red); self.SetTargetLine(Target.FromCell(TargetLocation.Value), Color.Red);
} }
@@ -63,13 +59,8 @@ namespace OpenRA.Mods.RA
if (order.OrderString == "AttackMove") if (order.OrderString == "AttackMove")
{ {
if (info.JustMove) TargetLocation = move.NearestMoveableCell(order.TargetLocation);
mobile.ResolveOrder(self, new Order("Move", order)); Activate(self);
else
{
TargetLocation = mobile.NearestMoveableCell(order.TargetLocation);
Activate(self);
}
} }
} }

View File

@@ -1,31 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 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. For more information,
* see COPYING.
*/
#endregion
using System;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class CheckAutotargetWiring : ILintPass
{
public void Run(Action<string> emitError, Action<string> emitWarning)
{
foreach( var i in Rules.Info )
{
if (i.Key.StartsWith("^"))
continue;
var attackMove = i.Value.Traits.GetOrDefault<AttackMoveInfo>();
if (attackMove != null && !attackMove.JustMove &&
!i.Value.Traits.Contains<AutoTargetInfo>())
emitError( "{0} has AttackMove setup without AutoTarget, and will crash when resolving that order.".F(i.Key) );
}
}
}
}

View File

@@ -254,7 +254,6 @@
<Compile Include="LightPaletteRotator.cs" /> <Compile Include="LightPaletteRotator.cs" />
<Compile Include="LimitedAmmo.cs" /> <Compile Include="LimitedAmmo.cs" />
<Compile Include="Lint\CheckActorReferences.cs" /> <Compile Include="Lint\CheckActorReferences.cs" />
<Compile Include="Lint\CheckAutotargetWiring.cs" />
<Compile Include="Lint\CheckSyncAnnotations.cs" /> <Compile Include="Lint\CheckSyncAnnotations.cs" />
<Compile Include="Lint\CheckTraitPrerequisites.cs" /> <Compile Include="Lint\CheckTraitPrerequisites.cs" />
<Compile Include="Lint\LintBuildablePrerequisites.cs" /> <Compile Include="Lint\LintBuildablePrerequisites.cs" />

View File

@@ -93,6 +93,13 @@ namespace OpenRA.Utility
ConvertPxToRange(ref node.Value.Value); ConvertPxToRange(ref node.Value.Value);
} }
// AttackMove was generalized to support all moveable actor types
if (engineVersion < 20140116)
{
if (depth == 1 && node.Key == "AttackMove")
node.Value.Nodes.RemoveAll(n => n.Key == "JustMove");
}
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
} }
} }

View File

@@ -455,3 +455,4 @@ VICE:
QuantizedFacings: 8 QuantizedFacings: 8
PoisonedByTiberium: PoisonedByTiberium:
Weapon: Heal Weapon: Heal

View File

@@ -209,7 +209,6 @@
ScaredyCat: ScaredyCat:
RenderInfantryPanic: RenderInfantryPanic:
AttackMove: AttackMove:
JustMove: yes
CrushableInfantry: CrushableInfantry:
^DINO: ^DINO:

View File

@@ -172,7 +172,6 @@ E6:
CaptureTypes: building, husk CaptureTypes: building, husk
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true
RenderInfantryProne: RenderInfantryProne:
IdleAnimations: idle1,idle2 IdleAnimations: idle1,idle2
StandAnimations: stand, stand2 StandAnimations: stand, stand2

View File

@@ -67,6 +67,5 @@ LST:
MaxWeight: 5 MaxWeight: 5
PipCount: 5 PipCount: 5
AttackMove: AttackMove:
JustMove: true
RejectsOrders: RejectsOrders:

View File

@@ -187,3 +187,4 @@ Player:
htnk: 50% htnk: 50%
orca: 10% orca: 10%
SquadSize: 8 SquadSize: 8

View File

@@ -16,3 +16,4 @@ Player:
Shroud: Shroud:
PlayerStatistics: PlayerStatistics:
FrozenActorLayer: FrozenActorLayer:

View File

@@ -175,3 +175,4 @@ World:
DebugPauseState: DebugPauseState:
ConquestObjectivesPanel: ConquestObjectivesPanel:
ObjectivesPanel: CONQUEST_OBJECTIVES ObjectivesPanel: CONQUEST_OBJECTIVES

View File

@@ -28,7 +28,6 @@ MCV:
RenderUnit: RenderUnit:
MustBeDestroyed: MustBeDestroyed:
AttackMove: AttackMove:
JustMove: true
BaseBuilding: BaseBuilding:
LeavesHusk: LeavesHusk:
HuskActor: MCV.Husk HuskActor: MCV.Husk
@@ -69,7 +68,6 @@ HARV:
RevealsShroud: RevealsShroud:
Range: 4 Range: 4
AttackMove: AttackMove:
JustMove: true
LeavesHusk: LeavesHusk:
HuskActor: HARV.Husk HuskActor: HARV.Husk
-GainsExperience: -GainsExperience:
@@ -559,7 +557,6 @@ MHQ:
Sequence: spinner Sequence: spinner
Offset: -256,0,256 Offset: -256,0,256
AttackMove: AttackMove:
JustMove: yes
Explodes: Explodes:
Weapon: UnitExplodeSmall Weapon: UnitExplodeSmall
EmptyWeapon: UnitExplodeSmall EmptyWeapon: UnitExplodeSmall

View File

@@ -1030,4 +1030,5 @@ Claw:
Demolish: Demolish:
Warhead: Warhead:
ImpactSound: xplobig6.aud ImpactSound: xplobig6.aud
Explosion: building Explosion: building

View File

@@ -249,3 +249,4 @@
Huntable: Huntable:
LuaScriptEvents: LuaScriptEvents:
Demolishable: Demolishable:

View File

@@ -50,7 +50,6 @@ ENGINEER:
ExternalCaptures: ExternalCaptures:
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true
BAZOOKA: BAZOOKA:
Inherits: ^Infantry Inherits: ^Infantry
@@ -109,5 +108,4 @@ MEDIC:
PipType: Blue PipType: Blue
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true

View File

@@ -294,5 +294,4 @@ SABOTEUR:
C4Delay: 45 C4Delay: 45
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true

View File

@@ -303,3 +303,4 @@ Player:
combath: 100% combath: 100%
combato: 100% combato: 100%
SquadSize: 10 SquadSize: 10

View File

@@ -51,3 +51,4 @@ Player:
FrozenActorLayer: FrozenActorLayer:
HarvesterAttackNotifier: HarvesterAttackNotifier:
PlayerStatistics: PlayerStatistics:

View File

@@ -126,3 +126,4 @@ World:
PathFinder: PathFinder:
ValidateOrder: ValidateOrder:
DebugPauseState: DebugPauseState:

View File

@@ -849,7 +849,6 @@ Rules:
Spy: Spy:
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true
-RenderInfantry: -RenderInfantry:
RenderSpy: RenderSpy:
IdleAnimations: idle1,idle2 IdleAnimations: idle1,idle2

View File

@@ -833,7 +833,6 @@ Rules:
RenderUnit: RenderUnit:
Image: MNLY Image: MNLY
AttackMove: AttackMove:
JustMove: true
MustBeDestroyed: MustBeDestroyed:
Transforms: Transforms:
IntoActor: ftur IntoActor: ftur

View File

@@ -175,7 +175,6 @@ E6:
TakeCover: TakeCover:
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true
-RenderInfantry: -RenderInfantry:
RenderInfantryProne: RenderInfantryProne:
IdleAnimations: idle1,idle2 IdleAnimations: idle1,idle2
@@ -211,7 +210,6 @@ SPY:
Types: Cash, SupportPower, Exploration Types: Cash, SupportPower, Exploration
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true
-RenderInfantry: -RenderInfantry:
RenderSpy: RenderSpy:
IdleAnimations: idle1,idle2 IdleAnimations: idle1,idle2
@@ -289,7 +287,6 @@ MEDI:
TakeCover: TakeCover:
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true
-RenderInfantry: -RenderInfantry:
RenderInfantryProne: RenderInfantryProne:
IdleAnimations: idle1,idle2 IdleAnimations: idle1,idle2
@@ -326,7 +323,6 @@ MECH:
TakeCover: TakeCover:
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true
-RenderInfantry: -RenderInfantry:
RenderInfantryProne: RenderInfantryProne:
IdleAnimations: idle1,idle2 IdleAnimations: idle1,idle2
@@ -348,7 +344,6 @@ EINSTEIN:
Range: 2 Range: 2
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true
ProximityCaptor: ProximityCaptor:
Types: CivilianInfantry Types: CivilianInfantry
-RenderInfantry: -RenderInfantry:
@@ -372,7 +367,6 @@ DELPHI:
Range: 2 Range: 2
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true
ProximityCaptor: ProximityCaptor:
Types: CivilianInfantry Types: CivilianInfantry
-RenderInfantry: -RenderInfantry:
@@ -414,7 +408,6 @@ THF:
TakeCover: TakeCover:
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true
SHOK: SHOK:
Inherits: ^Infantry Inherits: ^Infantry

View File

@@ -226,7 +226,6 @@ LST:
IronCurtainable: IronCurtainable:
RepairableNear: RepairableNear:
AttackMove: AttackMove:
JustMove: true
PT: PT:
Inherits: ^Ship Inherits: ^Ship

View File

@@ -173,3 +173,4 @@ waypoint:
Waypoint: Waypoint:
RenderEditorOnly: RenderEditorOnly:
BodyOrientation: BodyOrientation:

View File

@@ -477,3 +477,4 @@ Player:
arty: 15% arty: 15%
harv: 10% harv: 10%
SquadSize: 7 SquadSize: 7

View File

@@ -56,3 +56,4 @@ Player:
FrozenActorLayer: FrozenActorLayer:
BaseAttackNotifier: BaseAttackNotifier:
PlayerStatistics: PlayerStatistics:

View File

@@ -164,3 +164,4 @@ World:
PathFinder: PathFinder:
ValidateOrder: ValidateOrder:
DebugPauseState: DebugPauseState:

View File

@@ -419,7 +419,6 @@ MNLY.AP:
LimitedAmmo: LimitedAmmo:
Ammo: 5 Ammo: 5
AttackMove: AttackMove:
JustMove: true
DetectCloaked: DetectCloaked:
Range: 5 Range: 5
RenderDetectionCircle: RenderDetectionCircle:
@@ -453,7 +452,6 @@ MNLY.AT:
LimitedAmmo: LimitedAmmo:
Ammo: 3 Ammo: 3
AttackMove: AttackMove:
JustMove: true
DetectCloaked: DetectCloaked:
Range: 5 Range: 5
RenderDetectionCircle: RenderDetectionCircle:
@@ -483,7 +481,6 @@ TRUK:
SupplyTruck: SupplyTruck:
Payload: 500 Payload: 500
AttackMove: AttackMove:
JustMove: yes
MGG: MGG:
Inherits: ^Vehicle Inherits: ^Vehicle
@@ -509,7 +506,6 @@ MGG:
Offset: -299,0,171 Offset: -299,0,171
Sequence: spinner Sequence: spinner
AttackMove: AttackMove:
JustMove: yes
RevealsShroud: RevealsShroud:
Range: 6 Range: 6
CreatesShroud: CreatesShroud:
@@ -557,7 +553,6 @@ MRJ:
Sequence: spinner Sequence: spinner
Offset: -256,0,256 Offset: -256,0,256
AttackMove: AttackMove:
JustMove: yes
Explodes: Explodes:
Weapon: UnitExplodeSmall Weapon: UnitExplodeSmall
EmptyWeapon: UnitExplodeSmall EmptyWeapon: UnitExplodeSmall
@@ -719,7 +714,6 @@ DTRK:
Range: 3 Range: 3
RenderUnit: RenderUnit:
AttackMove: AttackMove:
JustMove: yes
Explodes: Explodes:
Weapon: MiniNuke Weapon: MiniNuke
EmptyWeapon: MiniNuke EmptyWeapon: MiniNuke
@@ -791,7 +785,6 @@ QTNK:
Bounds: 44,38,0,-4 Bounds: 44,38,0,-4
RenderUnit: RenderUnit:
AttackMove: AttackMove:
JustMove: True
Explodes: Explodes:
Weapon: UnitExplodeSmall Weapon: UnitExplodeSmall
MadTank: MadTank:

View File

@@ -166,7 +166,6 @@ ENGINEER:
CaptureTypes: building CaptureTypes: building
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true
-RenderInfantry: -RenderInfantry:
RenderInfantryProne: RenderInfantryProne:
IdleAnimations: idle1,idle2 IdleAnimations: idle1,idle2
@@ -294,7 +293,6 @@ CHAMSPY:
Types: Cash, SupportPower, Exploration Types: Cash, SupportPower, Exploration
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true
-RenderInfantry: -RenderInfantry:
RenderSpy: RenderSpy:
IdleAnimations: idle1,idle2 IdleAnimations: idle1,idle2

View File

@@ -7,3 +7,4 @@ waypoint:
Waypoint: Waypoint:
RenderEditorOnly: RenderEditorOnly:
BodyOrientation: BodyOrientation:

View File

@@ -1 +1,2 @@
Player: Player:

View File

@@ -40,3 +40,4 @@ Player:
Shroud: Shroud:
BaseAttackNotifier: BaseAttackNotifier:
PlayerStatistics: PlayerStatistics:

View File

@@ -96,3 +96,4 @@ World:
ValidateOrder: ValidateOrder:
DebugPauseState: DebugPauseState:
ScreenShaker: ScreenShaker:

View File

@@ -94,7 +94,6 @@ HARV:
RevealsShroud: RevealsShroud:
Range: 4 Range: 4
AttackMove: AttackMove:
JustMove: yes
-GainsExperience: -GainsExperience:
RenderSprites: RenderSprites:
RenderVoxels: RenderVoxels:
@@ -190,7 +189,6 @@ TRUCKB:
SupplyTruck: SupplyTruck:
Payload: 500 Payload: 500
AttackMove: AttackMove:
JustMove: yes
RenderSprites: RenderSprites:
RenderVoxels: RenderVoxels:
WithVoxelBody: WithVoxelBody:
@@ -215,7 +213,6 @@ LPST:
RevealsShroud: RevealsShroud:
Range: 10 Range: 10
AttackMove: AttackMove:
JustMove: yes
RenderSprites: RenderSprites:
RenderVoxels: RenderVoxels:
WithVoxelBody: WithVoxelBody:
@@ -246,7 +243,6 @@ ICBM:
RevealsShroud: RevealsShroud:
Range: 7 Range: 7
AttackMove: AttackMove:
JustMove: yes
RenderSprites: RenderSprites:
RenderVoxels: RenderVoxels:
WithVoxelBody: WithVoxelBody:
@@ -280,7 +276,6 @@ REPAIR:
AttackMedic: AttackMedic:
Cursor: repair Cursor: repair
AttackMove: AttackMove:
JustMove: true
RenderSprites: RenderSprites:
RenderVoxels: RenderVoxels:
WithVoxelBody: WithVoxelBody:
@@ -305,7 +300,6 @@ ART2:
RevealsShroud: RevealsShroud:
Range: 9 Range: 9
AttackMove: AttackMove:
JustMove: yes
RenderSprites: RenderSprites:
RenderVoxels: RenderVoxels:
WithVoxelBody: WithVoxelBody:
@@ -337,7 +331,6 @@ WEED:
RevealsShroud: RevealsShroud:
Range: 4 Range: 4
AttackMove: AttackMove:
JustMove: yes
-GainsExperience: -GainsExperience:
RenderSprites: RenderSprites:
RenderVoxels: RenderVoxels:
@@ -451,7 +444,6 @@ GGHUNT:
Range: 7 Range: 7
RenderUnit: RenderUnit:
AttackMove: AttackMove:
JustMove: yes
DemoTruck: DemoTruck:
Explodes: Explodes:
Weapon: SuicideBomb Weapon: SuicideBomb