diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
index 4f91d64281..cc134e0f1f 100644
--- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
+++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
@@ -84,6 +84,7 @@
+
diff --git a/OpenRA.Mods.RA/Scripting/Properties/DisguiseProperties.cs b/OpenRA.Mods.RA/Scripting/Properties/DisguiseProperties.cs
new file mode 100644
index 0000000000..b017153b56
--- /dev/null
+++ b/OpenRA.Mods.RA/Scripting/Properties/DisguiseProperties.cs
@@ -0,0 +1,42 @@
+#region Copyright & License Information
+/*
+ * Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
+ * This file is part of OpenRA, which is free software. It is made
+ * available to you under the terms of the GNU General Public License
+ * as published by the Free Software Foundation. For more information,
+ * see COPYING.
+ */
+#endregion
+
+using System.Linq;
+using OpenRA.Mods.RA.Traits;
+using OpenRA.Scripting;
+using OpenRA.Traits;
+
+namespace OpenRA.Mods.RA.Scripting
+{
+ [ScriptPropertyGroup("Ability")]
+ public class DisguiseProperties : ScriptActorProperties, Requires
+ {
+ readonly Disguise disguise;
+
+ public DisguiseProperties(ScriptContext context, Actor self)
+ : base(context, self)
+ {
+ disguise = Self.Trait();
+ }
+
+ [Desc("Disguises as the target actor.")]
+ public void DisguiseAs(Actor target)
+ {
+ disguise.DisguiseAs(target);
+ }
+
+ [Desc("Disguises as the target type with the specified owner.")]
+ public void DisguiseAsType(string actorType, Player newOwner)
+ {
+ var actorInfo = Self.World.Map.Rules.Actors[actorType];
+ disguise.DisguiseAs(actorInfo, newOwner);
+ }
+ }
+}
diff --git a/OpenRA.Mods.RA/Traits/Disguise.cs b/OpenRA.Mods.RA/Traits/Disguise.cs
index 7dae8aa490..05290108b1 100644
--- a/OpenRA.Mods.RA/Traits/Disguise.cs
+++ b/OpenRA.Mods.RA/Traits/Disguise.cs
@@ -128,7 +128,7 @@ namespace OpenRA.Mods.RA.Traits
return AsPlayer.Color.RGB;
}
- void DisguiseAs(Actor target)
+ public void DisguiseAs(Actor target)
{
var oldDisguiseSetting = Disguised;
var oldEffectiveOwner = AsPlayer;
@@ -159,6 +159,24 @@ namespace OpenRA.Mods.RA.Traits
AsSprite = null;
}
+ HandleDisguise(oldEffectiveOwner, oldDisguiseSetting);
+ }
+
+ public void DisguiseAs(ActorInfo actorInfo, Player newOwner)
+ {
+ var oldDisguiseSetting = Disguised;
+ var oldEffectiveOwner = AsPlayer;
+
+ var renderSprites = actorInfo.Traits.GetOrDefault();
+ AsSprite = renderSprites == null ? null : renderSprites.GetImage(actorInfo, self.World.Map.SequenceProvider, newOwner.Country.Race);
+ AsPlayer = newOwner;
+ AsTooltipInfo = actorInfo.Traits.WithInterface().FirstOrDefault();
+
+ HandleDisguise(oldEffectiveOwner, oldDisguiseSetting);
+ }
+
+ void HandleDisguise(Player oldEffectiveOwner, bool oldDisguiseSetting)
+ {
foreach (var t in self.TraitsImplementing())
t.OnEffectiveOwnerChanged(self, oldEffectiveOwner, AsPlayer);