Results 1 to 6 of 6

Thread: FindBridgeColors: Integer;

  1. #1
    Join Date
    Dec 2006
    Posts
    908
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default FindBridgeColors: Integer;

    SCAR Code:
    function FindBridgeColors: Integer;
    var
      GC, I, L, TestColor, WaterColor, X, Y: integer;
      P : TPointArray;
    begin
      WaterColor := FindWaterColor;
      if (not (FindColor(X, Y, WaterColor, MMX1, MMY1, MMX2, MMY2))) then
        WaterColor := FindWaterColor;
      if (WaterColor = 0) then
      begin
        Result := 0;
        Exit;
      end;
      GC := 1389645;
      Flag;
      FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 60);
      L := GetArrayLength(P);
      for I := 0 to L - 1 do
      begin
        if rs_OnMinimap(P[I].X, P[I].Y) then
        begin
          TestColor := GetColor(P[I].X, P[I].Y);
          if GetColor(P[I].X + 1, P[I].Y) = WaterColor then
            if GetColor(P[I].X - 2, P[I].Y) = TestColor then
              if GetColor(P[I].X, P[I].Y - 3) = TestColor then
              begin
                Result := TestColor;
                WriteLn('Bridge Color = ' + IntToStr(Result));
                Exit;
              end;
        end;
      end;
      WriteLn('Could not find Bridge Color.');
      Result := 0;
    end;

    The old one is broken, this one works on the Entrana Bridge. Yes I am making a Law Crafter, but anyways this should be fixed (Mine might be incorrect, but I'm just saying this function needs to be fixed.)

    Peace out! And look for my Law Crafter when it comes out! (Its not based on Reflection.)

  2. #2
    Join Date
    Jun 2008
    Location
    San Diego, California
    Posts
    276
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Looks nice, Good Job!!
    Current Project: All In 1 Falador Script - 20% DONE

  3. #3
    Join Date
    Dec 2006
    Posts
    908
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default

    Thanks Shermanator ;p I am gonna make a tutorial of this sometime ;p

  4. #4
    Join Date
    Mar 2006
    Posts
    3,051
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Good job on the rewrite. I fixed the old function, and this should now work for any "striped" bridge, including the one on Entrana.

    Code:
    function FindBridgeColor: Integer;
    var
      GC, a, l, TestColor, x, y: integer;
    var
      P:array of Tpoint;
    begin
      if WaterColor = 0 then WaterColor := FindWaterColor;
      if not(FindColor(x, y, WaterColor, MMX1, MMY1, MMX2, MMY2)) then
        WaterColor := FindWaterColor;
      if WaterColor = 0 then
      begin
        WriteLn('No water on screen... aborting');
        Result := 0;
        Exit;
      end;
      GC := 1389645;
      Flag;
      FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 60);
      l:=GetArrayLength(P);
      for a:= 0 to l-1 do
      begin
        if rs_OnMinimap(P[a].x,P[a].y) then
        begin
          TestColor := GetColor(P[a].x,P[a].y);
          if GetColor(P[a].x-1,P[a].y)=Testcolor+395277 then
          begin
            if FindColor(x,y,WaterColor,P[a].x-3,P[a].y-3,P[a].x+3,P[a].y+3) then
            begin
              Result := TestColor;
              WriteLn('Bridge Color = ' + IntToStr(TestColor));
              Exit;
            end;
          end;
        end;
      end;
      WriteLn('Could not find Bridge Color!');
      Result := 0;
    end;
    Your function looks like it's based on a geometric arrangement of 4 pixels. It's essentially a DDTM. There's nothing wrong with that, and it may work great on Entrana, but it might run into problems other places around the map where the riverbanks are wide. The old broken function and this function are based on the color "distance" between the two adjacent bridge colors being a specific value, 395277. I will update this one to SRL, but use what works best for you.


  5. #5
    Join Date
    Dec 2006
    Posts
    908
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default

    Thanks tarajunky, seems my version works so far in Entrana, but i still don't seem to get how the SRL Auto coloring works. I see this...

    SCAR Code:
    if GetColor(P[a].x-1,P[a].y)=Testcolor+395277 then

    I thought a while ago it meant the differences of the color next to the Testcolor. So like, the Testcolor - 395277 = Color of the other strip of the bridge.

    EDIT:
    And yes, it is like a DTM (DDTM because of a auto-color). I just noticed!

    EDIT EDIT:
    Never mind, i figured it out thanks to you. Although i was right the whole time.

  6. #6
    Join Date
    Dec 2006
    Posts
    908
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default

    SCAR Code:
    function FindBridgeColors: Integer;
    var
      GC, A, L, TestColor, x, y: integer;
      P: TPointArray;
    begin
      if (WaterColor = 0) then
        WaterColor := FindWaterColor;
      if (not (FindColor(X, Y, WaterColor, MMX1, MMY1, MMX2, MMY2))) then
        WaterColor := FindWaterColor;
      if (WaterColor = 0) then
      begin
        Result := 0;
        Exit;
      end;
      GC := 1389645;
      Flag;
      FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 60);
      L := GetArrayLength(P);
      for A := 0 to L-1 do
      begin
        if rs_OnMinimap(P[A].X, P[A].Y) and rs_OnMinimap(P[A].X-1, P[A].Y) then
        begin
          TestColor := GetColor(P[A].X, P[A].Y);
          if (GetColor(P[A].X-1, P[A].Y) = TestColor+395277) then
          begin
            if (FindColor(X, Y, WaterColor, P[A].X-3, P[A].Y-3, P[A].X+3, P[A].Y+3)) then
            begin
              Result := TestColor;
              WriteLn('Bridge Color = ' + IntToStr(TestColor));
              Exit;
            end;
          end
          else
          begin
            if (InRange(iAbs(TestColor - GetColor(P[A].X-1, P[A].Y)), 264205, 395277)) then
              if (FindColor(X, Y, WaterColor, P[A].X-3, P[A].Y-3, P[A].X+3, P[A].Y+3)) then
              begin
                Result := TestColor;
                WriteLn('Bridge Color = ' + IntToStr(TestColor));
                Exit;
              end;
          end;
        end;
      end;
      WriteLn('Could not find Bridge Color.');
      Result := 0;
    end;

    I found out the difference changes every 12 hours i think, anyways i added a fail safe if yours fail ;p

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. function SendKeyboard(FKey:Integer; Text:String): Integer;
    By Daniel in forum Research & Development Lounge
    Replies: 4
    Last Post: 07-18-2007, 04:28 PM

Posting Permissions

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