From 64b1aea065abe890eb9abd122fdfd1f94f957fb7 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 4 Nov 2015 23:32:24 +0100 Subject: [PATCH 1/3] Only allow spice blooms to grow on certain terrain types --- OpenRA.Mods.D2k/Traits/SpiceBloom.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenRA.Mods.D2k/Traits/SpiceBloom.cs b/OpenRA.Mods.D2k/Traits/SpiceBloom.cs index 26aa51b352..1f06fb200d 100644 --- a/OpenRA.Mods.D2k/Traits/SpiceBloom.cs +++ b/OpenRA.Mods.D2k/Traits/SpiceBloom.cs @@ -34,6 +34,9 @@ namespace OpenRA.Mods.D2k.Traits public readonly string ResourceType = "Spice"; + [Desc("Spice blooms only grow on these terrain types.")] + public readonly HashSet GrowthTerrainTypes = new HashSet(); + [Desc("The weapon to use for spice creation.")] [WeaponReference] public readonly string Weapon = "SpiceExplosion"; @@ -78,6 +81,12 @@ namespace OpenRA.Mods.D2k.Traits public void Tick(Actor self) { + if (!self.World.Map.Contains(self.Location)) + return; + + if (info.GrowthTerrainTypes.Count > 0 && !info.GrowthTerrainTypes.Contains(self.World.Map.GetTerrainInfo(self.Location).Type)) + return; + ticks++; if (ticks >= growTicks) From a175f53ba73d802b27ab91c724becabe0b6a5870 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 8 Nov 2015 13:59:38 +0100 Subject: [PATCH 2/3] Improve spice bloom seeding mechanism Improve seeding target cell determination. Draw out spice seedable cells before loop. Default to null for SpiceBloom.Weapon. Pull spice seeding into its own method. Skip it completely if no seed weapon is defined. --- OpenRA.Mods.D2k/Traits/SpiceBloom.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.D2k/Traits/SpiceBloom.cs b/OpenRA.Mods.D2k/Traits/SpiceBloom.cs index 1f06fb200d..bc258aacc3 100644 --- a/OpenRA.Mods.D2k/Traits/SpiceBloom.cs +++ b/OpenRA.Mods.D2k/Traits/SpiceBloom.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.D2k.Traits [Desc("The weapon to use for spice creation.")] [WeaponReference] - public readonly string Weapon = "SpiceExplosion"; + public readonly string Weapon = null; [Desc("The amount of spice to expel.")] public readonly int[] Pieces = { 2, 12 }; @@ -98,18 +98,19 @@ namespace OpenRA.Mods.D2k.Traits } } - public void Killed(Actor self, AttackInfo e) + void SeedResources(Actor self) { var pieces = self.World.SharedRandom.Next(info.Pieces[0], info.Pieces[1]) * ticks / growTicks; if (pieces < info.Pieces[0]) pieces = info.Pieces[0]; - for (var i = 0; pieces > i; i++) + var cells = self.World.Map.FindTilesInAnnulus(self.Location, 1, info.Range); + + for (var i = 0; i < pieces; i++) { - var cells = OpenRA.Traits.Util.RandomWalk(self.Location, self.World.SharedRandom); - var cell = cells.Take(info.Range).SkipWhile(p => resLayer.GetResource(p) == resType && resLayer.IsFull(p)).Cast().RandomOrDefault(self.World.SharedRandom); + var cell = cells.SkipWhile(p => resLayer.GetResource(p) == resType && resLayer.IsFull(p)).Cast().RandomOrDefault(self.World.SharedRandom); if (cell == null) - cell = cells.Take(info.Range).Random(self.World.SharedRandom); + cell = cells.Random(self.World.SharedRandom); var args = new ProjectileArgs { @@ -140,6 +141,12 @@ namespace OpenRA.Mods.D2k.Traits } }); } + } + + public void Killed(Actor self, AttackInfo e) + { + if (!string.IsNullOrEmpty(info.Weapon)) + SeedResources(self); self.World.AddFrameEndTask(t => t.Add(new DelayedAction(respawnTicks, () => { From c4ca5d649798740359f156f053723fff52ecb332 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 4 Nov 2015 23:34:13 +0100 Subject: [PATCH 3/3] Add invisible spice bloom spawn When real spiceblooms explode, they spawn an invisible spicebloom.spawnpoint actor, which only 'grows' when the cell is of GrowthTerrainType. When 'exploding', it then displays the animation of blowing spice up into the air, and spawns a real spicebloom. This replicates the original behavior where spice blooms would only grow on sand cells that had been harvested and free of spice. --- OpenRA.Mods.D2k/Traits/SpiceBloom.cs | 5 ++++- mods/d2k/rules/arrakis.yaml | 22 ++++++++++++++++++++++ mods/d2k/sequences/misc.yaml | 10 ++++++++++ mods/d2k/weapons.yaml | 9 +++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.D2k/Traits/SpiceBloom.cs b/OpenRA.Mods.D2k/Traits/SpiceBloom.cs index bc258aacc3..197c660669 100644 --- a/OpenRA.Mods.D2k/Traits/SpiceBloom.cs +++ b/OpenRA.Mods.D2k/Traits/SpiceBloom.cs @@ -23,6 +23,9 @@ namespace OpenRA.Mods.D2k.Traits [Desc("Seeds resources by explosive eruptions after accumulation times.")] public class SpiceBloomInfo : ITraitInfo, Requires { + [ActorReference] + public readonly string SpawnActor = "spicebloom.spawnpoint"; + [SequenceReference] public readonly string[] GrowthSequences = { "grow1", "grow2", "grow3" }; @@ -159,7 +162,7 @@ namespace OpenRA.Mods.D2k.Traits new FactionInit(self.Owner.Faction.InternalName), new SkipMakeAnimsInit() }; - self.World.CreateActor(self.Info.Name, td); + self.World.CreateActor(info.SpawnActor, td); }))); } } diff --git a/mods/d2k/rules/arrakis.yaml b/mods/d2k/rules/arrakis.yaml index 18b67265a1..06df17e56d 100644 --- a/mods/d2k/rules/arrakis.yaml +++ b/mods/d2k/rules/arrakis.yaml @@ -1,3 +1,25 @@ +spicebloom.spawnpoint: + HiddenUnderShroud: + Type: CenterPosition + BodyOrientation: + QuantizedFacings: 1 + RenderSprites: + Image: spicebloom + SpiceBloom: + GrowthTerrainTypes: Sand + SpawnActor: spicebloom + GrowthSequences: grow0 + GrowthDelay: 250, 750 + RespawnDelay: 1, 2 + Explodes: + Weapon: BloomSpawn + EmptyWeapon: BloomSpawn + Health: + HP: 9999 + Radius: 1 + Immobile: + OccupiesSpace: false + spicebloom: HiddenUnderShroud: BodyOrientation: diff --git a/mods/d2k/sequences/misc.yaml b/mods/d2k/sequences/misc.yaml index 756bf5dba3..9023b2b42e 100644 --- a/mods/d2k/sequences/misc.yaml +++ b/mods/d2k/sequences/misc.yaml @@ -46,6 +46,11 @@ explosion: BlendMode: Alpha Offset: 12, -10 Tick: 120 + bloomspawn: DATA.R8 + Start: 3980 + Length: 8 + Tick: 120 + Offset: 0, -16 corpse: DATA.R8 Start: 430 Length: 12 @@ -328,6 +333,11 @@ crate: Offset: -16,-16 spicebloom: + grow0: DATA.R8 + Start: 106 + Length: 1 + ZOffset: -1023 + Offset: -16,-16 grow1: DATA.R8 Start: 107 Length: 1 diff --git a/mods/d2k/weapons.yaml b/mods/d2k/weapons.yaml index 26b4542eb0..aa0ede7b75 100644 --- a/mods/d2k/weapons.yaml +++ b/mods/d2k/weapons.yaml @@ -820,3 +820,12 @@ BloomExplosion: DamageTypes: Prone50Percent, TriggerProne, ExplosionDeath AffectsParent: true +BloomSpawn: + Range: 0c1 + Projectile: Bullet + Speed: 1c0 + Blockable: false + Image: null + Warhead@1Eff: CreateEffect + Explosion: bloomspawn +