diff --git a/OpenRA.Mods.Common/Traits/Burns.cs b/OpenRA.Mods.Common/Traits/Burns.cs deleted file mode 100644 index e138b20857..0000000000 --- a/OpenRA.Mods.Common/Traits/Burns.cs +++ /dev/null @@ -1,53 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2020 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, either version 3 of - * the License, or (at your option) any later version. For more - * information, see COPYING. - */ -#endregion - -using OpenRA.Graphics; -using OpenRA.Mods.Common.Traits.Render; -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Traits -{ - [Desc("This actor will play a fire animation over its body and take damage over time.")] - class BurnsInfo : TraitInfo, Requires - { - public readonly string Anim = "1"; - public readonly int Damage = 1; - public readonly int Interval = 8; - - public override object Create(ActorInitializer init) { return new Burns(init.Self, this); } - } - - class Burns : ITick, ISync - { - readonly BurnsInfo info; - [Sync] - int ticks; - - public Burns(Actor self, BurnsInfo info) - { - this.info = info; - - var anim = new Animation(self.World, "fire"); - anim.IsDecoration = true; - anim.PlayRepeating(info.Anim); - self.Trait().Add(anim); - } - - void ITick.Tick(Actor self) - { - if (--ticks <= 0) - { - self.InflictDamage(self, new Damage(info.Damage)); - ticks = info.Interval; - } - } - } -} diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/ReplaceBurns.cs b/OpenRA.Mods.Common/UpdateRules/Rules/ReplaceBurns.cs new file mode 100644 index 0000000000..5fb0f17ef5 --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/ReplaceBurns.cs @@ -0,0 +1,63 @@ +#region Copyright & License Information +/* + * Copyright 2007-2020 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, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using System.Collections.Generic; + +namespace OpenRA.Mods.Common.UpdateRules.Rules +{ + public class ReplaceBurns : UpdateRule + { + public override string Name { get { return "Replaced Burns with separate render and health change traits."; } } + public override string Description + { + get + { + return "Burns can be replaced using WithIdleOverlay and ChangesHealth."; + } + } + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + var addNodes = new List(); + + foreach (var burns in actorNode.ChildrenMatching("Burns")) + { + var anim = burns.LastChildMatching("Anim"); + var animValue = anim != null ? anim.NodeValue() : "1"; + + var damage = burns.LastChildMatching("Damage"); + var damageValue = damage != null ? damage.NodeValue() : 1; + + var interval = burns.LastChildMatching("Interval"); + var intervalValue = interval != null ? interval.NodeValue() : 8; + + var overlay = new MiniYamlNode("WithIdleOverlay@Burns", ""); + overlay.AddNode("Image", FieldSaver.FormatValue("fire")); + overlay.AddNode("Sequence", FieldSaver.FormatValue(animValue)); + overlay.AddNode("IsDecoration", FieldSaver.FormatValue(true)); + addNodes.Add(overlay); + + var changesHealth = new MiniYamlNode("ChangesHealth", ""); + changesHealth.AddNode("Step", FieldSaver.FormatValue(-damageValue)); + changesHealth.AddNode("StartIfBelow", FieldSaver.FormatValue(101)); + changesHealth.AddNode("Delay", FieldSaver.FormatValue(intervalValue)); + addNodes.Add(changesHealth); + } + + actorNode.RemoveNodes("Burns"); + + foreach (var addNode in addNodes) + actorNode.AddNode(addNode); + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index 78b3921182..5ba8a745c5 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -71,6 +71,7 @@ namespace OpenRA.Mods.Common.UpdateRules new ChangeTargetLineDelayToMilliseconds(), new ReplaceFacingAngles(), new RenameSelfHealing(), + new ReplaceBurns(), }) }; diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 53e43882a5..7329b25bec 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -1042,9 +1042,6 @@ Inherits: ^CommonHuskDefaults Husk: AllowedTerrain: Clear, Rough, Road, Tiberium, BlueTiberium, Beach - Burns: - Damage: 100 - Interval: 6 Targetable: RequiresForceFire: true TargetTypes: Ground, Husk @@ -1062,6 +1059,14 @@ Explodes: Weapon: UnitExplodeSmall EmptyWeapon: UnitExplodeSmall + WithIdleOverlay@Burns: + Image: fire + Sequence: 1 + IsDecoration: True + ChangesHealth: + Step: -100 + StartIfBelow: 101 + Delay: 6 ^LightHusk: Inherits: ^Husk diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index 351abed08b..8aada48dfb 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -265,9 +265,6 @@ Inherits: ^Husk Husk: AllowedTerrain: Sand, Rock, Transition, Concrete, Spice, SpiceSand, SpiceBlobs, Dune - Burns: - Damage: 10 - Interval: 4 Targetable: TargetTypes: Ground, Vehicle RequiresForceFire: true @@ -276,6 +273,14 @@ Explodes: Weapon: UnitExplodeMed EmptyWeapon: UnitExplodeMed + WithIdleOverlay@Burns: + Image: fire + Sequence: 1 + IsDecoration: True + ChangesHealth: + Step: -10 + StartIfBelow: 101 + Delay: 4 ^AircraftHusk: Inherits: ^Husk diff --git a/mods/ra/maps/desert-shellmap/rules.yaml b/mods/ra/maps/desert-shellmap/rules.yaml index 87325bde60..1b9a9109bd 100644 --- a/mods/ra/maps/desert-shellmap/rules.yaml +++ b/mods/ra/maps/desert-shellmap/rules.yaml @@ -46,8 +46,10 @@ OILB: ShowTicks: false TRAN.Husk2: - Burns: - Damage: 0 + WithIdleOverlay@Burns: + Image: fire + Sequence: 1 + IsDecoration: True MISS: DamageMultiplier@INVULNERABLE: diff --git a/mods/ra/maps/evacuation/rules.yaml b/mods/ra/maps/evacuation/rules.yaml index 089c5ba869..a9cab1ed42 100644 --- a/mods/ra/maps/evacuation/rules.yaml +++ b/mods/ra/maps/evacuation/rules.yaml @@ -40,12 +40,16 @@ DOG: ScriptTags: TRAN.Husk1: - Burns: - Damage: 0 + WithIdleOverlay@Burns: + Image: fire + Sequence: 1 + IsDecoration: True TRAN.Husk2: - Burns: - Damage: 0 + WithIdleOverlay@Burns: + Image: fire + Sequence: 1 + IsDecoration: True E7: Passenger: diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index aebcadaaf9..f7aad13091 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -983,8 +983,14 @@ Inherits@2: ^ClassicFacingSpriteActor Husk: AllowedTerrain: Clear, Rough, Road, Ore, Gems, Beach - Burns: - Damage: 200 + WithIdleOverlay@Burns: + Image: fire + Sequence: 1 + IsDecoration: true + ChangesHealth: + Step: -200 + StartIfBelow: 101 + Delay: 8 OwnerLostAction: Action: ChangeOwner CaptureManager: