Merge pull request #4216 from pchote/cnc-shellmap
Rewrite C&C shellmap in lua
This commit is contained in:
@@ -986,24 +986,6 @@ Actors:
|
||||
Location: 65,20
|
||||
Owner: Nod
|
||||
Facing: 192
|
||||
tl1: mpspawn
|
||||
Location: 8,33
|
||||
Owner: Neutral
|
||||
tr1: mpspawn
|
||||
Location: 87,33
|
||||
Owner: Neutral
|
||||
tl2: mpspawn
|
||||
Location: 8,35
|
||||
Owner: Neutral
|
||||
tr2: mpspawn
|
||||
Location: 87,35
|
||||
Owner: Neutral
|
||||
tl3: mpspawn
|
||||
Location: 8,37
|
||||
Owner: Neutral
|
||||
tr3: mpspawn
|
||||
Location: 87,37
|
||||
Owner: Neutral
|
||||
|
||||
Smudges:
|
||||
|
||||
@@ -1015,7 +997,8 @@ Rules:
|
||||
PlayMusicOnMapLoad:
|
||||
Music: map1
|
||||
Loop: true
|
||||
CncShellmapScript:
|
||||
LuaScriptInterface:
|
||||
LuaScripts: shellmap.lua
|
||||
LoadWidgetAtGameStart:
|
||||
Widget: MENU_BACKGROUND
|
||||
LST:
|
||||
|
||||
44
mods/cnc/maps/shellmap/shellmap.lua
Normal file
44
mods/cnc/maps/shellmap/shellmap.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
ticks = 0
|
||||
speed = 5
|
||||
|
||||
Tick = function()
|
||||
ticks = ticks + 1
|
||||
local t = (ticks + 45) % (360 * speed) * (math.pi / 180) / speed;
|
||||
OpenRA.SetViewportCenterPosition(WPos.op_Addition(viewportOrigin, MakeVec(-15360 * math.sin(t), 4096 * math.cos(t))))
|
||||
end
|
||||
|
||||
WorldLoaded = function()
|
||||
viewportOrigin = OpenRA.GetViewportCenterPosition()
|
||||
CreateUnitsInTransport(lst1, { "htnk" });
|
||||
CreateUnitsInTransport(lst2, { "mcv" });
|
||||
CreateUnitsInTransport(lst3, { "htnk" });
|
||||
|
||||
local units = { boat1, boat2, boat3, boat4, lst1, lst2, lst3}
|
||||
for i, unit in ipairs(units) do
|
||||
LoopTrack(unit, MakePos(8, unit.Location.Y), MakePos(87, unit.Location.Y))
|
||||
end
|
||||
end
|
||||
|
||||
LoopTrack = function(actor, left, right)
|
||||
Actor.ScriptedMove(actor, left)
|
||||
Actor.Teleport(actor, right)
|
||||
Actor.CallFunc(actor, function() LoopTrack(actor, left, right) end)
|
||||
end
|
||||
|
||||
CreateUnitsInTransport = function(transport, passengerNames)
|
||||
local cargo = Actor.Trait(transport, "Cargo")
|
||||
local owner = transport.owner
|
||||
for i, passengerName in ipairs(passengerNames) do
|
||||
cargo:Load(transport, Actor.Create(passengerName, { AddToWorld = false, Owner = owner }))
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO: The standard library should expose CPos.New() etc
|
||||
MakePos = function(x, y)
|
||||
return OpenRA.New("CPos", { {x, "Int32"}, {y, "Int32"} })
|
||||
end
|
||||
|
||||
MakeVec = function(x, y)
|
||||
return OpenRA.New("WVec", { {x, "Int32"}, {y, "Int32"}, {0, "Int32"} })
|
||||
end
|
||||
@@ -27,6 +27,14 @@ Actor.MoveNear = function(actor, location, nearEnough)
|
||||
actor:QueueActivity(OpenRA.New("Move", { location, Map.GetWRangeFromCells(nearEnough) }))
|
||||
end
|
||||
|
||||
Actor.ScriptedMove = function(actor, location)
|
||||
actor:QueueActivity(OpenRA.New("Move", { location }))
|
||||
end
|
||||
|
||||
Actor.Teleport = function(actor, location)
|
||||
actor:QueueActivity(OpenRA.New("SimpleTeleport", { location }))
|
||||
end
|
||||
|
||||
Actor.HeliFly = function(actor, position)
|
||||
actor:QueueActivity(OpenRA.New("HeliFly", { position }))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user