Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added destructible concrete for Dune 2000 #15610

Merged
merged 1 commit into from Sep 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj
Expand Up @@ -83,6 +83,7 @@
<Compile Include="Traits\World\D2kEditorResourceLayer.cs" />
<Compile Include="Lint\CheckImportActors.cs" />
<Compile Include="PackageLoaders\D2kSoundResources.cs" />
<Compile Include="Warheads\DamagesConcreteWarhead.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
Expand Down
23 changes: 23 additions & 0 deletions OpenRA.Mods.D2k/Traits/World/BuildableTerrainLayer.cs
Expand Up @@ -21,6 +21,9 @@ public class BuildableTerrainLayerInfo : ITraitInfo
[Desc("Palette to render the layer sprites in.")]
public readonly string Palette = TileSet.TerrainPaletteInternalName;

[Desc("The hitpoints, which can be reduced by the DamagesConcreteWarhead.")]
public readonly int MaxStrength = 9000;

public object Create(ActorInitializer init) { return new BuildableTerrainLayer(init.Self, this); }
}

Expand All @@ -29,6 +32,7 @@ public class BuildableTerrainLayer : IRenderOverlay, IWorldLoaded, ITickRender,
readonly BuildableTerrainLayerInfo info;
readonly Dictionary<CPos, Sprite> dirty = new Dictionary<CPos, Sprite>();
readonly Map map;
readonly CellLayer<int> strength;

TerrainSpriteLayer render;
Theater theater;
Expand All @@ -38,6 +42,7 @@ public BuildableTerrainLayer(Actor self, BuildableTerrainLayerInfo info)
{
this.info = info;
map = self.World.Map;
strength = new CellLayer<int>(self.World.Map);
}

public void WorldLoaded(World w, WorldRenderer wr)
Expand All @@ -49,12 +54,30 @@ public void WorldLoaded(World w, WorldRenderer wr)
public void AddTile(CPos cell, TerrainTile tile)
{
map.CustomTerrain[cell] = map.Rules.TileSet.GetTerrainIndex(tile);
strength[cell] = info.MaxStrength;

// Terrain tiles define their origin at the topleft
var s = theater.TileSprite(tile);
dirty[cell] = new Sprite(s.Sheet, s.Bounds, s.ZRamp, float2.Zero, s.Channel, s.BlendMode);
}

public void HitTile(CPos cell, int damage)
{
if (strength[cell] == 0)
return;

strength[cell] = strength[cell] - damage;
if (strength[cell] < 1)
RemoveTile(cell);
}

public void RemoveTile(CPos cell)
{
map.CustomTerrain[cell] = byte.MaxValue;
strength[cell] = 0;
dirty[cell] = null;
}

