anchor.diff:  //* If the unit type is utAny any unit type will be accepted
   //* Result: Unit ID
   function TKMScriptStates.ClosestUnitEx(aPlayer, X, Y: Integer; aUnitType: TKMUnitType): Integer;
  -begin
  -  Result := _ClosestUnit(aPlayer, X, Y, aUnitType, 'States.ClosestUnitEx');
  -end;
  -
  -
  -function TKMScriptStates._ClosestUnitMultipleTypes(aPlayer, X, Y: Integer; aUnitTypes: TKMUnitTypeSet; aMethodName: string): Integer;
  +var
  +  succeed: Boolean;
  +begin
  +  try
  +    Result := _ClosestUnit(aPlayer, X, Y, aUnitType, succeed);
  +    if not succeed then
  +      LogParamWarn('States.ClosestUnitEx', [aPlayer, X, Y, GetEnumName(TypeInfo(TKMUnitType), Integer(aUnitType))]);
  +  except
  +    gScriptEvents.ExceptionOutsideScript := True; //Don't blame script for this exception
  +    raise;
  +  end;
  +end;
  +
  +
  +function TKMScriptStates._ClosestUnitMultipleTypes(aPlayer, X, Y: Integer; aUnitTypes: TKMUnitTypeSet; out aSucceed: Boolean): Integer;
   var
     U: TKMUnit;
   begin
     Result := -1;
  -  try
  -    if InRange(aPlayer, 0, gHands.Count - 1) and (gHands[aPlayer].Enabled)
  -      and gTerrain.TileInMapCoords(X, Y) then
  -    begin
  -      aUnitTypes := aUnitTypes * [UNIT_MIN..UNIT_MAX];
  -      U := gHands[aPlayer].Units.GetClosestUnit(KMPoint(X,Y), aUnitTypes);
  -      if U <> nil then
  -      begin
  -        Result := U.UID;
  -        fIDCache.CacheUnit(U, U.UID);
  -      end;
  -    end
  -    else
  -      LogIntParamWarn(aMethodName, [aPlayer, X, Y]);
  -  except
  -    gScriptEvents.ExceptionOutsideScript := True; //Don't blame script for this exception
  -    raise;
  +  aSucceed := False;
  +  if InRange(aPlayer, 0, gHands.Count - 1) and (gHands[aPlayer].Enabled)
  +    and gTerrain.TileInMapCoords(X, Y) then
  +  begin
  +    aUnitTypes := aUnitTypes * [UNIT_MIN..UNIT_MAX];
  +    U := gHands[aPlayer].Units.GetClosestUnit(KMPoint(X,Y), aUnitTypes);
  +    if U <> nil then
  +    begin
  +      Result := U.UID;
  +      fIDCache.CacheUnit(U, U.UID);
  +    end;
  +    aSucceed := True;
     end;
   end;
   
  
positive.code:       Result := G.UID;
        fIDCache.CacheGroup(G, G.UID);
      end;
    end
    else
      LogIntParamWarn(aMethodName, [aPlayer, X, Y, Ord(aGroupType)]);
  end;
  
  
  
negative.code:   TKMScriptStates = class(TKMScriptEntity)
    private
      procedure _AIGroupsFormationGet(aPlayer: Integer; aGroupType: TKMGroupType; out aCount, aColumns: Integer; out aSucceed: Boolean);
      function _ClosestGroup(aPlayer, X, Y: Integer; aGroupType: TKMGroupType; out aSucceed: Boolean): Integer;
      function _ClosestGroupMultipleTypes(aPlayer, X, Y: Integer; aGroupTypes: TKMGroupTypeSet; out aSucceed: Boolean): Integer;
      function _ClosestHouse(aPlayer, X, Y: Integer; aHouseType: TKMHouseType; out aSucceed: Boolean): Integer;
      function _ClosestHouseMultipleTypes(aPlayer, X, Y: Integer; aHouseTypes: TKMHouseTypeSet; out aSucceed: Boolean): Integer;
      function _ClosestUnit(aPlayer, X, Y: Integer; aUnitType: TKMUnitType; out aSucceed: Boolean): Integer;
      function _ClosestUnitMultipleTypes(aPlayer, X, Y: Integer; aUnitTypes: TKMUnitTypeSet; out aSucceed: Boolean): Integer;
    public
      function AIArmyType(aPlayer: Byte): TKMArmyType;
      function AIAutoAttack(aPlayer: Byte): Boolean;
  