diff --git a/OpenRA.Mods.Common/Traits/Crates/Crate.cs b/OpenRA.Mods.Common/Traits/Crates/Crate.cs index e5bbf41076..372f658588 100644 --- a/OpenRA.Mods.Common/Traits/Crates/Crate.cs +++ b/OpenRA.Mods.Common/Traits/Crates/Crate.cs @@ -20,9 +20,9 @@ namespace OpenRA.Mods.Common.Traits { public class CrateInfo : TraitInfo, IPositionableInfo, Requires { - [Desc("Length of time (in seconds) until the crate gets removed automatically. " + + [Desc("Length of time (in ticks) until the crate gets removed automatically. " + "A value of zero disables auto-removal.")] - public readonly int Lifetime = 0; + public readonly int Duration = 0; [Desc("Allowed to land on.")] public readonly HashSet TerrainTypes = new HashSet(); @@ -171,7 +171,7 @@ namespace OpenRA.Mods.Common.Traits void ITick.Tick(Actor self) { - if (info.Lifetime != 0 && self.IsInWorld && ++ticks >= info.Lifetime * 25) + if (info.Duration != 0 && self.IsInWorld && ++ticks >= info.Duration) self.Dispose(); } @@ -215,7 +215,7 @@ namespace OpenRA.Mods.Common.Traits self.World.ActorMap.AddInfluence(self, this); } - public bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any) { return self.Location == location && ticks + 1 == info.Lifetime * 25; } + public bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any) { return self.Location == location && ticks + 1 == info.Duration; } public SubCell GetValidSubCell(SubCell preferred = SubCell.Any) { return SubCell.FullCell; } public SubCell GetAvailableSubCell(CPos cell, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, BlockedByActor check = BlockedByActor.All) { diff --git a/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs b/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs index 2476c9f3a9..ab18b2ba47 100644 --- a/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs +++ b/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits public readonly int PanicChance = 100; [Desc("How long (in ticks) the actor should panic for.")] - public readonly int PanicLength = 250; + public readonly int PanicDuration = 250; [Desc("Panic movement speed as a percentage of the normal speed.")] public readonly int PanicSpeedModifier = 200; @@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits if (!Panicking) return; - if (self.World.WorldTick >= panicStartedTick + info.PanicLength) + if (self.World.WorldTick >= panicStartedTick + info.PanicDuration) { self.CancelActivity(); panicStartedTick = 0; diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20201213/ReplaceCrateSecondsWithTicks.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20201213/ReplaceCrateSecondsWithTicks.cs new file mode 100644 index 0000000000..f39807b372 --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/20201213/ReplaceCrateSecondsWithTicks.cs @@ -0,0 +1,45 @@ +#region Copyright & License Information +/* + * Copyright 2007-2021 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 ReplaceCrateSecondsWithTicks : UpdateRule + { + public override string Name => "Changed Crate Lifetime to Duration and use ticks and renamed PanicLength to PanicDuration."; + + public override string Description => + "Crate.Lifetime was the last non-sound-related place to still use 'seconds'\n" + + "by multiplying with 25 internally. Converted to use ticks like everything else.\n" + + "Also renamed Lifetime to Duration and ScaredyCat.PanicLength to PanicDuration to match other places."; + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + foreach (var crateNode in actorNode.ChildrenMatching("Crate")) + { + foreach (var lifetimeNode in crateNode.ChildrenMatching("Lifetime")) + { + var lifetime = lifetimeNode.NodeValue(); + lifetimeNode.Value.Value = FieldSaver.FormatValue(lifetime * 25); + lifetimeNode.RenameKey("Duration"); + } + } + + foreach (var scNode in actorNode.ChildrenMatching("ScaredyCat")) + { + scNode.RenameChildrenMatching("PanicLength", "PanicDuration"); + } + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index a27d43f449..15fc433b52 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -94,6 +94,7 @@ namespace OpenRA.Mods.Common.UpdateRules new RemoveResourceType(), new ConvertBoundsToWDist(), new RemoveSmokeTrailWhenDamaged(), + new ReplaceCrateSecondsWithTicks(), }) }; diff --git a/mods/cnc/rules/misc.yaml b/mods/cnc/rules/misc.yaml index 21954340ff..c2b1d76a35 100644 --- a/mods/cnc/rules/misc.yaml +++ b/mods/cnc/rules/misc.yaml @@ -5,7 +5,7 @@ CRATE.plain: CRATE: Inherits: ^Crate Crate: - Lifetime: 240 + Duration: 6000 GiveCashCrateAction: Amount: 1000 SelectionShares: 20 diff --git a/mods/d2k/rules/misc.yaml b/mods/d2k/rules/misc.yaml index 50c55e5082..651559d613 100644 --- a/mods/d2k/rules/misc.yaml +++ b/mods/d2k/rules/misc.yaml @@ -3,7 +3,7 @@ crate: Tooltip: Name: Crate Crate: - Lifetime: 120 + Duration: 3000 TerrainTypes: Sand, Rock, Transition, Spice, SpiceSand, Dune, Concrete GiveCashCrateAction@1: Amount: 750 diff --git a/mods/ra/rules/campaign-rules.yaml b/mods/ra/rules/campaign-rules.yaml index eab97b7689..6ff5a43ddb 100644 --- a/mods/ra/rules/campaign-rules.yaml +++ b/mods/ra/rules/campaign-rules.yaml @@ -56,7 +56,7 @@ HARV: ^Crate: Crate: - Lifetime: 0 + Duration: 0 MONEYCRATE: Tooltip: diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index c0dc8ec104..fd840c4051 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -1129,7 +1129,7 @@ GenericName: Crate ShowOwnerRow: false Crate: - Lifetime: 180 + Duration: 4500 TerrainTypes: Clear, Rough, Road, Ore, Beach, Water RenderSprites: Palette: effect diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index 67a2d2ee40..9457958d39 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -458,7 +458,7 @@ Tooltip: Name: Crate Crate: - Lifetime: 180 + Duration: 4500 TerrainTypes: Clear, Rough, Sand, Road, DirtRoad, Tiberium, BlueTiberium, Veins, Green, Pavement RenderSprites: Palette: terraindecoration