Merge pull request #5190 from pchote/new-lua

New Lua API.
This commit is contained in:
Matthias Mailänder
2014-05-02 13:29:28 +02:00
81 changed files with 3408 additions and 233 deletions

View File

@@ -520,10 +520,10 @@ Actors:
Location: 11,52
Owner: Neutral
GDIReinforcementsEntry: waypoint
Location: 7, 50
Location: 7,50
Owner: Neutral
Auto1Trigger: waypoint
Location: 52, 47
Location: 52,47
Owner: Neutral
NodHeliEntry: waypoint
Location: 41,23
@@ -561,6 +561,7 @@ Rules:
-GiveCashCrateAction:
-ExplodeCrateAction@fire:
-CloakCrateAction:
ScriptTriggers:
Sequences:

View File

@@ -993,8 +993,8 @@ Rules:
PlayMusicOnMapLoad:
Music: map1
Loop: true
LuaScriptInterface:
LuaScripts: shellmap.lua
LuaScript:
Scripts: shellmap.lua
LoadWidgetAtGameStart:
Widget: MENU_BACKGROUND
LST:

View File

@@ -5,15 +5,14 @@ speed = 5
Tick = function()
ticks = ticks + 1
local t = (ticks + 45) % (360 * speed) * (math.pi / 180) / speed;
OpenRA.SetViewportCenterPosition(WPos.op_Addition(viewportOrigin, WVec.New(-15360 * math.sin(t), 4096 * math.cos(t))))
Camera.Position = viewportOrigin + WVec.New(-15360 * math.sin(t), 4096 * math.cos(t), 0)
end
WorldLoaded = function()
viewportOrigin = OpenRA.GetViewportCenterPosition()
CreateUnitsInTransport(lst1, { "htnk" });
CreateUnitsInTransport(lst2, { "mcv" });
CreateUnitsInTransport(lst3, { "htnk" });
viewportOrigin = Camera.Position
LoadTransport(lst1, "htnk")
LoadTransport(lst2, "mcv")
LoadTransport(lst3, "htnk")
local units = { boat1, boat2, boat3, boat4, lst1, lst2, lst3}
for i, unit in ipairs(units) do
LoopTrack(unit, CPos.New(8, unit.Location.Y), CPos.New(87, unit.Location.Y))
@@ -21,17 +20,11 @@ WorldLoaded = function()
end
LoopTrack = function(actor, left, right)
Actor.ScriptedMove(actor, left)
Actor.Teleport(actor, right)
Actor.CallFunc(actor, function() LoopTrack(actor, left, right) end)
actor.ScriptedMove(left)
actor.Teleport(right)
actor.CallFunc(function() LoopTrack(actor, left, right) end)
end
CreateUnitsInTransport = function(transport, passengerNames)
local cargo = Actor.Trait(transport, "Cargo")
local owner = Actor.Owner(transport)
local facing = Actor.Facing(transport)
for i, passengerName in ipairs(passengerNames) do
cargo:Load(transport, Actor.Create(passengerName, { AddToWorld = false, Owner = owner, Facing = { facing, "Int32" } }))
end
LoadTransport = function(transport, passenger)
transport.LoadPassenger(Actor.Create(passenger, false, { Owner = transport.Owner, Facing = transport.Facing }))
end

View File

