Results 1 to 5 of 5

Thread: Monster finding method

  1. #1
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default Monster finding method

    I have this function to find Moss giants in my script. Im kinda newbie at TPAs. I think this method is a little slow.
    Any help to improve this would be appreciated. (like faster algorithms)
    Simba Code:
    function FindMoss(LookForRedHpBar : Boolean) : Boolean;
    var
      TPA1, TPA2, TPA3, TPA4, TPA5, TPA6, TPA7, TPA8, TPA : TPointArray;
      ATPA : Array of TPointArray;
      RedHpBarDTM : Integer;
      i, DetectTime, UptextTime, RedHpBarDTMTime : Integer;
      ExcludeNearRedHpBAr : Boolean;
    begin
      MarkTime(DetectTime);
      ExcludeNearRedHpBAr := False;

      if LookForRedHPBar then                                                       //finding the red hpbar from the last fight then we exclude points around it to avoid to attack a dying monster
      begin
        RedHpBarDTM:= DTMFromString('mWAAAAHicY2FgYOBjZGDgAmJOKH0IKHYAiA8D8TEg3sfBwmDNzgTHrEAxZMyIhkEAABsyBO0=');
        if FindDTM(RedHpBarDTM,X,Y,MSX1,MSY1,MSX2,MSY2) then
          ExcludeNearRedHpBAr := True;
        FreeDTM(RedHpBarDTM);
      end;
      RedHpBarDTMTime := TimeFromMark(DetectTime);


      FindColorsTolerance(TPA1,3823447,MSX1,MSY1,MSX2,MSY2,12);                     //colors for Mossies
      FindColorsTolerance(TPA2,5665130,MSX1,MSY1,MSX2,MSY2,12);
      FindColorsTolerance(TPA3,2375742,MSX1,MSY1,MSX2,MSY2,9);
      FindColorsTolerance(TPA4,2179404,MSX1,MSY1,MSX2,MSY2,8);

      FindColorsTolerance(TPA5,2371894,MSX1,MSY1,MSX2,MSY2,11);
      FindColorsTolerance(TPA6,1844005,MSX1,MSY1,MSX2,MSY2,8);
      FindColorsTolerance(TPA7,4611177,MSX1,MSY1,MSX2,MSY2,8);
      FindColorsTolerance(TPA8,1581349,MSX1,MSY1,MSX2,MSY2,10);


      AppendTPA(TPA,TPA1);
      AppendTPA(TPA,TPA2);
      AppendTPA(TPA,TPA3);
      AppendTPA(TPA,TPA4);
      AppendTPA(TPA,TPA5);
      AppendTPA(TPA,TPA6);
      AppendTPA(TPA,TPA7);
      AppendTPA(TPA,TPA8);


      if (High(TPA)> 0) then
      begin

        if ExcludeNearRedHpBAr then
        begin
          SortTPAFrom(TPA,Point(X,Y));
          InvertTPA(TPA);
          for i:=0 to High(TPA) do
            if (Abs(TPA[i].x - (X+30)) <  75) and (Abs(TPA[i].y - Y) <  75) then
              Break;
          SetArrayLength(TPA,i);
        end;

                                                                                    //excluding points near middle
        SortTPAFrom(TPA,Point(MSCX,MSCY));
        InvertTPA(TPA);
        for i:=0 to High(TPA) do
        if (Abs(TPA[i].x - MSCX) <  30) and (Abs(TPA[i].y - MSCY) <  30) then
          Break;
        SetArrayLength(TPA,i);


        ATPA := SplitTPA(TPA,10);                                                   //splitting TPAs
        SortATPASize(ATPA,True);


        for i:=0 to High(ATPA) do                                                   //excluding TPAs with less than 300 points
        begin
          if High(ATPA[i]) < 400 then
            Break;
        end;
        SetArrayLength(ATPA,i);

        if High(ATPA) < 1 then
          Exit;  

        SortATPAFromFirstPoint(ATPA,Point(MSCX,MSCY));                              //making the closest TPA the first in the array

        if DebugTPAs then                                                           //DebugTPAs
          DebugPoints(TPA,ATPA);

        if DebugLines and  (High(ATPA) > 0) then                                    //DebugLines
        begin
          Writeln('[Mosses] (400)');
          for i:=0 to High(ATPA) do
            Writeln('-'+IntToStr(High(ATPA[i])));
        end;

        if MiddleTPAEx(ATPA[0],X,Y) then                                            //getting the middle point of the TPA, moving mouse there then looking for uptext
        begin
          MMouse(X,Y,0,0);
          MarkTime(UptextTime);
          if WaitUpText('ttack',400) then
          begin
            if DebugLines then                                                      //DebugLines
              Writeln('Found Moss in ' + IntToStr(TimeFromMark(DetectTime)) + ' ms. Uptext was ' + IntToStr(TimeFromMark(UptextTime)) + ' ms. RedTime was ' + IntToStr(RedHpBarDTMTime) + ' ms.');
            Result := True;
            Exit;
          end;
        end;
      end;
      Result := False;
    end;
    Last edited by Shatterhand; 04-24-2012 at 06:46 PM.

  2. #2
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    woah! just a quick tip, get rid of all those findcolortolerance()'s and just craete an autocolor.

  3. #3
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by x[Warrior]x3500 View Post
    woah! just a quick tip, get rid of all those findcolortolerance()'s and just craete an autocolor.
    What is that? Just checked autocolor.simba but found only road color/ladder color..., pre set color related things.

  4. #4
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    well the EASIEST possible way to create an autocolor function is to use ACAv2 (autocolor aide v2) - this is recommended


    or if you enjoy trying to figure it out on your own you can use this tut:http://villavu.com/forum/showthread....ight=autocolor (i used this when i first came to srl)
    or http://villavu.com/forum/showthread....ight=autocolor

  5. #5
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Autocolor is an overused to tool to get good colors and test them with different cts methods before using it.

    I think a better way to short the code would be:

    Simba Code:
    var
      j:Integer;
      NewTPA,TPA:TPointArray;
      colorsToSearch, colorsTol:TIntegerArray;

    Simba Code:
    colorsToSearch := [3823447,5665130,2375742,2179404,2371894,1844005,4611177,1581349];
      colorsTol := [12,12,9,8,11,8,8,10];
      for j := 0 to High(colorsToSearch) do
      begin
        FindColorsTolerance(NewTPA,colorsToSearch[j],MSX1,MSY1,MSX2,MSY2,colorsTol[j]);
        AppendTPA(TPA,NewTPA);
      end;
    Working on: Tithe Farmer

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
  •