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
{
[Desc("Attach this to actors which should be able to regenerate their health points.")]
class SelfHealingInfo : ConditionalTraitInfo, Requires<IHealthInfo>
[Desc("Attach this to actors which should regenerate or lose health points over time.")]
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;
[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<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;
@@ -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<IHealth>();
@@ -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));
}
}

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 ChangeTargetLineDelayToMilliseconds(),
new ReplaceFacingAngles(),
new RenameSelfHealing(),
})
};

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

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

View File

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

View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

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

View File

@@ -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:

View File

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

View File

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

View File

@@ -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

View File

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

View File

@@ -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