@@ -42,6 +42,7 @@
UncloakSound: trans1.aud
Huntable:
LuaScriptEvents:
ScriptTriggers:
^Tank:
AppearsOnRadar:
@@ -90,6 +91,7 @@
UncloakSound: trans1.aud
Huntable:
LuaScriptEvents:
ScriptTriggers:
^Helicopter:
AppearsOnRadar:
@@ -122,6 +124,7 @@
UpdatesPlayerStatistics:
Huntable:
LuaScriptEvents:
ScriptTriggers:
^Infantry:
AppearsOnRadar:
@@ -183,6 +186,7 @@
LuaScriptEvents:
DetectCloaked:
Range: 1
ScriptTriggers:
^CivInfantry:
Inherits: ^Infantry
@@ -261,6 +265,7 @@
UpdatesPlayerStatistics:
Huntable:
LuaScriptEvents:
ScriptTriggers:
^Plane:
AppearsOnRadar:
@@ -280,6 +285,7 @@
Huntable:
AttackMove:
LuaScriptEvents:
ScriptTriggers:
^Ship:
AppearsOnRadar:
@@ -305,6 +311,7 @@
UpdatesPlayerStatistics:
Huntable:
LuaScriptEvents:
ScriptTriggers:
^Building:
AppearsOnRadar:
@@ -348,6 +355,7 @@
Huntable:
LuaScriptEvents:
Demolishable:
ScriptTriggers:
^BaseBuilding:
Inherits: ^Building
@@ -389,6 +397,7 @@
FrozenUnderFog:
StartsRevealed: true
LuaScriptEvents:
ScriptTriggers:
^TechBuilding:
Inherits: ^CivBuilding
@@ -429,6 +438,7 @@
FrozenUnderFog:
StartsRevealed: true
LuaScriptEvents:
ScriptTriggers:
^Wall:
AppearsOnRadar:
@@ -460,6 +470,7 @@
BodyOrientation:
FrozenUnderFog:
LuaScriptEvents:
ScriptTriggers:
^Tree:
Tooltip:
@@ -484,6 +495,7 @@
FrozenUnderFog:
StartsRevealed: true
LuaScriptEvents:
ScriptTriggers:
^TibTree:
Tooltip:
@@ -520,6 +532,7 @@
FrozenUnderFog:
StartsRevealed: true
LuaScriptEvents:
ScriptTriggers:
^Husk:
Health:
@@ -545,6 +558,7 @@
BodyOrientation:
LuaScriptEvents:
DisabledOverlay:
ScriptTriggers:
^HelicopterHusk:
Inherits: ^Husk
@@ -573,4 +587,5 @@
DestroyedSound: xplobig4.aud
BodyOrientation:
LuaScriptEvents:
ScriptTriggers:

View File

@@ -38,6 +38,7 @@
Huntable:
LuaScriptEvents:
Demolishable:
ScriptTriggers:
^Tank:
AppearsOnRadar:
@@ -79,6 +80,7 @@
Huntable:
LuaScriptEvents:
Demolishable:
ScriptTriggers:
^Husk:
Health:
@@ -107,6 +109,7 @@
TransformOnCapture:
ForceHealthPercentage: 25
DisabledOverlay:
ScriptTriggers:
^TowerHusk:
Health:
@@ -126,6 +129,7 @@
Types: Husk
BodyOrientation:
LuaScriptEvents:
ScriptTriggers:
^AircraftHusk:
Inherits: ^Husk
@@ -190,6 +194,7 @@
UpdatesPlayerStatistics:
Huntable:
LuaScriptEvents:
ScriptTriggers:
^Plane:
AppearsOnRadar:
@@ -214,6 +219,7 @@
Huntable:
AttackMove:
LuaScriptEvents:
ScriptTriggers:
^Helicopter:
Inherits: ^Plane
@@ -270,3 +276,5 @@
Weapons: shrapnel
Pieces: 3, 7
Range: 2c0, 5c0
ScriptTriggers:

View File

