Skip to content

Bug Repair By OpenAI: #113

Description

@jed4s

You can copy this:


Hi CA team,

I found a bug in BuildingRepairBotModuleCA.cs that prevents AI from repairing damaged buildings.

The problem is that the code caches RepairableBuilding in Created():

rb = self.TraitOrDefault<RepairableBuilding>();

However, the self actor in Created() is the Player actor, not the damaged building actor. Therefore rb is always null:

rb = false

When RespondToAttack() is later called, self is the damaged building (for example, sfac), but the stored rb value is still null, so the repair order is never issued.

The original OpenRA BuildingRepairBotModule.cs gets RepairableBuilding inside RespondToAttack():

var rb = self.TraitOrDefault<RepairableBuilding>();

Moving the RepairableBuilding lookup from Created() into RespondToAttack() fixes the issue. After this change, AI buildings repair normally.

Thanks!
You can also attach the fix as a patch:

Diff

  • RepairableBuilding rb;

  • protected override void Created(Actor self)

  • {

  • base.Created(self);
    
  • rb = self.TraitOrDefault<RepairableBuilding>();
    
  • }

    void IBotRespondToAttack.RespondToAttack(IBot bot, Actor self, AttackInfo e)
    {

  • var rb = self.TraitOrDefault<RepairableBuilding>();
    
    ...
    
    }
    This should be enough for the CA developers to understand the bug quickly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions