diff --git a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs index 52e71fd7d3..9ead8be8f8 100644 --- a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs +++ b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs @@ -19,14 +19,17 @@ namespace OpenRA.Mods.Common.Traits { public class CrateSpawnerInfo : ITraitInfo { - [Desc("Minimum number of crates")] + [Desc("Minimum number of crates.")] public readonly int Minimum = 1; - [Desc("Maximum number of crates")] + [Desc("Maximum number of crates.")] public readonly int Maximum = 255; - [Desc("Average time (seconds) between crate spawn")] - public readonly int SpawnInterval = 180; + [Desc("Average time (ticks) between crate spawn.")] + public readonly int SpawnInterval = 180 * 25; + + [Desc("Delay (in ticks) before the first crate spawns.")] + public readonly int InitialSpawnDelay = 300 * 25; [Desc("Which terrain types can we drop on?")] public readonly HashSet ValidGround = new HashSet { "Clear", "Rough", "Road", "Ore", "Beach" }; @@ -34,8 +37,8 @@ namespace OpenRA.Mods.Common.Traits [Desc("Which terrain types count as water?")] public readonly HashSet ValidWater = new HashSet { "Water" }; - [Desc("Chance of generating a water crate instead of a land crate")] - public readonly float WaterChance = .2f; + [Desc("Chance of generating a water crate instead of a land crate.")] + public readonly int WaterChance = 20; [ActorReference] [Desc("Crate actors to drop")] @@ -68,6 +71,8 @@ namespace OpenRA.Mods.Common.Traits { this.info = info; this.self = self; + + ticks = info.InitialSpawnDelay; } public void Tick(Actor self) @@ -77,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits if (--ticks <= 0) { - ticks = info.SpawnInterval * 25; + ticks = info.SpawnInterval; var toSpawn = Math.Max(0, info.Minimum - crates) + (crates < info.Maximum ? 1 : 0); @@ -89,9 +94,8 @@ namespace OpenRA.Mods.Common.Traits void SpawnCrate(Actor self) { - var threshold = 100; - var inWater = self.World.SharedRandom.NextFloat() < info.WaterChance; - var pp = ChooseDropCell(self, inWater, threshold); + var inWater = self.World.SharedRandom.Next(100) < info.WaterChance; + var pp = ChooseDropCell(self, inWater, 100); if (pp == null) return; diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 724fa95639..82c413d521 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.UtilityCommands { var value = float.Parse(input, CultureInfo.InvariantCulture); - if (value < 1) + if (value <= 1) value = (int)Math.Round(value * 100, 0); else value = (int)Math.Round(value, 0); @@ -2158,6 +2158,23 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + if (engineVersion < 20150926) + { + if (node.Key == "CrateSpawner") + { + var interval = node.Value.Nodes.FirstOrDefault(n => n.Key == "SpawnInterval"); + if (interval != null) + { + var value = Exts.ParseIntegerInvariant(interval.Value.Value); + interval.Value.Value = (value * 25).ToString(); + } + + var chance = node.Value.Nodes.FirstOrDefault(n => n.Key == "WaterChance"); + if (chance != null) + ConvertFloatToIntPercentage(ref chance.Value.Value); + } + } + UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/mods/cnc/maps/the-hot-box/map.yaml b/mods/cnc/maps/the-hot-box/map.yaml index 3b41212c4a..b20c52dcc4 100644 --- a/mods/cnc/maps/the-hot-box/map.yaml +++ b/mods/cnc/maps/the-hot-box/map.yaml @@ -213,8 +213,9 @@ Rules: World: CrateSpawner: Maximum: 4 - SpawnInterval: 5 + SpawnInterval: 125 CrateActors: unitcrate + InitialSpawnDelay: 0 -SpawnMPUnits: -MPStartLocations: UNITCRATE: diff --git a/mods/cnc/rules/world.yaml b/mods/cnc/rules/world.yaml index f9a8019633..f8832d807a 100644 --- a/mods/cnc/rules/world.yaml +++ b/mods/cnc/rules/world.yaml @@ -139,7 +139,7 @@ World: CrateSpawner: Minimum: 1 Maximum: 6 - SpawnInterval: 120 + SpawnInterval: 3000 WaterChance: 0 PathFinder: ValidateOrder: diff --git a/mods/d2k/rules/world.yaml b/mods/d2k/rules/world.yaml index c8ac3b0a0b..35c448c614 100644 --- a/mods/d2k/rules/world.yaml +++ b/mods/d2k/rules/world.yaml @@ -62,7 +62,7 @@ World: CrateSpawner: Minimum: 0 Maximum: 2 - SpawnInterval: 60 + SpawnInterval: 1500 WaterChance: 0 ValidGround: Sand, Dune, Rock DomainIndex: diff --git a/mods/ra/maps/drop-zone-battle-of-tikiaki/map.yaml b/mods/ra/maps/drop-zone-battle-of-tikiaki/map.yaml index de6db7ac81..eb59e24aa5 100644 --- a/mods/ra/maps/drop-zone-battle-of-tikiaki/map.yaml +++ b/mods/ra/maps/drop-zone-battle-of-tikiaki/map.yaml @@ -294,8 +294,9 @@ Rules: World: CrateSpawner: Maximum: 3 - SpawnInterval: 5 + SpawnInterval: 125 CrateActors: unitcrate + InitialSpawnDelay: 0 -SpawnMPUnits: -MPStartLocations: UNITCRATE: diff --git a/mods/ra/maps/drop-zone-w/map.yaml b/mods/ra/maps/drop-zone-w/map.yaml index 4914b8b404..13fc0a9e79 100644 --- a/mods/ra/maps/drop-zone-w/map.yaml +++ b/mods/ra/maps/drop-zone-w/map.yaml @@ -199,9 +199,10 @@ Rules: World: CrateSpawner: Maximum: 3 - SpawnInterval: 5 - WaterChance: 1 + SpawnInterval: 125 + WaterChance: 100 CrateActors: unitcrate + InitialSpawnDelay: 0 -SpawnMPUnits: -MPStartLocations: UNITCRATE: diff --git a/mods/ra/maps/drop-zone/map.yaml b/mods/ra/maps/drop-zone/map.yaml index ab0414a3ee..4bbbdd1734 100644 --- a/mods/ra/maps/drop-zone/map.yaml +++ b/mods/ra/maps/drop-zone/map.yaml @@ -189,8 +189,9 @@ Rules: World: CrateSpawner: Maximum: 3 - SpawnInterval: 5 + SpawnInterval: 125 CrateActors: unitcrate + InitialSpawnDelay: 0 -SpawnMPUnits: -MPStartLocations: UNITCRATE: diff --git a/mods/ra/maps/fort-lonestar/map.yaml b/mods/ra/maps/fort-lonestar/map.yaml index 9566e7e263..5220ceee8c 100644 --- a/mods/ra/maps/fort-lonestar/map.yaml +++ b/mods/ra/maps/fort-lonestar/map.yaml @@ -497,7 +497,7 @@ Rules: World: CrateSpawner: Maximum: 1 - SpawnInterval: 100 + SpawnInterval: 2500 CrateActors: fortcrate -SpawnMPUnits: -MPStartLocations: diff --git a/mods/ra/rules/world.yaml b/mods/ra/rules/world.yaml index a899109488..ae2d4193fc 100644 --- a/mods/ra/rules/world.yaml +++ b/mods/ra/rules/world.yaml @@ -105,8 +105,8 @@ World: QuantizedFacings: 16 Minimum: 1 Maximum: 3 - SpawnInterval: 120 - WaterChance: .2 + SpawnInterval: 3000 + WaterChance: 20 DomainIndex: SmudgeLayer@SCORCH: Type: Scorch diff --git a/mods/ts/rules/world.yaml b/mods/ts/rules/world.yaml index 9a2dd718ed..07a385eaa9 100644 --- a/mods/ts/rules/world.yaml +++ b/mods/ts/rules/world.yaml @@ -157,7 +157,7 @@ World: CrateSpawner: Minimum: 1 Maximum: 6 - SpawnInterval: 120 + SpawnInterval: 3000 WaterChance: 0 ValidGround: Clear, Rough, Road, DirtRoad, Tiberium, BlueTiberium PathFinder: