fixed #1232 -- bots repair their own damaged buildings

This commit is contained in:
Chris Forbes
2011-10-24 17:40:02 +13:00
parent 92f5d67ef1
commit bfddbeeb02
3 changed files with 16 additions and 3 deletions

View File

@@ -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<RepairableBuilding>())
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 });
}
}
}
}