Merge pull request #4239 from ScottNZ/lua-new

Move to a managed Lua implementation
This commit is contained in:
Paul Chote
2013-12-06 02:37:04 -08:00
28 changed files with 178 additions and 165 deletions

View File

@@ -69,7 +69,11 @@ Also thanks to:
Using GeoLite data created by MaxMind and
distributed under the CC BY-SA 3.0 license.
Using MonoBoxedLua created by Sparklin Labs
Using KopiLua created by Mark Feldman
and maintained by Vinicius Jarina
and distributed under the MIT license.
Using NLua created by Vinicius Jarina
and distributed under the MIT license.
Finally, special thanks goes to the original teams

View File

@@ -65,7 +65,7 @@ INSTALL_PROGRAM = $(INSTALL) -m755
INSTALL_DATA = $(INSTALL) -m644
# program targets
CORE = fileformats rcg rgl rsdl rnull game utility geoip irc lua
CORE = fileformats rcg rgl rsdl rnull game utility geoip irc
TOOLS = editor tsbuild ralint
VERSION = $(shell git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || echo git-`git rev-parse --short HEAD`)
@@ -107,14 +107,6 @@ irc_LIBS = $(COMMON_LIBS) $(irc_DEPS)
PROGRAMS += irc
irc: $(irc_TARGET)
lua_SRCS := $(shell find LuaInterface/ -name '*.cs')
lua_TARGET = LuaInterface.dll
lua_KIND = library
lua_DEPS = $(fileformats_TARGET)
lua_LIBS = $(COMMON_LIBS) $(lua_DEPS)
PROGRAMS += lua
lua: $(lua_TARGET)
# Renderer dlls
rsdl_SRCS := $(shell find OpenRA.Renderer.SdlCommon/ -iname '*.cs')
rsdl_TARGET = OpenRA.Renderer.SdlCommon.dll
@@ -152,15 +144,15 @@ renderers: $(rcg_TARGET) $(rgl_TARGET) $(rsdl2_TARGET) $(rnull_TARGET) $(rsdl_TA
##### Official Mods #####
STD_MOD_LIBS = $(fileformats_TARGET) $(game_TARGET)
STD_MOD_LIBS = $(fileformats_TARGET) $(game_TARGET) thirdparty/KopiLua.dll thirdparty/NLua.dll
STD_MOD_DEPS = $(STD_MOD_LIBS) $(ralint_TARGET)
# Red Alert
mod_ra_SRCS := $(shell find OpenRA.Mods.RA/ -iname '*.cs')
mod_ra_TARGET = mods/ra/OpenRA.Mods.RA.dll
mod_ra_KIND = library
mod_ra_DEPS = $(STD_MOD_DEPS) $(geoip_TARGET) $(irc_TARGET) $(lua_TARGET)
mod_ra_LIBS = $(COMMON_LIBS) $(STD_MOD_LIBS) $(geoip_TARGET) $(irc_TARGET) $(lua_TARGET)
mod_ra_DEPS = $(STD_MOD_DEPS) $(geoip_TARGET) $(irc_TARGET)
mod_ra_LIBS = $(COMMON_LIBS) $(STD_MOD_LIBS) $(geoip_TARGET) $(irc_TARGET)
PROGRAMS += mod_ra
mod_ra: $(mod_ra_TARGET)
@@ -303,8 +295,6 @@ distclean: clean
dependencies:
@ $(CP_R) thirdparty/*.dl* .
@ $(CP_R) thirdparty/*.dylib .
@ $(CP_R) thirdparty/*.so .
@ $(CP_R) thirdparty/Tao/* .
version: mods/ra/mod.yaml mods/cnc/mod.yaml mods/d2k/mod.yaml
@@ -348,10 +338,8 @@ install-core: default
@$(INSTALL_PROGRAM) thirdparty/SharpFont.dll "$(DATA_INSTALL_DIR)"
@$(CP) thirdparty/SharpFont.dll.config "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) thirdparty/Mono.Nat.dll "$(DATA_INSTALL_DIR)"
@$(CP) thirdparty/LuaInterface.dll.config "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) thirdparty/liblua-linux32.so "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) thirdparty/liblua-linux64.so "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) thirdparty/liblua-osx.dylib "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) thirdparty/KopiLua.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) thirdparty/NLua.dll "$(DATA_INSTALL_DIR)"
@echo "#!/bin/sh" > openra
@echo 'BINDIR=$$(dirname $$(readlink -f $$0))' >> openra

View File

@@ -63,6 +63,12 @@
<Reference Include="FuzzyLogicLibrary">
<HintPath>..\thirdparty\FuzzyLogicLibrary.dll</HintPath>
</Reference>
<Reference Include="KopiLua">
<HintPath>..\thirdparty\KopiLua.dll</HintPath>
</Reference>
<Reference Include="NLua">
<HintPath>..\thirdparty\NLua.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
@@ -478,10 +484,6 @@
<Compile Include="Effects\Rank.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LuaInterface\LuaInterface.csproj">
<Project>{E915A0A4-2641-4F7E-8A88-8F123FA88BF1}</Project>
<Name>LuaInterface</Name>
</ProjectReference>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
<Project>{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}</Project>
<Name>OpenRA.FileFormats</Name>

View File

@@ -12,18 +12,23 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using LuaInterface;
using NLua;
using NLua.Event;
using OpenRA.FileFormats;
namespace OpenRA.Mods.RA.Scripting
{
public class LuaScriptContext : IDisposable
{
public Lua Lua { get; private set; }
readonly Cache<string, LuaFunction> functionCache;
public LuaScriptContext()
{
Log.Write("debug", "Creating Lua script context");
Lua = new Lua();
Lua.HookException += OnLuaException;
functionCache = new Cache<string, LuaFunction>(Lua.GetFunction);
}
public void RegisterObject(object target, string tableName, bool exposeAllMethods)
@@ -76,11 +81,21 @@ namespace OpenRA.Mods.RA.Scripting
}
}
void LogException(Exception e)
void OnLuaException(object sender, HookExceptionEventArgs e)
{
Game.Debug("{0}", e.Message);
ShowException(e.Exception);
}
void ShowException(Exception e)
{
ShowErrorMessage(e.Message, e.ToString());
}
public void ShowErrorMessage(string shortMessage, string longMessage)
{
Game.Debug("{0}", shortMessage);
Game.Debug("See debug.log for details");
Log.Write("debug", "{0}", e);
Log.Write("debug", "{0}", longMessage ?? shortMessage);
}
public void LoadLuaScripts(Func<string, string> getFileContents, params string[] files)
@@ -95,7 +110,7 @@ namespace OpenRA.Mods.RA.Scripting
}
catch (Exception e)
{
LogException(e);
ShowException(e);
}
}
}
@@ -104,14 +119,14 @@ namespace OpenRA.Mods.RA.Scripting
{
try
{
var function = Lua.GetFunction(name);
var function = functionCache[name];
if (function == null)
return null;
return function.Call(args);
}
catch (Exception e)
{
LogException(e);
ShowException(e);
return null;
}
}

View File

@@ -9,7 +9,6 @@
#endregion
using System;
using System.Collections.Generic;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Scripting

View File

@@ -8,16 +8,17 @@
*/
#endregion
using LuaInterface;
using System;
using System.Linq;
using NLua;
using OpenRA.Effects;
using OpenRA.FileFormats;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Air;
using OpenRA.Mods.RA.Missions;
using OpenRA.Scripting;
using OpenRA.Support;
using OpenRA.Traits;
using System;
using System.Linq;
using WorldRenderer = OpenRA.Graphics.WorldRenderer;
namespace OpenRA.Mods.RA.Scripting
@@ -43,7 +44,7 @@ namespace OpenRA.Mods.RA.Scripting
public void WorldLoaded(World w, WorldRenderer wr)
{
world = w;
AddMapActorGlobals();
context.Lua["World"] = w;
context.Lua["WorldRenderer"] = wr;
context.RegisterObject(this, "Internal", false);
@@ -55,22 +56,33 @@ namespace OpenRA.Mods.RA.Scripting
context.RegisterType(typeof(WRange), "WRange", true);
context.RegisterType(typeof(int2), "int2", true);
context.RegisterType(typeof(float2), "float2", true);
var sharedScripts = Game.modData.Manifest.LuaScripts ?? new string[0];
if (sharedScripts.Any())
context.LoadLuaScripts(f => FileSystem.Open(f).ReadAllText(), sharedScripts);
AddMapActorGlobals();
context.LoadLuaScripts(f => w.Map.Container.GetContent(f).ReadAllText(), info.LuaScripts);
context.InvokeLuaFunction("WorldLoaded");
}
void AddMapActorGlobals()
{
foreach (var kv in world.WorldActor.Trait<SpawnMapActors>().Actors)
context.Lua[kv.Key] = kv.Value;
{
if (context.Lua[kv.Key] != null)
context.ShowErrorMessage("{0}: The global name '{1}' is reserved and may not be used by map actor {2}".F(GetType().Name, kv.Key, kv.Value), null);
else
context.Lua[kv.Key] = kv.Value;
}
}
public void Tick(Actor self)
{
context.InvokeLuaFunction("Tick");
using (new PerfSample("tick_lua"))
context.InvokeLuaFunction("Tick");
}
[LuaGlobal]

View File

@@ -41,8 +41,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Irc", "OpenRA.Irc\Op
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Renderer.Sdl2", "OpenRA.Renderer.Sdl2\OpenRA.Renderer.Sdl2.csproj", "{33D03738-C154-4028-8EA8-63A3C488A651}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaInterface", "LuaInterface\LuaInterface.csproj", "{E915A0A4-2641-4F7E-8A88-8F123FA88BF1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -138,14 +136,6 @@ Global
{E9C01A96-C3E2-4772-825B-A740AC513D31}.Release|Any CPU.Build.0 = Release|Any CPU
{E9C01A96-C3E2-4772-825B-A740AC513D31}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{E9C01A96-C3E2-4772-825B-A740AC513D31}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Release|Any CPU.Build.0 = Release|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{52FD9F0B-B209-4ED7-8A32-AC8033363263}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52FD9F0B-B209-4ED7-8A32-AC8033363263}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52FD9F0B-B209-4ED7-8A32-AC8033363263}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -186,14 +176,14 @@ Global
{85B48234-8B31-4BE6-AF9C-665CC6866841}.Release|Any CPU.Build.0 = Release|Any CPU
{85B48234-8B31-4BE6-AF9C-665CC6866841}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{85B48234-8B31-4BE6-AF9C-665CC6866841}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E915A0A4-2641-4F7E-8A88-8F123FA88BF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E915A0A4-2641-4F7E-8A88-8F123FA88BF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E915A0A4-2641-4F7E-8A88-8F123FA88BF1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{E915A0A4-2641-4F7E-8A88-8F123FA88BF1}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{E915A0A4-2641-4F7E-8A88-8F123FA88BF1}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{E915A0A4-2641-4F7E-8A88-8F123FA88BF1}.Release|Any CPU.Build.0 = Debug|Any CPU
{E915A0A4-2641-4F7E-8A88-8F123FA88BF1}.Release|Mixed Platforms.ActiveCfg = Debug|Any CPU
{E915A0A4-2641-4F7E-8A88-8F123FA88BF1}.Release|Mixed Platforms.Build.0 = Debug|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Release|Any CPU.Build.0 = Release|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Release|Mixed Platforms.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = OpenRA.Game\OpenRA.Game.csproj

