Reflect in naming that negative SelfHealing is a thing.

This commit is contained in:
Matthias Mailänder
2020-07-22 19:51:37 +02:00
committed by teinarss
parent c42fd5d2e2
commit 2d36d0a659
24 changed files with 110 additions and 64 deletions

View File

@@ -14,30 +14,34 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Attach this to actors which should be able to regenerate their health points.")] [Desc("Attach this to actors which should regenerate or lose health points over time.")]
class SelfHealingInfo : ConditionalTraitInfo, Requires<IHealthInfo> class ChangesHealthInfo : ConditionalTraitInfo, Requires<IHealthInfo>
{ {
[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; public readonly int Step = 5;
[Desc("Relative percentages of health added in each step.", [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.")] "When both values are defined, their summary will be applied.")]
public readonly int PercentageStep = 0; public readonly int PercentageStep = 0;
[Desc("Time in ticks to wait between each health modification.")]
public readonly int Delay = 5; public readonly int Delay = 5;
[Desc("Heal if current health is below this percentage of full health.")] [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; 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<DamageType> DamageTypes = default(BitSet<DamageType>); public readonly BitSet<DamageType> DamageTypes = default(BitSet<DamageType>);
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<SelfHealingInfo>, ITick, INotifyDamage class ChangesHealth : ConditionalTrait<ChangesHealthInfo>, ITick, INotifyDamage
{ {
readonly IHealth health; readonly IHealth health;
@@ -47,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits
[Sync] [Sync]
int damageTicks; int damageTicks;
public SelfHealing(Actor self, SelfHealingInfo info) public ChangesHealth(Actor self, ChangesHealthInfo info)
: base(info) : base(info)
{ {
health = self.Trait<IHealth>(); health = self.Trait<IHealth>();
@@ -59,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
return; return;
// Cast to long to avoid overflow when multiplying by the health // 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; return;
if (damageTicks > 0) if (damageTicks > 0)
@@ -73,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits
ticks = Info.Delay; ticks = Info.Delay;
// Cast to long to avoid overflow when multiplying by the health // 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));
} }
} }

View File

@@ -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<string> 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;
}
}
}

View File

@@ -70,6 +70,7 @@ namespace OpenRA.Mods.Common.UpdateRules
new CreateFlashPaletteEffectWarhead(), new CreateFlashPaletteEffectWarhead(),
new ChangeTargetLineDelayToMilliseconds(), new ChangeTargetLineDelayToMilliseconds(),
new ReplaceFacingAngles(), new ReplaceFacingAngles(),
new RenameSelfHealing(),
}) })
}; };

View File

@@ -83,10 +83,10 @@ RMBO.easy:
Inherits: RMBO Inherits: RMBO
Health: Health:
HP: 30000 HP: 30000
SelfHealing: ChangesHealth:
Step: 500 Step: 500
Delay: 10 Delay: 10
HealIfBelow: 50 StartIfBelow: 50
DamageCooldown: 200 DamageCooldown: 200
RenderSprites: RenderSprites:
Image: RMBO Image: RMBO

View File

@@ -176,10 +176,10 @@ RMBO.easy:
Inherits: RMBO Inherits: RMBO
Health: Health:
HP: 30000 HP: 30000
SelfHealing: ChangesHealth:
Step: 500 Step: 500
Delay: 10 Delay: 10
HealIfBelow: 50 StartIfBelow: 50
DamageCooldown: 200 DamageCooldown: 200
RenderSprites: RenderSprites:
Image: RMBO Image: RMBO

View File

@@ -45,10 +45,10 @@ RMBO.easy:
Inherits: RMBO Inherits: RMBO
Health: Health:
HP: 30000 HP: 30000
SelfHealing: ChangesHealth:
Step: 500 Step: 500
Delay: 10 Delay: 10
HealIfBelow: 50 StartIfBelow: 50
DamageCooldown: 200 DamageCooldown: 200
RenderSprites: RenderSprites:
Image: RMBO Image: RMBO

View File

