Merge pull request #8417 from abcdefg30/newlua_disguise

Added DisguiseAs and DisguiseAsType functions to lua
This commit is contained in:
Matthias Mailänder
2015-07-05 20:04:00 +02:00
6 changed files with 63 additions and 20 deletions

View File

@@ -18,7 +18,6 @@ namespace OpenRA
{
/// <summary>
/// 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.
/// </summary>
public class ActorInfo
{

View File

@@ -84,6 +84,7 @@
<Compile Include="Effects\TeslaZap.cs" />
<Compile Include="Graphics\TeslaZapRenderable.cs" />
<Compile Include="Scripting\Properties\InfiltrateProperties.cs" />
<Compile Include="Scripting\Properties\DisguiseProperties.cs" />
<Compile Include="Traits\Attack\AttackLeap.cs" />
<Compile Include="Traits\Buildings\Fake.cs" />
<Compile Include="Traits\Buildings\ClonesProducedUnits.cs" />

View File

@@ -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<DisguiseInfo>
{
readonly Disguise disguise;
public DisguiseProperties(ScriptContext context, Actor self)
: base(context, self)
{
disguise = Self.Trait<Disguise>();
}
[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);
}
}
}

View File

@@ -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<RenderSpritesInfo>();
AsSprite = renderSprites == null ? null : renderSprites.GetImage(actorInfo, self.World.Map.SequenceProvider, newOwner.Country.Race);
AsPlayer = newOwner;
AsTooltipInfo = actorInfo.Traits.WithInterface<TooltipInfo>().FirstOrDefault();
HandleDisguise(oldEffectiveOwner, oldDisguiseSetting);
}
void HandleDisguise(Player oldEffectiveOwner, bool oldDisguiseSetting)
{
foreach (var t in self.TraitsImplementing<INotifyEffectiveOwnerChanged>())
t.OnEffectiveOwnerChanged(self, oldEffectiveOwner, AsPlayer);

View File

@@ -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)

View File

@@ -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