Merge pull request #9060 from abcdefg30/cratespawndelay

Add a InitialSpawnDelay to CrateSpawner
This commit is contained in:
Oliver Brakmann
2015-09-26 01:26:41 +02:00
11 changed files with 47 additions and 22 deletions

View File

@@ -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<string> ValidGround = new HashSet<string> { "Clear", "Rough", "Road", "Ore", "Beach" };
@@ -34,8 +37,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Which terrain types count as water?")]
public readonly HashSet<string> ValidWater = new HashSet<string> { "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;

View File

@@ -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);
}
}

View File

@@ -213,8 +213,9 @@ Rules:
World:
CrateSpawner:
Maximum: 4
SpawnInterval: 5
SpawnInterval: 125
CrateActors: unitcrate
InitialSpawnDelay: 0
-SpawnMPUnits:
-MPStartLocations:
UNITCRATE:

View File

@@ -139,7 +139,7 @@ World:
CrateSpawner:
Minimum: 1
Maximum: 6
SpawnInterval: 120
SpawnInterval: 3000
WaterChance: 0
PathFinder:
ValidateOrder:

View File

@@ -62,7 +62,7 @@ World:
CrateSpawner:
Minimum: 0
Maximum: 2
SpawnInterval: 60
SpawnInterval: 1500
WaterChance: 0
ValidGround: Sand, Dune, Rock
DomainIndex:

View File

@@ -294,8 +294,9 @@ Rules:
World:
CrateSpawner:
Maximum: 3
SpawnInterval: 5
SpawnInterval: 125
CrateActors: unitcrate
InitialSpawnDelay: 0
-SpawnMPUnits:
-MPStartLocations:
UNITCRATE:

View File

@@ -199,9 +199,10 @@ Rules:
World:
CrateSpawner:
Maximum: 3
SpawnInterval: 5
WaterChance: 1
SpawnInterval: 125
WaterChance: 100
CrateActors: unitcrate
InitialSpawnDelay: 0
-SpawnMPUnits:
-MPStartLocations:
UNITCRATE:

View File

@@ -189,8 +189,9 @@ Rules:
World:
CrateSpawner:
Maximum: 3
SpawnInterval: 5
SpawnInterval: 125
CrateActors: unitcrate
InitialSpawnDelay: 0
-SpawnMPUnits:
-MPStartLocations:
UNITCRATE:

View File

@@ -497,7 +497,7 @@ Rules:
World:
CrateSpawner:
Maximum: 1
SpawnInterval: 100
SpawnInterval: 2500
CrateActors: fortcrate
-SpawnMPUnits:
-MPStartLocations:

View File

@@ -105,8 +105,8 @@ World:
QuantizedFacings: 16
Minimum: 1
Maximum: 3
SpawnInterval: 120
WaterChance: .2
SpawnInterval: 3000
WaterChance: 20
DomainIndex:
SmudgeLayer@SCORCH:
Type: Scorch

View File

@@ -157,7 +157,7 @@ World:
CrateSpawner:
Minimum: 1
Maximum: 6
SpawnInterval: 120
SpawnInterval: 3000
WaterChance: 0
ValidGround: Clear, Rough, Road, DirtRoad, Tiberium, BlueTiberium
PathFinder: