From 88d63d07e69e6f33784129767f66658733ba1160 Mon Sep 17 00:00:00 2001 From: Curtis S Date: Sun, 3 Apr 2011 22:25:28 -0600 Subject: [PATCH] Adds TRUK to both sides - donates cash to others --- AUTHORS | 1 + OpenRA.Mods.RA/AcceptsSupplies.cs | 18 +++++ OpenRA.Mods.RA/Activities/DonateSupplies.cs | 43 +++++++++++ OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 3 + OpenRA.Mods.RA/SupplyTruck.cs | 83 +++++++++++++++++++++ mods/ra/rules/defaults.yaml | 2 + mods/ra/rules/structures.yaml | 8 ++ mods/ra/rules/vehicles.yaml | 14 +++- 8 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 OpenRA.Mods.RA/AcceptsSupplies.cs create mode 100644 OpenRA.Mods.RA/Activities/DonateSupplies.cs create mode 100644 OpenRA.Mods.RA/SupplyTruck.cs diff --git a/AUTHORS b/AUTHORS index 49072138c6..d590899ca8 100644 --- a/AUTHORS +++ b/AUTHORS @@ -9,3 +9,4 @@ The OpenRA developers are: * Joakim Lindberg * Andrew Riedi * Tim Mylemans + * Curtis Shmyr \ No newline at end of file diff --git a/OpenRA.Mods.RA/AcceptsSupplies.cs b/OpenRA.Mods.RA/AcceptsSupplies.cs new file mode 100644 index 0000000000..68289f2a8f --- /dev/null +++ b/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 {} + + class AcceptsSupplies {} +} diff --git a/OpenRA.Mods.RA/Activities/DonateSupplies.cs b/OpenRA.Mods.RA/Activities/DonateSupplies.cs new file mode 100644 index 0000000000..308a01d2f4 --- /dev/null +++ b/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().OccupiedCells().Any(x => x.First == self.Location)) + return NextActivity; + + target.Owner.PlayerActor.Trait().GiveCash(payload); + self.Destroy(); + self.World.AddFrameEndTask(w => w.Add(new CashTick(payload, 30, 2, target.CenterLocation, target.Owner.ColorRamp.GetColor(0)))); + + return this; + } + } +} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index bb2c2a5109..f83da36810 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -52,9 +52,11 @@ + + @@ -106,6 +108,7 @@ + diff --git a/OpenRA.Mods.RA/SupplyTruck.cs b/OpenRA.Mods.RA/SupplyTruck.cs new file mode 100644 index 0000000000..c5977f4fa7 --- /dev/null +++ b/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 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 + { + 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()) return false; + + IsQueued = forceQueued; + return true; + } + } + } +} diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index cbac5c516a..848df98cd1 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -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 diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index 5ff43b468d..a1e7c75031 100755 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -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 diff --git a/mods/ra/rules/vehicles.yaml b/mods/ra/rules/vehicles.yaml index 8416ad7afc..982e59e79e 100644 --- a/mods/ra/rules/vehicles.yaml +++ b/mods/ra/rules/vehicles.yaml @@ -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