Skip to content

Commit

Permalink
Merge pull request #12969 from atlimit8/UncloakOnDamageSign
Browse files Browse the repository at this point in the history
UncloakOn: Damage, Heal, SelfHeal split
  • Loading branch information
abcdefg30 committed Mar 17, 2017
2 parents eb77c57 + abad50d commit fbd62c2
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/Activities/Repair.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public override Activity Tick(Actor self)
return this;
}

self.InflictDamage(self, new Damage(-hpToRepair));
self.InflictDamage(host.Actor, new Damage(-hpToRepair));

foreach (var depot in host.Actor.TraitsImplementing<INotifyRepair>())
depot.Repairing(host.Actor, self);
Expand Down
14 changes: 11 additions & 3 deletions OpenRA.Mods.Common/Traits/Cloak.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public enum UncloakType
Infiltrate = 8,
Demolish = 16,
Damage = 32,
Dock = 64
Heal = 64,
SelfHeal = 128,
Dock = 256
}

[Desc("This unit can cloak and uncloak in specific situations.")]
Expand All @@ -41,7 +43,7 @@ public class CloakInfo : ConditionalTraitInfo
[Desc("Measured in game ticks.")]
public readonly int CloakDelay = 30;

[Desc("Events leading to the actor getting uncloaked. Possible values are: Attack, Move, Unload, Infiltrate, Demolish, Dock and Damage")]
[Desc("Events leading to the actor getting uncloaked. Possible values are: Attack, Move, Unload, Infiltrate, Demolish, Dock, Damage, Heal and SelfHeal.")]
public readonly UncloakType UncloakOn = UncloakType.Attack
| UncloakType.Unload | UncloakType.Infiltrate | UncloakType.Demolish | UncloakType.Dock;

Expand Down Expand Up @@ -101,7 +103,13 @@ void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel

void INotifyDamage.Damaged(Actor self, AttackInfo e)
{
if (Info.UncloakOn.HasFlag(UncloakType.Damage))
if (e.Damage.Value == 0)
return;

var type = e.Damage.Value < 0
? (e.Attacker == self ? UncloakType.SelfHeal : UncloakType.Heal)
: UncloakType.Damage;
if (Info.UncloakOn.HasFlag(type))
Uncloak();
}

Expand Down
5 changes: 5 additions & 0 deletions OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,11 @@ internal static void UpgradeActorRules(ModData modData, int engineVersion, ref L
if (node.Key.StartsWith("DisguiseToolTip", StringComparison.Ordinal))
RenameNodeKey(node, "DisguiseTooltip");

// Split UncloakOn: Damage => Damage, Heal, SelfHeal
if (engineVersion < 20170315)
if (node.Key.StartsWith("UncloakOn", StringComparison.Ordinal))
node.Value.Value = node.Value.Value.Replace("Damage", "Damage, Heal, SelfHeal");

UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
}

Expand Down
4 changes: 2 additions & 2 deletions mods/d2k/rules/infantry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ fremen:
Cloak:
InitialDelay: 85
CloakDelay: 85
UncloakOn: Attack, Unload, Infiltrate, Demolish, Dock, Damage
UncloakOn: Attack, Unload, Infiltrate, Demolish, Dock, Damage, Heal
CloakSound: STEALTH1.WAV
UncloakSound: STEALTH2.WAV
IsPlayerPalette: true
Expand Down Expand Up @@ -251,7 +251,7 @@ saboteur:
CloakDelay: 85
CloakSound: STEALTH1.WAV
UncloakSound: STEALTH2.WAV
UncloakOn: Attack, Unload, Infiltrate, Demolish, Move, Damage
UncloakOn: Attack, Unload, Infiltrate, Demolish, Move, Damage, Heal
IsPlayerPalette: true
RequiresCondition: !cloak-force-disabled
GrantConditionOnDamageState@UNCLOAK:
Expand Down
2 changes: 1 addition & 1 deletion mods/d2k/rules/vehicles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ stealth_raider:
Cloak:
InitialDelay: 45
CloakDelay: 90
UncloakOn: Attack, Unload, Infiltrate, Demolish, Dock, Damage
UncloakOn: Attack, Unload, Infiltrate, Demolish, Dock, Damage, Heal
CloakSound: STEALTH1.WAV
UncloakSound: STEALTH2.WAV
IsPlayerPalette: true
Expand Down
2 changes: 1 addition & 1 deletion mods/ts/rules/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
IsPlayerPalette: true
CloakSound: cloak5.aud
UncloakSound: cloak5.aud
UncloakOn: Attack, Unload, Infiltrate, Demolish, Damage
UncloakOn: Attack, Unload, Infiltrate, Demolish, Damage, Heal
ExternalCondition@CLOAKGENERATOR:
Condition: cloakgenerator
ExternalCondition@CRATE-CLOAK:
Expand Down
2 changes: 1 addition & 1 deletion mods/ts/rules/nod-vehicles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ STNK:
CloakSound: cloak5.aud
UncloakSound: cloak5.aud
IsPlayerPalette: true
UncloakOn: Attack, Unload, Infiltrate, Demolish, Damage
UncloakOn: Attack, Unload, Infiltrate, Demolish, Damage, Heal
RequiresCondition: !cloak-force-disabled
GrantConditionOnDamageState@UNCLOAK:
Condition: cloak-force-disabled
Expand Down

0 comments on commit fbd62c2

Please sign in to comment.