Results 1 to 11 of 11

Thread: plant solver

  1. #1
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default plant solver

    i noticed that srl doesnt have a plant solver and i have had a perfectly working one for nearly a year
    so here it is
    SCAR Code:
    program PlantFinder;
    {.include srl/srl.scar}

    function Find2TPApoints(TPA1, TPA2: TPointArray; w, h: Integer): TPointArray;
    var i1, i2, l1, l2, r: LongInt;
    begin
      l1 := High(TPA1);
      l2 := High(TPA2);
      r := 0;
      for i1 := 0 to l1 do
      begin
        for i2 := 0 to l2 do
        begin
          if (ABS(TPA1[i1].x - TPA2[i2].x) <= w) and (ABS(TPA1[i1].y - TPA2[i2].y) <= h) then
          begin
            Inc(r);
            SetLength(Result, r + 1);
            result[r].x := ((TPA1[i1].x + TPA2[i2].x) div 2);
            result[r].y := ((TPA1[i1].y + TPA2[i2].y) div 2);
          end;
        end;
      end;
    end;

    function ItemCoordsDtm(area: string; dtm: Integer): TPointArray;
    var
      startx, starty, rowsize, colsize, colnumber, rownumber, col, row: Integer;
      x1, y1, x2, y2: Integer;
      itemx, itemy: Integer;
      i: Integer;
    begin
      SetArrayLength(Result, 0);
      if (CheckArea(area)) then
      begin
        AreaInfo(area, startx, starty, rowsize, colsize, colnumber, rownumber);
        for row := 0 to rownumber - 1 do
        for col := 0 to colnumber - 1 do
        begin
          x1 := startx + col * colsize;
          y1 := starty + row * rowsize;
          x2 := x1 + colsize;
          y2 := y1 + rowsize;
          if (FindDTM(dtm, itemx, itemy, x1, y1, x2, y2)) then
          begin
            i := GetArrayLength(Result);
            SetArrayLength(Result, i + 1);
            Result[i].x := x1;
            Result[i].y := y1;
          end;
        end;
      end;
    end;

    function CountItemsDtm(area: string; dtm: Integer): Integer;
    var
      coords: TPointArray;
    begin
      coords := ItemCoordsDtm(area, dtm);
      Result := GetArrayLength(coords);
    end;
    function StrangePlantFinder: Boolean;

    var
      l, spx, spy, StartSPF, FruitCount, FruitDTM: integer;
      TPA1, TPA2, TPA3: TPointArray;
    Begin
      if not LoggedIn then exit;
      result := false
      spx := MSCX;
      spy := MSCY;
      if FindColorTolerance(spx, spy, 945749, MSCX - 100, MSCY - 110, MSCX + 100, MSCY + 90, 4) and FindColorTolerance(spx, spy, 743503, MSCX - 100, MSCY - 110, MSCX + 100, MSCY + 90, 4) then
      begin
        FindColorsSpiralTolerance(spx, spy, TPA1, 945749, MSX1, MSY1, MSX2, MSY2, 4);
        FindColorsSpiralTolerance(spx, spy, TPA2, 743503, MSX1, MSY1, MSX2, MSY2, 4);
        SetLength(TPA1, High(TPA1) + 1);
        SetLength(TPA2, High(TPA2) + 1);
        TPA3 := Find2TPApoints(TPA1, TPA2, 18, 18);
        l := High(TPA3);
        if l >= 0 then
        begin
          if FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) then
          begin
            writeln('Found Strange Plant attempting to Pick fruit.');
            FruitDTM := DTMFromString('78DA63E4646060E0654001B30A8E30B001694' +
                        '620FE0F048CDC400633031A60442281B40090E026A08607488812' +
                        '50C30A244408A861C67433BA1A008467066B');
            FruitCount := CountItemsDtm('inv', FruitDTM);
            Result := True;
            MarkTime(StartSPF);
            repeat
              if FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) then
              begin
                MMouse(spx, spy, 1, 1);
                wait(250 + Random(250));
                if IsUpText('trange') then
                begin
                  wait(250 + Random(250));
                  Mouse(spx, spy, 1, 1, false);
                  wait(250 + Random(250));
                  ChooseOption('ick');
                  wait(500 + Random(600));
                  if Pos('ready to', GetBlackChatMessage) > 5 then
                    wait(2000 + Random(1000)) else //Text: The fruit isn't ready to be picked yet...
                  if (Pos('fruit from', GetBlackChatMessage) > 5) or (CountItemsDtm('inv', FruitDTM) > FruitCount) then //Text: You pick the fruit from the plant.
                  begin
                    result := true;
                    writeln('Picked Fruit From Strange Plant.. Waiting for plant to die...');
                    FreeDTM(FruitDTM);
                    repeat
                      BoredHuman;
                      wait(2000 + random(1000));
                    until not FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) or FindFight;
                    Plants := Plants + 1;
                    SRLRandomsReport;
                    exit;
                  end else
                  if Pos('unable', GetBlackChatMessage) > 5 then     //Text: You're unable to pick the fruit.
                  begin
                    result := false;
                    writeln('The plant is not after you.. Waiting for plant to go...');
                    FreeDTM(FruitDTM);
                    repeat
                      BoredHuman;
                      wait(2000 + random(1000));
                    until not FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) or FindFight;
                    exit;
                  end;
                end;
              end else break;
            until (TimeFromMark(StartSPF) > 120000) or FindFight;
            writeln('Failed to Pick Fruit From Strange Plant');
            FreeDTM(FruitDTM);
          end;
        end;
      end;
    end;

    begin
      SetupSrl;
      StrangePlantFinder;
    end.
    i hope this gets added into srl

    ~shut

    EDIT: markus's fix:
    SCAR Code:
    program PlantFinder;
    {.include srl/srl.scar}
     
    function Find2TPApoints(TPA1, TPA2: TPointArray; w, h: Integer): TPointArray;
    var
      i1, i2, l1, l2, r: LongInt;
    begin
      l1 := High(TPA1);
      l2 := High(TPA2);
      r := 0;
      for i1 := 0 to l1 do
      begin
        for i2 := 0 to l2 do
        begin
          if (ABS(TPA1[i1].x - TPA2[i2].x) <= w) and (ABS(TPA1[i1].y - TPA2[i2].y) <= h) then
          begin
            Inc(r);
            SetLength(Result, r + 1);
            result[r].x := ((TPA1[i1].x + TPA2[i2].x) div 2);
            result[r].y := ((TPA1[i1].y + TPA2[i2].y) div 2);
          end;
        end;
      end;
    end;
     
    function StrangePlantFinder: Boolean;
    var
      l, spx, spy, StartSPF, FruitCount, FruitDTM: integer;
      TPA1, TPA2, TPA3: TPointArray;
    Begin
      if not LoggedIn then exit;
      result := false
      //spx := MSCX;
      //spy := MSCY; //What's the use of this :p?
      if FindColorTolerance(spx, spy, 945749, MSCX - 100, MSCY - 110, MSCX + 100, MSCY + 90, 4) and FindColorTolerance(spx, spy, 743503, MSCX - 100, MSCY - 110, MSCX + 100, MSCY + 90, 4) then
      begin
        FindColorsSpiralTolerance(mscx, mscy, TPA1, 945749, MSX1, MSY1, MSX2, MSY2, 4);
        FindColorsSpiralTolerance(mscx, mscy, TPA2, 743503, MSX1, MSY1, MSX2, MSY2, 4);
        //SetLength(TPA1, High(TPA1) + 1); Setlength(tpa, length(tpa)) ? -.-
        //SetLength(TPA2, High(TPA2) + 1);
        TPA3 := Find2TPApoints(TPA1, TPA2, 18, 18);
        l := High(TPA3);
        if l >= 0 then
        begin
          if FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) then
          begin
            writeln('Found Strange Plant attempting to Pick fruit.');
            FruitDTM := DTMFromString('78DA63E4646060E0654001B30A8E30B001694' +
                        '620FE0F048CDC400633031A60442281B40090E026A08607488812' +
                        '50C30A244408A861C67433BA1A008467066B');
            FruitCount := CountItems(FruitDTM, 'dtm', [0]);   //:)
            Result := True;
            MarkTime(StartSPF);
            repeat
              if FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) then
              begin
                MMouse(spx, spy, 1, 1);
                wait(250 + Random(250));
                if IsUpText('trange') then
                begin
                  wait(250 + Random(250));
                  Mouse(spx, spy, 1, 1, false);
                  wait(250 + Random(250));
                  ChooseOption('ick');
                  wait(500 + Random(600));
                  if Pos('ready to', GetBlackChatMessage) > 5 then
                    wait(2000 + Random(1000)) else //Text: The fruit isn't ready to be picked yet...
                  if (Pos('fruit from', GetBlackChatMessage) > 5) or (CountItems(FruitDTM, 'dtm', [0]) > FruitCount) then //Text: You pick the fruit from the plant.
                  begin
                    result := true;
                    writeln('Picked Fruit From Strange Plant.. Waiting for plant to die...');
                    FreeDTM(FruitDTM);
                    repeat
                      BoredHuman;
                      wait(2000 + random(1000));
                    until not FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) or FindFight;
                    Plants := Plants + 1;
                    SRLRandomsReport;
                    exit;
                  end else
                  if Pos('unable', GetBlackChatMessage) > 5 then     //Text: You're unable to pick the fruit.
                  begin
                    result := false;
                    writeln('The plant is not after you.. Waiting for plant to go...');
                    FreeDTM(FruitDTM);
                    repeat
                      BoredHuman;
                      wait(2000 + random(1000));
                    until not FindObjTPA(spx, spy, 945749, 4, 1, 18, 18, 4, ['trange']) or FindFight;
                    exit;
                  end;
                end;
              end else break;
            until (TimeFromMark(StartSPF) > 120000) or FindFight;
            writeln('Failed to Pick Fruit From Strange Plant');
            FreeDTM(FruitDTM);
          end;
        end;
      end;
    end;
     
    begin
      SetupSrl;
      StrangePlantFinder;
    end.

  2. #2
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Those are some gross standards...

  3. #3
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  4. #4
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    This fine with you?
    SCAR Code:
    program PlantFinder;
    {.include srl/srl.scar}

    function Find2TPApoints(TPA1, TPA2: TPointArray; w, h: Integer): TPointArray;
    var
      i1, i2, l1, l2, r: LongInt;
    begin
      l1 := High(TPA1);
      l2 := High(TPA2);
      r := 0;
      for i1 := 0 to l1 do
      begin
        for i2 := 0 to l2 do
        begin
          if (ABS(TPA1[i1].x - TPA2[i2].x) <= w) and (ABS(TPA1[i1].y - TPA2[i2].y) <= h) then
          begin
            Inc(r);
            SetLength(Result, r + 1);
            result[r].x := ((TPA1[i1].x + TPA2[i2].x) div 2);
            result[r].y := ((TPA1[i1].y + TPA2[i2].y) div 2);
          end;
        end;
      end;
    end;

    function StrangePlantFinder: Boolean;
    var
      l, spx, spy, StartSPF, FruitCount, FruitDTM: integer;
      TPA1, TPA2, TPA3: TPointArray;
    Begin
      if not LoggedIn then exit;
      result := false
      //spx := MSCX;
      //spy := MSCY; //What's the use of this :p?
      if FindColorTolerance(spx, spy, 945749, MSCX - 100, MSCY - 110, MSCX + 100, MSCY + 90, 4) and FindColorTolerance(spx, spy, 743503, MSCX - 100, MSCY - 110, MSCX + 100, MSCY + 90, 4) then
      begin
        FindColorsSpiralTolerance(mscx, mscy, TPA1, 945749, MSX1, MSY1, MSX2, MSY2, 4);
        FindColorsSpiralTolerance(mscx, mscy, TPA2, 743503, MSX1, MSY1, MSX2, MSY2, 4);
        //SetLength(TPA1, High(TPA1) + 1); Setlength(tpa, length(tpa)) ? -.-
        //SetLength(TPA2, High(TPA2) + 1);
        TPA3 := Find2TPApoints(TPA1, TPA2, 18, 18);
        l := High(TPA3);
        if l >= 0 then
        begin
          if FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) then
          begin
            writeln('Found Strange Plant attempting to Pick fruit.');
            FruitDTM := DTMFromString('78DA63E4646060E0654001B30A8E30B001694' +
                        '620FE0F048CDC400633031A60442281B40090E026A08607488812' +
                        '50C30A244408A861C67433BA1A008467066B');
            FruitCount := CountItems(FruitDTM, 'dtm', [0]);   //:)
            Result := True;
            MarkTime(StartSPF);
            repeat
              if FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) then
              begin
                MMouse(spx, spy, 1, 1);
                wait(250 + Random(250));
                if IsUpText('trange') then
                begin
                  wait(250 + Random(250));
                  Mouse(spx, spy, 1, 1, false);
                  wait(250 + Random(250));
                  ChooseOption('ick');
                  wait(500 + Random(600));
                  if Pos('ready to', GetBlackChatMessage) > 5 then
                    wait(2000 + Random(1000)) else //Text: The fruit isn't ready to be picked yet...
                  if (Pos('fruit from', GetBlackChatMessage) > 5) or (CountItems(FruitDTM, 'dtm', [0]) > FruitCount) then //Text: You pick the fruit from the plant.
                  begin
                    result := true;
                    writeln('Picked Fruit From Strange Plant.. Waiting for plant to die...');
                    FreeDTM(FruitDTM);
                    repeat
                      BoredHuman;
                      wait(2000 + random(1000));
                    until not FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) or FindFight;
                    Plants := Plants + 1;
                    SRLRandomsReport;
                    exit;
                  end else
                  if Pos('unable', GetBlackChatMessage) > 5 then     //Text: You're unable to pick the fruit.
                  begin
                    result := false;
                    writeln('The plant is not after you.. Waiting for plant to go...');
                    FreeDTM(FruitDTM);
                    repeat
                      BoredHuman;
                      wait(2000 + random(1000));
                    until not FindObjTPA(spx, spy, 945749, 4, 1, 18, 18, 4, ['trange']) or FindFight;
                    exit;
                  end;
                end;
              end else break;
            until (TimeFromMark(StartSPF) > 120000) or FindFight;
            writeln('Failed to Pick Fruit From Strange Plant');
            FreeDTM(FruitDTM);
          end;
        end;
      end;
    end;

    begin
      SetupSrl;
      StrangePlantFinder;
    end.
    I made a new script, check it out!.

  5. #5
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    Markus, and Shut also for that sake: Doesn't that one belong to PriSoner? (His woodcutting script..)

    And, I also remember that JuKKa was working on one, but I don't know about his progress. I hope he sees my post and digs it up

  6. #6
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    yes that is fine as long as it still works

    also it did belong to PriSoner but i asked him about me takiong over Ultra Cut n Bank and he said that i could continue the script and i could claim all the code and work
    and as that plant solver was in there it now belongs to me

    ~shut

  7. #7
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    I'll credit you both then?
    I made a new script, check it out!.

  8. #8
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  9. #9
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Markus View Post
    I'll credit you both then?
    Wait. You're including it in SRL?


    Edit: If so, I'm pretty sure that you understand that you'll have to make a new var in SetUpSRL; UsePlantSolver.

    Edit2: Yes! After all this time, my battle is won!

  10. #10
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  11. #11
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Plant random finder and handler
    By Psychor in forum Research & Development Lounge
    Replies: 4
    Last Post: 11-28-2007, 06:02 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
  •