Merge pull request #8418 from abcdefg30/newlua_other_cool_stuff

Added even more lua functions
This commit is contained in:
Matthias Mailänder
2015-06-28 12:37:06 +02:00
7 changed files with 61 additions and 4 deletions

View File

@@ -12,10 +12,11 @@ using System;
using System.Collections.Generic;
using OpenRA.Effects;
using OpenRA.Graphics;
using OpenRA.Scripting;
namespace OpenRA.Mods.Common.Effects
{
public class Beacon : IEffect
public class Beacon : IEffect, IScriptBindable
{
static readonly int MaxArrowHeight = 512;

View File

@@ -213,6 +213,7 @@
<Compile Include="Scripting\Media.cs" />
<Compile Include="Scripting\ScriptTriggers.cs" />
<Compile Include="Scripting\Global\ActorGlobal.cs" />
<Compile Include="Scripting\Global\BeaconGlobal.cs" />
<Compile Include="Scripting\Global\CameraGlobal.cs" />
<Compile Include="Scripting\Global\CoordinateGlobals.cs" />
<Compile Include="Scripting\Global\DateTimeGlobal.cs" />

View File

@@ -0,0 +1,47 @@
#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.Common.Effects;
using OpenRA.Mods.Common.Traits;
using OpenRA.Scripting;
namespace OpenRA.Mods.Common.Scripting
{
[ScriptGlobal("Beacon")]
public class BeaconGlobal : ScriptGlobal
{
readonly RadarPings radarPings;
public BeaconGlobal(ScriptContext context) : base(context)
{
radarPings = context.World.WorldActor.TraitOrDefault<RadarPings>();
}
[Desc("Creates a new beacon that stays for the specified time at the specified WPos." +
"Does not remove player set beacons, nor gets removed by placing them.")]
public Beacon New(Player owner, WPos position, int duration = 30 * 25, bool showRadarPings = true, string palettePrefix = "player")
{
var playerBeacon = new Beacon(owner, position, duration, palettePrefix);
owner.PlayerActor.World.AddFrameEndTask(w => w.Add(playerBeacon));
if (showRadarPings && radarPings != null)
{
radarPings.Add(
() => owner.IsAlliedWith(owner.World.RenderPlayer),
position,
owner.Color.RGB,
duration);
}
return playerBeacon;
}
}
}

View File

@@ -54,5 +54,12 @@ namespace OpenRA.Mods.Common.Scripting
{
Self.Trait<Mobile>().Nudge(Self, Self, true);
}
[ScriptActorPropertyActivity]
[Desc("Move to and enter the transport.")]
public void EnterTransport(Actor transport)
{
Self.QueueActivity(new EnterTransport(Self, transport, 1, true));
}
}
}

View File

@@ -95,8 +95,7 @@ Expand = function()
return
end
mcvGG.IsInWorld = false
mcvtransport.LoadPassenger(mcvGG)
mcvGG.EnterTransport(mcvtransport)
mcvtransport.Move(GGUnloadPoint.Location)
mcvtransport.UnloadPassengers()
Trigger.AfterDelay(DateTime.Seconds(12), function()
@@ -151,7 +150,7 @@ Tick = function()
Greece.Cash = Greece.Cash + Greece.Resources - Greece.ResourceCapacity * 0.25
Greece.Resources = Greece.ResourceCapacity * 0.25
end
if GoodGuy.Resources >= GoodGuy.ResourceCapacity * 0.75 then
GoodGuy.Cash = GoodGuy.Cash + GoodGuy.Resources - GoodGuy.ResourceCapacity * 0.25
GoodGuy.Resources = GoodGuy.ResourceCapacity * 0.25

View File

@@ -263,6 +263,7 @@ TimerExpired = function()
SpawningInfantry = false
SpawnNavalUnits = false
Beacon.New(allies, SovietEntryPoint7.CenterPosition - WVec.New(3 * 1024, 0, 0))
Media.PlaySpeechNotification(allies, "AlliedReinforcementsArrived")
Reinforcements.Reinforce(allies, FrenchReinforcements, { SovietEntryPoint7.Location, Alliesbase.Location })

View File

@@ -151,6 +151,7 @@ end
SendFrenchReinforcements = function()
local camera = Actor.Create("camera", true, { Owner = allies, Location = SovietRally1.Location })
Beacon.New(allies, FranceEntry.CenterPosition - WVec.New(0, 3 * 1024, 0))
Media.PlaySpeechNotification(allies, "AlliedReinforcementsArrived")
Reinforcements.Reinforce(allies, FrenchSquad, { FranceEntry.Location, FranceRally.Location })
Trigger.AfterDelay(DateTime.Seconds(3), function() camera.Destroy() end)