anchor.diff:  end;
   
   
  -procedure TKMScriptStates._AIGroupsFormationGet(aPlayer: Integer; aGroupType: TKMGroupType; out aCount, aColumns: Integer; aMethodName: string);
  -begin
  -  try
  -    if InRange(aPlayer, 0, gHands.Count - 1) and (gHands[aPlayer].Enabled)
  -      and (aGroupType in GROUP_TYPES_VALID) then
  -    begin
  -      if gHands[aPlayer].AI.Setup.NewAI then
  -      begin
  -        aCount := gHands[aPlayer].AI.ArmyManagement.Defence.TroopFormations[aGroupType].NumUnits;
  -        aColumns := gHands[aPlayer].AI.ArmyManagement.Defence.TroopFormations[aGroupType].UnitsPerRow;
  -      end
  -      else
  -      begin
  -        aCount := gHands[aPlayer].AI.General.DefencePositions.TroopFormations[aGroupType].NumUnits;
  -        aColumns := gHands[aPlayer].AI.General.DefencePositions.TroopFormations[aGroupType].UnitsPerRow;
  -      end
  -    end
  -    else
  -      LogIntParamWarn(aMethodName, [aPlayer, Ord(aGroupType)]);
  -  except
  -    gScriptEvents.ExceptionOutsideScript := True; //Don't blame script for this exception
  -    raise;
  +procedure TKMScriptStates._AIGroupsFormationGet(aPlayer: Integer; aGroupType: TKMGroupType; out aCount, aColumns: Integer; out aSucceed: Boolean);
  +begin
  +  aSucceed := False;
  +  if InRange(aPlayer, 0, gHands.Count - 1) and (gHands[aPlayer].Enabled)
  +    and (aGroupType in GROUP_TYPES_VALID) then
  +  begin
  +    if gHands[aPlayer].AI.Setup.NewAI then
  +    begin
  +      aCount := gHands[aPlayer].AI.ArmyManagement.Defence.TroopFormations[aGroupType].NumUnits;
  +      aColumns := gHands[aPlayer].AI.ArmyManagement.Defence.TroopFormations[aGroupType].UnitsPerRow;
  +    end
  +    else
  +    begin
  +      aCount := gHands[aPlayer].AI.General.DefencePositions.TroopFormations[aGroupType].NumUnits;
  +      aColumns := gHands[aPlayer].AI.General.DefencePositions.TroopFormations[aGroupType].UnitsPerRow;
  +    end;
  +    aSucceed := True;
     end;
   end;
   
  
positive.code: procedure TKMScriptStates.AIGroupsFormationGet(aPlayer, aType: Byte; out aCount, aColumns: Integer);
  var
    gt: TKMGroupType;
  begin
    gt := gtNone;
  
    if InRange(aType, 0, 3) then
      gt := TKMGroupType(aType + GROUP_TYPE_MIN_OFF);
  
    _AIGroupsFormationGet(aPlayer, gt, aCount, aColumns, 'States.AIGroupsFormationGet');
  end;
  
  
  
negative.code: //* Result: Group ID
  function TKMScriptStates.ClosestGroupEx(aPlayer, X, Y: Integer; aGroupType: TKMGroupType): Integer;
  begin
    try
      Result := _ClosestGroup(aPlayer, X, Y, aGroupType, 'States.ClosestGroupEx');
    except
      gScriptEvents.ExceptionOutsideScript := True; //Don't blame script for this exception
      raise;
    end;
  end;
  
  
  