Skip to content

Commit

Permalink
v2 explodes with napalm if it dies while loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisforbes committed May 16, 2010
1 parent c7b2ac3 commit 362525c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
30 changes: 24 additions & 6 deletions OpenRA.Game/Traits/Explodes.cs
Expand Up @@ -22,20 +22,38 @@

namespace OpenRA.Traits
{
class ExplodesInfo : TraitInfo<Explodes> { public readonly string Weapon = "UnitExplode"; }
class ExplodesInfo : TraitInfo<Explodes>
{
public readonly string Weapon = "UnitExplode";
public readonly string EmptyWeapon = "UnitExplode";
}

class Explodes : INotifyDamage
{
public void Damaged(Actor self, AttackInfo e)
{
if (self.IsDead)
{
var unit = self.traits.GetOrDefault<Unit>();
var altitude = unit != null ? unit.Altitude : 0;
Combat.DoExplosion(e.Attacker,
self.Info.Traits.Get<ExplodesInfo>().Weapon,
self.CenterLocation.ToInt2(), altitude);
var weapon = ChooseWeaponForExplosion(self);
if (weapon != null)
{
var unit = self.traits.GetOrDefault<Unit>();
var altitude = unit != null ? unit.Altitude : 0;
Combat.DoExplosion(e.Attacker,
self.Info.Traits.Get<ExplodesInfo>().Weapon,
self.CenterLocation.ToInt2(), altitude);
}
}
}

string ChooseWeaponForExplosion(Actor self)
{
var info = self.Info.Traits.Get<ExplodesInfo>();
var attack = self.traits.GetOrDefault<AttackBase>();

if (attack == null) return info.Weapon;

return attack.IsReloading() ? info.EmptyWeapon : info.Weapon;
}
}
}
7 changes: 7 additions & 0 deletions mods/ra/vehicles.yaml
Expand Up @@ -57,6 +57,9 @@ V2RL:
PrimaryWeapon: SCUD
RenderUnitReload:
AutoTarget:
Explodes:
Weapon: SCUD
EmptyWeapon:

1TNK:
Inherits: ^Vehicle
Expand Down Expand Up @@ -84,6 +87,7 @@ V2RL:
AutoTarget:
Explodes:
Weapon: UnitExplodeSmall
EmptyWeapon: UnitExplodeSmall
LeavesHusk:
HuskActor: 1TNK.Husk

Expand Down Expand Up @@ -113,6 +117,7 @@ V2RL:
AutoTarget:
Explodes:
Weapon: UnitExplodeSmall
EmptyWeapon: UnitExplodeSmall
LeavesHusk:
HuskActor: 2TNK.Husk

Expand Down Expand Up @@ -142,6 +147,7 @@ V2RL:
AutoTarget:
Explodes:
Weapon: UnitExplodeSmall
EmptyWeapon: UnitExplodeSmall
LeavesHusk:
HuskActor: 3TNK.Husk

Expand Down Expand Up @@ -174,6 +180,7 @@ V2RL:
AutoTarget:
Explodes:
Weapon: UnitExplodeSmall
EmptyWeapon: UnitExplodeSmall
LeavesHusk:
HuskActor: 4TNK.Husk

Expand Down

0 comments on commit 362525c

Please sign in to comment.