Merge pull request #9771 from reaperrr/d2k-thumper

Implement D2k thumper
This commit is contained in:
Pavel Penev
2015-10-31 15:47:33 +02:00
6 changed files with 87 additions and 26 deletions

View File

@@ -13,22 +13,61 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Plays a looping audio file at the actor position. Attach this to the `World` actor to cover the whole map.")] [Desc("Plays a looping audio file at the actor position. Attach this to the `World` actor to cover the whole map.")]
class AmbientSoundInfo : ITraitInfo class AmbientSoundInfo : UpgradableTraitInfo
{ {
[FieldLoader.Require] [FieldLoader.Require]
public readonly string SoundFile = null; public readonly string SoundFile = null;
public object Create(ActorInitializer init) { return new AmbientSound(init.Self, this); } [Desc("Interval between playing the sound (in ticks).")]
public readonly int Interval = 0;
public override object Create(ActorInitializer init) { return new AmbientSound(init.Self, this); }
} }
class AmbientSound class AmbientSound : UpgradableTrait<AmbientSoundInfo>, ITick
{ {
ISound currentSound;
bool wasDisabled = true;
int interval;
public AmbientSound(Actor self, AmbientSoundInfo info) public AmbientSound(Actor self, AmbientSoundInfo info)
: base(info)
{
interval = info.Interval;
}
public void Tick(Actor self)
{
if (IsTraitDisabled)
{
Game.Sound.StopSound(currentSound);
currentSound = null;
wasDisabled = true;
return;
}
if (wasDisabled && Info.Interval <= 0)
{ {
if (self.OccupiesSpace != null) if (self.OccupiesSpace != null)
Game.Sound.PlayLooped(info.SoundFile, self.CenterPosition); currentSound = Game.Sound.PlayLooped(Info.SoundFile, self.CenterPosition);
else else
Game.Sound.PlayLooped(info.SoundFile); currentSound = Game.Sound.PlayLooped(Info.SoundFile);
}
wasDisabled = false;
if (Info.Interval <= 0)
return;
if (interval-- > 0)
return;
interval = Info.Interval;
if (self.OccupiesSpace != null)
Game.Sound.Play(Info.SoundFile, self.CenterPosition);
else
Game.Sound.Play(Info.SoundFile);
} }
} }
} }

View File

@@ -99,7 +99,8 @@ namespace OpenRA.Mods.D2k.Traits
targetCountdown = Info.TargetRescanInterval; targetCountdown = Info.TargetRescanInterval;
// If close enough, we don't care about other actors. // If close enough, we don't care about other actors.
var target = self.World.FindActorsInCircle(self.CenterPosition, Info.IgnoreNoiseAttackRange).FirstOrDefault(x => x.Info.HasTraitInfo<AttractsWormsInfo>()); var target = self.World.FindActorsInCircle(self.CenterPosition, Info.IgnoreNoiseAttackRange)
.FirstOrDefault(x => attackTrait.HasAnyValidWeapons(Target.FromActor(x)));
if (target != null) if (target != null)
{ {
self.CancelActivity(); self.CancelActivity();

View File

@@ -74,34 +74,53 @@ trooper:
WithInfantryBody: WithInfantryBody:
AttackSequence: shoot AttackSequence: shoot
medic: thumper:
Inherits: ^Infantry Inherits: ^Infantry
-AutoTarget:
Buildable: Buildable:
Queue: Infantry Queue: Infantry
BuildPaletteOrder: 60 BuildPaletteOrder: 60
Prerequisites: ~barracks.medics, upgrade.barracks, ~techlevel.high Prerequisites: upgrade.barracks, ~techlevel.high
Valued: Valued:
Cost: 200 Cost: 200
CustomBuildTimeValue: CustomBuildTimeValue:
Value: 108 Value: 108
Tooltip: Tooltip:
Name: Medic Name: Thumper
Description: Heals nearby infantry\n Strong vs Nothing\n Weak vs Everything Description: Attracts nearby worms\n Unarmed
Health: Health:
HP: 375 HP: 375
RevealsShroud: RevealsShroud:
Range: 2c768 Range: 2c768
Mobile: Mobile:
Speed: 42 Speed: 43
Armament: DeployToUpgrade:
Weapon: Heal Upgrades: deployed
Cursor: ability Facing: 128
OutsideRangeCursor: ability AllowedTerrainTypes: Sand, Spice, Dune
TargetStances: Ally
ForceTargetStances: None
AttackFrontal:
WithInfantryBody: WithInfantryBody:
AttackSequence: heal UpgradeTypes: deployed
UpgradeMaxEnabledLevel: 0
WithSpriteBody@DEPLOYED:
Sequence: thump
UpgradeTypes: deployed
UpgradeMinEnabledLevel: 1
WithIdleOverlay@DEPLOYED:
Sequence: thump-sand
UpgradeTypes: deployed
UpgradeMinEnabledLevel: 1
AmbientSound:
SoundFile: THUMPER1.WAV
Interval: 60
UpgradeTypes: deployed
UpgradeMinEnabledLevel: 1
AttractsWorms:
Intensity: 1000
UpgradeTypes: deployed
UpgradeMinEnabledLevel: 1
DisableOnUpgrade:
UpgradeTypes: deployed
UpgradeMinEnabledLevel: 1
Passenger: Passenger:
PipType: Blue PipType: Blue
Voiced: Voiced:

View File

@@ -168,9 +168,6 @@ barracks:
ProvidesPrerequisite@harkonnen: ProvidesPrerequisite@harkonnen:
Prerequisite: barracks.harkonnen Prerequisite: barracks.harkonnen
Factions: harkonnen Factions: harkonnen
ProvidesPrerequisite@medics:
Prerequisite: barracks.medics
Factions: atreides, ordos
Power: Power:
Amount: -30 Amount: -30
RenderSprites: RenderSprites:

View File

@@ -170,7 +170,7 @@ engineer:
Start: 4013 Start: 4013
Offset: -30,-24 Offset: -30,-24
medic: # actually thumper thumper:
stand: DATA.R8 stand: DATA.R8
Start: 1402 Start: 1402
Facings: -8 Facings: -8
@@ -196,10 +196,15 @@ medic: # actually thumper
Facings: -8 Facings: -8
Transpose: true Transpose: true
Tick: 120 Tick: 120
heal: DATA.R8 thump: DATA.R8
Start: 1458 Start: 1458
Length: 5 Length: 5
Tick: 480 Tick: 480
thump-sand: DATA.R8
Frames: 3629, 3630, 3626, 3627, 3628
Length: 5
Tick: 480
BlendMode: Multiply
die1: DATA.R8 die1: DATA.R8
Frames: 1543, 1550, 1557, 1564, 1571, 1578, 1585, 1592, 1599, 1600, 1601, 1602 Frames: 1543, 1550, 1557, 1564, 1571, 1578, 1585, 1592, 1599, 1600, 1601, 1602
Length: 12 Length: 12

View File

@@ -563,10 +563,10 @@ Heal:
WormJaw: WormJaw:
ReloadDelay: 10 ReloadDelay: 10
InvalidTargets: Structure InvalidTargets: Structure, Infantry
Range: 1c512 Range: 1c512
Warhead@1Dam: SpreadDamage Warhead@1Dam: SpreadDamage
InvalidTargets: Structure InvalidTargets: Structure, Infantry
Spread: 768 Spread: 768
Falloff: 100, 100, 0 Falloff: 100, 100, 0
Damage: 10000 Damage: 10000