Results 1 to 12 of 12

Thread: Function GetDamageIn(x1, y1, x2, y2: LongInt): Array Of Integer;

  1. #1
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default Function GetDamageIn(x1, y1, x2, y2: LongInt): Array Of Integer;

    It searches for damage splashes in x1, y1, x2 ,y2.
    Make sure you got chat effects on off, in case someone starts typing in white.

    I let the debug in, so you can see what it does.

    I'll make one later that returns the position on every damage splash on the screen.

    SCAR Code:
    program New;

    Function NearbyPointInArray(P: TPoint; Dist:Integer; a: TPointArray): Boolean;

    Var
       I: Integer;

    Begin
      For I := 0 To GetArrayLength(a) - 1 Do
        If (Abs(P.x - a[i].x) <= Dist) And (Abs(P.y - a[i].y) <= Dist) Then
        Begin
          Result := True;
          Exit;
        End;
    End;

    Function RearrangeAndShortenArray(a: TPointArray): TPointArray;

    Var
       I: Integer;

    Begin
      For I := 0 To GetArrayLength(a) - 1 Do
        If Not NearbyPointInArray(a[I], 14, Result) Then
        Begin
          SetArrayLength(Result, GetArrayLength(Result) + 1);
          Result[GetArrayLength(Result) - 1] := a[I];
        End;
    End;

    Function GetDamage(x, y: integer): String;

    Begin
      Result := GetTextAtEx(x, y, 0, StatChars, False, False, 0,
        3, 16777215, 2, False, tr_Digits);
    End;

    Function GetDamageIn(x1, y1, x2, y2: LongInt): Array Of Integer;

    Var
       Width, Height, ClientBMP, I, TempH: LongInt;
       Points, YATPA: TPointArray;

    Begin
      TempH := GetClientWindowHandle;

      DisplayDebugImgWindow(Width, Height);
      GetClientDimensions(Width, Height);
      ClientBMP := BitmapFromString(Width, Height, '');
      CopyClientToBitmap(ClientBMP, 0, 0, Width, Height);
      SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
      DisplayDebugImgWindow(Width, Height);
      SetTargetBitmap(ClientBMP);
      FindColorsTolerance(YATPA, 16777215, x1, y1, x2, y2, 0);
      Points := ReArrangeAndShortenArray(YATPA);
      SetArrayLength(Result, GetArrayLength(Points));
      For I := 0 To GetArrayLength(Points) - 1 Do
      Begin
        Points[I].X := Points[I].X - 5;
        Points[I].Y := Points[I].Y - 2;
        FindColor(Points[I].X, Points[I].Y, 16777215, Points[I].X, Points[I].Y,
        Points[I].X + 8, Points[I].Y + 5);
        Points[I].X := Points[I].X - 3;
        Points[I].Y := Points[I].Y - 1;
        Try
          Result[I] := StrToInt(Trim(GetDamage(Points[I].X, Points[I].Y)));
        Except Result[I] := -1 End;
        WriteLn(IntToStr(Result[I]));
        FastSetPixel(ClientBMP, Points[I].X, Points[I].Y, 65280);
      End;
      SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
      DisplayDebugImgWindow(Width, Height);
      FreeBitmap(ClientBMP);
      SetClientWindowHandle(TempH);
    End;

    Var
       I1, I2: Integer;
    begin
      i1 := getsystemtime;
        GetDamageIn(MSX1, MSY1, MSX2, MSY2);
      i2 := getsystemtime;
      writeln('time '+inttostr(i2-i1));
    end.

    ~ Wizzup?



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  2. #2
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    I'm in a perfect spot to test. I'll edit my post after I'm done testing

    EDIT: It works perfectly, great job! BUT it sometimes writes -1 into the debug box.

  3. #3
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    Nice! This could come handy in Fighters; to see if you/mosters are in fight .
    Hup Holland Hup!

  4. #4
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    I'll be using this, thanks Wizzup?
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  5. #5
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by bullzeye95 View Post
    I'm in a perfect spot to test. I'll edit my post after I'm done testing

    EDIT: It works perfectly, great job! BUT it sometimes writes -1 into the debug box.
    Thats when it finds the whitecolor on the MS while there is no Number.
    I'll make it filter those.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

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

    Default

    Gj!! I'll propably use that if I ever make an autofighter.

  7. #7
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    Gj!! I'll propably use that if I ever make an autofighter.
    I am making one.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  8. #8
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    public?


  9. #9
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by bobarkinator View Post
    public?
    Problaby, and I forgot to mention I am making it together with Lorax.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  10. #10
    Join Date
    Jun 2006
    Location
    Tennessee, USA
    Posts
    2,603
    Mentioned
    1 Post(s)
    Quoted
    46 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Problaby, and I forgot to mention I am making it together with Lorax.
    Awesome! It's gonna own!

  11. #11
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Yay new script from Wizzy and with Lorax!!! I can't wait. Will probably be perfect for training my guys.


  12. #12
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    i got
    //i edited the way it was written
    2
    88, 88
    88, 88
    15, 88
    88, 88
    88, -1
    88, 88
    -1, -1
    88, 88
    88, 88
    88, -1
    88, 88
    88, 88
    88, 88
    88, 88
    88, 88
    88, 88
    9, 88
    -1, 88
    88
    88
    88
    1
    88
    88
    time 25516
    i know what -1 is...but no one hit a 15 and whats the 88's? also, is there a way to make sure that its you or your opponent, and not someone else in the screen being attacked?
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


Thread Information

Users Browsing this Thread

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

Similar Threads

  1. ItemColors: Array of Array of Integer
    By n3ss3s in forum Research & Development Lounge
    Replies: 5
    Last Post: 10-30-2007, 06:04 PM
  2. 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
  •