Results 1 to 22 of 22

Thread: TPA to image (bmp?)

  1. #1
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default TPA to image (bmp?)

    Hey ok im trying to make an antiban function that goes into your equipment stats and screws around =D its a little project to keep me busy. so far ive gotten up to finding the object.. now im trying to make a TPA of the black outline around the object and then find that exact TPA again. do i have to convert it into a bitmap and surch for that? im still a major nub at TPA's so im probably doing this all wrong :S

    SCAR Code:
    program New;
    {.Include SRL/SRL/Misc/SMART.SCAR}
    {.include SRL\SRL.Scar}
    {

            Fighting: Red / Yellow X detector when clicking things
           
      EquipmentStats.x := 588 + RanInt(15);
      EquipmentStats.y := 432 + RanInt(15);

      ExitButton.x := 490 + RanInt(6);
      ExitButton.y := 45 + RanInt(6);

      Head.x := 420 + RanInt(15);
      Head.y := 85 + RanInt(15);

      Neak.x := 420 + RanInt(15);
      Neak.y := 125 + RanInt(15);

      Body.x := 420 + RanInt(15);
      Body.y := 165 + RanInt(15);

      Leggs.x := 420 + RanInt(15);
      Leggs.y := 205 + RanInt(15);

      Feet.x := 420 + RanInt(15);
      Feet.y := 245 + RanInt(15);

      Cape.x := 380 + RanInt(15);
      Cape.y := 125 + RanInt(15);

      Arrow.x := 460 + RanInt(15);
      Arrow.y := 123 + RanInt(15);

      Wepon.x := 365 + RanInt(15);
      Wepon.y := 160 + RanInt(15);

      Shild.x := 480 + RanInt(15);
      Shild.y := 160 + RanInt(15);

      Glove.x := 365 + RanInt(15);
      Glove.y := 245 + RanInt(15);

      Ring.x := 480 + RanInt(15);
      Ring.y := 245 + RanInt(15);
    }

    var
      ItemShapTPA : TPointArray;
    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      Players[0].Name :='';
      Players[0].Pass :='';
      Players[0].Nick :='';
      Players[0].Active := True;
      Players[0].Integers[0] := 2;
    end;

    procedure SetupSmart;
    begin
    SMARTSetupEx(153, False, True, False);
      Wait(5000);
      SetTargetDC(SmartGetDC);
      repeat
        wait(100);
      until(SmartGetColor(253, 233)<>1118604);
    end;

    function RanInt(magnitude : Integer) : Integer;
    var
      product : Integer;
    begin
      product := Random(magnitude+1) - Random(magnitude+1);
      if(product=0) then Result := Random(magnitude) - Random(magnitude)
      else Result := product;
    end;

    procedure ScriptSetup;
    begin
      SetupSRL;
      SetupSmart;
      ActivateClient;
      ClearDebug;
      DeclarePlayers;
      if not LoggedIn then LogInPlayer;
      SetAngle(true);
      MakeCompass('n');
      SetRun(true);
    end;

    {ANTIBAN FUNCTIONS}

    function CheckIfEquipted(position : Integer) : Boolean;
    begin
      case Position of
        0: if GetColor(424, 88) <> 2304814 then Result := True;//Head
        1: if GetColor(385, 118) <> 2304814 then Result := True;//Cape
        2: if GetColor(428, 121) <> 2304814 then Result := True;//Neak
        3: if GetColor(466, 126) <> 2304814 then Result := True;//Arrow
        4: if GetColor(370, 166) <> 2304814 then Result := True;//Wepon
        5: if GetColor(425, 162) <> 2304814 then Result := True;//Body
        6: if GetColor(472, 153) <> 2304814 then Result := True;//Shild
        7: if GetColor(424, 204) <> 2304814 then Result := True;//Leggs
        8: if GetColor(370, 247) <> 2304814 then Result := True;//Gloves
        9: if GetColor(420, 233) <> 2304814 then Result := True;//Feet
        10: if GetColor(478, 240) <> 2304814 then Result := True;//Ring
      end;
    end;

    function RemoveEquipment(position : Integer) : TPoint;
    var
      x, y, ran : Integer;
      Head, Neak, Body, Leggs, Feet, Cape, Arrow, Wepon, Shild, Glove, Ring  : Tpoint;

    begin
      ran := RanInt(10);
      case position of
        0: Result := IntToPoint(420 + ran, 85 + ran);
        1: Result := IntToPoint(380 + ran, 125 + ran);
        2: Result := IntToPoint(420 + ran, 125 + ran);
        3: Result := IntToPoint(460 + ran, 123 + ran);
        4: Result := IntToPoint(365 + ran, 160 + ran);
        5: Result := IntToPoint(420 + ran, 165 + ran);
        6: Result := IntToPoint(480 + ran, 160 + ran);
        7: Result := IntToPoint(420 + ran, 203 + ran);
        8: Result := IntToPoint(365 + ran, 245 + ran);
        9: Result := IntToPoint(420 + ran, 245 + ran);
        10: Result := IntToPoint(480 + ran, 245 + ran);
      end;
      Mouse(Result.x, Result.y, 0, 0, true);
    end;

    function ItemShapeTPA(position : Integer) : TPointArray;
    var
      Box : TBox;//W: 29; H: 29;
    begin
      case position of
        0: Box := IntToBox(406, 69, 435, 98);
      end;
      FindColorsTolerance(Result, 65536, Box.x1, Box.y1, Box.x2, Box.y2, 15);
    end;

    function CheckEquipmentStats : Boolean;
    var
      x, y, i : Integer;
      EquipmentStats, ExitButton, Position : TPoint;
      ItemShape : TPointArray;

    begin
      EquipmentStats := IntToPoint(588 + RanInt(15), 432 + RanInt(15));
      ExitButton := IntToPoint(490 + RanInt(6), 45 + RanInt(6));
      //if InvCount > 23 then Exit;
      //GameTab(5);
      //Mouse(EquipmentStats.x, EquipmentStats.y, 0, 0, true);
      Wait(500+RanInt(50));
      for i := 0 to 0 do // ONLY CHECKING SLOT 1
      begin
        if CheckIfEquipted(i) then
        begin
          FindColorsTolerance(ItemShape, 65536, 403, 66, 438, 101, 15);
          Writeln(IntToStr(High(ItemShape)));
          if High(ItemShape) < 1 then Exit;
          Wait(500+RanInt(50));
          //RemoveEquipment(i);
          Wait(500+RanInt(50));
          for i := 0 to High(ItemShape) do
          begin
            Position := ItemShape[i];
            Writeln('ITEMSHAPE: ' + IntToStr(i));
            Mouse(Position.x, Position.y, 2, 2, true);
            Writeln(IntToStr(x) + IntToStr(y));
          end;
        end;
      end;
    //  Mouse(ExitButton.x, ExitButton.y, 0, 0, true);
    end;

    var
      i : Integer;
    begin
      ScriptSetup;
      CheckEquipmentStats;
    end.
    Lance. Da. Pants.

  2. #2
    Join Date
    May 2009
    Location
    Holland-Friesland-Leeuwarden
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yea, You need to conver it into a BMP File (I'm still a kind of noob also just started scripting)

    here i find you something (2 minutes later)

    http://www.graphic-converter.net/download.htm

    Then use the end of this guide http://villavu.com/forum/showthread.php?t=4625
    To help you getting the Bitmaps up for you script and how to set it up,
    Last edited by tarajunky; 05-19-2009 at 11:24 PM. Reason: No rep begging

  3. #3
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    erm... i dont understand. a TPA isnt a file its an array of Points o.O lol. im more looking for a SRL function that would convert the shape that all the Points in my TpointArray make, into a bitmap. but thanks anyway xP

    Edit: anyoneee elsee...?
    Last edited by Lance; 05-19-2009 at 12:35 PM.
    Lance. Da. Pants.

  4. #4
    Join Date
    Mar 2008
    Location
    In a cave
    Posts
    345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I'm not sure whether there is such function in Scar, but you can always convert the TPA(s) into DTM(s) :P
    A Chinese wiseman once said: "Shu ciu!", it was considered very smart, but now people know it means: "Something stinks here!"
    FalBuggySmelter v.1.31
    [Updated on the 1st of March 2010]
    RimmBugger BETA V1.8

  5. #5
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    DebugTPA, Debug ATPA?

    In SRL/Misc/Debug.scar

  6. #6
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    Quote Originally Posted by TazManian View Post
    Yea, You need to conver it into a BMP File (I'm still a kind of noob also just started scripting)

    here i find you something (2 minutes later)

    http://www.graphic-converter.net/download.htm

    Then use the end of this guide http://villavu.com/forum/showthread.php?t=4625
    To help you getting the Bitmaps up for you script and how to set it up,

    if helped rep++.
    Man that was kinda a sweet from you ( Non homo ) Well he didn't mean exaclty that (: But we still aprreciate that you are trying (:


    ~Home
    Btw.. Rep + (:

  7. #7
    Join Date
    May 2009
    Location
    Holland-Friesland-Leeuwarden
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks guys!, Apreciate that much, It feels good that people think so about me!.


    And i hope you fixed this error Lance .

  8. #8
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    What is this shit about bitmaps btw? How about you just use FindTPAinTPA, if you want to find the same outline again...

  9. #9
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Or find the TPA, Do a GetTPABounds, and store the co-ords to a TBox and thats basically where your object is.

  10. #10
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    What is this shit about bitmaps btw? How about you just use FindTPAinTPA, if you want to find the same outline again...
    ditto

  11. #11
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Im sorry Taz if i sounded rude :P i didnt mean for it to come out that way. i do appreciate it and you did spend 2 min looking for how to help xP so thanks alot

    and erm ok ill look into those other methods

    Edit: i dont understand FindTPAinTPA, what does it do exactly?

    what im looking for is something that will take a TPA, then surch your screen for a matching TPA and return the x, y coordinate of it.
    Last edited by Lance; 05-20-2009 at 02:31 PM.
    Lance. Da. Pants.

  12. #12
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    How about you tell us what do you want to do so we can help?

  13. #13
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    How about you tell us what do you want to do so we can help?
    Haha i agree with Ness, tell us what you are doing so we can help you


    ~Home

  14. #14
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    haha this is all quite confuseing. pretty much what i want to do is make an antiban function for my script where it goes into your equipment stats page (the pop up page, not the GameTab), unequipts armor, and then equipts it again.

    im at the point where i need to equipt it back, and i need a way of finding that item agian in your inventory.

    since this item could be anything i cant realy make a DTM or a bitmap of it, so what i thought is maby take a TPA of the black outline around the object before its uneqipted, then convert it to a DTM to find it again in your inventory. Someone on irc gave me a tutorial on how to do this actualy :] so i think im fine for now.. but if you guys know any easyer/faster way of converting a TPA to an image that can be used to find an object, plz tell.

    lol ill post my script so you can run it and see what im doing. its a compleate mess though :S

    Edit: i dont know if it will run properly, i just tried running it and ive discovered it keeps giving me this error:
    [Runtime Error] : Exception: Access violation at address 697C14D3 in module 'Embedded_SMART.dll'. Read of address 000009F8 in line 48

    my other script i was working on also keeps gliching up and freezing when just yesterday it worked =S shit maby my scar is screwd up again =S
    Last edited by Lance; 05-22-2009 at 07:07 AM.
    Lance. Da. Pants.

  15. #15
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    FindTPAinTPA maybe.

    But can't you just get the empty spots in inventory before unequipping, then unequip, then check for any previously empty spots that are now filled?

    Or maybe make a bitmap of the spot in the equipment stats screen. Then search later to equip it.
    Last edited by Da 0wner; 05-22-2009 at 08:27 AM.

  16. #16
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    FindTPAInTPA returns the matching points. So you can just use MiddleTPA to get the middle of those matching points.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  17. #17
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Aha .
    SCAR Code:
    function ClickBlackOutline(Outline : TPointArray) : boolean;
    var
      TPA : TPointArray;
      Box : TBox;
      i : integer;
    begin
      for i := 1 to 28 do
      begin
        if not ExistsItem(i) then
          continue;
        Box := InvBox(i);
        FindColors(TPA, 65536, Box.x1, Box.y1, Box.x2, Box.y2);
        if GetArrayLength(TPA) = GetArrayLength(Outline) then
        begin
          result := true;
          TPA[0] := MiddleTPA(TPA);
          Mouse(TPA[0].x, TPA[0].y, 3, 3, true);
          exit;
        end;
      end;
    end;

    Use that.

    You can use it like:
    SCAR Code:
    FindColors(Outline, 65536, x1, y1, x2, y2);
      ClickBlackOutline(Outline);
    Last edited by Da 0wner; 05-22-2009 at 09:03 AM.

  18. #18
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    why thankyou much better than makeing a DDTM lol. and erm i was origionaly gonna use just checking which inv slot was open, but i just figured that this way would be alot safer. it would be bad if i unequipted a vital item and then couldnt equipt it back :P
    Lance. Da. Pants.

  19. #19
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    However, you should modify it to check uptext to be sure. You can get the uptext and store into a variable when you unequip it. Some objects might have the same number of black points. This is not the best but is fine it seems. If you want you can make it check the coordinates of the points and see that way instead of the length of the TPA.

  20. #20
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yeah thats a good idea, though i just remembered something, isnt there a maximum of TPoints 70 points to every TPA? i just figured this cause one time i tried kinda the same idea, and for every High(TPA) i took it always came out as 70. so if any of the outlines have more than 70 points to them then they will look the same. though i havent had a chance to test your function out yet man ive been busy with my yew cutter ;P
    Lance. Da. Pants.

  21. #21
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nope, there is not a maximum of 70. But I have tested it and it works fine.

  22. #22
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    oh k sweet! well im excited about this then. thanks man :]
    Lance. Da. Pants.

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
  •