@@ -37,10 +37,10 @@ RMBO.easy:
Inherits: RMBO Inherits: RMBO
Health: Health:
HP: 30000 HP: 30000
SelfHealing: ChangesHealth:
Step: 500 Step: 500
Delay: 10 Delay: 10
HealIfBelow: 50 StartIfBelow: 50
DamageCooldown: 200 DamageCooldown: 200
RenderSprites: RenderSprites:
Image: RMBO Image: RMBO

View File

@@ -105,11 +105,10 @@
ReloadDelayMultiplier@RANK-ELITE: ReloadDelayMultiplier@RANK-ELITE:
RequiresCondition: rank-elite RequiresCondition: rank-elite
Modifier: 75 Modifier: 75
SelfHealing@ELITE: ChangesHealth@ELITE:
Step: 0 Step: 200
PercentageStep: 5
Delay: 100 Delay: 100
HealIfBelow: 100 StartIfBelow: 100
DamageCooldown: 125 DamageCooldown: 125
RequiresCondition: rank-elite RequiresCondition: rank-elite
WithDecoration@RANK-1: WithDecoration@RANK-1:
@@ -429,10 +428,10 @@
WarnProbability: 75 WarnProbability: 75
CrushSound: squish2.aud CrushSound: squish2.aud
Guardable: Guardable:
SelfHealing@HOSPITAL: ChangesHealth@HOSPITAL:
Step: 500 Step: 500
Delay: 100 Delay: 100
HealIfBelow: 100 StartIfBelow: 100
DamageCooldown: 125 DamageCooldown: 125
RequiresCondition: hospitalheal RequiresCondition: hospitalheal
GrantConditionOnPrerequisite@HOSPITAL: GrantConditionOnPrerequisite@HOSPITAL:

View File

@@ -508,10 +508,10 @@ HTNK:
MuzzleSequence: muzzle MuzzleSequence: muzzle
AttackTurreted: AttackTurreted:
WithMuzzleOverlay: WithMuzzleOverlay:
SelfHealing: ChangesHealth:
Step: 500 Step: 500
Delay: 10 Delay: 10
HealIfBelow: 50 StartIfBelow: 50
DamageCooldown: 200 DamageCooldown: 200
SpawnActorOnDeath: SpawnActorOnDeath:
Actor: HTNK.Husk Actor: HTNK.Husk

View File

@@ -38,10 +38,10 @@ carryall.reinforce:
LocalOffset: 0, 0, -128 LocalOffset: 0, 0, -128
RenderSprites: RenderSprites:
Image: carryall Image: carryall
SelfHealing: ChangesHealth:
Step: 50 Step: 50
Delay: 3 Delay: 3
HealIfBelow: 50 StartIfBelow: 50
Buildable: Buildable:
BuildDuration: 750 BuildDuration: 750
BuildDurationModifier: 100 BuildDurationModifier: 100

View File

@@ -84,11 +84,11 @@
InaccuracyMultiplier@RANK-ELITE: InaccuracyMultiplier@RANK-ELITE:
RequiresCondition: rank-elite RequiresCondition: rank-elite
Modifier: 50 Modifier: 50
SelfHealing@ELITE: ChangesHealth@ELITE:
Step: 0 Step: 0
PercentageStep: 4 PercentageStep: 4
Delay: 125 Delay: 125
HealIfBelow: 100 StartIfBelow: 100
DamageCooldown: 125 DamageCooldown: 125
RequiresCondition: rank-elite RequiresCondition: rank-elite
WithDecoration@RANK-1: WithDecoration@RANK-1:

View File

@@ -41,10 +41,10 @@ mcv:
EffectiveOwnerFromOwner: true EffectiveOwnerFromOwner: true
AttractsWorms: AttractsWorms:
Intensity: 700 Intensity: 700
SelfHealing: ChangesHealth:
Step: 50 Step: 50
Delay: 3 Delay: 3
HealIfBelow: 50 StartIfBelow: 50
-RevealOnFire: -RevealOnFire:
harvester: harvester:
@@ -92,10 +92,10 @@ harvester:
WithDockingAnimation: WithDockingAnimation:
AttractsWorms: AttractsWorms:
Intensity: 700 Intensity: 700
SelfHealing: ChangesHealth:
Step: 50 Step: 50
Delay: 3 Delay: 3
HealIfBelow: 50 StartIfBelow: 50
-RevealOnFire: -RevealOnFire:
WithHarvesterPipsDecoration: WithHarvesterPipsDecoration:
Position: BottomLeft Position: BottomLeft
@@ -385,10 +385,10 @@ devastator:
GrantsCondition: meltdown GrantsCondition: meltdown
AttractsWorms: AttractsWorms:
Intensity: 700 Intensity: 700
SelfHealing: ChangesHealth:
Step: 50 Step: 50
Delay: 3 Delay: 3
HealIfBelow: 50 StartIfBelow: 50
Selectable: Selectable:
DecorationBounds: 44,38,0,0 DecorationBounds: 44,38,0,0

