diff --git a/OpenRA.Mods.Common/Traits/Sound/AmbientSound.cs b/OpenRA.Mods.Common/Traits/Sound/AmbientSound.cs index 9b1ca95441..4236692e10 100644 --- a/OpenRA.Mods.Common/Traits/Sound/AmbientSound.cs +++ b/OpenRA.Mods.Common/Traits/Sound/AmbientSound.cs @@ -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, 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); } } } diff --git a/OpenRA.Mods.D2k/Traits/Sandworm.cs b/OpenRA.Mods.D2k/Traits/Sandworm.cs index b525e58239..2ee042dc1f 100644 --- a/OpenRA.Mods.D2k/Traits/Sandworm.cs +++ b/OpenRA.Mods.D2k/Traits/Sandworm.cs @@ -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()); + var target = self.World.FindActorsInCircle(self.CenterPosition, Info.IgnoreNoiseAttackRange) + .FirstOrDefault(x => attackTrait.HasAnyValidWeapons(Target.FromActor(x))); if (target != null) { self.CancelActivity(); diff --git a/mods/d2k/rules/infantry.yaml b/mods/d2k/rules/infantry.yaml index 150ba32b31..4ecee1381c 100644 --- a/mods/d2k/rules/infantry.yaml +++ b/mods/d2k/rules/infantry.yaml @@ -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: diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml index cab05e7141..e4d159d9cb 100644 --- a/mods/d2k/rules/structures.yaml +++ b/mods/d2k/rules/structures.yaml @@ -168,9 +168,6 @@ barracks: ProvidesPrerequisite@harkonnen: Prerequisite: barracks.harkonnen Factions: harkonnen - ProvidesPrerequisite@medics: - Prerequisite: barracks.medics - Factions: atreides, ordos Power: Amount: -30 RenderSprites: diff --git a/mods/d2k/sequences/infantry.yaml b/mods/d2k/sequences/infantry.yaml index e0f59cdbc3..1f114d484d 100644 --- a/mods/d2k/sequences/infantry.yaml +++ b/mods/d2k/sequences/infantry.yaml @@ -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 diff --git a/mods/d2k/weapons.yaml b/mods/d2k/weapons.yaml index 3d13dd3b67..f1fc599a27 100644 --- a/mods/d2k/weapons.yaml +++ b/mods/d2k/weapons.yaml @@ -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