Skip to content

Commit

Permalink
Adds TRUK to both sides - donates cash to others
Browse files Browse the repository at this point in the history
  • Loading branch information
cjshmyr authored and chrisforbes committed Apr 5, 2011
1 parent b4fe481 commit 88d63d0
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -9,3 +9,4 @@ The OpenRA developers are:
* Joakim Lindberg
* Andrew Riedi
* Tim Mylemans
* Curtis Shmyr
18 changes: 18 additions & 0 deletions OpenRA.Mods.RA/AcceptsSupplies.cs
@@ -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 {}
}
43 changes: 43 additions & 0 deletions OpenRA.Mods.RA/Activities/DonateSupplies.cs
@@ -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;
}
}
}
3 changes: 3 additions & 0 deletions OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
Expand Up @@ -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" />
Expand Down Expand Up @@ -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" />
Expand Down
83 changes: 83 additions & 0 deletions OpenRA.Mods.RA/SupplyTruck.cs
@@ -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;
}
}
}
}
2 changes: 2 additions & 0 deletions mods/ra/rules/defaults.yaml
Expand Up @@ -164,6 +164,7 @@
ProximityCaptor:
Types:Building
Sellable:
AcceptsSupplies:

^Wall:
AppearsOnRadar:
Expand Down Expand Up @@ -207,6 +208,7 @@
Name: Civilian Building
ProximityCaptor:
Types:CivilianBuilding
-AcceptsSupplies:

^CivField:
Inherits: ^CivBuilding
Expand Down
8 changes: 8 additions & 0 deletions mods/ra/rules/structures.yaml
Expand Up @@ -254,6 +254,7 @@ PDOX:
Duration: 30
KillCargo: yes
SupportPowerChargeBar:
-AcceptsSupplies:

TSLA:
RequiresPower:
Expand Down Expand Up @@ -289,6 +290,7 @@ TSLA:
IronCurtainable:
-RenderBuilding:
RenderRangeCircle:
-AcceptsSupplies:

AGUN:
RequiresPower:
Expand Down Expand Up @@ -328,6 +330,7 @@ AGUN:
-RenderBuilding:
RenderRangeCircle:
RangeCircleType: aa
-AcceptsSupplies:

DOME:
RequiresPower:
Expand Down Expand Up @@ -386,6 +389,7 @@ PBOX:
AutoTarget:
IronCurtainable:
RenderRangeCircle:
-AcceptsSupplies:

HBOX:
Inherits: ^Building
Expand Down Expand Up @@ -414,6 +418,7 @@ HBOX:
AutoTarget:
IronCurtainable:
RenderRangeCircle:
-AcceptsSupplies:

GUN:
Inherits: ^Building
Expand Down Expand Up @@ -447,6 +452,7 @@ GUN:
IronCurtainable:
-RenderBuilding:
RenderRangeCircle:
-AcceptsSupplies:

FTUR:
Inherits: ^Building
Expand Down Expand Up @@ -476,6 +482,7 @@ FTUR:
AutoTarget:
IronCurtainable:
RenderRangeCircle:
-AcceptsSupplies:

SAM:
Inherits: ^Building
Expand Down Expand Up @@ -514,6 +521,7 @@ SAM:
RangeCircleType: aa
RequiresPower:
CanPowerDown:
-AcceptsSupplies:

ATEK:
Inherits: ^Building
Expand Down
14 changes: 13 additions & 1 deletion mods/ra/rules/vehicles.yaml
Expand Up @@ -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
Expand Down

0 comments on commit 88d63d0

Please sign in to comment.