ported first Nod mission to Lua

This commit is contained in:
Matthias Mailänder
2013-12-29 19:48:10 +01:00
parent d20a47d37a
commit 4a4885a905
3 changed files with 110 additions and 247 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
Description: Conversion of first Nod mission from Cnc
Description: Conversion of the first Nod mission
Author: Dan9550
Author: Westwood Studios
Tileset: DESERT
@@ -35,18 +35,18 @@ Players:
OwnsWorld: True
NonCombatant: True
Race: gdi
PlayerReference@Creeps:
Name: Creeps
PlayerReference@Villagers:
Name: Villagers
NonCombatant: True
Race: gdi
PlayerReference@GDI:
Name: GDI
Race: gdi
ColorRamp: 31,222,183
Allies: Creeps
Enemies: NOD
PlayerReference@NOD:
Name: NOD
Allies: Villagers
Enemies: Nod
PlayerReference@Nod:
Name: Nod
Playable: True
AllowBots: False
Required: True
@@ -56,7 +56,7 @@ Players:
ColorRamp: 3,255,127
LockSpawn: True
LockTeam: True
Enemies: GDI,Creeps
Enemies: GDI,Villagers
Actors:
Actor0: rock2
@@ -136,67 +136,67 @@ Actors:
Owner: Neutral
Vil01: v21
Location: 29,23
Owner: Creeps
Owner: Villagers
Vil02: v24
Location: 22,24
Owner: Creeps
Owner: Villagers
Vil03: v24
Location: 21,16
Owner: Creeps
Owner: Villagers
Vil04: v32
Location: 21,20
Owner: Creeps
Owner: Villagers
Vil05: v27
Location: 22,21
Owner: Creeps
Owner: Villagers
Vil06: v20
Location: 21,21
Owner: Creeps
Owner: Villagers
Vil07: v26
Location: 22,23
Owner: Creeps
Owner: Villagers
Vil08: v20
Location: 27,23
Owner: Creeps
Owner: Villagers
Vil09: v22
Location: 26,23
Owner: Creeps
Owner: Villagers
Vil10: v23
Location: 26,22
Owner: Creeps
Owner: Villagers
Vil11: v26
Location: 26,21
Owner: Creeps
Owner: Villagers
Vil12: v25
Location: 29,21
Owner: Creeps
Owner: Villagers
Vil13: v30
Location: 32,18
Owner: Creeps
Owner: Villagers
Civ01: c9
Location: 28,20
Owner: Creeps
Owner: Villagers
Civ02: c6
Location: 28,19
Owner: Creeps
Owner: Villagers
Civ03: c8
Location: 27,19
Owner: Creeps
Owner: Villagers
Civ04: c7
Location: 29,20
Owner: Creeps
Owner: Villagers
Civ05: c4
Location: 31,19
Owner: Creeps
Owner: Villagers
Civ06: c2
Location: 30,19
Owner: Creeps
Owner: Villagers
Civ07: c5
Location: 29,19
Owner: Creeps
Owner: Villagers
Nikoomba: c10
Location: 29,16
Owner: Creeps
Owner: Villagers
Actor46: e1
Location: 28,28
Owner: GDI
@@ -244,43 +244,49 @@ Actors:
Owner: GDI
Actor61: e1
Location: 52,17
Owner: NOD
Owner: Nod
Actor62: e1
Location: 51,17
Owner: NOD
Owner: Nod
Actor63: e1
Location: 51,16
Owner: NOD
Owner: Nod
Actor64: e1
Location: 52,16
Owner: NOD
Owner: Nod
Actor65: e1
Location: 55,17
Owner: NOD
Owner: Nod
Actor66: e1
Location: 56,17
Owner: NOD
Owner: Nod
Actor67: e1
Location: 56,16
Owner: NOD
Owner: Nod
Actor68: e1
Location: 55,16
Owner: NOD
Owner: Nod
Actor69: bggy
Location: 53,16
Owner: NOD
Owner: Nod
Actor70: bggy
Location: 54,16
Owner: NOD
NODReinforceNthA: waypoint
Owner: Nod
StartSpawnPointLeft: waypoint
Location: 52,14
Owner: NOD
NODReinforceNWstA: waypoint
Location: 24,14
Owner: NOD
NODReinforceNthB: waypoint
Owner: Nod
StartSpawnPointRight: waypoint
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
Location: 31,28
Owner: GDI
@@ -297,12 +303,21 @@ Rules:
-CrateSpawner:
-SpawnMPUnits:
-MPStartLocations:
Nod01Script:
LuaScriptInterface:
LuaScripts: mission.lua
C10:
Tooltip:
Name: Nikoomba
^Bridge:
Invulnerable:
^CivBuilding:
MustBeDestroyed:
^CivInfantry:
MustBeDestroyed:
^Infantry:
MustBeDestroyed:
^Vehicle:
MustBeDestroyed:
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