From 362525cb94c3619e1b13c7dac662fd6c53ee0a26 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 16 May 2010 15:42:59 +1200 Subject: [PATCH] v2 explodes with napalm if it dies while loaded --- OpenRA.Game/Traits/Explodes.cs | 30 ++++++++++++++++++++++++------ mods/ra/vehicles.yaml | 7 +++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/OpenRA.Game/Traits/Explodes.cs b/OpenRA.Game/Traits/Explodes.cs index 923812d8a8b7..3d26f711def3 100644 --- a/OpenRA.Game/Traits/Explodes.cs +++ b/OpenRA.Game/Traits/Explodes.cs @@ -22,7 +22,11 @@ namespace OpenRA.Traits { - class ExplodesInfo : TraitInfo { public readonly string Weapon = "UnitExplode"; } + class ExplodesInfo : TraitInfo + { + public readonly string Weapon = "UnitExplode"; + public readonly string EmptyWeapon = "UnitExplode"; + } class Explodes : INotifyDamage { @@ -30,12 +34,26 @@ public void Damaged(Actor self, AttackInfo e) { if (self.IsDead) { - var unit = self.traits.GetOrDefault(); - var altitude = unit != null ? unit.Altitude : 0; - Combat.DoExplosion(e.Attacker, - self.Info.Traits.Get().Weapon, - self.CenterLocation.ToInt2(), altitude); + var weapon = ChooseWeaponForExplosion(self); + if (weapon != null) + { + var unit = self.traits.GetOrDefault(); + var altitude = unit != null ? unit.Altitude : 0; + Combat.DoExplosion(e.Attacker, + self.Info.Traits.Get().Weapon, + self.CenterLocation.ToInt2(), altitude); + } } } + + string ChooseWeaponForExplosion(Actor self) + { + var info = self.Info.Traits.Get(); + var attack = self.traits.GetOrDefault(); + + if (attack == null) return info.Weapon; + + return attack.IsReloading() ? info.EmptyWeapon : info.Weapon; + } } } diff --git a/mods/ra/vehicles.yaml b/mods/ra/vehicles.yaml index 865f81416faf..07abc1543f7b 100644 --- a/mods/ra/vehicles.yaml +++ b/mods/ra/vehicles.yaml @@ -57,6 +57,9 @@ V2RL: PrimaryWeapon: SCUD RenderUnitReload: AutoTarget: + Explodes: + Weapon: SCUD + EmptyWeapon: 1TNK: Inherits: ^Vehicle @@ -84,6 +87,7 @@ V2RL: AutoTarget: Explodes: Weapon: UnitExplodeSmall + EmptyWeapon: UnitExplodeSmall LeavesHusk: HuskActor: 1TNK.Husk @@ -113,6 +117,7 @@ V2RL: AutoTarget: Explodes: Weapon: UnitExplodeSmall + EmptyWeapon: UnitExplodeSmall LeavesHusk: HuskActor: 2TNK.Husk @@ -142,6 +147,7 @@ V2RL: AutoTarget: Explodes: Weapon: UnitExplodeSmall + EmptyWeapon: UnitExplodeSmall LeavesHusk: HuskActor: 3TNK.Husk @@ -174,6 +180,7 @@ V2RL: AutoTarget: Explodes: Weapon: UnitExplodeSmall + EmptyWeapon: UnitExplodeSmall LeavesHusk: HuskActor: 4TNK.Husk