View File

@@ -175,10 +175,10 @@ MINVV:
WithSpriteBody: WithSpriteBody:
Tooltip: Tooltip:
Name: Bomb Name: Bomb
SelfHealing: ChangesHealth:
Step: -100 Step: -100
Delay: 1 Delay: 1
HealIfBelow: 101 StartIfBelow: 101
Explodes: Explodes:
Weapon: CrateNuke Weapon: CrateNuke
EmptyWeapon: CrateNuke EmptyWeapon: CrateNuke

View File

@@ -337,10 +337,10 @@ V2RL:
Explodes: Explodes:
Weapon: napalm Weapon: napalm
EmptyWeapon: napalm EmptyWeapon: napalm
SelfHealing: ChangesHealth:
Step: 200 Step: 200
Delay: 1 Delay: 1
HealIfBelow: 40 StartIfBelow: 40
powerproxy.parabombs: powerproxy.parabombs:
AirstrikePower: AirstrikePower:

View File

@@ -163,10 +163,10 @@ PBOX:
EmptyWeapon: MiniNuke EmptyWeapon: MiniNuke
SpawnActorOnDeath: SpawnActorOnDeath:
Actor: 5TNK.Husk Actor: 5TNK.Husk
SelfHealing: ChangesHealth:
Step: 100 Step: 100
Delay: 1 Delay: 1
HealIfBelow: 100 StartIfBelow: 100
DamageCooldown: 150 DamageCooldown: 150
Selectable: Selectable:
Bounds: 44,38,0,-4 Bounds: 44,38,0,-4

View File

@@ -104,11 +104,11 @@
ReloadDelayMultiplier@RANK-ELITE: ReloadDelayMultiplier@RANK-ELITE:
RequiresCondition: rank-elite RequiresCondition: rank-elite
Modifier: 75 Modifier: 75
SelfHealing@ELITE: ChangesHealth@ELITE:
Step: 0 Step: 0
PercentageStep: 5 PercentageStep: 5
Delay: 100 Delay: 100
HealIfBelow: 100 StartIfBelow: 100
DamageCooldown: 125 DamageCooldown: 125
RequiresCondition: rank-elite RequiresCondition: rank-elite
WithDecoration@RANK-1: WithDecoration@RANK-1:
@@ -368,10 +368,10 @@
Guardable: Guardable:
Tooltip: Tooltip:
GenericName: Soldier GenericName: Soldier
SelfHealing@HOSPITAL: ChangesHealth@HOSPITAL:
Step: 500 Step: 500
Delay: 100 Delay: 100
HealIfBelow: 100 StartIfBelow: 100
DamageCooldown: 125 DamageCooldown: 125
RequiresCondition: hospitalheal RequiresCondition: hospitalheal
GrantConditionOnPrerequisite@HOSPITAL: GrantConditionOnPrerequisite@HOSPITAL:

View File

@@ -232,10 +232,10 @@ V2RL:
WithSpriteTurret: WithSpriteTurret:
SpawnActorOnDeath: SpawnActorOnDeath:
Actor: 4TNK.Husk Actor: 4TNK.Husk
SelfHealing: ChangesHealth:
Step: 100 Step: 100
Delay: 3 Delay: 3
HealIfBelow: 50 StartIfBelow: 50
DamageCooldown: 150 DamageCooldown: 150
ProducibleWithLevel: ProducibleWithLevel:
Prerequisites: vehicles.upgraded Prerequisites: vehicles.upgraded
@@ -327,10 +327,10 @@ HARV:
HarvesterHuskModifier: HarvesterHuskModifier:
FullHuskActor: HARV.FullHusk FullHuskActor: HARV.FullHusk
FullnessThreshold: 50 FullnessThreshold: 50
SelfHealing: ChangesHealth:
Step: 100 Step: 100
Delay: 25 Delay: 25
HealIfBelow: 50 StartIfBelow: 50
DamageCooldown: 500 DamageCooldown: 500
Explodes: Explodes:
RequiresCondition: !no-ore RequiresCondition: !no-ore

