diff --git a/OpenRA.Mods.Cnc/Traits/SpawnViceroid.cs b/OpenRA.Mods.Cnc/Traits/SpawnViceroid.cs index 1cf6642d38..cdeaf5444c 100644 --- a/OpenRA.Mods.Cnc/Traits/SpawnViceroid.cs +++ b/OpenRA.Mods.Cnc/Traits/SpawnViceroid.cs @@ -9,6 +9,7 @@ #endregion using System.Linq; +using OpenRA.Mods.Common.Warheads; using OpenRA.Primitives; using OpenRA.Traits; @@ -33,9 +34,12 @@ namespace OpenRA.Mods.Cnc.Traits public void Killed(Actor self, AttackInfo e) { if (!self.World.LobbyInfo.GlobalSettings.Creeps) return; - if (e.Warhead == null || !e.Warhead.DamageTypes.Contains(info.DeathType)) return; if (self.World.SharedRandom.Next(100) > info.Probability) return; + var warhead = e.Warhead as DamageWarhead; + if (warhead == null || !warhead.DamageTypes.Contains(info.DeathType)) + return; + self.World.AddFrameEndTask(w => { var td = new TypeDictionary diff --git a/OpenRA.Mods.Common/Traits/Explodes.cs b/OpenRA.Mods.Common/Traits/Explodes.cs index 58bd5f05b3..3dcf1ad02c 100644 --- a/OpenRA.Mods.Common/Traits/Explodes.cs +++ b/OpenRA.Mods.Common/Traits/Explodes.cs @@ -9,6 +9,7 @@ #endregion using System.Linq; +using OpenRA.Mods.Common.Warheads; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits @@ -40,7 +41,8 @@ namespace OpenRA.Mods.Common.Traits if (self.World.SharedRandom.Next(100) > info.Chance) return; - if (info.DeathType != null && e.Warhead != null && !info.DeathType.Intersect(e.Warhead.DamageTypes).Any()) + var warhead = e.Warhead as DamageWarhead; + if (info.DeathType != null && warhead != null && !info.DeathType.Intersect(warhead.DamageTypes).Any()) return; var weaponName = ChooseWeaponForExplosion(self); diff --git a/OpenRA.Mods.Common/Traits/Render/WithDeathAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithDeathAnimation.cs index 6be98a8294..7977656e70 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithDeathAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithDeathAnimation.cs @@ -12,6 +12,7 @@ using System; using System.Collections.Generic; using System.Linq; using OpenRA.Mods.Common.Effects; +using OpenRA.Mods.Common.Warheads; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits @@ -72,16 +73,17 @@ namespace OpenRA.Mods.Common.Traits { // Killed by some non-standard means. This includes being crushed // by a vehicle (Actors with Crushable trait will spawn CrushedSequence instead). - if (e.Warhead == null) + if (e.Warhead == null || !(e.Warhead is DamageWarhead)) return; var sequence = Info.DeathSequence; if (Info.UseDeathTypeSuffix) { - var damageType = e.Warhead.DamageTypes.Intersect(Info.DeathTypes.Keys).FirstOrDefault(); + var warhead = e.Warhead as DamageWarhead; + var damageType = warhead.DamageTypes.Intersect(Info.DeathTypes.Keys).FirstOrDefault(); if (damageType == null) throw new Exception("Actor type `{0}` does not define a death animation for weapon with damage types `{1}`!" - .F(self.Info.Name, string.Join(", ", e.Warhead.DamageTypes))); + .F(self.Info.Name, string.Join(", ", warhead.DamageTypes))); sequence += Info.DeathTypes[damageType]; } diff --git a/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs b/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs index 9148956259..49a70f50db 100644 --- a/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs +++ b/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs @@ -9,6 +9,7 @@ #endregion using System.Linq; +using OpenRA.Mods.Common.Warheads; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits @@ -37,11 +38,13 @@ namespace OpenRA.Mods.Common.Traits public void Killed(Actor self, AttackInfo e) { + var warhead = e.Warhead as DamageWarhead; + // Killed by some non-standard means - if (e.Warhead == null) + if (warhead == null) return; - if (info.DeathTypes.Intersect(e.Warhead.DamageTypes).Any()) + if (info.DeathTypes.Intersect(warhead.DamageTypes).Any()) self.PlayVoiceLocal(info.Voice, info.VolumeMultiplier); } }