From 20ac129433fe632343b5cb7c9f962a5fcb7f48af Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Sun, 7 Jun 2015 09:11:50 +0200 Subject: [PATCH 1/3] Add DisguiseAs and DisguiseAsType functions to lua --- OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 1 + .../Properties/DisguiseProperties.cs | 42 +++++++++++++++++++ OpenRA.Mods.RA/Traits/Disguise.cs | 20 ++++++++- 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 OpenRA.Mods.RA/Scripting/Properties/DisguiseProperties.cs 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); From d72fd39d61d17aa4f8b53e5ee5ae4b23b9995e0b Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Sun, 7 Jun 2015 09:16:46 +0200 Subject: [PATCH 2/3] Make use of the new DisguiseAsType function in allies05a and remove the cloak hack --- mods/ra/maps/allies-05a/allies05a.lua | 5 +---- mods/ra/maps/allies-05a/map.yaml | 14 -------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/mods/ra/maps/allies-05a/allies05a.lua b/mods/ra/maps/allies-05a/allies05a.lua index a90da28896..f93e667f19 100644 --- a/mods/ra/maps/allies-05a/allies05a.lua +++ b/mods/ra/maps/allies-05a/allies05a.lua @@ -160,8 +160,6 @@ WarfactoryInfiltrated = function() end MissInfiltrated = function() - CloakProvider.Destroy() - for i = 0, 5, 1 do local sound = Utils.Random(TanyaVoices) Trigger.AfterDelay(DateTime.Seconds(i), function() @@ -247,9 +245,8 @@ InitTriggers = function() if a == Truk then Trigger.RemoveFootprintTrigger(id) - CloakProvider = Actor.Create("CloakUpgrade", true, { Owner = greece, Location = Prison.Location }) - Spy = Actor.Create("spy", true, { Owner = greece, Location = TrukWaypoint5.Location }) + Spy.DisguiseAsType("e1", ussr) Spy.Move(SpyWaypoint.Location) Spy.Infiltrate(Prison) Media.PlaySoundNotification(greece, SpyVoice) diff --git a/mods/ra/maps/allies-05a/map.yaml b/mods/ra/maps/allies-05a/map.yaml index e5ae9d780d..cf66949521 100644 --- a/mods/ra/maps/allies-05a/map.yaml +++ b/mods/ra/maps/allies-05a/map.yaml @@ -1694,20 +1694,6 @@ Rules: Types: Mission Objectives DisguiseToolTip: ShowOwnerRow: false - Cloak@MISS: - UpgradeTypes: miss - UpgradeMinEnabledLevel: 1 - InitialDelay: 0 - CloakDelay: 0 - Palette: - CloakUpgrade: - AlwaysVisible: - Immobile: - OccupiesSpace: false - BodyOrientation: - UpgradeActorsNear: - Upgrades: miss - Range: 5c512 WEAP: TargetableBuilding: TargetTypes: Ground, C4, DetonateAttack, Structure, Mission Objectives From 6afc6a879eb9f89a2be247a9069190229aa5944d Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Sat, 4 Jul 2015 13:02:18 +0200 Subject: [PATCH 3/3] Update the ActorInfo summary --- OpenRA.Game/GameRules/ActorInfo.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenRA.Game/GameRules/ActorInfo.cs b/OpenRA.Game/GameRules/ActorInfo.cs index ccfadccc4c..65d2060c00 100644 --- a/OpenRA.Game/GameRules/ActorInfo.cs +++ b/OpenRA.Game/GameRules/ActorInfo.cs @@ -18,7 +18,6 @@ namespace OpenRA { /// /// A unit/building inside the game. Every rules starts with one and adds trait to it. - /// Special actors like world or player are usually defined in system.yaml and affect everything. /// public class ActorInfo {