void ITickRender.TickRender(WorldRenderer wr, Actor self)
{
var remove = new List<CPos>();
Expand Down
34 changes: 34 additions & 0 deletions OpenRA.Mods.D2k/Warheads/DamagesConcreteWarhead.cs
@@ -0,0 +1,34 @@
#region Copyright & License Information
/*
* Copyright 2007-2018 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, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion

using System.Collections.Generic;
using OpenRA.Mods.Common.Warheads;
using OpenRA.Mods.D2k.Traits;
using OpenRA.Traits;

namespace OpenRA.Mods.D2k.Warheads
{
[Desc("Interacts with the BuildableTerrainLayer trait.")]
public class DamagesConcreteWarhead : Warhead
{
[Desc("How much damage to deal.")]
[FieldLoader.Require]
public readonly int Damage = 0;

public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
{
var world = firedBy.World;
var layer = world.WorldActor.Trait<BuildableTerrainLayer>();
var cell = world.Map.CellContaining(target.CenterPosition);
layer.HitTile(cell, Damage);
}
}
}
6 changes: 6 additions & 0 deletions mods/d2k/weapons/debris.yaml
Expand Up @@ -32,6 +32,8 @@ Debris:
Warhead@3Eff: CreateEffect
Explosions: tiny_explosion
ImpactActors: false
Warhead@4Concrete: DamagesConcrete
Damage: 300

Debris2:
Inherits: Debris
Expand All @@ -56,6 +58,8 @@ Debris2:
DamageTypes: Prone50Percent, TriggerProne, ExplosionDeath
Warhead@3Eff: CreateEffect
Explosions: small_napalm
Warhead@4Concrete: DamagesConcrete
Damage: 2250

Debris3:
Inherits: Debris2
Expand All @@ -64,6 +68,8 @@ Debris3:
TrailImage: small_trail2
Warhead@1Dam: SpreadDamage
Damage: 1500
Warhead@4Concrete: DamagesConcrete
Damage: 1350

Debris4:
Inherits: Debris2
Expand Down
8 changes: 8 additions & 0 deletions mods/d2k/weapons/largeguns.yaml
Expand Up @@ -26,6 +26,8 @@
Warhead@3Eff: CreateEffect
Explosions: small_napalm
ImpactActors: false
Warhead@4Concrete: DamagesConcrete
Damage: 540

110mm_Gun:
Inherits: ^Cannon
Expand All @@ -37,6 +39,8 @@
Blockable: false
Warhead@1Dam: SpreadDamage
Damage: 2900
Warhead@2Concrete: DamagesConcrete
Damage: 2900

80mm_A:
Inherits: ^Cannon
Expand Down Expand Up @@ -69,6 +73,8 @@ DevBullet:
invulnerable: 0
cy: 40
harvester: 100
Warhead@2Concrete: DamagesConcrete
Damage: 3250
Warhead@3Eff: CreateEffect
Explosions: shockwave
ImpactSounds: EXPLMD1.WAV
Expand Down Expand Up @@ -101,6 +107,8 @@ DevBullet:
cy: 20
harvester: 25
DamageTypes: Prone50Percent, TriggerProne, ExplosionDeath
Warhead@2Concrete: DamagesConcrete
Damage: 5625
Warhead@3Eff: CreateEffect
Explosions: med_explosion
ImpactSounds: EXPLMD2.WAV
10 changes: 10 additions & 0 deletions mods/d2k/weapons/missiles.yaml
Expand Up @@ -32,6 +32,8 @@
Explosions: tiny_explosion
ImpactActors: false
ValidTargets: Ground, Air
Warhead@3Concrete: DamagesConcrete
Damage: 240

^Missile:
Inherits: ^Rocket
Expand Down Expand Up @@ -62,6 +64,8 @@
invulnerable: 0
cy: 30
harvester: 50
Warhead@2Concrete: DamagesConcrete
Damage: 720
Warhead@3Eff: CreateEffect
Explosions: small_explosion
ImpactSounds: EXPLSML1.WAV
Expand All @@ -88,6 +92,8 @@ Rocket:
invulnerable: 0
cy: 20
harvester: 50
Warhead@2Concrete: DamagesConcrete
Damage: 625
Warhead@3Eff: CreateEffect
Explosions: rocket_explosion
ExplosionPalette: effect75alpha
Expand Down Expand Up @@ -117,6 +123,8 @@ mtank_pri:
Warhead@1Dam: SpreadDamage
Damage: 6000
ValidTargets: Ground, Air
Warhead@2Concrete: DamagesConcrete
Damage: 900

DeviatorMissile:
Inherits: ^Missile
Expand Down Expand Up @@ -151,3 +159,5 @@ DeviatorMissile:
Range: 512
Duration: 375
InvalidTargets: Infantry, Structure
Warhead@5Concrete: DamagesConcrete
Damage: 1000
16 changes: 16 additions & 0 deletions mods/d2k/weapons/other.yaml
Expand Up @@ -46,6 +46,8 @@ Sound:
cy: 20
harvester: 50
DamageTypes: Prone50Percent, TriggerProne, SoundDeath
Warhead@3Concrete: DamagesConcrete
Damage: 1720

WormJaw:
ReloadDelay: 10
Expand Down Expand Up @@ -86,6 +88,8 @@ OrniBomb:
Explosions: large_explosion
ImpactSounds: EXPLSML4.WAV
ImpactActors: false
Warhead@4Concrete: DamagesConcrete
Damage: 6750

Crush:
Warhead@1Dam: SpreadDamage
Expand Down Expand Up @@ -122,6 +126,8 @@ Atomic:
Explosions: nuke
ImpactSounds: EXPLLG2.WAV
ImpactActors: false
Warhead@3Concrete: DamagesConcrete
Damage: 24300

CrateNuke:
Inherits: Atomic
Expand Down Expand Up @@ -152,6 +158,8 @@ CrateExplosion:
Explosions: large_explosion
ImpactSounds: EXPLSML4.WAV
ImpactActors: false
Warhead@2Concrete: DamagesConcrete
Damage: 4500

UnitExplodeSmall:
Warhead@1Eff: CreateEffect
Expand Down Expand Up @@ -212,6 +220,8 @@ grenade:
Explosions: med_explosion
ImpactSounds: EXPLMD2.WAV
ImpactActors: false
Warhead@4Concrete: DamagesConcrete
Damage: 1875

GrenDeath:
Warhead@1Dam: SpreadDamage
Expand All @@ -233,6 +243,8 @@ GrenDeath:
Explosions: building
ImpactSounds: EXPLSML4.WAV
ImpactActors: false
Warhead@4Concrete: DamagesConcrete
Damage: 1875

SardDeath:
Warhead@1Dam: SpreadDamage
Expand All @@ -255,6 +267,8 @@ SardDeath:
Explosions: small_napalm
ImpactSounds: EXPLSML2.WAV
ImpactActors: false
Warhead@4Concrete: DamagesConcrete
Damage: 450

SpiceExplosion:
Projectile: Bullet
Expand Down Expand Up @@ -323,3 +337,5 @@ PlasmaExplosion:
SmudgeType: SandCrater
Warhead@3Eff: CreateEffect
Explosions: devastator
Warhead@4Concrete: DamagesConcrete
Damage: 20000
6 changes: 6 additions & 0 deletions mods/d2k/weapons/smallguns.yaml
Expand Up @@ -20,6 +20,8 @@
Warhead@2Eff: CreateEffect
Explosions: piffs
ImpactActors: false
Warhead@3Concrete: DamagesConcrete
Damage: 1250

LMG:
Inherits: ^MG
Expand Down Expand Up @@ -57,6 +59,8 @@ M_HMG:
invulnerable: 0
cy: 20
harvester: 50
Warhead@2Concrete: DamagesConcrete
Damage: 625

M_HMG_H:
Inherits: M_HMG
Expand All @@ -79,6 +83,8 @@ HMG:
Spread: 160
Falloff: 100, 60, 30, 0
Damage: 1800
Warhead@2Concrete: DamagesConcrete
Damage: 1800

HMGo:
Inherits: HMG
Expand Down