Merge pull request #3373 from ScottNZ/husk

Rework aircraft destruction to use husks instead of the original actor. Fixes #3324 and closes #3216.
This commit is contained in:
Matthias Mailänder
2013-06-06 10:20:17 -07:00
9 changed files with 318 additions and 67 deletions

View File

@@ -8,28 +8,26 @@
*/ */
#endregion #endregion
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA.Air namespace OpenRA.Mods.RA.Air
{ {
class FallsToEarthInfo : TraitInfo<FallsToEarth> class FallsToEarthInfo : ITraitInfo
{ {
[WeaponReference] [WeaponReference]
public readonly string Explosion = null; public readonly string Explosion = "UnitExplode";
public readonly bool Spins = true; public readonly bool Spins = true;
public readonly bool Moves = false; public readonly bool Moves = false;
public object Create(ActorInitializer init) { return new FallsToEarth(init.self, this); }
} }
class FallsToEarth : INotifyKilled class FallsToEarth
{ {
public void Killed(Actor self, AttackInfo e) public FallsToEarth(Actor self, FallsToEarthInfo info)
{ {
self.Trait<Health>().RemoveOnDeath = false; self.QueueActivity(false, new FallToEarth(self, info));
self.CancelActivity();
self.QueueActivity(new FallToEarth(self, self.Info.Traits.Get<FallsToEarthInfo>()));
} }
} }

View File

@@ -10,8 +10,9 @@
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Traits; using OpenRA.Mods.RA.Air;
using OpenRA.Mods.RA.Move; using OpenRA.Mods.RA.Move;
using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
@@ -35,11 +36,11 @@ namespace OpenRA.Mods.RA
{ {
self.World.AddFrameEndTask(w => self.World.AddFrameEndTask(w =>
{ {
var td = new TypeDictionary() var td = new TypeDictionary
{ {
new LocationInit( self.Location ), new LocationInit(self.Location),
new CenterLocationInit(self.CenterLocation), new CenterLocationInit(self.CenterLocation),
new OwnerInit( self.Owner ), new OwnerInit(self.Owner),
new SkipMakeAnimsInit() new SkipMakeAnimsInit()
}; };
@@ -51,6 +52,10 @@ namespace OpenRA.Mods.RA
td.Add(new HuskSpeedInit(mobile.MovementSpeedForCell(self, self.Location))); td.Add(new HuskSpeedInit(mobile.MovementSpeedForCell(self, self.Location)));
} }
var aircraft = self.TraitOrDefault<Aircraft>();
if (aircraft != null)
td.Add(new AltitudeInit(aircraft.Altitude));
var facing = self.TraitOrDefault<IFacing>(); var facing = self.TraitOrDefault<IFacing>();
if (facing != null) if (facing != null)
td.Add(new FacingInit( facing.Facing )); td.Add(new FacingInit( facing.Facing ));

View File

@@ -20,6 +20,7 @@ namespace OpenRA.Mods.RA
public readonly WVec Offset = WVec.Zero; public readonly WVec Offset = WVec.Zero;
public readonly int Interval = 3; public readonly int Interval = 3;
public readonly string Sprite = "smokey"; public readonly string Sprite = "smokey";
public readonly DamageState MinDamage = DamageState.Heavy;
public object Create(ActorInitializer init) { return new SmokeTrailWhenDamaged(init.self, this); } public object Create(ActorInitializer init) { return new SmokeTrailWhenDamaged(init.self, this); }
} }
@@ -41,7 +42,7 @@ namespace OpenRA.Mods.RA
if (--ticks <= 0) if (--ticks <= 0)
{ {
var position = self.CenterPosition; var position = self.CenterPosition;
if (position.Z > 0 && self.GetDamageState() >= DamageState.Heavy && if (position.Z > 0 && self.GetDamageState() >= info.MinDamage &&
!self.World.FogObscures(new CPos(position))) !self.World.FogObscures(new CPos(position)))
{ {
var offset = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation)); var offset = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation));

View File

@@ -36,8 +36,8 @@ TRAN:
Types: Infantry Types: Infantry
MaxWeight: 10 MaxWeight: 10
PipCount: 10 PipCount: 10
FallsToEarth: LeavesHusk:
Explosion: HeliCrash HuskActor: TRAN.Husk
Explodes: Explodes:
Weapon: HeliExplode Weapon: HeliExplode
EmptyWeapon: HeliExplode EmptyWeapon: HeliExplode
@@ -86,8 +86,8 @@ HELI:
Offset: 0,0,85 Offset: 0,0,85
WithMuzzleFlash: WithMuzzleFlash:
WithShadow: WithShadow:
FallsToEarth: LeavesHusk:
Explosion: HeliCrash HuskActor: HELI.Husk
AutoTarget: AutoTarget:
Explodes: Explodes:
Weapon: HeliExplode Weapon: HeliExplode
@@ -134,8 +134,8 @@ ORCA:
Period: 200 Period: 200
RenderUnit: RenderUnit:
WithShadow: WithShadow:
FallsToEarth: LeavesHusk:
Explosion: HeliCrash HuskActor: ORCA.Husk
AutoTarget: AutoTarget:
Explodes: Explodes:
Weapon: HeliExplode Weapon: HeliExplode
@@ -206,3 +206,42 @@ A10:
-GainsExperience: -GainsExperience:
FlyAwayOnIdle: FlyAwayOnIdle:
TRAN.Husk:
Inherits: ^HelicopterHusk
Tooltip:
Name: Chinook Transport
Helicopter:
ROT: 5
Speed: 15
WithRotor@PRIMARY:
Offset: -597,0,171
WithRotor@SECONDARY:
Id: rotor_2
Offset: 597,0,85
RenderUnit:
Image: tran
WithShadow:
HELI.Husk:
Inherits: ^HelicopterHusk
Tooltip:
Name: Apache Longbow
Helicopter:
ROT: 4
Speed: 20
WithRotor:
Offset: 0,0,85
RenderUnit:
Image: heli
WithShadow:
ORCA.Husk:
Inherits: ^HelicopterHusk
Tooltip:
Name: Orca
Helicopter:
ROT: 4
Speed: 20
RenderUnit:
Image: orca
WithShadow:

View File

@@ -422,6 +422,18 @@
# AllowNeutral: true # AllowNeutral: true
# AllowEnemies: true # AllowEnemies: true
^HelicopterHusk:
Inherits: ^Husk
-Husk:
-Burns:
FallsToEarth:
Spins: True
Moves: False
Explosion: HeliCrash
-BelowUnits:
-TransformOnCapture:
-TargetableUnit:
^Bridge: ^Bridge:
Tooltip: Tooltip:
Name: Bridge Name: Bridge

View File

@@ -29,10 +29,8 @@
MaxWeight: 1 MaxWeight: 1
PipCount: 1 PipCount: 1
minimalUnloadAltitude: 25 minimalUnloadAltitude: 25
FallsToEarth: LeavesHusk:
Spins: no HuskActor: CARRYALL.Husk
Moves: yes
Explosion: UnitExplodeScale
FRIGATE: FRIGATE:
ParaDrop: ParaDrop:
@@ -92,10 +90,8 @@ ORNI:
WithShadow: WithShadow:
Selectable: Selectable:
Bounds: 38,32,0,0 Bounds: 38,32,0,0
FallsToEarth: LeavesHusk:
Spins: no HuskActor: ORNI.Husk
Moves: yes
Explosion: UnitExplodeScale
ORNI.bomber: ORNI.bomber:
CarpetBomb: CarpetBomb:
@@ -122,10 +118,8 @@ ORNI.bomber:
-GainsExperience: -GainsExperience:
Tooltip: Tooltip:
Name: Ornithopter Name: Ornithopter
FallsToEarth: LeavesHusk:
Spins: no HuskActor: ORNI.bomber.Husk
Moves: yes
Explosion: UnitExplodeScale
CARRYALL.infantry: CARRYALL.infantry:
ParaDrop: ParaDrop:
@@ -153,10 +147,8 @@ CARRYALL.infantry:
-GainsExperience: -GainsExperience:
Tooltip: Tooltip:
Name: Carryall Name: Carryall
FallsToEarth: LeavesHusk:
Spins: no HuskActor: CARRYALL.infantry.Husk
Moves: yes
Explosion: UnitExplodeScale
BADR: BADR:
Inherits: CARRYALL.infantry Inherits: CARRYALL.infantry
@@ -164,3 +156,70 @@ BADR:
LZRange: 4 LZRange: 4
Tooltip: Tooltip:
Name: Crate Carryall Name: Crate Carryall
LeavesHusk:
HuskActor: BADR.Husk
CARRYALL.Husk:
Inherits: ^AircraftHusk
Tooltip:
Name: Carryall
Helicopter:
ROT: 4
Speed: 30
RepairBuildings: repair
RearmBuildings: starporta,starporto,starporth
RenderUnit:
Image: carryall
WithShadow:
ORNI.Husk:
Inherits: ^AircraftHusk
Tooltip:
Name: Ornithopter
Helicopter:
ROT: 6
Speed: 40
RepairBuildings: repair
RearmBuildings: starporta,starporto,starporth
RenderUnit:
Image: orni
WithShadow:
ORNI.bomber.Husk:
Inherits: ^AircraftHusk
Tooltip:
Name: Ornithopter
Plane:
ROT: 5
Speed: 50
RepairBuildings: repair
RearmBuildings: starporta,starporto,starporth
RenderUnit:
Image: orni
WithShadow:
CARRYALL.infantry.Husk:
Inherits: ^AircraftHusk
Tooltip:
Name: Carryall
Plane:
ROT: 4
Speed: 40
RepairBuildings: repair
RearmBuildings: starporta,starporto,starporth
RenderUnit:
Image: carryall
WithShadow:
BADR.Husk:
Inherits: ^AircraftHusk
Tooltip:
Name: Crate Carryall
Plane:
ROT: 4
Speed: 40
RepairBuildings: repair
RearmBuildings: starporta,starporto,starporth
RenderUnit:
Image: carryall
WithShadow:

View File

@@ -106,6 +106,15 @@
Types:Husk Types:Husk
BodyOrientation: BodyOrientation:
^AircraftHusk:
Inherits: ^Husk
-Husk:
-Burns:
FallsToEarth:
Spins: False
Moves: True
Explosion: UnitExplodeScale
^Infantry: ^Infantry:
AppearsOnRadar: AppearsOnRadar:
Health: Health:

View File

@@ -23,10 +23,8 @@ BADR:
Offset: -469,469,0 Offset: -469,469,0
Contrail@2: Contrail@2:
Offset: -469,-469,0 Offset: -469,-469,0
FallsToEarth: LeavesHusk:
Spins: no HuskActor: BADR.Husk
Moves: yes
Explosion: UnitExplode
SmokeTrailWhenDamaged@0: SmokeTrailWhenDamaged@0:
Offset: -469,469,0 Offset: -469,469,0
Interval: 2 Interval: 2
@@ -36,7 +34,7 @@ BADR:
-EjectOnDeath: -EjectOnDeath:
-GpsDot: -GpsDot:
BADR.bomber: BADR.Bomber:
CarpetBomb: CarpetBomb:
Range: 3 Range: 3
Weapon: ParaBomb Weapon: ParaBomb
@@ -53,7 +51,7 @@ BADR.bomber:
RenderUnit: RenderUnit:
Image: badr Image: badr
WithShadow: WithShadow:
IronCurtainable: IronCurtainable:
-Selectable: -Selectable:
-GainsExperience: -GainsExperience:
Tooltip: Tooltip:
@@ -62,10 +60,8 @@ BADR.bomber:
Offset: 469,469,0 Offset: 469,469,0
Contrail@2: Contrail@2:
Offset: 469,-469,0 Offset: 469,-469,0
FallsToEarth: LeavesHusk:
Spins: no HuskActor: BADR.Husk
Moves: yes
Explosion: UnitExplode
SmokeTrailWhenDamaged@0: SmokeTrailWhenDamaged@0:
Offset: -469,469,0 Offset: -469,469,0
Interval: 2 Interval: 2
@@ -119,10 +115,8 @@ MIG:
Offset: -598,-683,0 Offset: -598,-683,0
Contrail@2: Contrail@2:
Offset: -598,683,0 Offset: -598,683,0
FallsToEarth: LeavesHusk:
Spins: no HuskActor: MIG.Husk
Moves: yes
Explosion: UnitExplode
SmokeTrailWhenDamaged: SmokeTrailWhenDamaged:
Offset: -853,0,171 Offset: -853,0,171
Interval: 2 Interval: 2
@@ -172,14 +166,11 @@ YAK:
WithMuzzleFlash: WithMuzzleFlash:
Contrail: Contrail:
Offset: -853,0,0 Offset: -853,0,0
FallsToEarth: LeavesHusk:
Spins: no HuskActor: YAK.Husk
Moves: yes
Explosion: UnitExplode
SmokeTrailWhenDamaged: SmokeTrailWhenDamaged:
Offset: -853,0,0 Offset: -853,0,0
Interval: 2 Interval: 2
TRAN: TRAN:
Inherits: ^Helicopter Inherits: ^Helicopter
@@ -219,9 +210,9 @@ TRAN:
MaxWeight: 8 MaxWeight: 8
PipCount: 8 PipCount: 8
IronCurtainable: IronCurtainable:
FallsToEarth: LeavesHusk:
Explosion: UnitExplode HuskActor: TRAN.Husk
TRAN.Husk1: TRAN.Husk1:
Inherits: ^Husk Inherits: ^Husk
Tooltip: Tooltip:
@@ -277,8 +268,8 @@ HELI:
LimitedAmmo: LimitedAmmo:
Ammo: 8 Ammo: 8
IronCurtainable: IronCurtainable:
FallsToEarth: LeavesHusk:
Explosion: UnitExplode HuskActor: HELI.Husk
SmokeTrailWhenDamaged: SmokeTrailWhenDamaged:
Offset: -427,0,0 Offset: -427,0,0
@@ -327,8 +318,8 @@ HIND:
Selectable: Selectable:
Bounds: 38,32,0,0 Bounds: 38,32,0,0
WithMuzzleFlash: WithMuzzleFlash:
FallsToEarth: LeavesHusk:
Explosion: UnitExplode HuskActor: HIND.Husk
SmokeTrailWhenDamaged: SmokeTrailWhenDamaged:
Offset: -427,0,0 Offset: -427,0,0
@@ -350,10 +341,129 @@ U2:
Offset: -725,683,0 Offset: -725,683,0
Contrail@2: Contrail@2:
Offset: -725,-683,0 Offset: -725,-683,0
FallsToEarth: LeavesHusk:
Spins: no HuskActor: U2.Husk
Moves: yes
Explosion: UnitExplode
SmokeTrailWhenDamaged: SmokeTrailWhenDamaged:
Offset: -1c43,0,0 Offset: -1c43,0,0
Interval: 2 Interval: 2
BADR.Husk:
Inherits: ^PlaneHusk
Tooltip:
Name: Badger
RenderUnit:
Image: badr
WithShadow:
Plane:
ROT: 5
Speed: 16
SmokeTrailWhenDamaged@0:
Offset: -469,469,0
Interval: 2
MinDamage: Undamaged
SmokeTrailWhenDamaged@1:
Offset: -469,-469,0
Interval: 2
MinDamage: Undamaged
MIG.Husk:
Inherits: ^PlaneHusk
Tooltip:
Name: Mig Attack Plane
RenderUnit:
CameraPitch: 99
Image: mig
WithShadow:
Contrail@1:
Offset: -598,-683,0
Contrail@2:
Offset: -598,683,0
Plane:
ROT: 5
Speed: 20
SmokeTrailWhenDamaged:
Offset: -853,0,171
Interval: 2
MinDamage: Undamaged
YAK.Husk:
Inherits: ^PlaneHusk
Tooltip:
Name: Yak Attack Plane
RenderUnit:
CameraPitch: 99
Image: yak
WithShadow:
Contrail:
Offset: -853,0,0
Plane:
ROT: 5
Speed: 16
SmokeTrailWhenDamaged:
Offset: -853,0,0
Interval: 2
MinDamage: Undamaged
TRAN.Husk:
Inherits: ^HelicopterHusk
Tooltip:
Name: Transport Helicopter
RenderUnit:
Image: tran
WithShadow:
Helicopter:
ROT: 4
Speed: 16
WithRotor@PRIMARY:
Offset: -597,0,341
WithRotor@SECONDARY:
Id: rotor_2
Offset: 597,0,213
HELI.Husk:
Inherits: ^HelicopterHusk
Tooltip:
Name: Longbow
RenderUnit:
Image: heli
WithShadow:
Helicopter:
ROT: 4
Speed: 16
WithRotor:
Offset: 0,0,85
SmokeTrailWhenDamaged:
Offset: -427,0,0
MinDamage: Undamaged
HIND.Husk:
Inherits: ^HelicopterHusk
Tooltip:
Name: Hind
RenderUnit:
Image: hind
WithShadow:
Helicopter:
ROT: 4
Speed: 12
WithRotor:
SmokeTrailWhenDamaged:
Offset: -427,0,0
MinDamage: Undamaged
U2.Husk:
Inherits: ^PlaneHusk
RenderUnit:
Image: u2
WithShadow:
Plane:
ROT: 7
Speed: 40
Contrail@1:
Offset: -725,683,0
Contrail@2:
Offset: -725,-683,0
SmokeTrailWhenDamaged:
Offset: -1c43,0,0
Interval: 2
MinDamage: Undamaged

View File

@@ -368,6 +368,24 @@
BelowUnits: BelowUnits:
BodyOrientation: BodyOrientation:
^HelicopterHusk:
Inherits: ^Husk
-Husk:
-Burns:
FallsToEarth:
Spins: True
Moves: False
-BelowUnits:
^PlaneHusk:
Inherits: ^Husk
-Husk:
-Burns:
FallsToEarth:
Spins: False
Moves: True
-BelowUnits:
^Bridge: ^Bridge:
Tooltip: Tooltip:
Name: Bridge Name: Bridge