diff --git a/OpenRA.Mods.Cnc/Activities/Teleport.cs b/OpenRA.Mods.Cnc/Activities/Teleport.cs index d7b10254cc..ac980b8151 100644 --- a/OpenRA.Mods.Cnc/Activities/Teleport.cs +++ b/OpenRA.Mods.Cnc/Activities/Teleport.cs @@ -15,6 +15,7 @@ using OpenRA.Activities; using OpenRA.Mods.Cnc.Traits; using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits.Render; +using OpenRA.Primitives; using OpenRA.Traits; namespace OpenRA.Mods.Cnc.Activities @@ -23,12 +24,16 @@ namespace OpenRA.Mods.Cnc.Activities { readonly Actor teleporter; readonly int? maximumDistance; + readonly bool killOnFailure; + readonly BitSet killDamageTypes; CPos destination; bool killCargo; bool screenFlash; string sound; - public Teleport(Actor teleporter, CPos destination, int? maximumDistance, bool killCargo, bool screenFlash, string sound) + public Teleport(Actor teleporter, CPos destination, int? maximumDistance, + bool killCargo, bool screenFlash, string sound, bool interruptable = true, + bool killOnFailure = false, BitSet killDamageTypes = default(BitSet)) { var max = teleporter.World.Map.Grid.MaximumTileSearchRange; if (maximumDistance > max) @@ -40,17 +45,32 @@ namespace OpenRA.Mods.Cnc.Activities this.killCargo = killCargo; this.screenFlash = screenFlash; this.sound = sound; + this.killOnFailure = killOnFailure; + this.killDamageTypes = killDamageTypes; + + if (!interruptable) + IsInterruptible = false; } public override Activity Tick(Actor self) { var pc = self.TraitOrDefault(); if (teleporter == self && pc != null && !pc.CanTeleport) + { + if (killOnFailure) + self.Kill(teleporter, killDamageTypes); + return NextActivity; + } var bestCell = ChooseBestDestinationCell(self, destination); if (bestCell == null) + { + if (killOnFailure) + self.Kill(teleporter, killDamageTypes); + return NextActivity; + } destination = bestCell.Value; diff --git a/OpenRA.Mods.Cnc/Traits/Chronoshiftable.cs b/OpenRA.Mods.Cnc/Traits/Chronoshiftable.cs index 9fd43bdb50..1e7e306f34 100644 --- a/OpenRA.Mods.Cnc/Traits/Chronoshiftable.cs +++ b/OpenRA.Mods.Cnc/Traits/Chronoshiftable.cs @@ -10,6 +10,7 @@ #endregion using System.Drawing; +using OpenRA.Activities; using OpenRA.Mods.Cnc.Activities; using OpenRA.Mods.Common.Activities; using OpenRA.Mods.Common.Traits; @@ -24,7 +25,8 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Should the actor die instead of being teleported?")] public readonly bool ExplodeInstead = false; - [Desc("Types of damage that this trait causes to self when 'ExplodeInstead' is true. Leave empty for no damage types.")] + [Desc("Types of damage that this trait causes to self when 'ExplodeInstead' is true", + "or the return-to-origin is blocked. Leave empty for no damage types.")] public readonly BitSet DamageTypes = default(BitSet); public readonly string ChronoshiftSound = "chrono2.aud"; @@ -78,7 +80,10 @@ namespace OpenRA.Mods.Cnc.Traits if (--ReturnTicks == 0) { self.CancelActivity(); - self.QueueActivity(new Teleport(chronosphere, Origin, null, killCargo, true, Info.ChronoshiftSound)); + + // The actor is killed using Info.DamageTypes if the teleport fails + self.QueueActivity(new Teleport(chronosphere, Origin, null, true, killCargo, Info.ChronoshiftSound, + false, true, Info.DamageTypes)); } }