View File

@@ -172,3 +172,5 @@ LuaScripts:
mods/ra/lua/team.lua
mods/ra/lua/media.lua
mods/ra/lua/mission.lua
mods/ra/lua/reinforcements.lua
mods/ra/lua/supportpowers.lua

View File

@@ -152,3 +152,5 @@ LuaScripts:
mods/ra/lua/team.lua
mods/ra/lua/media.lua
mods/ra/lua/mission.lua
mods/ra/lua/reinforcements.lua
mods/ra/lua/supportpowers.lua

View File

@@ -1,87 +1,5 @@
Mission = { }
Mission.PerformHelicopterInsertion = function(owner, helicopterName, passengerNames, enterPosition, unloadPosition, exitPosition)
local facing = { Map.GetFacing(WPos.op_Subtraction(unloadPosition, enterPosition), 0), "Int32" }
local altitude = { Actor.TraitInfo(helicopterName, "AircraftInfo").CruiseAltitude, "Int32" }
local heli = Actor.Create(helicopterName, { Owner = owner, CenterPosition = enterPosition, Facing = facing, Altitude = altitude })
local cargo = Actor.Trait(heli, "Cargo")
local passengers = { }
for i, passengerName in ipairs(passengerNames) do
local passenger = Actor.Create(passengerName, { AddToWorld = false, Owner = owner })
cargo:Load(heli, passenger)
passengers[i] = passenger
end
Actor.HeliFly(heli, unloadPosition)
Actor.Turn(heli, 0)
Actor.HeliLand(heli, true)
Actor.UnloadCargo(heli, true)
Actor.Wait(heli, 125)
Actor.HeliFly(heli, exitPosition)
Actor.RemoveSelf(heli)
return heli, passengers
end
Mission.PerformHelicopterExtraction = function(owner, helicopterName, passengers, enterPosition, loadPosition, exitPosition)
local facing = { Map.GetFacing(WPos.op_Subtraction(loadPosition, enterPosition), 0), "Int32" }
local altitude = { Actor.TraitInfo(helicopterName, "AircraftInfo").CruiseAltitude, "Int32" }
local heli = Actor.Create(helicopterName, { Owner = owner, CenterPosition = enterPosition, Facing = facing, Altitude = altitude })
local cargo = Actor.Trait(heli, "Cargo")
Actor.HeliFly(heli, loadPosition)
Actor.Turn(heli, 0)
Actor.HeliLand(heli, true)
Actor.WaitFor(heli, function()
for i, passenger in ipairs(passengers) do
if not cargo.Passengers:Contains(passenger) then
return false
end
end
return true
end)
Actor.Wait(heli, 125)
Actor.HeliFly(heli, exitPosition)
Actor.RemoveSelf(heli)
return heli
end
Mission.Reinforce = function(owner, reinforcementNames, enterLocation, rallyPointLocation, interval, onCreateFunc)
local facing = { Map.GetFacing(CPos.op_Subtraction(rallyPointLocation, enterLocation), 0), "Int32" }
local ret = { }
for i = 1, #reinforcementNames do
local reinforcement = Actor.Create(reinforcementNames[i], { AddToWorld = false, Owner = owner, Location = enterLocation, Facing = facing })
table.insert(ret, reinforcement)
OpenRA.RunAfterDelay((i - 1) * interval, function()
World:Add(reinforcement)
Actor.MoveNear(reinforcement, rallyPointLocation, 2)
if onCreateFunc ~= nil then
onCreateFunc(reinforcement)
end
end)
end
return ret
end
Mission.Parabomb = function(owner, planeName, enterLocation, bombLocation)
local facing = { Map.GetFacing(CPos.op_Subtraction(bombLocation, enterLocation), 0), "Int32" }
local altitude = { Actor.TraitInfo(planeName, "AircraftInfo").CruiseAltitude, "Int32" }
local plane = Actor.Create(planeName, { Location = enterLocation, Owner = owner, Facing = facing, Altitude = altitude })
Actor.Trait(plane, "AttackBomber"):SetTarget(bombLocation.CenterPosition)
Actor.Fly(plane, bombLocation.CenterPosition)
Actor.FlyOffMap(plane)
Actor.RemoveSelf(plane)
end
Mission.Paradrop = function(owner, planeName, passengerNames, enterLocation, dropLocation)
local facing = { Map.GetFacing(CPos.op_Subtraction(dropLocation, enterLocation), 0), "Int32" }
local altitude = { Actor.TraitInfo(planeName, "AircraftInfo").CruiseAltitude, "Int32" }
local plane = Actor.Create(planeName, { Location = enterLocation, Owner = owner, Facing = facing, Altitude = altitude })
Actor.FlyAttackCell(plane, dropLocation)
Actor.Trait(plane, "ParaDrop"):SetLZ(dropLocation)
local cargo = Actor.Trait(plane, "Cargo")
for i, passengerName in ipairs(passengerNames) do
cargo:Load(plane, Actor.Create(passengerName, { AddToWorld = false, Owner = owner }))
end
end
Mission.MissionOver = function(winners, losers, setWinStates)
World:SetLocalPauseState(true)
World:set_PauseStateLocked(true)

