From a2af88da219370a2eac127970cb931889adc3085 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Thu, 13 Aug 2015 23:09:27 +0200 Subject: [PATCH 1/8] Add a InitialSpawnDelay to CrateSpawner --- OpenRA.Mods.Common/Traits/World/CrateSpawner.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs index 52e71fd7d3..ac94678333 100644 --- a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs +++ b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs @@ -28,6 +28,9 @@ namespace OpenRA.Mods.Common.Traits [Desc("Average time (seconds) between crate spawn")] public readonly int SpawnInterval = 180; + [Desc("Delay (in seconds) before the first crate spawns.")] + public readonly int InitialSpawnDelay = 300; + [Desc("Which terrain types can we drop on?")] public readonly HashSet ValidGround = new HashSet { "Clear", "Rough", "Road", "Ore", "Beach" }; @@ -68,6 +71,8 @@ namespace OpenRA.Mods.Common.Traits { this.info = info; this.self = self; + + ticks = info.InitialSpawnDelay * 25; } public void Tick(Actor self) From 10c2a897f4ccd7da1654ecbfd02e8339f43bb667 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Thu, 13 Aug 2015 23:09:43 +0200 Subject: [PATCH 2/8] Small code cleanup --- OpenRA.Mods.Common/Traits/World/CrateSpawner.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs index ac94678333..e95fa237a5 100644 --- a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs +++ b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs @@ -19,13 +19,13 @@ 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")] + [Desc("Average time (seconds) between crate spawn.")] public readonly int SpawnInterval = 180; [Desc("Delay (in seconds) before the first crate spawns.")] @@ -37,7 +37,7 @@ 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")] + [Desc("Chance of generating a water crate instead of a land crate.")] public readonly float WaterChance = .2f; [ActorReference] @@ -94,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 pp = ChooseDropCell(self, inWater, 100); if (pp == null) return; From 7fd3ae7db948dca1c864ff3c54166940281c08a3 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Thu, 13 Aug 2015 23:14:17 +0200 Subject: [PATCH 3/8] Adjust the dropzone maps --- mods/cnc/maps/the-hot-box/map.yaml | 1 + mods/ra/maps/drop-zone-battle-of-tikiaki/map.yaml | 1 + mods/ra/maps/drop-zone-w/map.yaml | 1 + mods/ra/maps/drop-zone/map.yaml | 1 + 4 files changed, 4 insertions(+) diff --git a/mods/cnc/maps/the-hot-box/map.yaml b/mods/cnc/maps/the-hot-box/map.yaml index 3b41212c4a..dc2ce204f0 100644 --- a/mods/cnc/maps/the-hot-box/map.yaml +++ b/mods/cnc/maps/the-hot-box/map.yaml @@ -215,6 +215,7 @@ Rules: Maximum: 4 SpawnInterval: 5 CrateActors: unitcrate + InitialSpawnDelay: 0 -SpawnMPUnits: -MPStartLocations: UNITCRATE: 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..e4beae812f 100644 --- a/mods/ra/maps/drop-zone-battle-of-tikiaki/map.yaml +++ b/mods/ra/maps/drop-zone-battle-of-tikiaki/map.yaml @@ -296,6 +296,7 @@ Rules: Maximum: 3 SpawnInterval: 5 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..6bc46f5b68 100644 --- a/mods/ra/maps/drop-zone-w/map.yaml +++ b/mods/ra/maps/drop-zone-w/map.yaml @@ -202,6 +202,7 @@ Rules: SpawnInterval: 5 WaterChance: 1 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..70464b0e7b 100644 --- a/mods/ra/maps/drop-zone/map.yaml +++ b/mods/ra/maps/drop-zone/map.yaml @@ -191,6 +191,7 @@ Rules: Maximum: 3 SpawnInterval: 5 CrateActors: unitcrate + InitialSpawnDelay: 0 -SpawnMPUnits: -MPStartLocations: UNITCRATE: From 277f9acb892ab07fb25c224d01ca62529a128a12 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Sun, 16 Aug 2015 22:40:25 +0200 Subject: [PATCH 4/8] Replace seconds by ticks --- OpenRA.Mods.Common/Traits/World/CrateSpawner.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs index e95fa237a5..27c5021b83 100644 --- a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs +++ b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs @@ -25,11 +25,11 @@ namespace OpenRA.Mods.Common.Traits [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 seconds) before the first crate spawns.")] - public readonly int InitialSpawnDelay = 300; + [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" }; @@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits this.info = info; this.self = self; - ticks = info.InitialSpawnDelay * 25; + ticks = info.InitialSpawnDelay; } public void Tick(Actor self) @@ -82,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); From e7c62b070b1e8b720517971bd9899b1ef0237699 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Sun, 16 Aug 2015 23:01:22 +0200 Subject: [PATCH 5/8] Add an upgrade rule for the seconds -> ticks change and update the default mods --- OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs | 13 +++++++++++++ mods/cnc/maps/the-hot-box/map.yaml | 2 +- mods/cnc/rules/world.yaml | 2 +- mods/d2k/rules/world.yaml | 2 +- mods/ra/maps/drop-zone-battle-of-tikiaki/map.yaml | 2 +- mods/ra/maps/drop-zone-w/map.yaml | 2 +- mods/ra/maps/drop-zone/map.yaml | 2 +- mods/ra/maps/fort-lonestar/map.yaml | 2 +- mods/ra/rules/world.yaml | 2 +- mods/ts/rules/world.yaml | 2 +- 10 files changed, 22 insertions(+), 9 deletions(-) diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 724fa95639..00b5a112f4 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -2158,6 +2158,19 @@ 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(); + } + } + } + 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 dc2ce204f0..b20c52dcc4 100644 --- a/mods/cnc/maps/the-hot-box/map.yaml +++ b/mods/cnc/maps/the-hot-box/map.yaml @@ -213,7 +213,7 @@ Rules: World: CrateSpawner: Maximum: 4 - SpawnInterval: 5 + SpawnInterval: 125 CrateActors: unitcrate InitialSpawnDelay: 0 -SpawnMPUnits: 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 e4beae812f..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,7 +294,7 @@ Rules: World: CrateSpawner: Maximum: 3 - SpawnInterval: 5 + SpawnInterval: 125 CrateActors: unitcrate InitialSpawnDelay: 0 -SpawnMPUnits: diff --git a/mods/ra/maps/drop-zone-w/map.yaml b/mods/ra/maps/drop-zone-w/map.yaml index 6bc46f5b68..2f0de1c019 100644 --- a/mods/ra/maps/drop-zone-w/map.yaml +++ b/mods/ra/maps/drop-zone-w/map.yaml @@ -199,7 +199,7 @@ Rules: World: CrateSpawner: Maximum: 3 - SpawnInterval: 5 + SpawnInterval: 125 WaterChance: 1 CrateActors: unitcrate InitialSpawnDelay: 0 diff --git a/mods/ra/maps/drop-zone/map.yaml b/mods/ra/maps/drop-zone/map.yaml index 70464b0e7b..4bbbdd1734 100644 --- a/mods/ra/maps/drop-zone/map.yaml +++ b/mods/ra/maps/drop-zone/map.yaml @@ -189,7 +189,7 @@ Rules: World: CrateSpawner: Maximum: 3 - SpawnInterval: 5 + SpawnInterval: 125 CrateActors: unitcrate InitialSpawnDelay: 0 -SpawnMPUnits: 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..49e8a63df1 100644 --- a/mods/ra/rules/world.yaml +++ b/mods/ra/rules/world.yaml @@ -105,7 +105,7 @@ World: QuantizedFacings: 16 Minimum: 1 Maximum: 3 - SpawnInterval: 120 + SpawnInterval: 3000 WaterChance: .2 DomainIndex: SmudgeLayer@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: From 589e673aa909120d2f1e9ded9b7f5c941dd6e02b Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Sun, 16 Aug 2015 23:09:03 +0200 Subject: [PATCH 6/8] Replace the float WaterChance by an integer percentage --- OpenRA.Mods.Common/Traits/World/CrateSpawner.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs index 27c5021b83..9ead8be8f8 100644 --- a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs +++ b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs @@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits public readonly HashSet ValidWater = new HashSet { "Water" }; [Desc("Chance of generating a water crate instead of a land crate.")] - public readonly float WaterChance = .2f; + public readonly int WaterChance = 20; [ActorReference] [Desc("Crate actors to drop")] @@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits void SpawnCrate(Actor self) { - var inWater = self.World.SharedRandom.NextFloat() < info.WaterChance; + var inWater = self.World.SharedRandom.Next(100) < info.WaterChance; var pp = ChooseDropCell(self, inWater, 100); if (pp == null) From ccf184413eb44136a4c049e277a12f4f868c166d Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Sun, 16 Aug 2015 23:33:31 +0200 Subject: [PATCH 7/8] Add an upgrade rule for the float to int percentage change --- OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs | 4 ++++ mods/ra/maps/drop-zone-w/map.yaml | 2 +- mods/ra/rules/world.yaml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 00b5a112f4..48570cf6ed 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -2168,6 +2168,10 @@ namespace OpenRA.Mods.Common.UtilityCommands 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); } } diff --git a/mods/ra/maps/drop-zone-w/map.yaml b/mods/ra/maps/drop-zone-w/map.yaml index 2f0de1c019..13fc0a9e79 100644 --- a/mods/ra/maps/drop-zone-w/map.yaml +++ b/mods/ra/maps/drop-zone-w/map.yaml @@ -200,7 +200,7 @@ Rules: CrateSpawner: Maximum: 3 SpawnInterval: 125 - WaterChance: 1 + WaterChance: 100 CrateActors: unitcrate InitialSpawnDelay: 0 -SpawnMPUnits: diff --git a/mods/ra/rules/world.yaml b/mods/ra/rules/world.yaml index 49e8a63df1..ae2d4193fc 100644 --- a/mods/ra/rules/world.yaml +++ b/mods/ra/rules/world.yaml @@ -106,7 +106,7 @@ World: Minimum: 1 Maximum: 3 SpawnInterval: 3000 - WaterChance: .2 + WaterChance: 20 DomainIndex: SmudgeLayer@SCORCH: Type: Scorch From 4c52d10aaf358dcab33665c8ed0bbc48b35b4de4 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Sun, 16 Aug 2015 23:34:12 +0200 Subject: [PATCH 8/8] Fix an oversight in ConvertFloatToIntPercentage --- OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 48570cf6ed..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);