Start scripting the cnc shellmap.
This commit is contained in:
87
OpenRA.Mods.Cnc/Missions/CncShellmapScript.cs
Executable file
87
OpenRA.Mods.Cnc/Missions/CncShellmapScript.cs
Executable file
@@ -0,0 +1,87 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Mods.RA.Air;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Move;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class CncShellmapScriptInfo : TraitInfo<CncShellmapScript> { }
|
||||
|
||||
class CncShellmapScript: IWorldLoaded, ITick
|
||||
{
|
||||
Dictionary<string, Actor> Actors;
|
||||
static int2 ViewportOrigin;
|
||||
Map Map;
|
||||
|
||||
public void WorldLoaded(World w)
|
||||
{
|
||||
Map = w.Map;
|
||||
var b = w.Map.Bounds;
|
||||
ViewportOrigin = new int2(b.Left + b.Width/2, b.Top + b.Height/2);
|
||||
Game.MoveViewport(ViewportOrigin);
|
||||
|
||||
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
||||
Sound.SoundVolumeModifier = 0.25f;
|
||||
}
|
||||
|
||||
int ticks = 0;
|
||||
float speed = 4f;
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
var loc = new float2(
|
||||
(float)(-System.Math.Sin((ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed) * 15f + ViewportOrigin.X),
|
||||
(float)(0.4f*System.Math.Cos((ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed) * 10f + ViewportOrigin.Y));
|
||||
Game.MoveViewport(loc);
|
||||
|
||||
if (ticks == 0)
|
||||
{
|
||||
var w = Map.Waypoints;
|
||||
LoopTrack(Actors["boat1"], w["tl1"], w["tr1"]);
|
||||
LoopTrack(Actors["boat3"], w["tl1"], w["tr1"]);
|
||||
LoopTrack(Actors["boat2"], w["tl3"], w["tr3"]);
|
||||
LoopTrack(Actors["boat4"], w["tl3"], w["tr3"]);
|
||||
CreateUnitsInTransport(Actors["lst1"], new string[] {"htnk"});
|
||||
CreateUnitsInTransport(Actors["lst2"], new string[] {"mcv"});
|
||||
CreateUnitsInTransport(Actors["lst3"], new string[] {"htnk"});
|
||||
LoopTrack(Actors["lst1"], w["tl2"], w["tr2"]);
|
||||
LoopTrack(Actors["lst2"], w["tl2"], w["tr2"]);
|
||||
LoopTrack(Actors["lst3"], w["tl2"], w["tr2"]);
|
||||
}
|
||||
|
||||
ticks++;
|
||||
}
|
||||
|
||||
void CreateUnitsInTransport(Actor transport, string[] cargo)
|
||||
{
|
||||
var f = transport.Trait<IFacing>();
|
||||
var c = transport.Trait<Cargo>();
|
||||
foreach (var i in cargo)
|
||||
c.Load(transport, transport.World.CreateActor(false, i.ToLowerInvariant(), new TypeDictionary
|
||||
{
|
||||
new OwnerInit( transport.Owner ),
|
||||
new FacingInit( f.Facing ),
|
||||
}));
|
||||
}
|
||||
|
||||
void LoopTrack(Actor self, int2 left, int2 right)
|
||||
{
|
||||
var mobile = self.Trait<Mobile>();
|
||||
self.QueueActivity(mobile.ScriptedMove(left));
|
||||
self.QueueActivity(new Teleport(right));
|
||||
self.QueueActivity(new CallFunc(() => LoopTrack(self,left,right)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,7 @@
|
||||
<Compile Include="RenderCargo.cs" />
|
||||
<Compile Include="CncLoadScreen.cs" />
|
||||
<Compile Include="WithRoof.cs" />
|
||||
<Compile Include="Missions\CncShellmapScript.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -1 +1 @@
|
||||
e7b9badb3b7d49ccc773a7aa086c0ff9a1136b77
|
||||
2cc2a95c89dc6594acec52d7acbc720f45fc5d9e
|
||||
@@ -8,7 +8,7 @@ Description: CNC Shellmap
|
||||
|
||||
Author: Chris Forbes
|
||||
|
||||
PlayerCount: 0
|
||||
PlayerCount: 6
|
||||
|
||||
Tileset: WINTER
|
||||
|
||||
@@ -19,33 +19,145 @@ TopLeft: 8,1
|
||||
BottomRight: 88,46
|
||||
|
||||
Players:
|
||||
PlayerReference@BadGuy:
|
||||
PlayerReference@Nod:
|
||||
Name: Nod
|
||||
Palette:
|
||||
Race: nod
|
||||
OwnsWorld: False
|
||||
NonCombatant: False
|
||||
Playable: False
|
||||
DefaultStartingUnits: False
|
||||
AllowBots: True
|
||||
LockRace: False
|
||||
Race: nod
|
||||
LockColor: False
|
||||
Color: 255,255,20,0
|
||||
Color2: 255,56,0,0
|
||||
InitialCash: 0
|
||||
Allies: Nod
|
||||
Enemies: GDI
|
||||
PlayerReference@GoodGuy:
|
||||
PlayerReference@GDI:
|
||||
Name: GDI
|
||||
Race: gdi
|
||||
Palette:
|
||||
OwnsWorld: False
|
||||
NonCombatant: False
|
||||
Playable: False
|
||||
DefaultStartingUnits: False
|
||||
AllowBots: True
|
||||
LockRace: False
|
||||
Race: gdi
|
||||
LockColor: False
|
||||
Color: 255,246,214,121
|
||||
Color2: 255,40,32,8
|
||||
InitialCash: 0
|
||||
Allies: GDI
|
||||
Enemies: Nod
|
||||
PlayerReference@Neutral:
|
||||
Name: Neutral
|
||||
Palette:
|
||||
Race: gdi
|
||||
OwnsWorld: True
|
||||
NonCombatant: True
|
||||
Playable: False
|
||||
DefaultStartingUnits: False
|
||||
AllowBots: True
|
||||
LockRace: False
|
||||
Race: gdi
|
||||
LockColor: False
|
||||
Color: 255,238,238,238
|
||||
Color2: 255,44,28,24
|
||||
InitialCash: 0
|
||||
Allies:
|
||||
Enemies:
|
||||
PlayerReference@Multi0:
|
||||
Name: Multi0
|
||||
Palette:
|
||||
OwnsWorld: False
|
||||
NonCombatant: False
|
||||
Playable: True
|
||||
DefaultStartingUnits: True
|
||||
AllowBots: True
|
||||
LockRace: False
|
||||
Race: Random
|
||||
LockColor: False
|
||||
Color: 255,238,238,238
|
||||
Color2: 255,44,28,24
|
||||
InitialCash: 0
|
||||
Allies:
|
||||
Enemies:
|
||||
PlayerReference@Multi1:
|
||||
Name: Multi1
|
||||
Palette:
|
||||
OwnsWorld: False
|
||||
NonCombatant: False
|
||||
Playable: True
|
||||
DefaultStartingUnits: True
|
||||
AllowBots: True
|
||||
LockRace: False
|
||||
Race: Random
|
||||
LockColor: False
|
||||
Color: 255,238,238,238
|
||||
Color2: 255,44,28,24
|
||||
InitialCash: 0
|
||||
Allies:
|
||||
Enemies:
|
||||
PlayerReference@Multi2:
|
||||
Name: Multi2
|
||||
Palette:
|
||||
OwnsWorld: False
|
||||
NonCombatant: False
|
||||
Playable: True
|
||||
DefaultStartingUnits: True
|
||||
AllowBots: True
|
||||
LockRace: False
|
||||
Race: Random
|
||||
LockColor: False
|
||||
Color: 255,238,238,238
|
||||
Color2: 255,44,28,24
|
||||
InitialCash: 0
|
||||
Allies:
|
||||
Enemies:
|
||||
PlayerReference@Multi3:
|
||||
Name: Multi3
|
||||
Palette:
|
||||
OwnsWorld: False
|
||||
NonCombatant: False
|
||||
Playable: True
|
||||
DefaultStartingUnits: True
|
||||
AllowBots: True
|
||||
LockRace: False
|
||||
Race: Random
|
||||
LockColor: False
|
||||
Color: 255,238,238,238
|
||||
Color2: 255,44,28,24
|
||||
InitialCash: 0
|
||||
Allies:
|
||||
Enemies:
|
||||
PlayerReference@Multi4:
|
||||
Name: Multi4
|
||||
Palette:
|
||||
OwnsWorld: False
|
||||
NonCombatant: False
|
||||
Playable: True
|
||||
DefaultStartingUnits: True
|
||||
AllowBots: True
|
||||
LockRace: False
|
||||
Race: Random
|
||||
LockColor: False
|
||||
Color: 255,238,238,238
|
||||
Color2: 255,44,28,24
|
||||
InitialCash: 0
|
||||
Allies:
|
||||
Enemies:
|
||||
PlayerReference@Multi5:
|
||||
Name: Multi5
|
||||
Palette:
|
||||
OwnsWorld: False
|
||||
NonCombatant: False
|
||||
Playable: True
|
||||
DefaultStartingUnits: True
|
||||
AllowBots: True
|
||||
LockRace: False
|
||||
Race: Random
|
||||
LockColor: False
|
||||
Color: 255,238,238,238
|
||||
Color2: 255,44,28,24
|
||||
InitialCash: 0
|
||||
@@ -53,17 +165,17 @@ Players:
|
||||
Enemies:
|
||||
|
||||
Actors:
|
||||
Actor0: boat
|
||||
Location: 32,34
|
||||
boat1: boat
|
||||
Location: 45,33
|
||||
Owner: GDI
|
||||
Actor1: boat
|
||||
Location: 39,36
|
||||
boat2: boat
|
||||
Location: 39,37
|
||||
Owner: GDI
|
||||
Actor2: boat
|
||||
boat3: boat
|
||||
Location: 70,33
|
||||
Owner: GDI
|
||||
Actor3: boat
|
||||
Location: 79,36
|
||||
boat4: boat
|
||||
Location: 79,37
|
||||
Owner: GDI
|
||||
Actor4: fix
|
||||
Location: 59,44
|
||||
@@ -938,8 +1050,34 @@ Actors:
|
||||
Actor221: jeep
|
||||
Location: 57,45
|
||||
Owner: GDI
|
||||
lst1: lst
|
||||
Location: 53,35
|
||||
Owner: GDI
|
||||
Facing: 64
|
||||
lst2: lst
|
||||
Location: 58,35
|
||||
Owner: GDI
|
||||
Facing: 64
|
||||
lst3: lst
|
||||
Location: 63,35
|
||||
Owner: GDI
|
||||
Facing: 64
|
||||
ftnk1: ftnk
|
||||
Location: 67,22
|
||||
Owner: Nod
|
||||
Facing: 228
|
||||
ftnk2: ftnk
|
||||
Location: 65,20
|
||||
Owner: Nod
|
||||
Facing: 192
|
||||
|
||||
Waypoints:
|
||||
tl1: 8,33
|
||||
tr1: 87,33
|
||||
tl2: 8,35
|
||||
tr2: 87,35
|
||||
tl3: 8,37
|
||||
tr3: 87,37
|
||||
|
||||
Smudges:
|
||||
|
||||
@@ -948,3 +1086,17 @@ Rules:
|
||||
-SpawnMPUnits:
|
||||
-MPStartLocations:
|
||||
-CrateSpawner:
|
||||
CncShellmapScript:
|
||||
LST:
|
||||
Mobile:
|
||||
Speed: 3
|
||||
BOAT:
|
||||
Mobile:
|
||||
Speed: 3
|
||||
|
||||
Sequences:
|
||||
|
||||
Weapons:
|
||||
|
||||
Voices:
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ TileSets:
|
||||
mods/cnc/tilesets/snow.yaml
|
||||
|
||||
LoadScreen: CncLoadScreen
|
||||
ShellmapUid:e7b9badb3b7d49ccc773a7aa086c0ff9a1136b77
|
||||
ShellmapUid:2cc2a95c89dc6594acec52d7acbc720f45fc5d9e
|
||||
ServerTraits:
|
||||
PlayerCommands
|
||||
LobbyCommands
|
||||
|
||||
Reference in New Issue
Block a user