Merge pull request #4397 from Mailaender/nod01-lua

Ported first Nod mission to Lua
This commit is contained in:
Paul Chote
2014-01-03 14:04:54 -08:00
3 changed files with 155 additions and 292 deletions

View File

@@ -1,199 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2013 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;
using System.Collections.Generic;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Mods.RA;
using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Missions;
using OpenRA.Mods.RA.Move;
using OpenRA.Scripting;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Missions
{
class Nod01ScriptInfo : TraitInfo<Nod01Script>, Requires<SpawnMapActorsInfo> { }
class Nod01Script : IHasObjectives, IWorldLoaded, ITick
{
public event Action<bool> OnObjectivesUpdated = notify => { };
public IEnumerable<Objective> Objectives { get { return new[] { killnikoomba, levelvillage }; } }
Objective killnikoomba = new Objective(ObjectiveType.Primary, KillNikoombaText, ObjectiveStatus.InProgress);
Objective levelvillage = new Objective(ObjectiveType.Primary, LevelVillageText, ObjectiveStatus.Inactive);
const string KillNikoombaText = "Find Nikoomba. Once found he must be assasinated.";
const string LevelVillageText = "Nikoomba has met his demise, now level the village.";
Player nod;
Actor nikoomba;
Actor vil01;
Actor vil02;
Actor vil03;
Actor vil04;
Actor vil05;
Actor vil06;
Actor vil07;
Actor vil08;
Actor vil09;
Actor vil10;
Actor vil11;
Actor vil12;
Actor vil13;
Actor civ01;
Actor civ02;
Actor civ03;
Actor civ04;
Actor civ05;
Actor civ06;
Actor civ07;
Actor nr1;
Actor nr2;
Actor nr3;
World world;
const string ReInfE1 = "E1";
const string ReInfE3 = "E3";
void MissionFailed(string text)
{
MissionUtils.CoopMissionFailed(world, text, nod);
}
void MissionAccomplished(string text)
{
MissionUtils.CoopMissionAccomplished(world, text, nod);
}
public void Tick(Actor self)
{
if (nod.WinState != WinState.Undefined) return;
if (world.FrameNumber == 700)
{
NODReinforceNthA();
Sound.Play("reinfor1.aud");
}
if (world.FrameNumber == 1400)
{
NODReinforceNthB();
Sound.Play("reinfor1.aud");
}
if (killnikoomba.Status == ObjectiveStatus.InProgress)
{
if (nikoomba.Destroyed)
{
killnikoomba.Status = ObjectiveStatus.Completed;
levelvillage.Status = ObjectiveStatus.InProgress;
OnObjectivesUpdated(true);
NODReinforceNWstA();
Sound.Play("reinfor1.aud");
}
}
if (levelvillage.Status == ObjectiveStatus.InProgress)
{
if (vil01.Destroyed && vil02.Destroyed && vil03.Destroyed && vil04.Destroyed && vil05.Destroyed && vil06.Destroyed &&
vil07.Destroyed && vil08.Destroyed && vil09.Destroyed && vil10.Destroyed && vil11.Destroyed && vil12.Destroyed &&
vil13.Destroyed && civ01.Destroyed && civ02.Destroyed && civ03.Destroyed && civ04.Destroyed && civ05.Destroyed &&
civ06.Destroyed && civ07.Destroyed)
{
levelvillage.Status = ObjectiveStatus.Completed;
OnObjectivesUpdated(true);
Sound.StopMusic();
MissionAccomplished("Nikoomba was killed and the village was destroyed.");
}
}
var unitsAndBuildings = world.Actors.Where(a => !a.IsDead() && a.IsInWorld && (a.HasTrait<Mobile>() || (a.HasTrait<Building>() && !a.HasTrait<Wall>())));
if (!unitsAndBuildings.Any(a => a.Owner == nod))
{
Action afterFMV = () =>
{
Sound.StopMusic();
MissionFailed("The Nod forces in the area have been wiped out.");
};
Game.RunAfterDelay(0, () => Media.PlayFMVFullscreen(world, "nodlose.vqa", afterFMV));
}
}
void NODReinforceNthA()
{
nr1 = world.CreateActor(true, ReInfE1, new TypeDictionary { new OwnerInit(nod), new LocationInit(nr1.Location) });
nr1.QueueActivity(nr1.Trait<Mobile>().ScriptedMove(nr1.Location - new CVec(0, -2)));
nr1 = world.CreateActor(true, ReInfE1, new TypeDictionary { new OwnerInit(nod), new LocationInit(nr1.Location) });
nr1.QueueActivity(nr1.Trait<Mobile>().ScriptedMove(nr1.Location - new CVec(0, -2)));
}
void NODReinforceNthB()
{
nr2 = world.CreateActor(true, ReInfE1, new TypeDictionary { new OwnerInit(nod), new LocationInit(nr2.Location) });
nr2.QueueActivity(nr2.Trait<Mobile>().ScriptedMove(nr2.Location - new CVec(0, -2)));
nr2 = world.CreateActor(true, ReInfE1, new TypeDictionary { new OwnerInit(nod), new LocationInit(nr2.Location) });
nr2.QueueActivity(nr2.Trait<Mobile>().ScriptedMove(nr2.Location - new CVec(0, -2)));
}
void NODReinforceNWstA()
{
nr3 = world.CreateActor(true, ReInfE3, new TypeDictionary { new OwnerInit(nod), new LocationInit(nr3.Location) });
nr3.QueueActivity(nr3.Trait<Mobile>().ScriptedMove(nr3.Location - new CVec(0, -5)));
nr3 = world.CreateActor(true, ReInfE3, new TypeDictionary { new OwnerInit(nod), new LocationInit(nr3.Location) });
nr3.QueueActivity(nr3.Trait<Mobile>().ScriptedMove(nr3.Location - new CVec(0, -5)));
nr3 = world.CreateActor(true, ReInfE3, new TypeDictionary { new OwnerInit(nod), new LocationInit(nr3.Location) });
nr3.QueueActivity(nr3.Trait<Mobile>().ScriptedMove(nr3.Location - new CVec(0, -5)));
}
public void WorldLoaded(World w, WorldRenderer wr)
{
world = w;
nod = w.Players.Single(p => p.InternalName == "NOD");
nod.PlayerActor.Trait<PlayerResources>().Cash = 0;
var actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
nikoomba = actors["Nikoomba"];
vil01 = actors["Vil01"];
vil02 = actors["Vil02"];
vil03 = actors["Vil03"];
vil04 = actors["Vil04"];
vil05 = actors["Vil05"];
vil06 = actors["Vil06"];
vil07 = actors["Vil07"];
vil08 = actors["Vil08"];
vil09 = actors["Vil09"];
vil10 = actors["Vil10"];
vil11 = actors["Vil11"];
vil12 = actors["Vil12"];
vil13 = actors["Vil13"];
civ01 = actors["Civ01"];
civ02 = actors["Civ02"];
civ03 = actors["Civ03"];
civ04 = actors["Civ04"];
civ05 = actors["Civ05"];
civ06 = actors["Civ06"];
civ07 = actors["Civ07"];
nr1 = actors["NODReinforceNthA"];
nr2 = actors["NODReinforceNthB"];
nr3 = actors["NODReinforceNWstA"];
wr.Viewport.Center(nr1.Location.CenterPosition);
Game.RunAfterDelay(0, () => Media.PlayFMVFullscreen(w, "nod1pre.vqa", () =>
Media.PlayFMVFullscreen(w, "nod1.vqa", MissionUtils.PlayMissionMusic)));
}
}
}

