diff --git a/OpenRA.Mods.Common/Traits/SelfHealing.cs b/OpenRA.Mods.Common/Traits/ChangesHealth.cs similarity index 64% rename from OpenRA.Mods.Common/Traits/SelfHealing.cs rename to OpenRA.Mods.Common/Traits/ChangesHealth.cs index e55dd8547b..bf10fc0b24 100644 --- a/OpenRA.Mods.Common/Traits/SelfHealing.cs +++ b/OpenRA.Mods.Common/Traits/ChangesHealth.cs @@ -14,30 +14,34 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - [Desc("Attach this to actors which should be able to regenerate their health points.")] - class SelfHealingInfo : ConditionalTraitInfo, Requires + [Desc("Attach this to actors which should regenerate or lose health points over time.")] + class ChangesHealthInfo : ConditionalTraitInfo, Requires { - [Desc("Absolute amount of health points added in each step.")] + [Desc("Absolute amount of health points added in each step.", + "Use negative values to apply damage.")] public readonly int Step = 5; [Desc("Relative percentages of health added in each step.", + "Use negative values to apply damage.", "When both values are defined, their summary will be applied.")] public readonly int PercentageStep = 0; + [Desc("Time in ticks to wait between each health modification.")] public readonly int Delay = 5; [Desc("Heal if current health is below this percentage of full health.")] - public readonly int HealIfBelow = 50; + public readonly int StartIfBelow = 50; + [Desc("Time in ticks to wait after taking damage.")] public readonly int DamageCooldown = 0; - [Desc("Apply the selfhealing using these damagetypes.")] + [Desc("Apply the health change when encountering these damage types.")] public readonly BitSet DamageTypes = default(BitSet); - public override object Create(ActorInitializer init) { return new SelfHealing(init.Self, this); } + public override object Create(ActorInitializer init) { return new ChangesHealth(init.Self, this); } } - class SelfHealing : ConditionalTrait, ITick, INotifyDamage + class ChangesHealth : ConditionalTrait, ITick, INotifyDamage { readonly IHealth health; @@ -47,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits [Sync] int damageTicks; - public SelfHealing(Actor self, SelfHealingInfo info) + public ChangesHealth(Actor self, ChangesHealthInfo info) : base(info) { health = self.Trait(); @@ -59,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits return; // Cast to long to avoid overflow when multiplying by the health - if (health.HP >= Info.HealIfBelow * (long)health.MaxHP / 100) + if (health.HP >= Info.StartIfBelow * (long)health.MaxHP / 100) return; if (damageTicks > 0) @@ -73,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits ticks = Info.Delay; // Cast to long to avoid overflow when multiplying by the health - self.InflictDamage(self, new Damage((int)(-(Info.Step + Info.PercentageStep * (long)health.MaxHP / 100)), Info.DamageTypes)); + self.InflictDamage(self, new Damage((int)-(Info.Step + Info.PercentageStep * (long)health.MaxHP / 100), Info.DamageTypes)); } } diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/RenameSelfHealing.cs b/OpenRA.Mods.Common/UpdateRules/Rules/RenameSelfHealing.cs new file mode 100644 index 0000000000..d35ec6cf5c --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/RenameSelfHealing.cs @@ -0,0 +1,42 @@ +#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; +using System.Linq; + +namespace OpenRA.Mods.Common.UpdateRules.Rules +{ + public class RenameSelfHealing : UpdateRule + { + public override string Name { get { return "SelfHealing was renamed as negative SelfHealing is a common usecase."; } } + public override string Description + { + get + { + return "SelfHealing was renamed to ChangesHealth\n" + + "HealIfBelow was renamed to StartIfBelow."; + } + } + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + var modId = modData.Manifest.Id; + + foreach (var sh in actorNode.ChildrenMatching("SelfHealing")) + { + sh.RenameChildrenMatching("HealIfBelow", "StartIfBelow"); + sh.RenameKey("ChangesHealth"); + } + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index d31c39df24..78b3921182 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -70,6 +70,7 @@ namespace OpenRA.Mods.Common.UpdateRules new CreateFlashPaletteEffectWarhead(), new ChangeTargetLineDelayToMilliseconds(), new ReplaceFacingAngles(), + new RenameSelfHealing(), }) }; diff --git a/mods/cnc/maps/gdi06/rules.yaml b/mods/cnc/maps/gdi06/rules.yaml index 7eabbc85eb..8d6213c597 100644 --- a/mods/cnc/maps/gdi06/rules.yaml +++ b/mods/cnc/maps/gdi06/rules.yaml @@ -83,10 +83,10 @@ RMBO.easy: Inherits: RMBO Health: HP: 30000 - SelfHealing: + ChangesHealth: Step: 500 Delay: 10 - HealIfBelow: 50 + StartIfBelow: 50 DamageCooldown: 200 RenderSprites: Image: RMBO diff --git a/mods/cnc/maps/nod09/rules.yaml b/mods/cnc/maps/nod09/rules.yaml index 4ea68a4d79..4a27c97435 100644 --- a/mods/cnc/maps/nod09/rules.yaml +++ b/mods/cnc/maps/nod09/rules.yaml @@ -176,10 +176,10 @@ RMBO.easy: Inherits: RMBO Health: HP: 30000 - SelfHealing: + ChangesHealth: Step: 500 Delay: 10 - HealIfBelow: 50 + StartIfBelow: 50 DamageCooldown: 200 RenderSprites: Image: RMBO diff --git a/mods/cnc/maps/nod10a/rules.yaml b/mods/cnc/maps/nod10a/rules.yaml index 86060c27eb..26e9708e55 100644 --- a/mods/cnc/maps/nod10a/rules.yaml +++ b/mods/cnc/maps/nod10a/rules.yaml @@ -45,10 +45,10 @@ RMBO.easy: Inherits: RMBO Health: HP: 30000 - SelfHealing: + ChangesHealth: Step: 500 Delay: 10 - HealIfBelow: 50 + StartIfBelow: 50 DamageCooldown: 200 RenderSprites: Image: RMBO diff --git a/mods/cnc/maps/nod10b/rules.yaml b/mods/cnc/maps/nod10b/rules.yaml index 2917320292..c45d610781 100644 --- a/mods/cnc/maps/nod10b/rules.yaml +++ b/mods/cnc/maps/nod10b/rules.yaml @@ -37,10 +37,10 @@ RMBO.easy: Inherits: RMBO Health: HP: 30000 - SelfHealing: + ChangesHealth: Step: 500 Delay: 10 - HealIfBelow: 50 + StartIfBelow: 50 DamageCooldown: 200 RenderSprites: Image: RMBO diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index bad26302b5..53e43882a5 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -105,11 +105,10 @@ ReloadDelayMultiplier@RANK-ELITE: RequiresCondition: rank-elite Modifier: 75 - SelfHealing@ELITE: - Step: 0 - PercentageStep: 5 + ChangesHealth@ELITE: + Step: 200 Delay: 100 - HealIfBelow: 100 + StartIfBelow: 100 DamageCooldown: 125 RequiresCondition: rank-elite WithDecoration@RANK-1: @@ -429,10 +428,10 @@ WarnProbability: 75 CrushSound: squish2.aud Guardable: - SelfHealing@HOSPITAL: + ChangesHealth@HOSPITAL: Step: 500 Delay: 100 - HealIfBelow: 100 + StartIfBelow: 100 DamageCooldown: 125 RequiresCondition: hospitalheal GrantConditionOnPrerequisite@HOSPITAL: diff --git a/mods/cnc/rules/vehicles.yaml b/mods/cnc/rules/vehicles.yaml index 0094076e04..55d7adc6fd 100644 --- a/mods/cnc/rules/vehicles.yaml +++ b/mods/cnc/rules/vehicles.yaml @@ -508,10 +508,10 @@ HTNK: MuzzleSequence: muzzle AttackTurreted: WithMuzzleOverlay: - SelfHealing: + ChangesHealth: Step: 500 Delay: 10 - HealIfBelow: 50 + StartIfBelow: 50 DamageCooldown: 200 SpawnActorOnDeath: Actor: HTNK.Husk diff --git a/mods/d2k/rules/aircraft.yaml b/mods/d2k/rules/aircraft.yaml index 81a32a94d7..b6cb9d6a73 100644 --- a/mods/d2k/rules/aircraft.yaml +++ b/mods/d2k/rules/aircraft.yaml @@ -38,10 +38,10 @@ carryall.reinforce: LocalOffset: 0, 0, -128 RenderSprites: Image: carryall - SelfHealing: + ChangesHealth: Step: 50 Delay: 3 - HealIfBelow: 50 + StartIfBelow: 50 Buildable: BuildDuration: 750 BuildDurationModifier: 100 diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index 27c321b5d6..351abed08b 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -84,11 +84,11 @@ InaccuracyMultiplier@RANK-ELITE: RequiresCondition: rank-elite Modifier: 50 - SelfHealing@ELITE: + ChangesHealth@ELITE: Step: 0 PercentageStep: 4 Delay: 125 - HealIfBelow: 100 + StartIfBelow: 100 DamageCooldown: 125 RequiresCondition: rank-elite WithDecoration@RANK-1: diff --git a/mods/d2k/rules/vehicles.yaml b/mods/d2k/rules/vehicles.yaml index af78aa2570..b857b405f0 100644 --- a/mods/d2k/rules/vehicles.yaml +++ b/mods/d2k/rules/vehicles.yaml @@ -41,10 +41,10 @@ mcv: EffectiveOwnerFromOwner: true AttractsWorms: Intensity: 700 - SelfHealing: + ChangesHealth: Step: 50 Delay: 3 - HealIfBelow: 50 + StartIfBelow: 50 -RevealOnFire: harvester: @@ -92,10 +92,10 @@ harvester: WithDockingAnimation: AttractsWorms: Intensity: 700 - SelfHealing: + ChangesHealth: Step: 50 Delay: 3 - HealIfBelow: 50 + StartIfBelow: 50 -RevealOnFire: WithHarvesterPipsDecoration: Position: BottomLeft @@ -385,10 +385,10 @@ devastator: GrantsCondition: meltdown AttractsWorms: Intensity: 700 - SelfHealing: + ChangesHealth: Step: 50 Delay: 3 - HealIfBelow: 50 + StartIfBelow: 50 Selectable: DecorationBounds: 44,38,0,0 diff --git a/mods/ra/maps/bomber-john/rules.yaml b/mods/ra/maps/bomber-john/rules.yaml index 000db1fdd1..6d5ceb0a9b 100644 --- a/mods/ra/maps/bomber-john/rules.yaml +++ b/mods/ra/maps/bomber-john/rules.yaml @@ -175,10 +175,10 @@ MINVV: WithSpriteBody: Tooltip: Name: Bomb - SelfHealing: + ChangesHealth: Step: -100 Delay: 1 - HealIfBelow: 101 + StartIfBelow: 101 Explodes: Weapon: CrateNuke EmptyWeapon: CrateNuke diff --git a/mods/ra/maps/fort-lonestar/rules.yaml b/mods/ra/maps/fort-lonestar/rules.yaml index 43adc15b18..edf91e5e5c 100644 --- a/mods/ra/maps/fort-lonestar/rules.yaml +++ b/mods/ra/maps/fort-lonestar/rules.yaml @@ -337,10 +337,10 @@ V2RL: Explodes: Weapon: napalm EmptyWeapon: napalm - SelfHealing: + ChangesHealth: Step: 200 Delay: 1 - HealIfBelow: 40 + StartIfBelow: 40 powerproxy.parabombs: AirstrikePower: diff --git a/mods/ra/maps/monster-tank-madness/rules.yaml b/mods/ra/maps/monster-tank-madness/rules.yaml index 8a27bc7e61..3263cf8d69 100644 --- a/mods/ra/maps/monster-tank-madness/rules.yaml +++ b/mods/ra/maps/monster-tank-madness/rules.yaml @@ -163,10 +163,10 @@ PBOX: EmptyWeapon: MiniNuke SpawnActorOnDeath: Actor: 5TNK.Husk - SelfHealing: + ChangesHealth: Step: 100 Delay: 1 - HealIfBelow: 100 + StartIfBelow: 100 DamageCooldown: 150 Selectable: Bounds: 44,38,0,-4 diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index d1bc27265b..aebcadaaf9 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -104,11 +104,11 @@ ReloadDelayMultiplier@RANK-ELITE: RequiresCondition: rank-elite Modifier: 75 - SelfHealing@ELITE: + ChangesHealth@ELITE: Step: 0 PercentageStep: 5 Delay: 100 - HealIfBelow: 100 + StartIfBelow: 100 DamageCooldown: 125 RequiresCondition: rank-elite WithDecoration@RANK-1: @@ -368,10 +368,10 @@ Guardable: Tooltip: GenericName: Soldier - SelfHealing@HOSPITAL: + ChangesHealth@HOSPITAL: Step: 500 Delay: 100 - HealIfBelow: 100 + StartIfBelow: 100 DamageCooldown: 125 RequiresCondition: hospitalheal GrantConditionOnPrerequisite@HOSPITAL: diff --git a/mods/ra/rules/vehicles.yaml b/mods/ra/rules/vehicles.yaml index e71ec662f9..9b8440d8f1 100644 --- a/mods/ra/rules/vehicles.yaml +++ b/mods/ra/rules/vehicles.yaml @@ -232,10 +232,10 @@ V2RL: WithSpriteTurret: SpawnActorOnDeath: Actor: 4TNK.Husk - SelfHealing: + ChangesHealth: Step: 100 Delay: 3 - HealIfBelow: 50 + StartIfBelow: 50 DamageCooldown: 150 ProducibleWithLevel: Prerequisites: vehicles.upgraded @@ -327,10 +327,10 @@ HARV: HarvesterHuskModifier: FullHuskActor: HARV.FullHusk FullnessThreshold: 50 - SelfHealing: + ChangesHealth: Step: 100 Delay: 25 - HealIfBelow: 50 + StartIfBelow: 50 DamageCooldown: 500 Explodes: RequiresCondition: !no-ore diff --git a/mods/ts/rules/civilian-vehicles.yaml b/mods/ts/rules/civilian-vehicles.yaml index 55ea2b58e2..575e01b98e 100644 --- a/mods/ts/rules/civilian-vehicles.yaml +++ b/mods/ts/rules/civilian-vehicles.yaml @@ -31,10 +31,10 @@ AttackTurreted: Voice: Attack PauseOnCondition: empdisable - SelfHealing: + ChangesHealth: Step: 500 Delay: 10 - HealIfBelow: 50 + StartIfBelow: 50 DamageCooldown: 200 WithVoxelTurret: WithVoxelBarrel: diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index 2f4b5f9d78..a210ec2fbb 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -51,10 +51,10 @@ ReloadDelayMultiplier@ELITE: RequiresCondition: rank-elite Modifier: 75 - SelfHealing@ELITE: + ChangesHealth@ELITE: Step: 200 Delay: 100 - HealIfBelow: 100 + StartIfBelow: 100 DamageCooldown: 125 RequiresCondition: rank-elite WithDecoration@VETERAN: @@ -591,10 +591,10 @@ Guard: Voice: Move Guardable: - SelfHealing@HOSPITAL: + ChangesHealth@HOSPITAL: Step: 500 Delay: 100 - HealIfBelow: 100 + StartIfBelow: 100 DamageCooldown: 125 RequiresCondition: hospitalheal GrantConditionOnPrerequisite@HOSPITAL: diff --git a/mods/ts/rules/gdi-infantry.yaml b/mods/ts/rules/gdi-infantry.yaml index bcf7c8b236..ab3c01a1b3 100644 --- a/mods/ts/rules/gdi-infantry.yaml +++ b/mods/ts/rules/gdi-infantry.yaml @@ -79,7 +79,7 @@ MEDIC: AttackFrontal: WithInfantryBody: DefaultAttackSequence: heal - SelfHealing: + ChangesHealth: Step: 500 Delay: 60 Passenger: diff --git a/mods/ts/rules/gdi-vehicles.yaml b/mods/ts/rules/gdi-vehicles.yaml index cbc3655ef9..c5c2f1cd22 100644 --- a/mods/ts/rules/gdi-vehicles.yaml +++ b/mods/ts/rules/gdi-vehicles.yaml @@ -236,7 +236,7 @@ HMEC: Speed: 42 Health: HP: 80000 - SelfHealing: + ChangesHealth: Step: 500 Armor: Type: Heavy diff --git a/mods/ts/rules/nod-vehicles.yaml b/mods/ts/rules/nod-vehicles.yaml index 3a13fc1ed7..3f6b1874d6 100644 --- a/mods/ts/rules/nod-vehicles.yaml +++ b/mods/ts/rules/nod-vehicles.yaml @@ -368,10 +368,10 @@ WEED: TurnSpeed: 20 Health: HP: 60000 - SelfHealing: + ChangesHealth: Step: 500 Delay: 10 - HealIfBelow: 50 + StartIfBelow: 50 DamageCooldown: 200 Armor: Type: Heavy diff --git a/mods/ts/rules/shared-infantry.yaml b/mods/ts/rules/shared-infantry.yaml index 8f56d48cc7..aa55795eff 100644 --- a/mods/ts/rules/shared-infantry.yaml +++ b/mods/ts/rules/shared-infantry.yaml @@ -93,9 +93,9 @@ FLAMEGUY: IdleSequences: run Health: HP: 16000 - SelfHealing: + ChangesHealth: Step: -1000 - HealIfBelow: 101 + StartIfBelow: 101 ScaredyCat: PanicSequencePrefix: WithDeathAnimation: diff --git a/mods/ts/rules/shared-vehicles.yaml b/mods/ts/rules/shared-vehicles.yaml index 66761b0373..d4d67e60a1 100644 --- a/mods/ts/rules/shared-vehicles.yaml +++ b/mods/ts/rules/shared-vehicles.yaml @@ -72,10 +72,10 @@ HARV: Speed: 71 Health: HP: 100000 - SelfHealing: + ChangesHealth: Step: 500 Delay: 10 - HealIfBelow: 50 + StartIfBelow: 50 DamageCooldown: 200 Armor: Type: Heavy