Merge pull request #10092 from pchote/saboteur-suicide

Implement suicide bomb for D2K Saboteur
This commit is contained in:
Matthias Mailänder
2015-11-27 13:41:23 +01:00
5 changed files with 26 additions and 10 deletions

View File

@@ -20,6 +20,7 @@ namespace OpenRA.Mods.Common.Activities
{ {
readonly Actor target; readonly Actor target;
readonly IDemolishable[] demolishables; readonly IDemolishable[] demolishables;
readonly EnterBehaviour enterBehaviour;
readonly int delay; readonly int delay;
readonly int flashes; readonly int flashes;
readonly int flashesDelay; readonly int flashesDelay;
@@ -28,11 +29,13 @@ namespace OpenRA.Mods.Common.Activities
readonly Cloak cloak; readonly Cloak cloak;
public Demolish(Actor self, Actor target, int delay, int flashes, int flashesDelay, int flashInterval, int flashDuration) public Demolish(Actor self, Actor target, EnterBehaviour enterBehaviour, int delay,
int flashes, int flashesDelay, int flashInterval, int flashDuration)
: base(self, target) : base(self, target)
{ {
this.target = target; this.target = target;
demolishables = target.TraitsImplementing<IDemolishable>().ToArray(); demolishables = target.TraitsImplementing<IDemolishable>().ToArray();
this.enterBehaviour = enterBehaviour;
this.delay = delay; this.delay = delay;
this.flashes = flashes; this.flashes = flashes;
this.flashesDelay = flashesDelay; this.flashesDelay = flashesDelay;
@@ -72,6 +75,11 @@ namespace OpenRA.Mods.Common.Activities
if (Util.ApplyPercentageModifiers(100, modifiers) > 0) if (Util.ApplyPercentageModifiers(100, modifiers) > 0)
demolishables.Do(d => d.Demolish(target, self)); demolishables.Do(d => d.Demolish(target, self));
})); }));
if (enterBehaviour == EnterBehaviour.Suicide)
self.Kill(self);
else if (enterBehaviour == EnterBehaviour.Dispose)
self.Dispose();
}); });
} }
} }

View File

@@ -15,6 +15,8 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Activities namespace OpenRA.Mods.Common.Activities
{ {
public enum EnterBehaviour { Exit, Suicide, Dispose }
public abstract class Enter : Activity public abstract class Enter : Activity
{ {
public enum ReserveStatus { None, TooFar, Pending, Ready } public enum ReserveStatus { None, TooFar, Pending, Ready }

View File

@@ -34,8 +34,8 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Demolish the target actor.")] [Desc("Demolish the target actor.")]
public void Demolish(Actor target) public void Demolish(Actor target)
{ {
Self.QueueActivity(new Demolish(Self, target, info.C4Delay, info.Flashes, Self.QueueActivity(new Demolish(Self, target, info.EnterBehaviour, info.C4Delay,
info.FlashesDelay, info.FlashInterval, info.FlashDuration)); info.Flashes, info.FlashesDelay, info.FlashInterval, info.FlashDuration));
} }
} }
} }

View File

@@ -23,18 +23,22 @@ namespace OpenRA.Mods.Common.Traits
"Measured in game ticks. Default is 1.8 seconds.")] "Measured in game ticks. Default is 1.8 seconds.")]
public readonly int C4Delay = 45; public readonly int C4Delay = 45;
[Desc("Number of times to flash the target")] [Desc("Number of times to flash the target.")]
public readonly int Flashes = 3; public readonly int Flashes = 3;
[Desc("Delay before the flashing starts")] [Desc("Delay before the flashing starts.")]
public readonly int FlashesDelay = 4; public readonly int FlashesDelay = 4;
[Desc("Interval between each flash")] [Desc("Interval between each flash.")]
public readonly int FlashInterval = 4; public readonly int FlashInterval = 4;
[Desc("Duration of each flash")] [Desc("Duration of each flash.")]
public readonly int FlashDuration = 3; public readonly int FlashDuration = 3;
[Desc("Behaviour when entering the structure.",
"Possible values are Exit, Suicide, Dispose.")]
public readonly EnterBehaviour EnterBehaviour = EnterBehaviour.Exit;
[Desc("Voice string when planting explosive charges.")] [Desc("Voice string when planting explosive charges.")]
[VoiceReference] public readonly string Voice = "Action"; [VoiceReference] public readonly string Voice = "Action";
@@ -83,8 +87,8 @@ namespace OpenRA.Mods.Common.Traits
self.CancelActivity(); self.CancelActivity();
self.SetTargetLine(target, Color.Red); self.SetTargetLine(target, Color.Red);
self.QueueActivity(new Demolish(self, self.QueueActivity(new Demolish(self, target.Actor, info.EnterBehaviour, info.C4Delay,
target.Actor, info.C4Delay, info.Flashes, info.FlashesDelay, info.FlashInterval, info.FlashDuration)); info.Flashes, info.FlashesDelay, info.FlashInterval, info.FlashDuration));
} }
public string VoicePhraseForOrder(Actor self, Order order) public string VoicePhraseForOrder(Actor self, Order order)

View File

@@ -243,7 +243,9 @@ saboteur:
Mobile: Mobile:
Speed: 43 Speed: 43
C4Demolition: C4Demolition:
C4Delay: 45 C4Delay: 0
Flashes: 0
EnterBehaviour: Suicide
-AutoTarget: -AutoTarget:
Cloak: Cloak:
InitialDelay: 85 InitialDelay: 85