View File

@@ -6,9 +6,9 @@ RequiresMod: cnc
Title: Nikoomba's Demise Title: Nikoomba's Demise
Description: Conversion of first Nod mission from Cnc Description: In order for the Brotherhood to gain a foothold, we must begin by eliminating certain elements. Nikoomba, the nearby village's leader, is one such element. His views and ours do not coincide. He and his whole group must be eliminated.
Author: Dan9550 Author: Westwood Studios
Tileset: DESERT Tileset: DESERT
@@ -35,18 +35,18 @@ Players:
OwnsWorld: True OwnsWorld: True
NonCombatant: True NonCombatant: True
Race: gdi Race: gdi
PlayerReference@Creeps: PlayerReference@Villagers:
Name: Creeps Name: Villagers
NonCombatant: True NonCombatant: True
Race: gdi Race: gdi
PlayerReference@GDI: PlayerReference@GDI:
Name: GDI Name: GDI
Race: gdi Race: gdi
ColorRamp: 31,222,183 ColorRamp: 31,222,183
Allies: Creeps Allies: Villagers
Enemies: NOD Enemies: Nod
PlayerReference@NOD: PlayerReference@Nod:
Name: NOD Name: Nod
Playable: True Playable: True
AllowBots: False AllowBots: False
Required: True Required: True
@@ -56,9 +56,54 @@ Players:
ColorRamp: 3,255,127 ColorRamp: 3,255,127
LockSpawn: True LockSpawn: True
LockTeam: True LockTeam: True
Enemies: GDI,Creeps Enemies: GDI,Villagers
Actors: Actors:
Actor46: e1
Location: 28,28
Owner: GDI
Actor47: e1
Location: 29,28
Owner: GDI
Actor48: e1
Location: 29,30
Owner: GDI
Actor49: e1
Location: 33,35
Owner: GDI
Actor50: e1
Location: 34,36
Owner: GDI
Actor51: e1
Location: 41,19
Owner: GDI
Actor52: e1
Location: 40,19
Owner: GDI
Actor53: e1
Location: 40,18
Owner: GDI
Actor54: e1
Location: 40,31
Owner: GDI
Actor55: e1
Location: 43,34
Owner: GDI
Actor56: e1
Location: 46,22
Owner: GDI
Actor57: e1
Location: 51,25
Owner: GDI
Actor58: e1
Location: 51,30
Owner: GDI
Actor59: e1
Location: 55,33
Owner: GDI
Actor60: e1
Location: 56,32
Owner: GDI
Actor0: rock2 Actor0: rock2
Location: 54,14 Location: 54,14
Owner: Neutral Owner: Neutral
@@ -136,151 +181,112 @@ Actors:
Owner: Neutral Owner: Neutral
Vil01: v21 Vil01: v21
Location: 29,23 Location: 29,23
Owner: Creeps Owner: Villagers
Vil02: v24 Vil02: v24
Location: 22,24 Location: 22,24
Owner: Creeps Owner: Villagers
Vil03: v24 Vil03: v24
Location: 21,16 Location: 21,16
Owner: Creeps Owner: Villagers
Vil04: v32 Vil04: v32
Location: 21,20 Location: 21,20
Owner: Creeps Owner: Villagers
Vil05: v27 Vil05: v27
Location: 22,21 Location: 22,21
Owner: Creeps Owner: Villagers
Vil06: v20 Vil06: v20
Location: 21,21 Location: 21,21
Owner: Creeps Owner: Villagers
Vil07: v26 Vil07: v26
Location: 22,23 Location: 22,23
Owner: Creeps Owner: Villagers
Vil08: v20 Vil08: v20
Location: 27,23 Location: 27,23
Owner: Creeps Owner: Villagers
Vil09: v22 Vil09: v22
Location: 26,23 Location: 26,23
Owner: Creeps Owner: Villagers
Vil10: v23 Vil10: v23
Location: 26,22 Location: 26,22
Owner: Creeps Owner: Villagers
Vil11: v26 Vil11: v26
Location: 26,21 Location: 26,21
Owner: Creeps Owner: Villagers
Vil12: v25 Vil12: v25
Location: 29,21 Location: 29,21
Owner: Creeps Owner: Villagers
Vil13: v30 Vil13: v30
Location: 32,18 Location: 32,18
Owner: Creeps Owner: Villagers
Civ01: c9 Civ01: c9
Location: 28,20 Location: 28,20
Owner: Creeps Owner: Villagers
Civ02: c6 Civ02: c6
Location: 28,19 Location: 28,19
Owner: Creeps Owner: Villagers
Civ03: c8 Civ03: c8
Location: 27,19 Location: 27,19
Owner: Creeps Owner: Villagers
Civ04: c7 Civ04: c7
Location: 29,20 Location: 29,20
Owner: Creeps Owner: Villagers
Civ05: c4 Civ05: c4
Location: 31,19 Location: 31,19
Owner: Creeps Owner: Villagers
Civ06: c2 Civ06: c2
Location: 30,19 Location: 30,19
Owner: Creeps Owner: Villagers
Civ07: c5 Civ07: c5
Location: 29,19 Location: 29,19
Owner: Creeps Owner: Villagers
Nikoomba: c10 Nikoomba: c10
Location: 29,16 Location: 29,16
Owner: Creeps Owner: Villagers
Actor46: e1
Location: 28,28
Owner: GDI
Actor47: e1
Location: 29,28
Owner: GDI
Actor48: e1
Location: 29,30
Owner: GDI
Actor49: e1
Location: 33,35
Owner: GDI
Actor50: e1
Location: 34,36
Owner: GDI
Actor51: e1
Location: 41,19
Owner: GDI
Actor52: e1
Location: 40,19
Owner: GDI
Actor53: e1
Location: 40,18
Owner: GDI
Actor54: e1
Location: 40,31
Owner: GDI
Actor55: e1
Location: 43,34
Owner: GDI
Actor56: e1
Location: 46,22
Owner: GDI
Actor57: e1
Location: 51,25
Owner: GDI
Actor58: e1
Location: 51,30
Owner: GDI
Actor59: e1
Location: 55,33
Owner: GDI
Actor60: e1
Location: 56,32
Owner: GDI
Actor61: e1 Actor61: e1
Location: 52,17 Location: 52,17
Owner: NOD Owner: Nod
Actor62: e1 Actor62: e1
Location: 51,17 Location: 51,17
Owner: NOD Owner: Nod
Actor63: e1 Actor63: e1
Location: 51,16 Location: 51,16
Owner: NOD Owner: Nod
Actor64: e1 Actor64: e1
Location: 52,16 Location: 52,16
Owner: NOD Owner: Nod
Actor65: e1 Actor65: e1
Location: 55,17 Location: 55,17
Owner: NOD Owner: Nod
Actor66: e1 Actor66: e1
Location: 56,17 Location: 56,17
Owner: NOD Owner: Nod
Actor67: e1 Actor67: e1
Location: 56,16 Location: 56,16
Owner: NOD Owner: Nod
Actor68: e1 Actor68: e1
Location: 55,16 Location: 55,16
Owner: NOD Owner: Nod
Actor69: bggy Actor69: bggy
Location: 53,16 Location: 53,16
Owner: NOD Owner: Nod
Actor70: bggy Actor70: bggy
Location: 54,16 Location: 54,16
Owner: NOD Owner: Nod
NODReinforceNthA: waypoint StartSpawnPointLeft: waypoint
Location: 52,14 Location: 52,14
Owner: NOD Owner: Nod
NODReinforceNWstA: waypoint StartSpawnPointRight: waypoint
Location: 24,14
Owner: NOD
NODReinforceNthB: waypoint
Location: 56,14 Location: 56,14
Owner: NOD Owner: Nod
StartRallyPoint: waypoint
Location: 54,16
Owner: Nod
VillageSpawnPoint: waypoint
Location: 24,14
Owner: Nod
VillageRallyPoint: waypoint
Location: 24,17
Owner: Nod
Actor27: jeep Actor27: jeep
Location: 31,28 Location: 31,28
Owner: GDI Owner: GDI
@@ -297,12 +303,21 @@ Rules:
-CrateSpawner: -CrateSpawner:
-SpawnMPUnits: -SpawnMPUnits:
-MPStartLocations: -MPStartLocations:
Nod01Script: LuaScriptInterface:
LuaScripts: mission.lua
C10: C10:
Tooltip: Tooltip:
Name: Nikoomba Name: Nikoomba
^Bridge: ^Bridge:
Invulnerable: Invulnerable:
^CivBuilding:
MustBeDestroyed:
^CivInfantry:
MustBeDestroyed:
^Infantry:
MustBeDestroyed:
^Vehicle:
MustBeDestroyed:
Sequences: Sequences:

View File

@@ -0,0 +1,47 @@
RifleInfantryReinforcements = { "e1", "e1", }
RocketInfantryReinforcements = { "e3", "e3", "e3" }
MissionAccomplished = function()
Mission.MissionOver({ player }, nil, false)
end
MissionFailed = function()
Mission.MissionOver(nil, { player }, false)
Media.PlayMovieFullscreen("nodlose.vqa")
end
SendFirstInfantryReinforcements = function()
Media.PlaySpeechNotification("Reinforce")
Reinforcements.Reinforce(player, RifleInfantryReinforcements, StartSpawnPointRight.Location, StartRallyPoint.Location, 15)
end
SendSecondInfantryReinforcements = function()
Media.PlaySpeechNotification("Reinforce")
Reinforcements.Reinforce(player, RifleInfantryReinforcements, StartSpawnPointLeft.Location, StartRallyPoint.Location, 15)
end
SendLastInfantryReinforcements = function()
Media.PlaySpeechNotification("Reinforce")
Reinforcements.Reinforce(player, RocketInfantryReinforcements, VillageSpawnPoint.Location, VillageRallyPoint.Location, 15)
end
WorldLoaded = function()
player = OpenRA.GetPlayer("Nod")
enemy = OpenRA.GetPlayer("Villagers")
Media.PlayMovieFullscreen("nod1pre.vqa", function() Media.PlayMovieFullscreen("nod1.vqa") end)
Actor.OnKilled(Nikoomba, SendLastInfantryReinforcements)
OpenRA.RunAfterDelay(25 * 30, SendFirstInfantryReinforcements)
OpenRA.RunAfterDelay(25 * 60, SendSecondInfantryReinforcements)
end
Tick = function()
if Mission.RequiredUnitsAreDestroyed(player) then
MissionFailed()
end
if Mission.RequiredUnitsAreDestroyed(enemy) then
MissionAccomplished()
end
end