View File

@@ -1,6 +1,11 @@
print = Internal.Debug
OpenRA = { }
OpenRA.New = function(className, args)
if args == nil then
args = { }
end
return Internal.New(className, args)
end
@@ -8,10 +13,6 @@ OpenRA.RunAfterDelay = function(delay, func)
Internal.RunAfterDelay(delay, func)
end
OpenRA.Debug = function(obj)
Internal.Debug(obj)
end
OpenRA.SetViewportCenterPosition = function(position)
WorldRenderer.Viewport:Center(position)
end

View File

@@ -0,0 +1,61 @@
Reinforcements = { }
Reinforcements.PerformHelicopterInsertion = function(owner, helicopterName, passengerNames, enterPosition, unloadPosition, exitPosition)
local facing = { Map.GetFacing(WPos.op_Subtraction(unloadPosition, enterPosition), 0), "Int32" }
local altitude = { Actor.TraitInfo(helicopterName, "AircraftInfo").CruiseAltitude, "Int32" }
local heli = Actor.Create(helicopterName, { Owner = owner, CenterPosition = enterPosition, Facing = facing, Altitude = altitude })
local cargo = Actor.Trait(heli, "Cargo")
local passengers = { }
for i, passengerName in ipairs(passengerNames) do
local passenger = Actor.Create(passengerName, { AddToWorld = false, Owner = owner })
cargo:Load(heli, passenger)
passengers[i] = passenger
end
Actor.HeliFly(heli, unloadPosition)
Actor.Turn(heli, 0)
Actor.HeliLand(heli, true)
Actor.UnloadCargo(heli, true)
Actor.Wait(heli, 125)
Actor.HeliFly(heli, exitPosition)
Actor.RemoveSelf(heli)
return heli, passengers
end
Reinforcements.PerformHelicopterExtraction = function(owner, helicopterName, passengers, enterPosition, loadPosition, exitPosition)
local facing = { Map.GetFacing(WPos.op_Subtraction(loadPosition, enterPosition), 0), "Int32" }
local altitude = { Actor.TraitInfo(helicopterName, "AircraftInfo").CruiseAltitude, "Int32" }
local heli = Actor.Create(helicopterName, { Owner = owner, CenterPosition = enterPosition, Facing = facing, Altitude = altitude })
local cargo = Actor.Trait(heli, "Cargo")
Actor.HeliFly(heli, loadPosition)
Actor.Turn(heli, 0)
Actor.HeliLand(heli, true)
Actor.WaitFor(heli, function()
for i, passenger in ipairs(passengers) do
if not cargo.Passengers:Contains(passenger) then
return false
end
end
return true
end)
Actor.Wait(heli, 125)
Actor.HeliFly(heli, exitPosition)
Actor.RemoveSelf(heli)
return heli
end
Reinforcements.Reinforce = function(owner, reinforcementNames, enterLocation, rallyPointLocation, interval, onCreateFunc)
local facing = { Map.GetFacing(CPos.op_Subtraction(rallyPointLocation, enterLocation), 0), "Int32" }
local ret = { }
for i = 1, #reinforcementNames do
local reinforcement = Actor.Create(reinforcementNames[i], { AddToWorld = false, Owner = owner, Location = enterLocation, Facing = facing })
table.insert(ret, reinforcement)
OpenRA.RunAfterDelay((i - 1) * interval, function()
World:Add(reinforcement)
Actor.MoveNear(reinforcement, rallyPointLocation, 2)
if onCreateFunc ~= nil then
onCreateFunc(reinforcement)
end
end)
end
return ret
end

