From bfddbeeb02a24e78520c25a664197c0db0d830e4 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 24 Oct 2011 17:40:02 +1300 Subject: [PATCH] fixed #1232 -- bots repair their own damaged buildings --- OpenRA.Mods.RA/Buildings/RepairableBuilding.cs | 2 +- OpenRA.Mods.RA/HackyAI.cs | 16 +++++++++++++++- OpenRA.Mods.RA/Player/AllyRepair.cs | 1 - 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.RA/Buildings/RepairableBuilding.cs b/OpenRA.Mods.RA/Buildings/RepairableBuilding.cs index 534c8a2ea9..2ad78658aa 100755 --- a/OpenRA.Mods.RA/Buildings/RepairableBuilding.cs +++ b/OpenRA.Mods.RA/Buildings/RepairableBuilding.cs @@ -93,7 +93,7 @@ namespace OpenRA.Mods.RA.Buildings --remainingTicks; } } + public class AllowsBuildingRepairInfo : TraitInfo { } public class AllowsBuildingRepair { } - } diff --git a/OpenRA.Mods.RA/HackyAI.cs b/OpenRA.Mods.RA/HackyAI.cs index 754617b2a8..ec974202bd 100644 --- a/OpenRA.Mods.RA/HackyAI.cs +++ b/OpenRA.Mods.RA/HackyAI.cs @@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA /* a pile of hacks, which control a local player on the host. */ - class HackyAI : ITick, IBot + class HackyAI : ITick, IBot, INotifyDamage { bool enabled; int ticks; @@ -507,5 +507,19 @@ namespace OpenRA.Mods.RA } } } + + public void Damaged(Actor self, AttackInfo e) + { + if (!enabled) return; + + if (self.HasTrait()) + if (e.DamageState > DamageState.Light && e.PreviousDamageState <= DamageState.Light) + { + BotDebug("Bot noticed damage {0} {1}->{2}, repairing.", + self, e.PreviousDamageState, e.DamageState); + world.IssueOrder(new Order("RepairBuilding", self.Owner.PlayerActor, false) + { TargetActor = self }); + } + } } } diff --git a/OpenRA.Mods.RA/Player/AllyRepair.cs b/OpenRA.Mods.RA/Player/AllyRepair.cs index 58227318e8..191f754043 100644 --- a/OpenRA.Mods.RA/Player/AllyRepair.cs +++ b/OpenRA.Mods.RA/Player/AllyRepair.cs @@ -30,6 +30,5 @@ namespace OpenRA.Mods.RA building.Trait().RepairBuilding(building, self.Owner); } } - } }