diff --git a/OpenRA.Mods.Common/Traits/DamagedByTerrain.cs b/OpenRA.Mods.Common/Traits/DamagedByTerrain.cs index 9877c7b8aa..a9a0a72020 100644 --- a/OpenRA.Mods.Common/Traits/DamagedByTerrain.cs +++ b/OpenRA.Mods.Common/Traits/DamagedByTerrain.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007-2016 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made @@ -9,6 +9,7 @@ */ #endregion +using System.Collections.Generic; using System.Linq; using OpenRA.GameRules; using OpenRA.Traits; @@ -16,10 +17,16 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("This actor receives damage from the given weapon when on the specified terrain type.")] - class DamagedByTerrainInfo : UpgradableTraitInfo, IRulesetLoaded, Requires + class DamagedByTerrainInfo : UpgradableTraitInfo, Requires { - [Desc("The weapon which is used to damage the actor.")] - [WeaponReference, FieldLoader.Require] public readonly string Weapon; + [Desc("Amount of damage received per DamageInterval ticks.")] + [FieldLoader.Require] public readonly int Damage = 0; + + [Desc("Delay between receiving damage.")] + public readonly int DamageInterval = 0; + + [Desc("Apply the damage using these damagetypes.")] + public readonly HashSet DamageTypes = new HashSet(); [Desc("Terrain types where the actor will take damage.")] [FieldLoader.Require] public readonly string[] Terrain = { }; @@ -30,10 +37,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Inflict damage down to the DamageThreshold when the actor gets created on damaging terrain.")] public readonly bool StartOnThreshold = false; - public WeaponInfo WeaponInfo { get; private set; } - public override object Create(ActorInitializer init) { return new DamagedByTerrain(init.Self, this); } - public void RulesetLoaded(Ruleset rules, ActorInfo ai) { WeaponInfo = rules.Weapons[Weapon.ToLowerInvariant()]; } } class DamagedByTerrain : UpgradableTrait, ITick, ISync, INotifyAddedToWorld @@ -70,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits // Actors start with maximum damage applied var delta = health.HP - damageThreshold; if (delta > 0) - health.InflictDamage(self, self.World.WorldActor, new Damage(delta), false); + self.InflictDamage(self.World.WorldActor, new Damage(delta, Info.DamageTypes)); } public void Tick(Actor self) @@ -86,8 +90,8 @@ namespace OpenRA.Mods.Common.Traits if (!Info.Terrain.Contains(t.Type)) return; - Info.WeaponInfo.Impact(Target.FromActor(self), self.World.WorldActor, Enumerable.Empty()); - damageTicks = Info.WeaponInfo.ReloadDelay; + self.InflictDamage(self.World.WorldActor, new Damage(Info.Damage, Info.DamageTypes)); + damageTicks = Info.DamageInterval; } } } diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 843333302d..61a4a7b4e7 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -234,8 +234,9 @@ namespace OpenRA.Mods.Common.UtilityCommands else node.Value.Nodes.Add(new MiniYamlNode("Terrain", new MiniYaml("Tiberium, BlueTiberium"))); - if (!node.Value.Nodes.Any(a => a.Key == "Weapon")) - node.Value.Nodes.Add(new MiniYamlNode("Weapon", new MiniYaml("Tiberium"))); + Console.WriteLine("PoisonedByTiberium: Weapon isn't converted. Copy out the appropriate"); + Console.WriteLine("weapon's Damage, ReloadDelay and DamageTypes to DamagedByTerrain's Damage,"); + Console.WriteLine("DamageInterval and DamageTypes, respectively, then remove the Weapon tag."); } } @@ -244,8 +245,9 @@ namespace OpenRA.Mods.Common.UtilityCommands node.Key = node.Key.Replace("DamagedWithoutFoundation", "DamagedByTerrain"); if (!node.Key.StartsWith("-")) { - if (!node.Value.Nodes.Any(a => a.Key == "Weapon")) - node.Value.Nodes.Add(new MiniYamlNode("Weapon", new MiniYaml("weathering"))); + Console.WriteLine("DamagedWithoutFoundation: Weapon isn't converted. Copy out the appropriate"); + Console.WriteLine("weapon's Damage, ReloadDelay and DamageTypes to DamagedByTerrain's Damage,"); + Console.WriteLine("DamageInterval and DamageTypes, respectively, then remove the Weapon tag."); Console.WriteLine("SafeTerrain isn't converted. Setup an inverted check using Terrain.");