Adds TRUK to both sides - donates cash to others

This commit is contained in:
Curtis S
2011-04-03 22:25:28 -06:00
committed by Chris Forbes
parent b4fe4818a9
commit 88d63d07e6
8 changed files with 171 additions and 1 deletions

View File

@@ -9,3 +9,4 @@ The OpenRA developers are:
* Joakim Lindberg
* Andrew Riedi
* Tim Mylemans
* Curtis Shmyr

View File

@@ -0,0 +1,18 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 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 OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class AcceptsSuppliesInfo : TraitInfo<AcceptsSupplies> {}
class AcceptsSupplies {}
}

View File

@@ -0,0 +1,43 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 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.Linq;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
using OpenRA.Mods.RA.Effects;
namespace OpenRA.Mods.RA.Activities
{
class DonateSupplies : CancelableActivity
{
Actor target;
int payload;
public DonateSupplies(Actor target, int payload)
{
this.target = target;
this.payload = payload;
}
public override IActivity Tick(Actor self)
{
if (IsCanceled) return NextActivity;
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
if (!target.Trait<IOccupySpace>().OccupiedCells().Any(x => x.First == self.Location))
return NextActivity;
target.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(payload);
self.Destroy();
self.World.AddFrameEndTask(w => w.Add(new CashTick(payload, 30, 2, target.CenterLocation, target.Owner.ColorRamp.GetColor(0))));
return this;
}
}
}

View File

@@ -52,9 +52,11 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AcceptsSupplies.cs" />
<Compile Include="Activities\Attack.cs" />
<Compile Include="Activities\CallFunc.cs" />
<Compile Include="Activities\CaptureBuilding.cs" />
<Compile Include="Activities\DonateSupplies.cs" />
<Compile Include="Activities\QueuedActivity.cs" />
<Compile Include="Activities\DeliverOre.cs" />
<Compile Include="Activities\Demolish.cs" />
@@ -106,6 +108,7 @@
<Compile Include="Buildings\TechTree.cs" />
<Compile Include="Buildings\Util.cs" />
<Compile Include="ProximityCaptor.cs" />
<Compile Include="SupplyTruck.cs" />
<Compile Include="SupportPowers\SupportPowerChargeBar.cs" />
<Compile Include="Valued.cs" />
<Compile Include="Combat.cs" />

View File

@@ -0,0 +1,83 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 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.Collections.Generic;
using System.Drawing;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Orders;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class SupplyTruckInfo : ITraitInfo
{
public readonly int Payload = 500;
public object Create(ActorInitializer init) { return new SupplyTruck(this); }
}
class SupplyTruck : IIssueOrder, IResolveOrder, IOrderVoice
{
int payload;
SupplyTruckInfo Info;
public SupplyTruck(SupplyTruckInfo info)
{
payload = info.Payload;
Info = info;
}
public IEnumerable<IOrderTargeter> Orders
{
get { yield return new SupplyTruckOrderTargeter(); }
}
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
{
if (order.OrderID == "SupplyTruck")
return new Order(order.OrderID, self, queued) { TargetActor = target.Actor };
return null;
}
public string VoicePhraseForOrder(Actor self, Order order)
{
return "Move";
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "SupplyTruck")
{
self.SetTargetLine(Target.FromOrder(order), Color.Yellow);
self.CancelActivity();
self.QueueActivity(new Enter(order.TargetActor));
self.QueueActivity(new DonateSupplies(order.TargetActor, payload));
}
}
class SupplyTruckOrderTargeter : UnitTraitOrderTargeter<Building>
{
public SupplyTruckOrderTargeter()
: base("SupplyTruck", 5, "enter", false, true)
{
}
public override bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor)
{
if (!base.CanTargetActor(self, target, forceAttack, forceMove, forceQueued, ref cursor)) return false;
if (target.AppearsHostileTo(self)) return false;
if (!target.HasTrait<AcceptsSupplies>()) return false;
IsQueued = forceQueued;
return true;
}
}
}
}

View File

@@ -164,6 +164,7 @@
ProximityCaptor:
Types:Building
Sellable:
AcceptsSupplies:
^Wall:
AppearsOnRadar:
@@ -207,6 +208,7 @@
Name: Civilian Building
ProximityCaptor:
Types:CivilianBuilding
-AcceptsSupplies:
^CivField:
Inherits: ^CivBuilding

View File

@@ -254,6 +254,7 @@ PDOX:
Duration: 30
KillCargo: yes
SupportPowerChargeBar:
-AcceptsSupplies:
TSLA:
RequiresPower:
@@ -289,6 +290,7 @@ TSLA:
IronCurtainable:
-RenderBuilding:
RenderRangeCircle:
-AcceptsSupplies:
AGUN:
RequiresPower:
@@ -328,6 +330,7 @@ AGUN:
-RenderBuilding:
RenderRangeCircle:
RangeCircleType: aa
-AcceptsSupplies:
DOME:
RequiresPower:
@@ -386,6 +389,7 @@ PBOX:
AutoTarget:
IronCurtainable:
RenderRangeCircle:
-AcceptsSupplies:
HBOX:
Inherits: ^Building
@@ -414,6 +418,7 @@ HBOX:
AutoTarget:
IronCurtainable:
RenderRangeCircle:
-AcceptsSupplies:
GUN:
Inherits: ^Building
@@ -447,6 +452,7 @@ GUN:
IronCurtainable:
-RenderBuilding:
RenderRangeCircle:
-AcceptsSupplies:
FTUR:
Inherits: ^Building
@@ -476,6 +482,7 @@ FTUR:
AutoTarget:
IronCurtainable:
RenderRangeCircle:
-AcceptsSupplies:
SAM:
Inherits: ^Building
@@ -514,6 +521,7 @@ SAM:
RangeCircleType: aa
RequiresPower:
CanPowerDown:
-AcceptsSupplies:
ATEK:
Inherits: ^Building

View File

@@ -464,15 +464,27 @@ MNLY.AT:
TRUK:
Inherits: ^Vehicle
Buildable:
Queue: Vehicle
BuildPaletteOrder: 120
Prerequisites: weap
Owner: allies, soviet
Valued:
Cost: 500
Tooltip:
Name: Supply Truck
Description: Transports cash to other players.\n Unarmed
Health:
HP: 110
Armor:
Type: Light
Mobile:
Speed: 10
Speed: 9
RevealsShroud:
Range: 3
RenderUnit:
SupplyTruck:
Payload: 500
SS:
Inherits: ^Ship