So why following program
Code:
program Project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, Crt;
  { you can add units after this }
var
  num:Integer;
  function Random2(const seed, offset: cardinal): double; overload;
  var oldSeed: cardinal;
  begin
    oldSeed:=randseed; // Save old seed
    randseed:=seed+offset; // Shouldn't need to check high(cardinal) ranges.
    // Overflowing should still do the math perfectly.
    result:=random();
    randseed:=oldSeed; // Restore it afterwards,
    // So that use of normal Random() outside of this function is not interrupted.
  end;

  function Random2(const n: cardinal; const seed, offset: cardinal): double; overload;
  begin
    result:=trunc(Random2(seed, offset)*n);
  end;
begin
  RandSeed:=3;
  num:=Random(30);
  writeln(num);
  num:=Random(30);
  writeln(num);
  num:=Trunc(Random2(30,3,0));
  writeln(num);
  num:=Trunc(Random2(30,3,1));
  writeln(num);
  readkey;
end.
gives me this output:
16
2
16
29

?

I need random function which will pass test, e.g. with offset of 1 it'll generate same value like second random.