Scriptable MSLO and shellmap win
This commit is contained in:
@@ -22,6 +22,8 @@ using OpenRA.Mods.RA.Effects;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -30,17 +32,38 @@ namespace OpenRA.Mods.RA
|
||||
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)
|
||||
{
|
||||
Game.MoveViewport((.5f * (w.Map.TopLeft + w.Map.BottomRight).ToFloat2()).ToInt2());
|
||||
// Sound.PlayMusic("hell226m.aud");
|
||||
var goodguy = w.players.Values.Where(x => x.InternalName == "GoodGuy").FirstOrDefault();
|
||||
var greece = w.players.Values.Where(x => x.InternalName == "Greece").FirstOrDefault();
|
||||
goodguy = w.players.Values.Where(x => x.InternalName == "GoodGuy").FirstOrDefault();
|
||||
greece = w.players.Values.Where(x => x.InternalName == "Greece").FirstOrDefault();
|
||||
MapActors = w.WorldActor.traits.Get<SpawnMapActors>().MapActors;
|
||||
|
||||
|
||||
goodguy.Stances[greece] = 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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
* This file is part of OpenRA.
|
||||
@@ -48,9 +48,24 @@ namespace OpenRA.Mods.RA.Effects
|
||||
this.targetLocation = targetLocation;
|
||||
anim = new Animation("nuke");
|
||||
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)
|
||||
{
|
||||
anim.Tick();
|
||||
@@ -58,13 +73,8 @@ namespace OpenRA.Mods.RA.Effects
|
||||
if (goingUp)
|
||||
{
|
||||
altitude += 10;
|
||||
if (altitude >= targetAltitude)
|
||||
{
|
||||
pos = OpenRA.Traits.Util.CenterOfCell(targetLocation);
|
||||
anim = new Animation("nuke");
|
||||
anim.PlayRepeating("down");
|
||||
goingUp = false;
|
||||
}
|
||||
if (altitude >= world.Map.Height*Game.CellSize)
|
||||
StartDescent(world);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
class NukePowerInfo : SupportPowerInfo
|
||||
{
|
||||
public readonly string MissileWeapon = "";
|
||||
public override object Create(Actor self) { return new NukePower(self, this); }
|
||||
}
|
||||
|
||||
@@ -53,15 +52,11 @@ namespace OpenRA.Mods.RA
|
||||
if (silo != null)
|
||||
silo.traits.Get<RenderBuilding>().PlayCustomAnim(silo, "active");
|
||||
|
||||
Owner.World.AddFrameEndTask(w =>
|
||||
{
|
||||
// Play to everyone but the current player
|
||||
if (Owner != Owner.World.LocalPlayer)
|
||||
Sound.Play(Info.LaunchSound);
|
||||
|
||||
//FIRE ZE MISSILES
|
||||
w.Add(new NukeLaunch(silo, (Info as NukePowerInfo).MissileWeapon, order.TargetLocation));
|
||||
});
|
||||
// Play to everyone but the current player
|
||||
if (Owner != Owner.World.LocalPlayer)
|
||||
Sound.Play(Info.LaunchSound);
|
||||
|
||||
silo.traits.Get<NukeSilo>().Attack(order.TargetLocation);
|
||||
|
||||
Game.controller.CancelInputMode();
|
||||
FinishActivate();
|
||||
@@ -70,6 +65,29 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
// tag trait for the building
|
||||
class NukeSiloInfo : TraitInfo<NukeSilo> { }
|
||||
class NukeSilo { }
|
||||
class NukeSiloInfo : ITraitInfo
|
||||
{
|
||||
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));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user