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
{
[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]
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)
: 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)
currentSound = Game.Sound.PlayLooped(Info.SoundFile, self.CenterPosition);
else
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.PlayLooped(info.SoundFile, self.CenterPosition);
Game.Sound.Play(Info.SoundFile, self.CenterPosition);
else
Game.Sound.PlayLooped(info.SoundFile);
Game.Sound.Play(Info.SoundFile);
}
}
}

View File

@@ -99,7 +99,8 @@ namespace OpenRA.Mods.D2k.Traits
targetCountdown = Info.TargetRescanInterval;
// 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)
{
self.CancelActivity();

View File

@@ -74,34 +74,53 @@ trooper:
WithInfantryBody:
AttackSequence: shoot
medic:
thumper:
Inherits: ^Infantry
-AutoTarget:
Buildable:
Queue: Infantry
BuildPaletteOrder: 60
Prerequisites: ~barracks.medics, upgrade.barracks, ~techlevel.high
Prerequisites: upgrade.barracks, ~techlevel.high
Valued:
Cost: 200
CustomBuildTimeValue:
Value: 108
Tooltip:
Name: Medic
Description: Heals nearby infantry\n Strong vs Nothing\n Weak vs Everything
Name: Thumper
Description: Attracts nearby worms\n Unarmed
Health:
HP: 375
RevealsShroud:
Range: 2c768
Mobile:
Speed: 42
Armament:
Weapon: Heal
Cursor: ability
OutsideRangeCursor: ability
TargetStances: Ally
ForceTargetStances: None
AttackFrontal:
Speed: 43
DeployToUpgrade:
Upgrades: deployed
Facing: 128
AllowedTerrainTypes: Sand, Spice, Dune
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:
PipType: Blue
Voiced:

View File

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

View File

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

View File

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