Results 1 to 7 of 7

Thread: How do I check if there is a monster attacking me?

  1. #1
    Join Date
    Dec 2014
    Posts
    37
    Mentioned
    0 Post(s)
    Quoted
    25 Post(s)

    Default How do I check if there is a monster attacking me?

    I'm trying to make a script for a RSPS and the only problem I'm having is.

    Sometimes whenever you're skilling, you will be attacked by a monster and it will kill you.

    How do I check if a monster is attacking me on a private server?

  2. #2
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    DTMs or bitmaps would be your best bet.

    You could search for the hitsplats or your health bar above your head.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  3. #3
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Look for the healthbar above your head, function I used:
    Simba Code:
    function healthBar(b:tbox):boolean;
    var
      red, green, bar:tpointarray;
      healthbar:t2dpointarray;
      i:integer;
      bx:tbox;
    begin
      if ((mainscreen.bounds.x1 + (b.x1 - 2)) < 0) then
        exit(false);
      findColors(green, 65280, b.x1 - 2, b.y1-7, b.x2, b.y2);
      findColors(red, 255, b.x1 - 2, b.y1 - 7, b.x2, b.y2);
      bar := mergeAtpa([green, red]);
      if (length(bar) > 0) then
      begin
        healthbar := clustertpa(bar, 1);
        if (length(healthbar) = 0) then
          exit(false);
        for i := 0 to high(healthbar) do
        begin
          bx := gettpabounds(healthbar[i]);
          if ((bx.x1 - bx.x1) > 25) then
            exit(true);
        end;
      end;
    end;

  4. #4
    Join Date
    Dec 2014
    Posts
    37
    Mentioned
    0 Post(s)
    Quoted
    25 Post(s)

    Default

    Quote Originally Posted by Robert View Post
    Look for the healthbar above your head, function I used:
    Simba Code:
    function healthBar(b:tbox):boolean;
    var
      red, green, bar:tpointarray;
      healthbar:t2dpointarray;
      i:integer;
      bx:tbox;
    begin
      if ((mainscreen.bounds.x1 + (b.x1 - 2)) < 0) then
        exit(false);
      findColors(green, 65280, b.x1 - 2, b.y1-7, b.x2, b.y2);
      findColors(red, 255, b.x1 - 2, b.y1 - 7, b.x2, b.y2);
      bar := mergeAtpa([green, red]);
      if (length(bar) > 0) then
      begin
        healthbar := clustertpa(bar, 1);
        if (length(healthbar) = 0) then
          exit(false);
        for i := 0 to high(healthbar) do
        begin
          bx := gettpabounds(healthbar[i]);
          if ((bx.x1 - bx.x1) > 25) then
            exit(true);
        end;
      end;
    end;
    I understand %0 of that code.

    I don't get how it works or how to implement it.

  5. #5
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Owinger View Post
    I understand %0 of that code.

    I don't get how it works or how to implement it.
    pass a box as a argument to looking for the healthbar

  6. #6
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Robert View Post
    pass a box as a argument to looking for the healthbar
    Code is flawed.

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

    Default

    Quote Originally Posted by Robert View Post
    Simba Code:
    if ((bx.x1 - bx.x1) > 25) then

    if (5-5 > 25) then

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
  •