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, Actor ignoredActor);
Activity MoveWithinRange(Target target, WRange range);
CPos NearestMoveableCell(CPos target);
}
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, Actor ignoredActor) { return new HeliFly(cell); }
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, Actor ignoredActor) { return Fly.ToCell(cell); }
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
{
public readonly bool JustMove = false;
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; } }
public CPos? TargetLocation = null;
readonly Mobile mobile;
readonly AttackMoveInfo info;
readonly IMove move;
public AttackMove(Actor self, AttackMoveInfo info)
{
this.info = info;
mobile = self.Trait<Mobile>();
move = self.Trait<IMove>();
}
public string VoicePhraseForOrder(Actor self, Order order)
@@ -47,7 +43,7 @@ namespace OpenRA.Mods.RA
void Activate(Actor self)
{
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);
}
@@ -63,15 +59,10 @@ namespace OpenRA.Mods.RA
if (order.OrderString == "AttackMove")
{
if (info.JustMove)
mobile.ResolveOrder(self, new Order("Move", order));
else
{
TargetLocation = mobile.NearestMoveableCell(order.TargetLocation);
TargetLocation = move.NearestMoveableCell(order.TargetLocation);
Activate(self);
}
}
}
public class AttackMoveActivity : Activity
{

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="LimitedAmmo.cs" />
<Compile Include="Lint\CheckActorReferences.cs" />
<Compile Include="Lint\CheckAutotargetWiring.cs" />
<Compile Include="Lint\CheckSyncAnnotations.cs" />
<Compile Include="Lint\CheckTraitPrerequisites.cs" />
<Compile Include="Lint\LintBuildablePrerequisites.cs" />

View File

@@ -93,6 +93,13 @@ namespace OpenRA.Utility
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);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1031,3 +1031,4 @@ Demolish:
Warhead:
ImpactSound: xplobig6.aud
Explosion: building

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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