View File

@@ -0,0 +1,23 @@
SupportPowers = { }
SupportPowers.Parabomb = function(owner, planeName, enterLocation, bombLocation)
local facing = { Map.GetFacing(CPos.op_Subtraction(bombLocation, enterLocation), 0), "Int32" }
local altitude = { Actor.TraitInfo(planeName, "AircraftInfo").CruiseAltitude, "Int32" }
local plane = Actor.Create(planeName, { Location = enterLocation, Owner = owner, Facing = facing, Altitude = altitude })
Actor.Trait(plane, "AttackBomber"):SetTarget(bombLocation.CenterPosition)
Actor.Fly(plane, bombLocation.CenterPosition)
Actor.FlyOffMap(plane)
Actor.RemoveSelf(plane)
end
SupportPowers.Paradrop = function(owner, planeName, passengerNames, enterLocation, dropLocation)
local facing = { Map.GetFacing(CPos.op_Subtraction(dropLocation, enterLocation), 0), "Int32" }
local altitude = { Actor.TraitInfo(planeName, "AircraftInfo").CruiseAltitude, "Int32" }
local plane = Actor.Create(planeName, { Location = enterLocation, Owner = owner, Facing = facing, Altitude = altitude })
Actor.FlyAttackCell(plane, dropLocation)
Actor.Trait(plane, "ParaDrop"):SetLZ(dropLocation)
local cargo = Actor.Trait(plane, "Cargo")
for i, passengerName in ipairs(passengerNames) do
cargo:Load(plane, Actor.Create(passengerName, { AddToWorld = false, Owner = owner }))
end
end