@@ -1,4 +1,4 @@
local ants = OpenRA.GetRandomInteger(0, 51) == 0
local ants = Utils.RandomInteger(0, 51) == 0
if ants then
UnitTypes = { "ant", "ant", "ant" }
@@ -29,85 +29,110 @@ else
{ SovietWarFactory1, { "3tnk", "4tnk", "v2rl", "ttnk", "apc" } }
}
end
ParadropPlaneType = "badr"
ParadropWaypointCount = 8
SendSovietUnits = function(entryCell, unitTypes, interval)
local units = Reinforcements.Reinforce(soviets, unitTypes, entryCell, entryCell, interval)
local team = Team.New(units)
Team.AddEventHandler(team.OnAllKilled, function()
SendSovietUnits(entryCell, unitTypes, interval)
end)
Team.Do(team, function(a)
Actor.OnDamaged(a, function()
if not Actor.CargoIsEmpty(a) then
Actor.Stop(a)
Actor.UnloadCargo(a, true)
ParadropWaypoints = { Paradrop1, Paradrop2, Paradrop3, Paradrop4, Paradrop5, Paradrop6, Paradrop7, Paradrop8 }
BindActorTriggers = function(a)
if a.HasProperty("Hunt") then
if a.Owner == allies then
Trigger.OnIdle(a, a.Hunt)
else
Trigger.OnIdle(a, function(a) a.AttackMove(AlliedTechnologyCenter.Location) end)
end
end
if a.HasProperty("HasPassengers") then
Trigger.OnDamaged(a, function()
if a.HasPassengers then
a.Stop()
a.UnloadPassengers()
end
end)
Actor.OnIdle(a, function() Actor.AttackMove(a, AlliedTechnologyCenter.Location) end)
end
end
SendSovietUnits = function(entryCell, unitTypes, interval)
local i = 0
team = {}
Utils.Do(unitTypes, function(type)
local a = Actor.Create(type, false, { Owner = soviets, Location = entryCell })
BindActorTriggers(a)
Trigger.AfterDelay(i * interval, function() a.IsInWorld = true end)
table.insert(team, a)
i = i + 1
end)
Trigger.OnAllKilled(team, function() SendSovietUnits(entryCell, unitTypes, interval) end)
end
ShipAlliedUnits = function()
local transport, reinforcements = Reinforcements.Insert(allies, "lst", { "1tnk", "1tnk", "jeep", "2tnk", "2tnk" }, { LstEntry.Location, LstUnload.Location }, { LstEntry.Location })
Utils.Do(reinforcements, function(a) Actor.OnIdle(a, Actor.Hunt) end)
OpenRA.RunAfterDelay(60 * 25, ShipAlliedUnits)
local transport = Actor.Create("lst", true, { Location = LstEntry.Location, Owner = allies })
Utils.Do({ "1tnk", "1tnk", "jeep", "2tnk", "2tnk" }, function(type)
local a = Actor.Create(type, false, { Owner = allies })
BindActorTriggers(a)
transport.LoadPassenger(a)
end)
transport.Move(LstUnload.Location)
transport.UnloadPassengers()
transport.Wait(50)
transport.Move(LstEntry.Location)
transport.Destroy()
Trigger.AfterDelay(60 * 25, ShipAlliedUnits)
end
ParadropSovietUnits = function()
local lz = Map.GetNamedActor("Paradrop" .. OpenRA.GetRandomInteger(1, ParadropWaypointCount - 1)).Location
local plane, passengers = SupportPowers.Paradrop(soviets, ParadropPlaneType, ParadropUnitTypes, Map.GetRandomEdgeCell(), lz)
Utils.Do(passengers, function(a) Actor.OnIdle(a, Actor.Hunt) end)
OpenRA.RunAfterDelay(35 * 25, ParadropSovietUnits)
local lz = Utils.Random(ParadropWaypoints).Location
local start = Utils.CenterOfCell(Map.RandomEdgeCell()) + WVec.New(0, 0, Actor.CruiseAltitude("badr"))
local transport = Actor.Create("badr", true, { CenterPosition = start, Owner = soviets, Facing = (Utils.CenterOfCell(lz) - start).Facing })
Utils.Do(ParadropUnitTypes, function(type)
local a = Actor.Create(type, false, { Owner = soviets })
BindActorTriggers(a)
transport.LoadPassenger(a)
end)
transport.Paradrop(lz)
Trigger.AfterDelay(35 * 25, ParadropSovietUnits)
end
ProduceUnits = function()
Utils.Do(ProducedUnitTypes, function(t)
local factory = t[1]
if not Actor.IsDead(factory) and not Production.PerFactoryQueueIsBusy(factory) then
local unitType = t[2][OpenRA.GetRandomInteger(1, #t[2] + 1)]
Production.BuildWithPerFactoryQueue(factory, unitType)
end
end)
OpenRA.RunAfterDelay(15, ProduceUnits)
ProduceUnits = function(t)
local factory = t[1]
if not factory.IsDead then
local unitType = t[2][Utils.RandomInteger(1, #t[2] + 1)]
factory.Wait(Actor.BuildTime(unitType))
factory.Produce(unitType)
factory.CallFunc(function() ProduceUnits(t) end)
end
end
SetupAlliedUnits = function()
for a in Utils.Enumerate(Map.GetNamedActors()) do
if Actor.Owner(a) == allies then
if Actor.HasTrait(a, "LuaScriptEvents") then
a:AddTrait(OpenRA.New("Invulnerable")) -- todo: replace
end
Actor.SetStance(a, "Defend")
Utils.Do(Map.NamedActors, function(a)
if a.Owner == allies and a.HasProperty("Invulnerable") then
a.Invulnerable = true
a.Stance = "Defend"
end
end
end
SetupFactories = function()
Utils.Do(ProducedUnitTypes, function(pair)
Actor.OnProduced(pair[1], function(self, other, ex)
Actor.Hunt(other)
Actor.OnDamaged(other, function()
if not Actor.CargoIsEmpty(other) then
Actor.Stop(other)
Actor.UnloadCargo(other, true)
end
end)
end)
end)
end
SetupFactories = function()
Utils.Do(ProducedUnitTypes, function(pair)
Trigger.OnProduction(pair[1], function(_, a) BindActorTriggers(a) end)
end)
end
ChronoshiftAlliedUnits = function()
local cells = Map.ExpandFootprint({ ChronoshiftLocation.Location }, false)
local cells = Utils.ExpandFootprint({ ChronoshiftLocation.Location }, false)
local units = { }
for i = 1, #cells do
local unit = Actor.Create("2tnk", { Owner = allies, Facing = { 0, "Int32" } })
Actor.OnIdle(unit, Actor.Hunt)
table.insert(units, { unit, cells[i] })
end
SupportPowers.Chronoshift(units, Chronosphere)
OpenRA.RunAfterDelay(60 * 25, ChronoshiftAlliedUnits)
local unit = Actor.Create("2tnk", true, { Owner = allies, Facing = 0 })
BindActorTriggers(unit)
units[unit] = cells[i]
end
Chronosphere.Chronoshift(units)
Trigger.AfterDelay(60 * 25, ChronoshiftAlliedUnits)
end
ticks = 0
@@ -117,33 +142,21 @@ Tick = function()
ticks = ticks + 1
local t = (ticks + 45) % (360 * speed) * (math.pi / 180) / speed;
OpenRA.SetViewportCenterPosition(WPos.op_Addition(viewportOrigin, WVec.New(19200 * math.sin(t), 20480 * math.cos(t))))
if ticks % 150 == 0 then
Utils.Do(Actor.ActorsWithTrait("AttackBase"), function(a)
if Actor.IsIdle(a) and not Map.IsNamedActor(a) and not Actor.IsDead(a) and Actor.IsInWorld(a) and (Actor.Owner(a) == soviets or Actor.Owner(a) == allies) then
Actor.Hunt(a)
end
end)
end
Camera.Position = viewportOrigin + WVec.New(19200 * math.sin(t), 20480 * math.cos(t), 0)
end
WorldLoaded = function()
allies = OpenRA.GetPlayer("Allies")
soviets = OpenRA.GetPlayer("Soviets")
viewportOrigin = OpenRA.GetViewportCenterPosition()
allies = Player.GetPlayer("Allies")
soviets = Player.GetPlayer("Soviets")
viewportOrigin = Camera.Position
SetupAlliedUnits()
SetupFactories()
ProduceUnits()
ShipAlliedUnits()
ParadropSovietUnits()
OpenRA.RunAfterDelay(5 * 25, ChronoshiftAlliedUnits)
OpenRA.GiveCash(allies, 1000000)
OpenRA.GiveCash(soviets, 1000000)
Trigger.AfterDelay(5 * 25, ChronoshiftAlliedUnits)
Utils.Do(ProducedUnitTypes, ProduceUnits)
SendSovietUnits(Entry1.Location, UnitTypes, 50)
SendSovietUnits(Entry2.Location, UnitTypes, 50)
SendSovietUnits(Entry3.Location, UnitTypes, 50)

View File

@@ -315,9 +315,6 @@ Actors:
Actor110: fcom
Location: 106,44
Owner: Soviets
Actor111: silo
Location: 96,28
Owner: Soviets
Actor106: fact
Location: 114,43
Owner: Soviets
@@ -477,9 +474,6 @@ Actors:
Actor105: brik
Location: 94,70
Owner: Allies
Actor154: silo
Location: 82,86
Owner: Allies
SovietBarracks1: barr
Location: 109,48
Owner: Soviets
@@ -956,30 +950,6 @@ Actors:
Actor195: hpad
Location: 70,75
Owner: Allies
Actor75: oilb
Location: 4,126
Owner: Allies
Actor334: oilb
Location: 6,126
Owner: Allies
Actor335: oilb
Location: 8,126
Owner: Allies
Actor336: oilb
Location: 10,126
Owner: Allies
Actor337: oilb
Location: 12,126
Owner: Allies
Actor338: oilb
Location: 14,126
Owner: Allies
Actor339: oilb
Location: 2,126
Owner: Allies
Actor340: oilb
Location: 0,126
Owner: Allies
Actor341: dome
Location: 63,73
Owner: Allies
@@ -1034,15 +1004,6 @@ Actors:
Actor361: pbox.e1
Location: 71,96
Owner: Allies
Actor55: silo
Location: 81,85
Owner: Allies
Actor76: silo
Location: 81,86
Owner: Allies
Actor159: silo
Location: 82,85
Owner: Allies
Actor365: hpad
Location: 64,78
Owner: Allies
@@ -1303,11 +1264,16 @@ Rules:
-CrateSpawner:
-SpawnMPUnits:
-MPStartLocations:
LuaScriptInterface:
LuaScripts: desert-shellmap.lua
ResourceType@ore:
ValuePerUnit: 0
LuaScript:
Scripts: desert-shellmap.lua
LoadWidgetAtGameStart:
Widget: MAINMENU
-StartGameNotification:
OILB:
CashTrickler:
ShowTicks: false
TRAN.Husk2:
Burns:
Damage: 0
@@ -1316,24 +1282,6 @@ Rules:
APC:
Cargo:
InitialUnits: e1, e1, e2, e3, e4
TENT:
ProductionQueue:
Type: Infantry
Group: Infantry
BuildSpeed: .4
LowPowerSlowdown: 3
BARR:
ProductionQueue:
Type: Infantry
Group: Infantry
BuildSpeed: .4
LowPowerSlowdown: 3
WEAP:
ProductionQueue:
Type: Vehicle
Group: Vehicle
BuildSpeed: .4
LowPowerSlowdown: 3
Ant:
Buildable:
Owner: soviet
@@ -1341,6 +1289,7 @@ Rules:
Health:
HP: 200
^Vehicle:
ScriptInvulnerable:
GivesBounty:
Percentage: 0
GainsExperience:
@@ -1349,6 +1298,7 @@ Rules:
ArmorModifier:
SpeedModifier:
^Tank:
ScriptInvulnerable:
GivesBounty:
Percentage: 0
GainsExperience:
@@ -1357,6 +1307,7 @@ Rules:
ArmorModifier:
SpeedModifier:
^Infantry:
ScriptInvulnerable:
-Selectable: # short-term hack to make infantry not play die sounds until we fix RenderInfantry
GivesBounty:
Percentage: 0
@@ -1366,12 +1317,15 @@ Rules:
ArmorModifier:
SpeedModifier:
^Ship:
ScriptInvulnerable:
GivesBounty:
Percentage: 0
^Plane:
ScriptInvulnerable:
GivesBounty:
Percentage: 0
^Building:
ScriptInvulnerable:
GivesBounty:
Percentage: 0

View File

@@ -52,6 +52,7 @@
CancelActivity: True
CaptureNotification:
Notification: UnitStolen
ScriptTriggers:
^Tank:
AppearsOnRadar:
@@ -107,6 +108,7 @@
CancelActivity: True
CaptureNotification:
Notification: UnitStolen
ScriptTriggers:
^Infantry:
AppearsOnRadar:
@@ -165,6 +167,7 @@
RequiresTech: InfantryHealing
Huntable:
LuaScriptEvents:
ScriptTriggers:
^Ship:
AppearsOnRadar:
@@ -197,6 +200,7 @@
BodyOrientation:
Huntable:
LuaScriptEvents:
ScriptTriggers:
^Plane:
AppearsOnRadar:
@@ -231,6 +235,7 @@
BodyOrientation:
Huntable:
LuaScriptEvents:
ScriptTriggers:
^Helicopter:
Inherits: ^Plane
@@ -283,6 +288,7 @@
Huntable:
LuaScriptEvents:
Demolishable:
ScriptTriggers:
^Wall:
AppearsOnRadar:
@@ -319,6 +325,7 @@
BodyOrientation:
FrozenUnderFog:
LuaScriptEvents:
ScriptTriggers:
^TechBuilding:
Inherits: ^Building
@@ -426,6 +433,7 @@
FrozenUnderFog:
StartsRevealed: true
LuaScriptEvents:
ScriptTriggers:
^Husk:
Husk:
@@ -455,6 +463,7 @@
TransformOnCapture:
ForceHealthPercentage: 25
DisabledOverlay:
ScriptTriggers:
^HelicopterHusk:
Inherits: ^Husk
@@ -499,6 +508,7 @@
AutoTargetIgnore:
BodyOrientation:
LuaScriptEvents:
ScriptTriggers:
^Rock:
Tooltip:
@@ -520,6 +530,7 @@
FrozenUnderFog:
StartsRevealed: true
LuaScriptEvents:
ScriptTriggers:
^DesertCivBuilding:
Inherits: ^CivBuilding

View File

@@ -39,6 +39,7 @@
Huntable:
LuaScriptEvents:
Demolishable:
ScriptTriggers:
^Wall:
AppearsOnRadar:
@@ -77,6 +78,7 @@
BodyOrientation:
LuaScriptEvents:
Demolishable:
ScriptTriggers:
^Infantry:
AppearsOnRadar:
@@ -129,6 +131,7 @@
BodyOrientation:
Huntable:
LuaScriptEvents:
ScriptTriggers:
^CivilianInfantry:
Inherits: ^Infantry
@@ -199,6 +202,7 @@
CameraPitch: 90
Huntable:
LuaScriptEvents:
ScriptTriggers:
^Helicopter:
AppearsOnRadar:
@@ -232,4 +236,5 @@
CameraPitch: 90
Huntable:
LuaScriptEvents:
ScriptTriggers: