Merge pull request #5242 from reaperrr/deathsounds-followup
Made DeathSounds and their InfDeath relation fully customizable
This commit is contained in:
@@ -17,9 +17,14 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
public class DeathSoundsInfo : ITraitInfo
|
||||
{
|
||||
public readonly string DeathVoice = "Die";
|
||||
public readonly string Burned = null;
|
||||
public readonly string Zapped = null;
|
||||
[Desc("Death notification voice.")]
|
||||
public readonly string DeathSound = "Die";
|
||||
|
||||
[Desc("Multiply volume with this factor.")]
|
||||
public readonly float VolumeMultiplier = 1f;
|
||||
|
||||
[Desc("InfDeaths that this should be used for. If empty, this will be used as the default sound.")]
|
||||
public readonly string[] InfDeaths = { };
|
||||
|
||||
public object Create(ActorInitializer init) { return new DeathSounds(this); }
|
||||
}
|
||||
@@ -38,16 +43,8 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
var cp = self.CenterPosition;
|
||||
|
||||
// Killed by fire
|
||||
if (info.Burned != null && e.Warhead.InfDeath == 5)
|
||||
Sound.Play(info.Burned, cp);
|
||||
|
||||
// Killed by Tesla/Laser zap
|
||||
if (info.Zapped != null && e.Warhead.InfDeath == 6)
|
||||
Sound.Play(info.Zapped, cp);
|
||||
|
||||
if ((e.Warhead.InfDeath < 5) || (info.Burned == null && info.Zapped == null))
|
||||
Sound.PlayVoiceLocal(info.DeathVoice, self, self.Owner.Country.Race, cp);
|
||||
if (info.InfDeaths.Contains(e.Warhead.InfDeath) || (!info.InfDeaths.Any() && !self.Info.Traits.WithInterface<DeathSoundsInfo>().Any(dsi => dsi.InfDeaths.Contains(e.Warhead.InfDeath))))
|
||||
Sound.PlayVoiceLocal(info.DeathSound, self, self.Owner.Country.Race, cp, info.VolumeMultiplier);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA
|
||||
public readonly string EmptyWeapon = "UnitExplode";
|
||||
|
||||
public readonly int Chance = 100;
|
||||
public readonly int[] InfDeath = null;
|
||||
public readonly string[] InfDeath = { };
|
||||
|
||||
public object Create(ActorInitializer init) { return new Explodes(this); }
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
|
||||
if (info.SpawnsCorpse)
|
||||
{
|
||||
SpawnCorpse(self, "die{0}".F(e.Warhead.InfDeath));
|
||||
SpawnCorpse(self, "die" + (e.Warhead.InfDeath));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -13,13 +13,23 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class TeslaInstantKillsInfo : TraitInfo<TeslaInstantKills> { }
|
||||
public class TeslaInstantKillsInfo : ITraitInfo
|
||||
{
|
||||
[Desc("InfDeath that leads to instant kill.")]
|
||||
public readonly string InfDeath = "6";
|
||||
|
||||
class TeslaInstantKills : IDamageModifier
|
||||
public object Create(ActorInitializer init) { return new TeslaInstantKills(this); }
|
||||
}
|
||||
|
||||
public class TeslaInstantKills : IDamageModifier
|
||||
{
|
||||
public float GetDamageModifier(Actor attacker, WarheadInfo warhead )
|
||||
TeslaInstantKillsInfo info;
|
||||
|
||||
public TeslaInstantKills(TeslaInstantKillsInfo info) { this.info = info; }
|
||||
|
||||
public float GetDamageModifier(Actor attacker, WarheadInfo warhead)
|
||||
{
|
||||
if( warhead != null && warhead.InfDeath == 6 )
|
||||
if( warhead != null && warhead.InfDeath == info.InfDeath )
|
||||
return 1000f;
|
||||
return 1f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user