Results 1 to 2 of 2

Thread: core/Inventory.scar

  1. #1
    Join Date
    Mar 2007
    Posts
    1,700
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default core/Inventory.scar

    The blackline functions,
    SCAR Code:
    Function CountItemsBlackLine(Count, Tol: Integer): Integer;

    Var
       TPA: TPointArray;
       I: Integer;
       TPAA: T2DPointArray;
    Begin
      GameTab(2);
      FindColorsTolerance(TPA, 65536, MIX1, MIY1, MIX2, MIY2, 0);
      TPAA := TPAToATPAEx(TPA, 42, 36);
      For I := 0 To High(TPAA) Do
        If InRange(GetArrayLength(TPAA[i]), Count - Tol, Count + Tol) Then
          Result := Result + 1;
    End;

    Function ClickAllItemsBlackLine(Count, Tol, WaitT, WaitR: Integer; Option: String): Integer;

    Var
       TPA: TPointArray;
       X, Y, Z: Integer;
       TPAA: T2DPointArray;
    Begin
      GameTab(2);
      FindColorsTolerance(TPA, 65536, MIX1, MIY1, MIX2, MIY2, 0);
      TPAA := TPAToATPAEx(TPA, 42, 36);
      For z := 0 To High(TPAA) Do
        If InRange(GetArrayLength(TPAA[z]), Count - Tol, Count + Tol) Then
        Begin
          MiddleTPAEx(TPAA[z], X, Y);
          Mouse(X, Y, 2, 2, False);
          If ChooseOption(Option) Then
          Begin
            Result := Result + 1;
            Wait(WaitT + Random(WaitR));
          End;
        End;
    End;
    both have a GameTab(2) before the rest of the function.
    Shouldn't that be GameTab(4)?

    Edit: I don't think these functions even work..

  2. #2
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Try using TDTMs, like this
    SCAR Code:
    program New;
    {.include Srl\SRL.scar}

    Function InvBox2(i :Integer): TBox;
    var
      row, col: Integer;

    begin
      if (i < 1) or (i > 28) then
      begin
        srl_Warn('InvBox', 'Incorrect index: ' + IntToStr(i), warn_AllVersions);
        exit;
      end;
      {1 x1 563 y1 213 x2 594 y2 244}
      {5 x1 605 y1 249}
      Result.x1 :=563+((((i+3)mod 4))*(605-563));
      Result.y1 :=213+((((i-1)/4))*(249-213));
      Result.x2 := Result.x1+31;
      Result.y2 := Result.y1+31;
    end;


    function UIDB_MakeDTMPoint(X,Y,Color,Tol:integer): TDTMPointDef;
    begin
      result.x:=X;
      result.y:=Y;
      result.areasize:=0;
      result.areashape:=0;
      result.color:=Color;
      result.tolerance:=Tol;
    end;


    function CreateTDTM(Area:string; Slot:integer): TDTM;
    var SlotBox:TBox;
    hx,hy,BlackPts:integer;

    tmpcount:integer;
    begin
      case lowercase(Area) of
        'inv': SlotBox:= InvBox2(Slot);
        'bank': SlotBox:= BankIndexToMSBox(Slot);
      end;
      repeat
        hy:=15;
        hx:=hx+1;
        repeat
          hy:=hy+1;
          if (((hx mod 2)=0) or ((hy mod 2)=0)) then
          begin
            if getcolor(hx+SlotBox.x1,hy+SlotBox.y1)=65536 then
            begin
              SetArrayLength(result.SubPoints,BlackPts+1);
              result.SubPoints[BlackPts]:=UIDB_MakeDTMPoint(hx,hy,65536,0);
              BlackPts:=BlackPts+1;
            end;
          end;
        until hy=31;
      until hx=31;
      result.MainPoint:=UIDB_MakeDTMPoint(BlackPts-1,0,0,255);
    end;

    function CompareTDTM(First,Second:TDTM):boolean;
    var i:integer;
    begin
      result:=false;
      if First.MainPoint.x <> Second.MainPoint.x then exit;
      for i:=0 to First.MainPoint.x do
      begin
        if First.SubPoints[i].x <> Second.SubPoints[i].x then exit;
        if First.SubPoints[i].y <> Second.SubPoints[i].y then exit;
      end;
      result:=true;
    end;


    var x,c,t,y:integer;
     MyTDTM:TDTM;
    begin
    //repeat
    t:=getsystemtime;
    MyTDTM:=CreateTDTM('inv',5);

    for c:=1 to 28 do
    begin
     if CompareTDTM(MyTDTM,CreateTDTM('inv',c)) then writeln(inttostr(c));
    end;
    //writeln(inttostr(getsystemtime-t));
    //until isfkeydown(12);

    end.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •