Changeset 273 for trunk/UClientAI.pas


Ignore:
Timestamp:
Jan 30, 2019, 8:08:44 AM (6 years ago)
Author:
chronos
Message:
  • Added: Show units shape to see in which cell units are placed.
  • Fixed: Do not place units with zero power in zero power cells.
  • Fixed: Better checks of cell power if cell is without unit.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UClientAI.pas

    r265 r273  
    111111  TargetCell: TPlayerCell;
    112112  NeighborCell: TPlayerCell;
     113  DefendCount: Integer;
    113114begin
    114115if ControlPlayer.Defensive then Exit;
     
    144145      end;
    145146      // Attack if target is weaker
    146       if Game.AttackProbability(TotalPower, TargetCell.MapCell.OneUnit.Power) >=
     147      if Assigned(TargetCell.MapCell.OneUnit) then
     148        DefendCount := TargetCell.MapCell.OneUnit.Power
     149        else DefendCount := 0;
     150      if Game.AttackProbability(TotalPower, DefendCount) >=
    147151        ComputerAggroProbability[ControlPlayer.Agressivity] then begin
    148152        // Try to limit total attacking power to necessary minimum
    149         while Game.AttackProbability(TotalPower - 1, TargetCell.MapCell.OneUnit.Power) >=
     153        while Game.AttackProbability(TotalPower - 1, DefendCount) >=
    150154          ComputerAggroProbability[ControlPlayer.Agressivity] do
    151155          Dec(TotalPower);
Note: See TracChangeset for help on using the changeset viewer.