Scriptable MSLO and shellmap win

This commit is contained in:
Paul Chote
2010-05-26 20:16:23 +12:00
parent b286a71487
commit 9dc8422adf
9 changed files with 108 additions and 34 deletions

View File

@@ -22,6 +22,8 @@ using OpenRA.Mods.RA.Effects;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA; using OpenRA;
using System.Linq; using System.Linq;
using System.Collections.Generic;
using System;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
@@ -30,17 +32,38 @@ namespace OpenRA.Mods.RA
public object Create(Actor self) { return new DefaultShellmapScript(); } public object Create(Actor self) { return new DefaultShellmapScript(); }
} }
class DefaultShellmapScript: ILoadWorldHook class DefaultShellmapScript: ILoadWorldHook, ITick
{ {
Player goodguy;
Player greece;
Dictionary<string, Actor> MapActors;
public void WorldLoaded(World w) public void WorldLoaded(World w)
{ {
Game.MoveViewport((.5f * (w.Map.TopLeft + w.Map.BottomRight).ToFloat2()).ToInt2()); Game.MoveViewport((.5f * (w.Map.TopLeft + w.Map.BottomRight).ToFloat2()).ToInt2());
// Sound.PlayMusic("hell226m.aud"); // Sound.PlayMusic("hell226m.aud");
var goodguy = w.players.Values.Where(x => x.InternalName == "GoodGuy").FirstOrDefault(); goodguy = w.players.Values.Where(x => x.InternalName == "GoodGuy").FirstOrDefault();
var greece = w.players.Values.Where(x => x.InternalName == "Greece").FirstOrDefault(); greece = w.players.Values.Where(x => x.InternalName == "Greece").FirstOrDefault();
MapActors = w.WorldActor.traits.Get<SpawnMapActors>().MapActors;
goodguy.Stances[greece] = Stance.Enemy; goodguy.Stances[greece] = Stance.Enemy;
greece.Stances[goodguy] = Stance.Enemy; greece.Stances[goodguy] = Stance.Enemy;
}
int ticks = 0;
public void Tick(Actor self)
{
if (ticks == 100)
MapActors["mslo1"].traits.Get<NukeSilo>().Attack(new int2(96,53));
if (ticks == 110)
MapActors["mslo2"].traits.Get<NukeSilo>().Attack(new int2(92,53));
if (ticks == 120)
MapActors["mslo3"].traits.Get<NukeSilo>().Attack(new int2(94,50));
ticks++;
} }
} }
} }

View File

@@ -1,4 +1,4 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
* This file is part of OpenRA. * This file is part of OpenRA.
@@ -48,7 +48,22 @@ namespace OpenRA.Mods.RA.Effects
this.targetLocation = targetLocation; this.targetLocation = targetLocation;
anim = new Animation("nuke"); anim = new Animation("nuke");
anim.PlayRepeating("up"); anim.PlayRepeating("up");
pos = silo.CenterLocation;
if (silo == null)
{
altitude = Game.world.Map.Height*Game.CellSize;
StartDescent(Game.world);
}
else
pos = silo.CenterLocation;
}
void StartDescent(World world)
{
pos = OpenRA.Traits.Util.CenterOfCell(targetLocation);
anim = new Animation("nuke");
anim.PlayRepeating("down");
goingUp = false;
} }
public void Tick(World world) public void Tick(World world)
@@ -58,13 +73,8 @@ namespace OpenRA.Mods.RA.Effects
if (goingUp) if (goingUp)
{ {
altitude += 10; altitude += 10;
if (altitude >= targetAltitude) if (altitude >= world.Map.Height*Game.CellSize)
{ StartDescent(world);
pos = OpenRA.Traits.Util.CenterOfCell(targetLocation);
anim = new Animation("nuke");
anim.PlayRepeating("down");
goingUp = false;
}
} }
else else
{ {

View File

@@ -27,7 +27,6 @@ namespace OpenRA.Mods.RA
{ {
class NukePowerInfo : SupportPowerInfo class NukePowerInfo : SupportPowerInfo
{ {
public readonly string MissileWeapon = "";
public override object Create(Actor self) { return new NukePower(self, this); } public override object Create(Actor self) { return new NukePower(self, this); }
} }
@@ -53,15 +52,11 @@ namespace OpenRA.Mods.RA
if (silo != null) if (silo != null)
silo.traits.Get<RenderBuilding>().PlayCustomAnim(silo, "active"); silo.traits.Get<RenderBuilding>().PlayCustomAnim(silo, "active");
Owner.World.AddFrameEndTask(w => // Play to everyone but the current player
{ if (Owner != Owner.World.LocalPlayer)
// Play to everyone but the current player Sound.Play(Info.LaunchSound);
if (Owner != Owner.World.LocalPlayer)
Sound.Play(Info.LaunchSound);
//FIRE ZE MISSILES silo.traits.Get<NukeSilo>().Attack(order.TargetLocation);
w.Add(new NukeLaunch(silo, (Info as NukePowerInfo).MissileWeapon, order.TargetLocation));
});
Game.controller.CancelInputMode(); Game.controller.CancelInputMode();
FinishActivate(); FinishActivate();
@@ -70,6 +65,29 @@ namespace OpenRA.Mods.RA
} }
// tag trait for the building // tag trait for the building
class NukeSiloInfo : TraitInfo<NukeSilo> { } class NukeSiloInfo : ITraitInfo
class NukeSilo { } {
public readonly string MissileWeapon = "";
public object Create(Actor self) { return new NukeSilo(self); }
}
class NukeSilo
{
Actor self;
public NukeSilo(Actor self)
{
this.self = self;
}
public void Attack(int2 targetLocation)
{
self.traits.Get<RenderBuilding>().PlayCustomAnim(self, "active");
self.World.AddFrameEndTask(w =>
{
//FIRE ZE MISSILES
w.Add(new NukeLaunch(self, self.Info.Traits.Get<NukeSiloInfo>().MissileWeapon, targetLocation));
});
}
}
} }

View File

@@ -1 +1 @@
a28a1988fcaca4de0c90a8cb9cd9a2b3aacb4582 f78ab8d4d40ac3c263d1e404e5bf8233dce1f1a7

View File

@@ -1203,7 +1203,7 @@ Actors:
Location: 92,46 Location: 92,46
Owner: GoodGuy Owner: GoodGuy
ActorReference@Actor233: ActorReference@Actor233:
Id: Actor233 Id: pdox
Type: pdox Type: pdox
Location: 94,52 Location: 94,52
Owner: GoodGuy Owner: GoodGuy
@@ -1958,10 +1958,30 @@ Actors:
Location: 84,56 Location: 84,56
Owner: GoodGuy Owner: GoodGuy
ActorReference@Actor384: ActorReference@Actor384:
Id: Actor384 Id: mslo1
Type: miss Type: mslo
Location: 95,78 Location: 89,84
Owner: Neutral Owner: Greece
ActorReference@Actor385:
Id: Actor385
Type: ca
Location: 119,66
Owner: GoodGuy
ActorReference@Actor386:
Id: Actor386
Type: ca
Location: 120,66
Owner: GoodGuy
ActorReference@Actor387:
Id: mslo2
Type: mslo
Location: 89,83
Owner: Greece
ActorReference@Actor388:
Id: mslo3
Type: mslo
Location: 89,82
Owner: Greece
Waypoints: Waypoints:
spawn0: 36,36 spawn0: 36,36

View File

@@ -53,4 +53,4 @@ Terrain:
Music: Music:
mods/ra/music.yaml mods/ra/music.yaml
ShellmapUid:a28a1988fcaca4de0c90a8cb9cd9a2b3aacb4582 ShellmapUid:f78ab8d4d40ac3c263d1e404e5bf8233dce1f1a7

View File

@@ -221,7 +221,7 @@
<sequence name="idle" start="0" length="1" /> <sequence name="idle" start="0" length="1" />
<sequence name="damaged-idle" start="8" length="1" /> <sequence name="damaged-idle" start="8" length="1" />
<sequence name="make" start="0" length="15" src="mslomake" /> <sequence name="make" start="0" length="15" src="mslomake" />
<sequence name="active" start="1" length="7" /> <sequence name="active" start="1" length="7" tick="80" />
<sequence name="damaged-active" start="9" length="7" /> <sequence name="damaged-active" start="9" length="7" />
</unit> </unit>
<!-- mcv --> <!-- mcv -->

View File

@@ -1,6 +1,7 @@
MSLO: MSLO:
Category: Defense Category: Defense
NukeSilo: NukeSilo:
MissileWeapon: atomic
Inherits: ^Building Inherits: ^Building
Buildable: Buildable:
BuildPaletteOrder: 130 BuildPaletteOrder: 130
@@ -25,6 +26,9 @@ GAP:
RequiresPower: RequiresPower:
CanPowerDown: CanPowerDown:
Inherits: ^Building Inherits: ^Building
Valued:
Cost: 500
Description: Gap Generator
# Buildable: # Buildable:
# BuildPaletteOrder: 100 # BuildPaletteOrder: 100
# Prerequisites: atek # Prerequisites: atek

View File

@@ -57,7 +57,6 @@ Player:
LongDesc: Launches a nuclear missile at a target location. LongDesc: Launches a nuclear missile at a target location.
Prerequisites: MSLO Prerequisites: MSLO
TechLevel: 12 TechLevel: 12
MissileWeapon: atomic
BeginChargeSound: aprep1.aud BeginChargeSound: aprep1.aud
EndChargeSound: aready1.aud EndChargeSound: aready1.aud
SelectTargetSound: slcttgt1.aud SelectTargetSound: slcttgt1.aud