Merge pull request #10381 from penev92/warheadEffects
Enhance CreateEffectWarhead
This commit is contained in:
@@ -3432,6 +3432,23 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
node.Value.Nodes.RemoveAll(x => x.Key == "Charges");
|
||||
}
|
||||
|
||||
// Enhance CreateEffectWarhead
|
||||
if (engineVersion < 20160131)
|
||||
{
|
||||
if (node.Key.StartsWith("Warhead") && node.Value.Value == "CreateEffect")
|
||||
{
|
||||
// Add support for multiple explosions to CreateEffectWarhead
|
||||
var explosionNode = node.Value.Nodes.FirstOrDefault(x => x.Key == "Explosion");
|
||||
if (explosionNode != null)
|
||||
explosionNode.Key = "Explosions";
|
||||
|
||||
// Add support for multiple impact sounds to CreateEffectWarhead
|
||||
var impactSoundNode = node.Value.Nodes.FirstOrDefault(x => x.Key == "ImpactSound");
|
||||
if (impactSoundNode != null)
|
||||
impactSoundNode.Key = "ImpactSounds";
|
||||
}
|
||||
}
|
||||
|
||||
UpgradeWeaponRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,17 +17,17 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
{
|
||||
public class CreateEffectWarhead : Warhead
|
||||
{
|
||||
[Desc("Explosion effect to use.")]
|
||||
public readonly string Explosion = null;
|
||||
[Desc("List of explosion effects that can be used.")]
|
||||
public readonly string[] Explosions = new string[0];
|
||||
|
||||
[Desc("Palette to use for explosion effect.")]
|
||||
[PaletteReference("UsePlayerPalette")] public readonly string ExplosionPalette = "effect";
|
||||
[Desc("Palette to use for explosion effect."), PaletteReference("UsePlayerPalette")]
|
||||
public readonly string ExplosionPalette = "effect";
|
||||
|
||||
[Desc("Remap explosion effect to player color, if art supports it.")]
|
||||
public readonly bool UsePlayerPalette = false;
|
||||
|
||||
[Desc("Sound to play on impact.")]
|
||||
public readonly string ImpactSound = null;
|
||||
[Desc("List of sounds that can be played on impact.")]
|
||||
public readonly string[] ImpactSounds = new string[0];
|
||||
|
||||
[Desc("What impact types should this effect apply to.")]
|
||||
public readonly ImpactType ValidImpactTypes = ImpactType.Ground | ImpactType.Water | ImpactType.Air | ImpactType.GroundHit | ImpactType.WaterHit | ImpactType.AirHit;
|
||||
@@ -99,11 +99,13 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
if (UsePlayerPalette)
|
||||
palette += firedBy.Owner.InternalName;
|
||||
|
||||
if (Explosion != null)
|
||||
world.AddFrameEndTask(w => w.Add(new Explosion(w, pos, Explosion, palette)));
|
||||
var explosion = Explosions.RandomOrDefault(Game.CosmeticRandom);
|
||||
if (explosion != null)
|
||||
world.AddFrameEndTask(w => w.Add(new Explosion(w, pos, explosion, palette)));
|
||||
|
||||
if (ImpactSound != null)
|
||||
Game.Sound.Play(ImpactSound, pos);
|
||||
var impactSound = ImpactSounds.RandomOrDefault(Game.CosmeticRandom);
|
||||
if (impactSound != null)
|
||||
Game.Sound.Play(impactSound, pos);
|
||||
}
|
||||
|
||||
public bool IsValidImpact(WPos pos, Actor firedBy)
|
||||
|
||||
Reference in New Issue
Block a user