View File

@@ -31,10 +31,10 @@
AttackTurreted: AttackTurreted:
Voice: Attack Voice: Attack
PauseOnCondition: empdisable PauseOnCondition: empdisable
SelfHealing: ChangesHealth:
Step: 500 Step: 500
Delay: 10 Delay: 10
HealIfBelow: 50 StartIfBelow: 50
DamageCooldown: 200 DamageCooldown: 200
WithVoxelTurret: WithVoxelTurret:
WithVoxelBarrel: WithVoxelBarrel:

View File

@@ -51,10 +51,10 @@
ReloadDelayMultiplier@ELITE: ReloadDelayMultiplier@ELITE:
RequiresCondition: rank-elite RequiresCondition: rank-elite
Modifier: 75 Modifier: 75
SelfHealing@ELITE: ChangesHealth@ELITE:
Step: 200 Step: 200
Delay: 100 Delay: 100
HealIfBelow: 100 StartIfBelow: 100
DamageCooldown: 125 DamageCooldown: 125
RequiresCondition: rank-elite RequiresCondition: rank-elite
WithDecoration@VETERAN: WithDecoration@VETERAN:
@@ -591,10 +591,10 @@
Guard: Guard:
Voice: Move Voice: Move
Guardable: Guardable:
SelfHealing@HOSPITAL: ChangesHealth@HOSPITAL:
Step: 500 Step: 500
Delay: 100 Delay: 100
HealIfBelow: 100 StartIfBelow: 100
DamageCooldown: 125 DamageCooldown: 125
RequiresCondition: hospitalheal RequiresCondition: hospitalheal
GrantConditionOnPrerequisite@HOSPITAL: GrantConditionOnPrerequisite@HOSPITAL:

View File

@@ -79,7 +79,7 @@ MEDIC:
AttackFrontal: AttackFrontal:
WithInfantryBody: WithInfantryBody:
DefaultAttackSequence: heal DefaultAttackSequence: heal
SelfHealing: ChangesHealth:
Step: 500 Step: 500
Delay: 60 Delay: 60
Passenger: Passenger:

View File

@@ -236,7 +236,7 @@ HMEC:
Speed: 42 Speed: 42
Health: Health:
HP: 80000 HP: 80000
SelfHealing: ChangesHealth:
Step: 500 Step: 500
Armor: Armor:
Type: Heavy Type: Heavy

View File

@@ -368,10 +368,10 @@ WEED:
TurnSpeed: 20 TurnSpeed: 20
Health: Health:
HP: 60000 HP: 60000
SelfHealing: ChangesHealth:
Step: 500 Step: 500
Delay: 10 Delay: 10
HealIfBelow: 50 StartIfBelow: 50
DamageCooldown: 200 DamageCooldown: 200
Armor: Armor:
Type: Heavy Type: Heavy

View File

@@ -93,9 +93,9 @@ FLAMEGUY:
IdleSequences: run IdleSequences: run
Health: Health:
HP: 16000 HP: 16000
SelfHealing: ChangesHealth:
Step: -1000 Step: -1000
HealIfBelow: 101 StartIfBelow: 101
ScaredyCat: ScaredyCat:
PanicSequencePrefix: PanicSequencePrefix:
WithDeathAnimation: WithDeathAnimation:

View File

@@ -72,10 +72,10 @@ HARV:
Speed: 71 Speed: 71
Health: Health:
HP: 100000 HP: 100000
SelfHealing: ChangesHealth:
Step: 500 Step: 500
Delay: 10 Delay: 10
HealIfBelow: 50 StartIfBelow: 50
DamageCooldown: 200 DamageCooldown: 200
Armor: Armor:
Type: Heavy Type: Heavy