View File

@@ -13,7 +13,7 @@ CivilianWait = 150
BaseAlertDelay = 300
SendInsertionHelicopter = function()
local heli, passengers = Mission.PerformHelicopterInsertion(player, InsertionHelicopterType, { TanyaType },
local heli, passengers = Reinforcements.PerformHelicopterInsertion(player, InsertionHelicopterType, { TanyaType },
InsertionEntry.CenterPosition, InsertionLZ.CenterPosition, InsertionEntry.CenterPosition)
tanya = passengers[1]
Actor.OnKilled(tanya, TanyaKilled)
@@ -21,7 +21,7 @@ end
SendJeeps = function()
Media.PlaySpeechNotification("ReinforcementsArrived")
Mission.Reinforce(player, JeepReinforcements, InsertionEntry.Location, InsertionLZ.Location, JeepInterval)
Reinforcements.Reinforce(player, JeepReinforcements, InsertionEntry.Location, InsertionLZ.Location, JeepInterval)
end
RunInitialActivities = function()
@@ -59,7 +59,7 @@ LabGuardsKilled = function()
end
SendExtractionHelicopter = function()
local heli = Mission.PerformHelicopterExtraction(player, ExtractionHelicopterType, { einstein },
local heli = Reinforcements.PerformHelicopterExtraction(player, ExtractionHelicopterType, { einstein },
SouthReinforcementsPoint.CenterPosition, ExtractionLZ.CenterPosition, ExtractionExitPoint.CenterPosition)
Actor.OnKilled(heli, HelicopterDestroyed)
Actor.OnRemovedFromWorld(heli, HelicopterExtractionCompleted)

View File

@@ -1,5 +1,5 @@
Reinforcements = { "e1", "e1", "e1", "jeep" }
ReinforcementsInterval = 15
JeepReinforcements = { "e1", "e1", "e1", "jeep" }
JeepReinforcementsInterval = 15
TruckNames = { "truk", "truk", "truk" }
TruckInterval = 25
TruckDelay = 75
@@ -15,7 +15,7 @@ end
SendJeepReinforcements = function()
Media.PlaySpeechNotification("ReinforcementsArrived")
Mission.Reinforce(player, Reinforcements, ReinforcementsEntryPoint.Location, ReinforcementsRallyPoint.Location, ReinforcementsInterval)
Reinforcements.Reinforce(player, JeepReinforcements, ReinforcementsEntryPoint.Location, ReinforcementsRallyPoint.Location, JeepReinforcementsInterval)
end
RunInitialActivities = function()
@@ -49,7 +49,7 @@ end
SendTrucks = function()
Media.PlaySpeechNotification("ConvoyApproaching")
OpenRA.RunAfterDelay(TruckDelay, function()
local trucks = Mission.Reinforce(france, TruckNames, TruckEntryPoint.Location, TruckRallyPoint.Location, TruckInterval,
local trucks = Reinforcements.Reinforce(france, TruckNames, TruckEntryPoint.Location, TruckRallyPoint.Location, TruckInterval,
function(truck)
Actor.Move(truck, TruckExitPoint.Location)
Actor.RemoveSelf(truck)

View File

@@ -172,3 +172,5 @@ LuaScripts:
mods/ra/lua/team.lua
mods/ra/lua/media.lua
mods/ra/lua/mission.lua
mods/ra/lua/reinforcements.lua
mods/ra/lua/supportpowers.lua

View File

@@ -193,3 +193,5 @@ LuaScripts:
mods/ra/lua/team.lua
mods/ra/lua/media.lua
mods/ra/lua/mission.lua
mods/ra/lua/reinforcements.lua
mods/ra/lua/supportpowers.lua

View File

@@ -25,9 +25,6 @@ cp *.sh "$PWD/packaging/linux/$ROOTDIR/usr/lib/openra/" || exit 3
# Icons and .desktop files
make install-shortcuts prefix="/usr" DESTDIR="$PWD/packaging/linux/$ROOTDIR"
# Remove Mac OS X libaries
rm -rf "$PWD/packaging/linux/$ROOTDIR/usr/lib/openra/liblua-osx.dylib" || exit 3
cd packaging/linux
(

View File

@@ -21,10 +21,6 @@ cp -rv $2/* "OpenRA.app/Contents/Resources/" || exit 3
rm OpenRA.app/Contents/Resources/OpenRA.ico
rm OpenRA.app/Contents/Resources/OpenRA.Editor.exe
# Install the stripped down Lua library
cp ../../liblua-osx.dylib OpenRA.app/Contents/Resources/
cp ../../LuaInterface.dll.config OpenRA.app/Contents/Resources/
# SDL2 is the only supported renderer
rm -rf OpenRA.app/Contents/Resources/cg
rm OpenRA.app/Contents/Resources/OpenRA.Renderer.Cg.dll

View File

@@ -32,7 +32,7 @@ FILES=('OpenRA.Game.exe' 'OpenRA.Editor.exe' 'OpenRA.Utility.exe' \
'cg' 'glsl' 'mods/ra' 'mods/cnc' 'mods/d2k' \
'AUTHORS' 'CHANGELOG' 'COPYING' \
'README.html' 'CONTRIBUTING.html' 'DOCUMENTATION.html' \
'global mix database.dat' 'GeoIP.dll' 'GeoIP.dat' 'LuaInterface.dll')
'global mix database.dat' 'GeoIP.dll' 'GeoIP.dat')
echo "Copying files..."
for i in "${FILES[@]}"; do
@@ -57,6 +57,10 @@ cp thirdparty/SDL2\#* packaging/built
# Mono.NAT for UPnP support
cp thirdparty/Mono.Nat.dll packaging/built
# Lua
cp thirdparty/KopiLua.dll packaging/built
cp thirdparty/NLua.dll packaging/built
# Copy game icon for windows package
cp OpenRA.Game/OpenRA.ico packaging/built

View File

@@ -83,8 +83,8 @@ Section "Game" GAME
File "${SRCDIR}\global mix database.dat"
File "${SRCDIR}\GeoIP.dll"
File "${SRCDIR}\GeoIP.dat"
File "${SRCDIR}\LuaInterface.dll"
File lua51.dll
File "${SRCDIR}\KopiLua.dll"
File "${SRCDIR}\NLua.dll"
File OpenAL32.dll
File SDL.dll
File freetype6.dll
@@ -203,8 +203,8 @@ Function ${UN}Clean
Delete "$INSTDIR\global mix database.dat"
Delete $INSTDIR\GeoIP.dat
Delete $INSTDIR\GeoIP.dll
Delete $INSTDIR\LuaInterface.dll
Delete $INSTDIR\lua51.dll
Delete $INSTDIR\KopiLua.dll
Delete $INSTDIR\NLua.dll
Delete $INSTDIR\OpenAL32.dll
Delete $INSTDIR\SDL.dll
Delete $INSTDIR\freetype6.dll

Binary file not shown.

BIN
thirdparty/KopiLua.dll vendored Normal file

Binary file not shown.

View File

@@ -1,5 +0,0 @@
<configuration>
<dllmap os="linux" dll="lua51.dll" target="liblua-linux32.so" cpu="x86" />
<dllmap os="linux" dll="lua51.dll" target="liblua-linux64.so" cpu="x86-64" />
<dllmap os="osx" dll="lua51.dll" target="liblua-osx.dylib" />
</configuration>

BIN
thirdparty/NLua.dll vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.