anchor.diff:  end;
   
   
  +procedure TKMScriptActions._AIGroupsFormationSetEx(aPlayer: TKMHandID; aGroupType: TKMGroupType; aCount, aColumns: Integer; aMethodName: string);
  +begin
  +  try
  +    if InRange(aPlayer, 0, gHands.Count - 1) and (gHands[aPlayer].Enabled)
  +      and (aGroupType in [gtMelee..gtMounted])
  +      and (aCount > 0) and (aColumns > 0) then
  +    begin
  +      gHands[aPlayer].AI.General.DefencePositions.TroopFormations[aGroupType].NumUnits := aCount;
  +      gHands[aPlayer].AI.General.DefencePositions.TroopFormations[aGroupType].UnitsPerRow := aColumns;
  +    end
  +    else
  +      LogParamWarning(aMethodName, [aPlayer, Byte(aGroupType), aCount, aColumns]);
  +  except
  +    gScriptEvents.ExceptionOutsideScript := True; //Don't blame script for this exception
  +    raise;
  +  end;
  +end;
  +
  +
   //* Version: 5778
   //* Sets the formation the AI uses for defence positions
   procedure TKMScriptActions.AIGroupsFormationSet(aPlayer, aType: Byte; aCount, aColumns: Word);
   var
     gt: TKMGroupType;
   begin
  -  try
  -    if InRange(aPlayer, 0, gHands.Count - 1) and (gHands[aPlayer].Enabled)
  -    and InRange(aType, 0, 3)
  -    and (aCount > 0) and (aColumns > 0) then
  -    begin
  -      gt := TKMGroupType(aType);
  -      gHands[aPlayer].AI.General.DefencePositions.TroopFormations[gt].NumUnits := aCount;
  -      gHands[aPlayer].AI.General.DefencePositions.TroopFormations[gt].UnitsPerRow := aColumns;
  -    end
  -    else
  -      LogParamWarning('Actions.AIGroupsFormationSet', [aPlayer, aType, aCount, aColumns]);
  -  except
  -    gScriptEvents.ExceptionOutsideScript := True; //Don't blame script for this exception
  -    raise;
  -  end;
  +  if InRange(aType, 0, 3) then
  +  begin
  +    gt := TKMGroupType(aType);
  +    _AIGroupsFormationSetEx(aPlayer, gt, aCount, aColumns, 'Actions.AIGroupsFormationSet');
  +  end
  +  else
  +    LogParamWarning('Actions.AIGroupsFormationSet', [aPlayer, aType, aCount, aColumns]);
   end;
   
   
  
positive.code: //* Sets the formation the AI uses for defence positions
  procedure TKMScriptActions.AIGroupsFormationSetEx(aPlayer: TKMHandID; aGroupType: TKMGroupType; aCount, aColumns: Integer);
  begin
    try
      if InRange(aPlayer, 0, gHands.Count - 1) and (gHands[aPlayer].Enabled)
      and (aGroupType in [gtMelee..gtMounted])
      and (aCount > 0) and (aColumns > 0) then
      begin
        gHands[aPlayer].AI.General.DefencePositions.TroopFormations[aGroupType].NumUnits := aCount;
        gHands[aPlayer].AI.General.DefencePositions.TroopFormations[aGroupType].UnitsPerRow := aColumns;
      end
      else
        LogParamWarning('Actions.AIGroupsFormationSetEx', [aPlayer, Byte(aGroupType), aCount, aColumns]);
    except
      gScriptEvents.ExceptionOutsideScript := True; //Don't blame script for this exception
      raise;
    end;
  end;
  
  
  
negative.code:   private
      fOnSetLogLinesMaxCnt: TIntegerEvent;
      procedure LogStr(const aText: String);
  
      procedure _AIGroupsFormationSetEx(aPlayer: TKMHandID; aGroupType: TKMGroupType; aCount, aColumns: Integer; aMethodName: string);
    public
      property OnSetLogLinesMaxCnt: TIntegerEvent read fOnSetLogLinesMaxCnt write fOnSetLogLinesMaxCnt;
  
  