add spice blooms
This commit is contained in:
@@ -92,6 +92,7 @@
|
|||||||
<Compile Include="Traits\Render\WithCrumbleOverlay.cs" />
|
<Compile Include="Traits\Render\WithCrumbleOverlay.cs" />
|
||||||
<Compile Include="Traits\Render\WithDeliveryOverlay.cs" />
|
<Compile Include="Traits\Render\WithDeliveryOverlay.cs" />
|
||||||
<Compile Include="Traits\Sandworm.cs" />
|
<Compile Include="Traits\Sandworm.cs" />
|
||||||
|
<Compile Include="Traits\SpiceBloom.cs" />
|
||||||
<Compile Include="Traits\TemporaryOwnerManager.cs" />
|
<Compile Include="Traits\TemporaryOwnerManager.cs" />
|
||||||
<Compile Include="Traits\World\BuildableTerrainLayer.cs" />
|
<Compile Include="Traits\World\BuildableTerrainLayer.cs" />
|
||||||
<Compile Include="Traits\World\D2kResourceLayer.cs" />
|
<Compile Include="Traits\World\D2kResourceLayer.cs" />
|
||||||
|
|||||||
148
OpenRA.Mods.D2k/Traits/SpiceBloom.cs
Normal file
148
OpenRA.Mods.D2k/Traits/SpiceBloom.cs
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2015 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. For more information,
|
||||||
|
* see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.Effects;
|
||||||
|
using OpenRA.GameRules;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Primitives;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.D2k.Traits
|
||||||
|
{
|
||||||
|
[Desc("Seeds resources by explosive eruptions after accumulation times.")]
|
||||||
|
public class SpiceBloomInfo : ITraitInfo, Requires<RenderSpritesInfo>
|
||||||
|
{
|
||||||
|
[SequenceReference]
|
||||||
|
public readonly string[] GrowthSequences = { "grow1", "grow2", "grow3" };
|
||||||
|
|
||||||
|
[Desc("The range of time (in ticks) that the spicebloom will take to respawn.")]
|
||||||
|
public readonly int[] RespawnDelay = { 1500, 2500 };
|
||||||
|
|
||||||
|
[Desc("The range of time (in ticks) that the spicebloom will take to grow.")]
|
||||||
|
public readonly int[] GrowthDelay = { 1000, 1500 };
|
||||||
|
|
||||||
|
public readonly string ResourceType = "Spice";
|
||||||
|
|
||||||
|
[Desc("The weapon to use for spice creation.")]
|
||||||
|
[WeaponReference]
|
||||||
|
public readonly string Weapon = "SpiceExplosion";
|
||||||
|
|
||||||
|
[Desc("The amount of spice to expel.")]
|
||||||
|
public readonly int[] Pieces = { 3, 10 };
|
||||||
|
|
||||||
|
[Desc("The maximum distance in cells that spice may be expelled.")]
|
||||||
|
public readonly int Range = 5;
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new SpiceBloom(init, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SpiceBloom : ITick, INotifyKilled
|
||||||
|
{
|
||||||
|
readonly Actor self;
|
||||||
|
readonly SpiceBloomInfo info;
|
||||||
|
readonly ResourceType resType;
|
||||||
|
readonly ResourceLayer resLayer;
|
||||||
|
readonly AnimationWithOffset anim;
|
||||||
|
|
||||||
|
readonly int respawnTicks;
|
||||||
|
readonly int growTicks;
|
||||||
|
int ticks;
|
||||||
|
|
||||||
|
public SpiceBloom(ActorInitializer init, SpiceBloomInfo info)
|
||||||
|
{
|
||||||
|
this.info = info;
|
||||||
|
self = init.Self;
|
||||||
|
|
||||||
|
resLayer = self.World.WorldActor.Trait<ResourceLayer>();
|
||||||
|
resType = self.World.WorldActor.TraitsImplementing<ResourceType>().First(t => t.Info.Name == info.ResourceType);
|
||||||
|
|
||||||
|
var render = self.Trait<RenderSprites>();
|
||||||
|
anim = new AnimationWithOffset(new Animation(init.Self.World, render.GetImage(self)), null, () => self.IsDead);
|
||||||
|
render.Add(anim);
|
||||||
|
|
||||||
|
respawnTicks = self.World.SharedRandom.Next(info.RespawnDelay[0], info.RespawnDelay[1]);
|
||||||
|
growTicks = self.World.SharedRandom.Next(info.GrowthDelay[0], info.GrowthDelay[1]);
|
||||||
|
anim.Animation.Play(info.GrowthSequences[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Tick(Actor self)
|
||||||
|
{
|
||||||
|
ticks++;
|
||||||
|
|
||||||
|
if (ticks >= growTicks)
|
||||||
|
self.Kill(self);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var index = info.GrowthSequences.Length * ticks / growTicks;
|
||||||
|
anim.Animation.Play(info.GrowthSequences[index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Killed(Actor self, AttackInfo e)
|
||||||
|
{
|
||||||
|
var args = new ProjectileArgs
|
||||||
|
{
|
||||||
|
Weapon = self.World.Map.Rules.Weapons[info.Weapon.ToLowerInvariant()],
|
||||||
|
Facing = 0,
|
||||||
|
|
||||||
|
DamageModifiers = self.TraitsImplementing<IFirepowerModifier>()
|
||||||
|
.Select(a => a.GetFirepowerModifier()).ToArray(),
|
||||||
|
|
||||||
|
InaccuracyModifiers = self.TraitsImplementing<IInaccuracyModifier>()
|
||||||
|
.Select(a => a.GetInaccuracyModifier()).ToArray(),
|
||||||
|
|
||||||
|
Source = self.CenterPosition,
|
||||||
|
SourceActor = self,
|
||||||
|
};
|
||||||
|
|
||||||
|
var pieces = self.World.SharedRandom.Next(info.Pieces[0], info.Pieces[1]) * ticks / growTicks;
|
||||||
|
for (var i = 0; pieces > i; 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<CPos?>().RandomOrDefault(self.World.SharedRandom);
|
||||||
|
if (cell == null)
|
||||||
|
cell = cells.Take(info.Range).Random(self.World.SharedRandom);
|
||||||
|
|
||||||
|
args.PassiveTarget = self.World.Map.CenterOfCell(cell.Value);
|
||||||
|
|
||||||
|
self.World.AddFrameEndTask(_ =>
|
||||||
|
{
|
||||||
|
if (args.Weapon.Projectile != null)
|
||||||
|
{
|
||||||
|
var projectile = args.Weapon.Projectile.Create(args);
|
||||||
|
if (projectile != null)
|
||||||
|
self.World.Add(projectile);
|
||||||
|
|
||||||
|
if (args.Weapon.Report != null && args.Weapon.Report.Any())
|
||||||
|
Game.Sound.Play(args.Weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
self.World.AddFrameEndTask(t => t.Add(new DelayedAction(respawnTicks, () =>
|
||||||
|
{
|
||||||
|
var td = new TypeDictionary
|
||||||
|
{
|
||||||
|
new ParentActorInit(self),
|
||||||
|
new LocationInit(self.Location),
|
||||||
|
new CenterPositionInit(self.CenterPosition),
|
||||||
|
new OwnerInit(self.Owner),
|
||||||
|
new FactionInit(self.Owner.Faction.InternalName),
|
||||||
|
new SkipMakeAnimsInit()
|
||||||
|
};
|
||||||
|
self.World.CreateActor(self.Info.Name, td);
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -1,20 +1,29 @@
|
|||||||
spicebloom:
|
spicebloom:
|
||||||
Inherits@1: ^SpriteActor
|
|
||||||
HiddenUnderShroud:
|
HiddenUnderShroud:
|
||||||
WithSpriteBody:
|
BodyOrientation:
|
||||||
Building:
|
QuantizedFacings: 1
|
||||||
Footprint: x
|
AutoSelectionSize:
|
||||||
Dimensions: 1,1
|
RenderSprites:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
|
UseLocation: yes
|
||||||
Tooltip:
|
Tooltip:
|
||||||
Name: Spice Bloom
|
Name: Spice Bloom
|
||||||
SeedsResource:
|
SpiceBloom:
|
||||||
ResourceType: Spice
|
Weapon: SpiceExplosion
|
||||||
Interval: 75
|
Crushable:
|
||||||
WithActiveAnimation:
|
CrushClasses: spicebloom
|
||||||
|
CrushedByFriendlies: true
|
||||||
RadarColorFromTerrain:
|
RadarColorFromTerrain:
|
||||||
Terrain: Spice
|
Terrain: Spice
|
||||||
WithMakeAnimation:
|
Immobile:
|
||||||
|
Health:
|
||||||
|
HP: 1
|
||||||
|
Radius: 512
|
||||||
|
Targetable:
|
||||||
|
TargetTypes: Ground
|
||||||
|
RequiresForceFire: yes
|
||||||
|
Armor:
|
||||||
|
Type: None
|
||||||
|
|
||||||
sandworm:
|
sandworm:
|
||||||
Inherits@1: ^SpriteActor
|
Inherits@1: ^SpriteActor
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
Inherits@2: ^GainsExperience
|
Inherits@2: ^GainsExperience
|
||||||
Inherits@3: ^SpriteActor
|
Inherits@3: ^SpriteActor
|
||||||
Mobile:
|
Mobile:
|
||||||
Crushes: crate
|
Crushes: crate, spicebloom
|
||||||
TerrainSpeeds:
|
TerrainSpeeds:
|
||||||
Sand: 100
|
Sand: 100
|
||||||
Rock: 100
|
Rock: 100
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
^Tank:
|
^Tank:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Vehicle
|
||||||
Mobile:
|
Mobile:
|
||||||
Crushes: crate, infantry
|
Crushes: crate, infantry, spicebloom
|
||||||
|
|
||||||
^Husk:
|
^Husk:
|
||||||
Inherits@1: ^SpriteActor
|
Inherits@1: ^SpriteActor
|
||||||
@@ -165,7 +165,7 @@
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 6c0
|
Range: 6c0
|
||||||
Mobile:
|
Mobile:
|
||||||
Crushes: crate
|
Crushes: crate, spicebloom
|
||||||
SharesCell: true
|
SharesCell: true
|
||||||
TerrainSpeeds:
|
TerrainSpeeds:
|
||||||
Sand: 100
|
Sand: 100
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ mcv:
|
|||||||
Type: light
|
Type: light
|
||||||
Mobile:
|
Mobile:
|
||||||
Speed: 31
|
Speed: 31
|
||||||
Crushes: crate, infantry
|
Crushes: crate, infantry, spicebloom
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 8c0
|
Range: 8c0
|
||||||
MustBeDestroyed:
|
MustBeDestroyed:
|
||||||
@@ -73,7 +73,7 @@ harvester:
|
|||||||
Type: harvester
|
Type: harvester
|
||||||
Mobile:
|
Mobile:
|
||||||
Speed: 43
|
Speed: 43
|
||||||
Crushes: crate, infantry
|
Crushes: crate, infantry, spicebloom
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 4c0
|
Range: 4c0
|
||||||
Explodes:
|
Explodes:
|
||||||
@@ -184,7 +184,6 @@ siege_tank:
|
|||||||
Mobile:
|
Mobile:
|
||||||
Speed: 43
|
Speed: 43
|
||||||
ROT: 3
|
ROT: 3
|
||||||
Crushes: crate, infantry
|
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 8c0
|
Range: 8c0
|
||||||
Turreted:
|
Turreted:
|
||||||
@@ -304,7 +303,6 @@ devastator:
|
|||||||
Mobile:
|
Mobile:
|
||||||
ROT: 3
|
ROT: 3
|
||||||
Speed: 31
|
Speed: 31
|
||||||
Crushes: crate, infantry
|
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 7c0
|
Range: 7c0
|
||||||
Armament:
|
Armament:
|
||||||
@@ -440,7 +438,6 @@ deviator:
|
|||||||
Mobile:
|
Mobile:
|
||||||
Speed: 75
|
Speed: 75
|
||||||
ROT: 5
|
ROT: 5
|
||||||
Crushes: crate, infantry
|
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 8c0
|
Range: 8c0
|
||||||
Turreted:
|
Turreted:
|
||||||
@@ -499,7 +496,6 @@ combat_tank_o:
|
|||||||
Mobile:
|
Mobile:
|
||||||
Speed: 85
|
Speed: 85
|
||||||
ROT: 5
|
ROT: 5
|
||||||
Crushes: crate, infantry
|
|
||||||
Health:
|
Health:
|
||||||
HP: 1800
|
HP: 1800
|
||||||
SpawnActorOnDeath:
|
SpawnActorOnDeath:
|
||||||
|
|||||||
@@ -327,19 +327,20 @@ crate:
|
|||||||
ZOffset: -511
|
ZOffset: -511
|
||||||
Offset: -16,-16
|
Offset: -16,-16
|
||||||
|
|
||||||
# TODO: keep the redundant spicebloom.shp for now for the awful WinForms maps editor
|
|
||||||
spicebloom:
|
spicebloom:
|
||||||
make: DATA.R8
|
grow1: DATA.R8
|
||||||
Start: 107
|
Start: 107
|
||||||
Length: 3
|
Length: 1
|
||||||
ZOffset: -1023
|
ZOffset: -1023
|
||||||
Offset: -16,-16
|
Offset: -16,-16
|
||||||
active: DATA.R8
|
grow2: DATA.R8
|
||||||
Start: 109
|
Start: 108
|
||||||
|
Length: 1
|
||||||
ZOffset: -1023
|
ZOffset: -1023
|
||||||
Offset: -16,-16
|
Offset: -16,-16
|
||||||
idle: DATA.R8
|
grow3: DATA.R8
|
||||||
Start: 109
|
Start: 109
|
||||||
|
Length: 1
|
||||||
ZOffset: -1023
|
ZOffset: -1023
|
||||||
Offset: -16,-16
|
Offset: -16,-16
|
||||||
|
|
||||||
|
|||||||
@@ -829,6 +829,13 @@ SardDeath:
|
|||||||
ImpactSound: EXPLSML2.WAV
|
ImpactSound: EXPLSML2.WAV
|
||||||
|
|
||||||
SpiceExplosion:
|
SpiceExplosion:
|
||||||
|
Report: EXPLMD1.WAV
|
||||||
|
Projectile: Bullet
|
||||||
|
Speed: 50, 75
|
||||||
|
High: true
|
||||||
|
Angle: 91, 264
|
||||||
|
Trail: large_trail
|
||||||
|
Image: null
|
||||||
Warhead@1Dam: SpreadDamage
|
Warhead@1Dam: SpreadDamage
|
||||||
Spread: 480
|
Spread: 480
|
||||||
Falloff: 100, 100, 100, 95, 60, 25, 0
|
Falloff: 100, 100, 100, 95, 60, 25, 0
|
||||||
|
|||||||
Reference in New Issue
Block a user