engineer stuff

This commit is contained in:
Chris Forbes
2009-12-28 19:49:33 +13:00
parent 1be973c18c
commit 8054292e17
4 changed files with 74 additions and 1 deletions

View File

@@ -109,6 +109,7 @@
<Compile Include="Support\PerfHistory.cs" />
<Compile Include="Traits\AcceptsOre.cs" />
<Compile Include="Traits\Activities\Attack.cs" />
<Compile Include="Traits\Activities\CaptureBuilding.cs" />
<Compile Include="Traits\Activities\Circle.cs" />
<Compile Include="Traits\Activities\Demolish.cs" />
<Compile Include="Traits\Activities\Fly.cs" />
@@ -179,6 +180,7 @@
<Compile Include="Traits\BelowUnits.cs" />
<Compile Include="Traits\Building.cs" />
<Compile Include="Traits\C4Demolition.cs" />
<Compile Include="Traits\EngineerCapture.cs" />
<Compile Include="Traits\Explodes.cs" />
<Compile Include="Traits\ChronoshiftDeploy.cs" />
<Compile Include="Traits\Fake.cs" />

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRa.Game.Traits.Activities
{
class CaptureBuilding : IActivity
{
Actor target;
public CaptureBuilding(Actor target) { this.target = target; }
public IActivity NextActivity { get; set; }
public IActivity Tick(Actor self)
{
if (target == null || target.IsDead) return NextActivity;
// todo: don't waste engineers on things that have been captured
// between order issue time and the time we hit the building.
target.Health -= EngineerCapture.EngineerDamage;
if (target.Health <= 0)
{
target.Owner = self.Owner;
target.Health = EngineerCapture.EngineerDamage;
}
// the engineer is sacrificed.
Game.world.AddFrameEndTask(w => w.Remove(self));
return NextActivity;
}
public void Cancel(Actor self) { target = null; NextActivity = null; }
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRa.Game.Traits.Activities;
namespace OpenRa.Game.Traits
{
class EngineerCapture : IOrder
{
public const int EngineerDamage = 300;
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
if (underCursor == null) return null;
if (!underCursor.traits.Contains<Building>()) return null;
// todo: other bits
return new Order(underCursor.Health <= EngineerDamage ? "Capture" : "Enter",
self, underCursor, int2.Zero, null);
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Enter" || order.OrderString == "Capture")
{
self.CancelActivity();
self.QueueActivity(new Move(order.TargetActor, 2));
self.QueueActivity(new CaptureBuilding(order.TargetActor));
}
}
}
}

View File

@@ -564,7 +564,7 @@ FireDelay=8
LongDesc=Advanced Anti-infantry unit.\n Strong vs Infantry, Buildings\n Weak vs Vehicles
[E6]
Description=Engineer
Traits=Unit, Mobile, RenderInfantry, TakeCover, SquishByTank
Traits=Unit, Mobile, EngineerCapture, RenderInfantry, TakeCover, SquishByTank
Voice=EngineerVoice
LongDesc=Infiltrates and captures enemy structures.\n Strong vs Nothing\n Weak vs Everything
[SPY]