Support multiple-damage states for walls (WTF Westwood: there are walls with 2, 3, and 4 damage states 0_o)

This commit is contained in:
pchote
2010-02-27 02:53:13 +13:00
parent bb9002aa61
commit 605ae8d4d5
6 changed files with 55 additions and 34 deletions

View File

@@ -24,12 +24,14 @@ namespace OpenRa.Traits
{
class RenderBuildingWallInfo : RenderBuildingInfo
{
public readonly int DamageStates = 2;
public override object Create(Actor self) { return new RenderBuildingWall(self); }
}
class RenderBuildingWall : RenderBuilding
{
string seqName;
int damageStates;
Actor self;
public RenderBuildingWall(Actor self)
@@ -37,8 +39,9 @@ namespace OpenRa.Traits
{
seqName = "idle";
this.self = self;
this.damageStates = self.Info.Traits.Get<RenderBuildingWallInfo>().DamageStates;
}
public override void Damaged(Actor self, AttackInfo e)
{
if (!e.DamageStateChanged) return;
@@ -48,10 +51,21 @@ namespace OpenRa.Traits
case DamageState.Normal:
seqName = "idle";
break;
case DamageState.ThreeQuarter:
if (damageStates >= 4)
seqName = "minor-damaged-idle";
break;
case DamageState.Half:
seqName = "damaged-idle";
Sound.Play("kaboom1.aud");
break;
case DamageState.Quarter:
if (damageStates >= 3)
{
seqName = "critical-idle";
Sound.Play("kaboom1.aud");
}
break;
}
}

View File

@@ -1,4 +1,4 @@
#region Copyright & License Information
#region Copyright & License Information
/*
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
* This file is part of OpenRA.
@@ -144,9 +144,19 @@ namespace OpenRa
public DamageState GetDamageState()
{
if (Health <= 0) return DamageState.Dead;
var halfStrength = this.GetMaxHP() * Rules.General.ConditionYellow;
return Health < halfStrength ? DamageState.Half : DamageState.Normal;
if (Health <= 0)
return DamageState.Dead;
if (Health < this.GetMaxHP() * Rules.General.ConditionRed)
return DamageState.Quarter;
if (Health < this.GetMaxHP() * Rules.General.ConditionYellow)
return DamageState.Half;
if (Health < this.GetMaxHP() * 0.75)
return DamageState.ThreeQuarter;
return DamageState.Normal;
}
public void InflictDamage(Actor attacker, int damage, WarheadInfo warhead)

View File

@@ -1,4 +1,4 @@
#region Copyright & License Information
#region Copyright & License Information
/*
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
* This file is part of OpenRA.
@@ -27,7 +27,7 @@ using OpenRa.Traits.Activities;
namespace OpenRa.Traits
{
public enum DamageState { Normal, Half, Dead };
public enum DamageState { Normal, ThreeQuarter, Half, Quarter, Dead };
// depends on the order of pips in WorldRenderer.cs!
public enum PipType { Transparent, Green, Yellow, Red, Gray };

View File

@@ -55,6 +55,8 @@
Crewed: no
Sight: 0
Wall:
Selectable:
RenderBuildingWall:
Palette: terrain
DamageStates: 2

View File

@@ -2499,7 +2499,7 @@ SBAG:
Buildable:
TechLevel: 2
Prerequisites: fact
Owner: soviet
Owner: allies
Cost: 25
Description: Sandbag Wall
LongDesc: Stops infantry and blocks enemy fire.\n Can be crushed by tanks.
@@ -2507,19 +2507,6 @@ SBAG:
HP: 100
Armor: none
BRIK:
Inherits: ^Wall
Buildable:
TechLevel: 8
Prerequisites: fact
Owner: soviet
Cost: 100
Description: Concrete Wall
LongDesc: Stop units from passing and block enemy fire.
Building:
HP: 100
Armor: none
FENC:
Inherits: ^Wall
Buildable:
@@ -2532,12 +2519,29 @@ FENC:
Building:
HP: 100
Armor: none
BRIK:
Inherits: ^Wall
Buildable:
TechLevel: 8
Prerequisites: fact
Owner: allies,soviet
Cost: 100
Description: Concrete Wall
LongDesc: Stop units from passing and block enemy fire.
Building:
HP: 100
Armor: none
RenderBuildingWall:
DamageStates: 4
CYCL:
Inherits: ^Wall
Building:
HP: 100
Armor: none
RenderBuildingWall:
DamageStates: 3
BARB:
Inherits: ^Wall
Building:

View File

@@ -861,44 +861,35 @@
</unit>
<unit name="brik">
<sequence name="idle" start="0" length="16" />
<sequence name="damaged-idle" start="16" length="16" />
<sequence name="quite-damaged-idle" start="32" length="16" />
<sequence name="minor-damaged-idle" start="16" length="16" />
<sequence name="damaged-idle" start="32" length="16" />
<sequence name="critical-idle" start="48" length="16" />
<sequence name="make" start="0" length="1" />
</unit>
<unit name="sbag">
<sequence name="idle" start="0" length="16" />
<sequence name="damaged-idle" start="16" length="16" />
<sequence name="quite-damaged-idle" start="32" length="16" />
<sequence name="critical-idle" start="48" length="16" />
<sequence name="make" start="0" length="1" />
</unit>
<unit name="fenc">
<sequence name="idle" start="0" length="16" />
<sequence name="damaged-idle" start="16" length="16" />
<sequence name="quite-damaged-idle" start="32" length="16" />
<sequence name="critical-idle" start="48" length="16" />
<sequence name="make" start="0" length="1" />
</unit>
<unit name="cycl">
<sequence name="idle" start="0" length="16" />
<sequence name="damaged-idle" start="16" length="16" />
<sequence name="quite-damaged-idle" start="32" length="16" />
<sequence name="critical-idle" start="48" length="16" />
<sequence name="critical-idle" start="32" length="16" />
<sequence name="make" start="0" length="1" />
</unit>
<unit name="barb">
<sequence name="idle" start="0" length="16" />
<sequence name="damaged-idle" start="16" length="16" />
<sequence name="quite-damaged-idle" start="32" length="16" />
<sequence name="critical-idle" start="48" length="16" />
<sequence name="make" start="0" length="1" />
</unit>
<unit name="wood">
<sequence name="idle" start="0" length="16" />
<sequence name="damaged-idle" start="16" length="16" />
<sequence name="quite-damaged-idle" start="32" length="16" />
<sequence name="critical-idle" start="48" length="16" />
<sequence name="make" start="0" length="1" />
</unit>
</sequences>