Results 1 to 10 of 10

Thread: Looting items

  1. #1
    Join Date
    Jun 2016
    Posts
    23
    Mentioned
    3 Post(s)
    Quoted
    15 Post(s)

    Default Looting items

    Hello, I'm trying to make a simple script that kills dragons and picks dragon bones and visages. I dont know how to make the script loot after the monster is dead. I have tried finding tpa or color tolerance, but whenever its in "NotFighting" state and it starts to look for white color on Main Screen (d bones color) it gets stuck because of white eggs next to the dragons, or if you are wearing any similar color it will just right click mouse on you. I cant use uptext because every time it drops there is different uptext (like iron battleaxe or any other useless item). Also I wanted to ask if i get it fixed and it starts picking the bones, how do i make to select "draconic visage" first, because if it select dragon bones first it wont look anymore for drops. Any ideas?

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

    Default

    Find everything that isn't the drop.



    This code isn't functional out of the box but it what I used to pick up bones

    Simba Code:
    function getOptionsString():TStringArray;
    var
      t:array of Toptions;
      i:integer;
    begin
      t := getOptions();
      setLength(result, length(t));
      for i := 0 to high(t) do
        result[i] := t[i].str;
    end;

    function validDropMenu():boolean;
    var
      i:integer;
      t:TStringArray;
    begin
      t := getOptionsString();
      for i := 0 to high(t) do
        if lowercase(t[i]).contains('take dragon bones') then
          exit(true);
    end;

    function getDropCount():integer;
    var
      i, k:integer;
      t:tStringArray;
    begin
      t := getOptionsString();
      for i := 0 to high(lootItems) do
        for k := 0 to high(t) do
          if lowercase(t[k]).contains(lowercase('Take ' + lootItems[i])) then
            result := result + 1;
    end;

    procedure pickUpItems();
    var
      redDotsTPA, groundTPA, objectsTPA:TPointArray;
      redDotsATPA, groundATPA, objectsATPA:T2DPointArray;
      itemsOnGround:TStringArray;
      nearestDirection, nearestDrop, me:TPoint;
      i, dx, dy, dropCount:integer;
    begin
      me := Point(630, 132);
      findColorsTolerance(redDotsTPA, 1776620, 630 - 30, 132 - 30, 630 + 30, 132 + 30, 43);
      redDotsATPA := clusterTPA(redDotsTPA, 1);
      filterTPAsBetween(redDotsATPA, 25, 200);
      sortATPAFrom(redDotsATPA, Point(630, 132));
      if (length(redDotsATPA) > 0) then
      begin
        nearestDrop := redDotsATPA[0].getBounds().getMiddle();
        findColorsTolerance(groundTPA, 2312279, intToBox(7, 49, 517, 383), 6, colorSetting(2, 0.18, 1.06));
        groundATPA := clusterTPA(groundTPA, 3);
        filterTPAsbetween(groundATPA, 0, 700);
        objectsTPA := returnPointsNotInTPA(mergeATPA(groundATPA), intToBox(7, 49, 517, 383));
        objectsATPA := clusterTPA(objectsTPA, 2);
        filterTPAsbetween(objectsATPA, 400, 50000);
        dx := me.x - nearestDrop.x;
        dy := me.y - nearestDrop.y;
        if abs(dx) > abs(dy) then
        begin
          if (dx < 0) then
            nearestDirection := Point(me.x + 15,me.y)
          else nearestDirection := Point(me.x - 15,me.y);
        end else
        if abs(dx) < abs(dy) then
        begin
          if (dy < 0) then
            nearestDirection := Point(me.x ,me.y + 15)
          else
            nearestDirection := Point(me.x ,me.y - 15)
        end else
          nearestDirection := me;
        sortATPAFromFirstPoint(objectsATPA, nearestDirection);
        for i := 0 to high(objectsATPA) do
        begin
          mouse(objectsATPA[i].getBounds().getMiddle(), 0);
          wait(250);
          if (validDropMenu()) then
          begin
            dropCount := getDropCount();
            if waitOptionMulti(lootItems, 1000) then
            begin
              dropCount := dropCount - 1;
              state('Drop count:' + toStr(dropCount));
              for i := 0 to dropCount do
              begin
                mouse(Point(265, 230), 0);
                if waitOptionMulti(lootItems, 1000) then
                  wait(750);
              end;
            end;
            exit();
          end else
          begin
            moveMouse(0, 0);
            wait(150);
          end;
        end;
      end;
    end;


    Finds red dots on minimap, gets the closest one. With the closest one it uses minimap to mainscreen to convert that to a point on screen. We will call this point 'Likely Drop'. Next, it finds the floor and wall colors. Combines them and returns anything that isn't inside them (such as your player, bones, fungus, dragon, walls on the side there). Next it deletes anything that is too small or too large. So the next potential objects is your player, the fungus, and the drop. The script will then arrange the objects in the order in which is closests to the Point "likely drop". It scrolls over each object, starting with the object closest to the 'likely drop' point because it's most likely going to be the drop. Then if it finds the option 'take dragon bones' that means it's the new drop. It will look at the options and see how many things it needs to pick up. If there are only d bones, it will pick them up. If there are more items, it will pick up the first item and then start checking at the players feet



    I can leave you my steel dragon killer & banker ON ONE CONDITION: I will not help you fix anything wrong with it. I wrote it a month ago and it wasn't functional persay. It walked to a specific spot, killed a steel dragon, had the potential to bank. But it had issues eating potions and I never added a system to move spots if another player crashes you. 90% of the script it written but it has kinks and isn't feasible to run. I stopped working on it because there are more afk methods that are easier to bot with less chance of being banned.



    Simba Code:
    {$I srl-6/srl.simba}

    const

      USERNAME = '';
      CLIENTNAME = 'Runique';
      CLIENTWIDTH = 765;
      CLIENTHEIGHT = 525;
      EAT_AT = 650;
      DRINK_PRAYER_AT = 450;
      lootItems = ['Dragon bones', 'Draconic visage',
      'Dragon platelegs', 'Dragon plateskirt', 'Runique chest key'];


      antiFireSTRING = 'mQwAAAHicY2ZgYDjMxMCwF4hPAnE6IwNDFBDHAHGZ8AygLCMUIwAjqigA6U8EmQ==';
      prayerSTRING = 'mQwAAAHicY2ZgYHBlYmDwAmJ7IHZmZGAwA2JzIHa/vAgoywjFCMCIKgoAlPADTA==';
      attackSTRING = 'mQwAAAHicY2ZgYDjCxMCwF4hPAHE3IwNDPRTbO10CyjJCMQIwoooCAAQ5BTc=';
      strengthSTRING = 'mQwAAAHicY2ZgYHBlYmDwBmJ7IF7PyMCwBIgXA/GFc+eAsoxgzMqAAIxIGAgA7AkFSA==';
      sharkSTRING = 'mWAAAAHicY2FgYChgYmDIB+IkIK4CYnNGBgZtILYEYjMgnteUDVTFCMesQBIZM6JhEAAAEHUEQw==';
      vialSTRING = 'mWAAAAHicY2FgYDjMxMBwAoj3AvEhIBZnZGAQgmI5IE5LzwSqYgTjmpoaBlYgCxkzomEQAACBAgY4';

    type

      TLOCATION = (SWBANK, NEWSPOT, DUNGEON, LOST);

      TDIRECTION = (NORTH, EAST, SOUTH, WEST);

      fnct_actionOptions = (ClickRight, ClickLeft, ClickMiddle, Move, Nothing);

      TOptions = record
        Str: string;
        Bounds, BigBox: TBox;
      end;

      TPOTIONTIMER = record
        potionDTM, lastSip, interval:integer;
        name:string;
      end;

      TRSInventory =  record
        bounds:tbox;
        slots:TBoxArray;
      end;

    var
      antiFireDTM, prayerDTM, attackDTM, strengthDTM:integer;
      sharkDTM, vialDTM, lastPotion:integer;
      rsClient:TSysProc;
      inventory:TRSInventory;

    function boxCenter(bx: TBox): TPoint; begin if ((bx.X1 > bx.X2) or (bx.Y1 > bx.Y2)) then begin if(bx.X1 > bx.X2) then Swap(bx.X1, bx.X2); if (bx.Y1 > bx.Y2) then Swap(bx.Y1, bx.Y2); end; Result := Point(Round(bx.X1 + ((bx.X2 - bx.X1) div 2)), Round(bx.Y1 + ((bx.Y2 - bx.Y1) div 2))); end;

    function explodeBox(bx: TBox; rows, columns: integer): TBoxArray; var r, c, w, h, ew, eh, ow, oh, i, x, y: integer; begin if ((rows > 0) and (columns > 0) and(bx.X1 <= bx.X2) and (bx.Y1 <= bx.Y2)) then begin w := ((bx.X2 - bx.X1) + 1); h := ((bx.Y2 - bx.Y1) + 1); if (rows < 1) then rows := 1 else if (rows > h) then rows := h; if (columns < 1) then columns := 1 else if (columns > w) then columns := w; w := (w div columns); h := (h div rows); ew := (((bx.X2 - bx.X1) + 1) - (w * columns)); eh := (((bx.Y2 - bx.Y1) + 1) - (h * rows)); SetLength(result, (rows * columns)); y :=bx.Y1;for r := 0 to (rows - 1) do begin x := bx.X1; if ((eh > 0) and (r < eh)) then oh := 1 else oh := 0; for c := 0 to (columns - 1) do begin if ((ew > 0) and (c < ew)) then ow := 1 else ow := 0; i := ((r * columns) + c); result[i].X1 := x; result[i].X2 := (x + (w - 1) + ow); result[i].Y1 := y; result[i].Y2 := (y + (h - 1) + oh); x := (Result[i].X2 + 1); end;y := (result[i].Y2 + 1); end; end else SetLength(result, 0); end;

    function isText(Text, theText: TStringArray): Boolean;
    var
      i, k: Integer;
    begin
      for i := 0 to High(Text) do
        for k := 0 to high(theText) do
          if (Pos(Text[i], TheText[k]) > 0) then
            exit(true);
    end;

    procedure clickMouse2(button:integer);
    begin
      holdMouse(0, 0, button);
      wait(50);
      releaseMouse(0, 0, button);
      wait(10);
    end;

    procedure Mouse(T:TPoint)override;
    begin
      moveMouse(T);
      wait(100);
      clickMouse2(1);
    end;

    function getOptions(): Array of TOptions;
    var
       B, BB: TBox;
       TPA, restpa, blacktpa, newtpa, merged: TPointArray;
       ATPA, tempatpa, blackatpa, newatpa: T2DPointArray;
       I, L, target, bmp, w, h: Integer;
       BoxColors: TIntegerArray;
    begin
      target := GetImageTarget;
      GetClientDimensions(B.X2, B.Y2);
      B := IntToBox(0, 0, B.X2-1, B.Y2-1);
      BoxColors := [4674653];
      SetLength(ATPA, Length(BoxColors));
      FindColors(tpa, 4674653, b);
      If Length(tpa) < 100 Then
        exit;
      atpa := clusterTpa(tpa, 3);
      for i := 0 to High(ATPA) do
      begin
        B := GetTPABounds(ATPA[i]);
        if ((B.x2-B.x1) > 95) and ((B.y2-B.y1) > 18) then
          Break
        else
          B := IntToBox(0, 0, 0, 0);
      end;
      If (B.x2 = 0) then
        exit;
      findcolors(blacktpa, 0, b);
      if (length(blacktpa) < 1) then
        exit;
      blackatpa := clustertpa(blacktpa, 1);
      for i := 0 to high(blackatpa) do
      begin
        b := gettpaBounds(blackatpa[i]);
         if ((B.x2-B.x1) > 95) and ((B.y2-B.y1) > 16) then
           break
        else
          b := inttobox(0, 0, 0, 0);
      end;
      findcolors(newtpa, 4674653, b);
      if (length(newtpa) < 0) then
        exit;
      newatpa := clustertpa(newtpa, 1);
      b := gettpaBounds(newatpa[0]);
      findcolors(blacktpa, 0, b);
      merged := mergeAtpa([blacktpa, newtpa]);
      ReturnPointsNotInTPAWrap(merged, b, resTPA);
      bmp := CreateBitmap(b.X2-B.X1+2, b.Y2-b.Y1+2);
      OffsetTPA(restpa, Point(-B.X1, -B.Y1));
      FastDrawClear(bmp, 0);
      DrawTPABitmap(bmp, restpa, clRed);//Text
      GetbitmapSize(bmp, w, h);
      settargetbitmap(bmp);
      SetLength(newatpa, H div 16);
      for i := 0 to High(newatpa) do
        FindColorsTolerance(newatpa[i], 255, 0, 2+i*15,  W-1, 15+i*15, 0);
      L := High(newatpa);
      SortATPAFromFirstPointY(newatpa, Point(w div 2,0));
      SetArrayLength(Result, Length(newatpa));
      Result[0].BigBox := b;
      for i := 0 to high(newatpa) do
      begin
        TPA := newatpa[i];
        tempatpa := SplitTPAEx(TPA, 1, 10);
        SortATPAFromFirstPointX(tempatpa, Point(0, 0));
        Result[i].Str := GetTextATPA(tempatpa, 4, 'UpChars07'); //Writeln(Result[i].Str);
        BB := GetTPABounds(newatpa[i]);
        Result[i].Bounds := IntToBox(BB.X1+B.X1, BB.Y1+B.Y1, BB.X2+B.X1, BB.Y2+B.Y1);
        setlength(tempatpa,0);
        setlength(TPA,0);
      end;
      SetImageTarget(target);
      FreeBitmap(bmp);
    end;

    function ArrInStr(arrS: TStringArray; str: string): Boolean;
    var
      I, L, H: Integer;
    begin
      Result := True;
      L := Low(arrS);    H := High(arrS);
      for I := L to H do
        if Pos(arrS[I], Str) > 0 then
          Exit;
      Result := False;
    end;

    function chooseOptionMulti(Texts: TStringArray; TextType: String; Action: fnct_ActionOptions): Boolean;
    var
       B: TBox;
       i, H, x, R: Integer;
       T: TPoint;
       Options: array of TOptions;
    begin
      Result := False;
      Options := getOptions();
      if (Length(Options) < 1) then
        Exit;
      H := High(Options);
      for i := 0 To H do
      begin
        if ArrInStr(Texts, Options[i].Str) then
        begin
          Result := True;
          B := Options[i].Bounds;
          GetMousePos(T.x, T.y);

          R:= Min(((B.X2 - B.X1) shr 1), 5);
          case Action of
            ClickLeft:
              if PointInBox(T, B) then
                ClickMouse2(mouse_left)
              else
                Mouse(intToBox(B.x1 + R, B.Y1, B.x2 - R, B.Y1 + 5).getMiddle(), mouse_Left);

            Move:
              if not PointInBox(T, B) then
                Mouse(intToBox(B.x1 + R, B.Y1, B.x2 - R, B.Y1 + 5).getMiddle(), mouse_move);

            Nothing:
              begin
              end;

            else
              writeLn('ChooseOptionMultiEx ', ' ClickRight not a valid click for RS menus!');
          end;
          Exit;
        end;
      end;
      B := Options[0].BigBox;
      if Action <> Nothing then
      begin
        x := Max(B.X1 - 52, 0);
        if x = 0 then
          x := B.X2+10;
        MoveMouse(0, 0);
        Wait(200 + Random(100));
      end;
    end;

    function chooseOptionMulti(Txt: TStringArray): Boolean; overload;
    begin
      Result := chooseOptionMulti(Txt, 'All', ClickLeft);
    end;

    function chooseOption2(Txt, TextType: string): Boolean;
    begin
      Result := chooseOptionMulti([Txt], TextType, ClickLeft);
    end;

    function chooseOption2(Txt: String): Boolean; overload;
    begin
      Result := chooseOptionMulti([Txt], 'All', ClickLeft);
    end;

    function waitOptionMulti(S: TStringArray; TextType: string; Action: fnct_ActionOptions; Time: Integer): Boolean;
    var
      T: Integer;
    begin
      Result := False;
      T := GetSystemTime + Time;
      while (GetSystemTime < T) do
      begin
        if (chooseOptionMulti(S, TextType, Action)) then
          exit(true);
        Wait(20 + Random(10));
      end;
    end;

    function waitOptionMulti(S: TStringArray; Time: Integer): Boolean; overload;
    begin
      Result := waitOptionMulti(S, 'all', ClickLeft, Time);
    end;

    function waitOption(S: string; Time: Integer): Boolean; overload;
    begin
      Result := waitOptionMulti([s], 'all', ClickLeft, Time);
    end;

    procedure markTime(var t:Integer);
    begin
      t := getSystemTime;
    end;

    function timeFromMark(i:Integer):Integer;
    begin
      result := i - getSystemTime;
    end;

    procedure DebugBitmap2(Bmp: Integer);
    var
      W, H: Integer;
    begin
      try
        GetBitmapSize(Bmp, W, H);
        DisplayDebugImgWindow(W, H);
        DrawBitmapDebugImg(Bmp);
      except
        writeLn('DebugBitmap Error in DebugBitmap');
      end;
    end;

    (*
      Auther: Wizzup?
      Description: Shows an image of the Debug screen, plotting colors over the points
      stored in Points TPA. If a name is specified, an image will be saved to that path..
    *)


    function DebugTPA2(Points: TPointArray; BmpName: string): Boolean;
    var
      Bmp: integer;
      Box : TBox;
      TempTPA : TPointArray;
    begin
      Box := GetTPABounds(Points);
      Bmp := BitmapFromClient(Box.x1,Box.y1,Box.x2,Box.y2);
      TempTPA := CopyTPA(Points);
      OffsetTPA(TempTPA,Point(-box.x1,-box.y1));
      DrawTPABitmap(Bmp,TempTPA,clRed);
      DisplayDebugImgWindow(box.x2-Box.x1 + 1, box.y2-box.y1 + 1);
      DrawBitmapDebugImg(Bmp);
      if bmpname <> '' then
        SaveBitmap(Bmp, ScriptPath + BmpName + '.bmp');
      FreeBitmap(Bmp);
      Result := True;
    end;

    (*
      Auther: Wizzup?
      Description: Shows an image of the client, plotting each TPA of the 2D point
      array aPoints. Each TPA is a different color. If a name is specified, an image
      will be saved.
    *)


    function DebugATPA2(aPoints: T2DPointArray; BmpName: string): Boolean;
    var
       Width, Height, ClientBMP: Integer;
       ATPA : T2DPointArray;Box : TBox;
    begin
      result := false;
      if length(aPoints) = 0 then
        exit;
      Box := GetATPABounds(aPoints);
      Width := box.x2 - box.x1 + 1;
      Height := box.y2 - box.y1 + 1;
      DisplayDebugImgWindow(Width, Height);
      ClientBMP := BitmapFromClient(box.x1,box.y1,box.x2,box.y2);
      ATPA := CopyATPA(aPoints);
      OffsetATPA(ATPA,point(-box.x1,-box.y1));
      DrawATPABitmap(ClientBMP,ATPA);
      DrawBitmapDebugImg(ClientBMP);
      if BmpName <> '' then
        SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
      FreeBitmap(ClientBMP);
      Result := True;
    end;

    (*
      Auther: Wizzup?, lordsaturn, & caused
      Description: Shows an image of the client, plotting each TPA's bounds as a box
      of different colour per TPA. If a name is specified, an image will be saved.
    *)


    procedure DebugATPABounds2(aPoints: array Of TPointArray);
    var
      Width, Height, ClientBMP, I: Integer;
      B, Box: TBox;
      BoxColors : TIntegerArray;
      SelColor: Integer;
      x,y : integer;
      BMP : Integer;
    begin
      Box := GetATPABounds(aPoints);
      Width := Box.X2 + 5;
      Height := Box.Y2 + 5;
      DisplayDebugImgWindow(Width, Height);
      BoxColors := [clRed, clBlue, clBlack, clGreen, clYellow];
      ClientBMP := BitmapFromClient(0,0,width-1,height-1);
      for i:= 0 to high(aPoints) do
      begin
        SelColor := BoxColors[Random(length(Boxcolors))];

        B := getTPABounds(aPoints[i]);
        for x := B.x1 to B.x2 do
        begin
          FastSetPixel(ClientBMP, x, b.y1, selColor);
          FastSetPixel(ClientBMP, x, B.y2, selColor);
        end;
        for y := B.y1 to B.y2 do
        begin
          FastSetPixel(ClientBMP, B.x1, y, selColor);
          FastSetPixel(ClientBMP, B.x2, y, selColor);
        end;

        BMP := BitmapFromText(inttostr(i),StatChars);
        FastReplaceColor(bmp,clblack,clyellow);
        FastReplaceColor(bmp,clwhite,clblack);
        SetTransparentColor(bmp,clYellow);
        FastDrawTransparent(B.x1 + 2, b.y1 + 2, bmp,clientbmp);
        FreeBitmap(BMP);
      end;
      DrawBitmapDebugImg(clientBMP);
      FreeBitmap(ClientBmp);
    end;

    procedure state(s:string);
    begin
      clearDebug();
      writeln('=======================================');
      writeln('Dragons killed: 0| Per hour: 0');
      writeln('XP Gained: 0| Per hour: 0');
      writeln('State:', s);
      writeln('=======================================');
    end;

    procedure initInv();
    begin
      inventory.slots := explodeBox(inventory.bounds, 7, 4);
    end;

    function TRSInventory.getSlot(slot:integer):Tbox;
    begin
      result := self.slots[slot];
    end;

    function TRSInventory.slotFull(s:Integer):Boolean;
    var
      xee, yee:integer;
    begin
      result := FindColor(xee, yee, 65536, self.slots[s]);
    end;

    function TRSInventory.count:Integer;
    var
      i:Integer;
    begin
      for i := 0 to high(self.slots) do
        if self.slotFull(i) then
          result := result + 1;
    end;

    function TRSInventory.full:Boolean;
    begin
      result := false;
      exit(self.count = 28);
    end;

    function getSimpleText(Colors:TIntegerArray;x1, y1, x2, y2:integer;font:string):String;
    var
      textTPA:TPointArray;
      textATPA, textATPAS:T2DPointArray;
      i:integer;
      textStr:string;
    begin
      setLength(textATPAS, length(colors));
      for i := 0 to high(colors) do
        findColors(textATPAS[i], Colors[i], x1, y1, x2, y2);
      textTPA := mergeATPA(textATPAS);
      textATPA := SplitTPAEx(textTPA, 1, 10);
      filtertpasbetween(textatpa, 0, 1);
      SortATPAFromFirstPointX(textATPA, Point(0, 0));
      result := getTextATPA(textATPA, 3, font);
    end;

    function getFightingMonster():string;
    begin
      result := getSimpleText([16777215], 33, 78, 142, 103, 'UpChars07');
    end;

    function inCombat(monster:string):boolean;
    begin
      result := getFightingMonster() = monster;
    end;

    function inCombat():boolean;overload;
    begin
      result := inCombat('Steel dragon');
    end;

    function getHealth():integer;
    begin;
      try
        result := strToInt(getSimpleText([65280, 65535, 501500, 855541], 724, 72, 750, 90, 'statchars07'));
      except
        result := 0;
      end;
    end;

    function getPrayer():integer;
    begin;
      try
        result := strToInt(getSimpleText([65280, 65535, 501500, 855541], 739, 112, 764, 130, 'statchars07'));
      except
        result := 0;
      end;
    end;

    function getXpBarTPA():TPointArray;
    begin
      findColors(result, 16777215, 424, 101, 519, 118);
    end;

    function getXpBarText():string;
    var
      textTPA:TPointArray;
      textATPA:T2DPointArray;
    begin
      textTPA := getXpBarTPA();
      textATPA := splittpaex(textTPA, 1, 10);
      filtertpasbetween(textatpa, 0, 1);
      SortATPAFromFirstPointX(textATPA, Point(0, 0));
      result := getTextATPA(textatpa, 3, 'smallchars07');
    end;

    function xpBarOpen():boolean;
    begin
      result := getXPBarText().contains('XP:');
    end;

    function getXpBarTotal():integer;
    var
      BARstring:string;
    begin
      BARstring := getXpBarText();
      BARstring := replace(BARstring, '''', '', [rfReplaceAll]);
      BARstring := replace(BARstring, 'XP:', '', [rfReplaceAll]);
      BARstring := replace(BARstring, ' ', '', [rfReplaceAll]);
      result := strtoInt(barString);
    end;

    function getLocation():TLOCATION;
    begin
      if (not isLoggedIn()) then
        exit
      else if (countColorTolerance(2678011, intToBox(550, 51, 717, 214), 1, colorSetting(2, 0.00, 0.00)) > 200) then
        result := SWBANK
      else if (countColorTolerance(0, intToBox(550, 51, 717, 214), 1, colorSetting(2, 0.00, 0.00)) > 500) and
        (countColorTolerance(2840425, intToBox(550, 51, 717, 214), 4, colorSetting(2, 0.24, 1.42)) > 600) then
          result := DUNGEON
      else
        result := LOST;
    end;

    procedure withdrawItems();
    begin
      wait(50);
      mouse(Point(189, 146), 1);
      wait(500);
      mouse(Point(232, 146), 1);
      wait(500);
      mouse(Point(277, 146), 1);
      wait(500);
      mouse(Point(321, 146), 1);
      wait(150);
      mouse(Point(321, 146), 1);
      wait(500);
      mouse(Point(366, 146), 1);
      wait(150);
      mouse(Point(366, 146), 1);
      wait(500);
    end;

    function bankOpen():boolean;
    begin
      result := getSimpleText([2070783], 180, 65, 312, 84, 'UpChars07') = 'The Bank of Runique';
    end;

    procedure bankAll();
    begin
      if bankOpen() then
        mouse(Point(356, 348), 1);
    end;

    procedure closeBank();
    begin
      if bankOpen() then
        mouse(Point(491, 75), 1);
    end;

    function findBank():boolean;
    var
      brownTPA, silverTPA:TPointArray;
      brownATPA, silverATPA:T2DPointArray;
      P:TPoint;
      i:integer;
    begin
      if findColorstolerancE(brownTPA, 6057341, intToBox(4, 47, 520, 384), 16, colorSetting(2, 0.05, 0.70)) then
      begin
        brownATPA := clusterTPA(brownTPA, 10);
        filterTPAsbetween(brownATPA, 0, 500);
        for i := 0 to high(brownATPA) do
          if findColorsTolerance(silverTPA, 11250613, brownATPA[i].getBounds(), 14, colorSetting(2, 0.15, 0.11)) then
          begin
            silverATPA := clusterTPA(silverTPA, 10);
            for i := 0 to high(silverATPA) do
            begin
              p := silverATPA[i].getBounds().getMiddle();
              mouse(p, 0);
              if waitOption('Use', 1000) then
                if waitFunc(@bankOpen, 40, 4000) then
                  exit(true)
              else
              begin
                mouse(Point(0, 0), 0);
                wait(100);
              end;
            end;
            //debugATPABounds2(silverATPA);
          end;
      end;

    end;

    function teleportTo(place:TLOCATION):boolean;
    var
      t:integer;
    begin
      wait(50);
      mouse(Point(504, 512));

      wait(500);
      case place of
        SWBANK : sendKeys('MS', 75, 75);
        DUNGEON: sendKeys('DB', 75, 75);
      end;

      markTime(t);
      repeat
        wait(100)
      until (getLocation() = place) or timeFromMark(t) > 3500;
      wait(1700);
    end;

    procedure makeCompassHigh;
    begin
      keyDown(vk_up);
      wait(2000);
      keyUp(vk_up);
    end;

    function tileToCoords(Location, Tile:TPoint):TPoint;
    begin
      if (Tile.x - Location.x > 17) or (Location.y - Tile.y > 17) then
      begin
        Result := Point(-1, -1);
        exit;
      end;
      result.x := ((Tile.x - Location.x) * 4) + 630;
      result.y := ((Location.y - Tile.y) * 4) + 132;
    end;

    function getTile():TPoint;
    var
      s:string;
    begin
      sendKeys('::mypos', 30, 300);
      pressKey(vk_enter);
      wait(700);
      s := getSimpleText([0], 13, 491, 105, 506, 'smallchars07');
      if s.contains('[') then
      begin
        try
          result.x := strToInt(between('[', '''', s));
          result.y := strtoInt(between(''' ','''',s));
        except
          result := Point(-1, -1);
        end;
      end;
      state('Tile has been read at ' + toStr(result));
    end;

    function walkTile(p:TPoint):boolean;
    var
      T:TPoint;
    begin
      T := tileToCoords(getTile(), p);
      if (T.X <> -1) then
      begin
        mouse(T, 1);
        wait(3000);
        result := true;
      end;
    end;

    function seeDragon(var p:TPoint):boolean;
    var
      dragonTPA:TPointArray;
      dragonATPA:T2DPointArray;
      i:integer;
    begin
      findColorstolerance(dragonTPA, 8620443, intToBox(7, 49, 517, 383), 14, colorSetting(2, 0.32, 0.53));
      dragonATPA := clusterTPA(dragonTPA, 8);
      filterTPAsbetween(dragonATPA, 0, 350);
      sortATPAFrom(dragonATPA, Point(336, 309));
      for i := 0 to high(dragonATPA) do
        if ((dragonATPA[i].getBounds().getWidth() > 90) and (dragonATPA[i].getBounds().getHeight() > 90)) then
        begin
          p := dragonATPA[i].getBounds().getMiddle();
          result := true;
        end;
    end;

    function seeDragon():boolean; overload;
    var
      p:TPoint;
    begin
      result := seeDragon(p);
    end;

    procedure walkToSpot;
    begin
      walkTile(Point(2704, 9459));
      waitFunc(@seeDragon, 40, 4000);
    end;

    function findDragon():boolean;
    var
      T:TPoint;
    begin
      if seeDragon(T) then
      begin
        result := true;
        mouse(t);
      end;
    end;

    function string.contains(s: string): Boolean;
    begin
      if ((self <> '') and (s <> '')) then
        result := (pos(s, self) > 0)
      else
        result := False;
    end;

    function getOptionsString():TStringArray;
    var
      t:array of Toptions;
      i:integer;
    begin
      t := getOptions();
      setLength(result, length(t));
      for i := 0 to high(t) do
        result[i] := t[i].str;
    end;

    function validDropMenu():boolean;
    var
      i:integer;
      t:TStringArray;
    begin
      t := getOptionsString();
      for i := 0 to high(t) do
        if lowercase(t[i]).contains('take dragon bones') then
          exit(true);
    end;

    function getDropCount():integer;
    var
      i, k:integer;
      t:tStringArray;
    begin
      t := getOptionsString();
      for i := 0 to high(lootItems) do
        for k := 0 to high(t) do
          if lowercase(t[k]).contains(lowercase('Take ' + lootItems[i])) then
            result := result + 1;
    end;

    procedure pickUpItems();
    var
      redDotsTPA, groundTPA, objectsTPA:TPointArray;
      redDotsATPA, groundATPA, objectsATPA:T2DPointArray;
      itemsOnGround:TStringArray;
      nearestDirection, nearestDrop, me:TPoint;
      i, dx, dy, dropCount:integer;
    begin
      me := Point(630, 132);
      findColorsTolerance(redDotsTPA, 1776620, 630 - 30, 132 - 30, 630 + 30, 132 + 30, 43);
      redDotsATPA := clusterTPA(redDotsTPA, 1);
      filterTPAsBetween(redDotsATPA, 25, 200);
      sortATPAFrom(redDotsATPA, Point(630, 132));
      if (length(redDotsATPA) > 0) then
      begin
        nearestDrop := redDotsATPA[0].getBounds().getMiddle();
        findColorsTolerance(groundTPA, 2312279, intToBox(7, 49, 517, 383), 6, colorSetting(2, 0.18, 1.06));
        groundATPA := clusterTPA(groundTPA, 3);
        filterTPAsbetween(groundATPA, 0, 700);
        objectsTPA := returnPointsNotInTPA(mergeATPA(groundATPA), intToBox(7, 49, 517, 383));
        objectsATPA := clusterTPA(objectsTPA, 2);
        filterTPAsbetween(objectsATPA, 400, 50000);
        dx := me.x - nearestDrop.x;
        dy := me.y - nearestDrop.y;
        if abs(dx) > abs(dy) then
        begin
          if (dx < 0) then
            nearestDirection := Point(me.x + 15,me.y)
          else nearestDirection := Point(me.x - 15,me.y);
        end else
        if abs(dx) < abs(dy) then
        begin
          if (dy < 0) then
            nearestDirection := Point(me.x ,me.y + 15)
          else
            nearestDirection := Point(me.x ,me.y - 15)
        end else
          nearestDirection := me;
        sortATPAFromFirstPoint(objectsATPA, nearestDirection);
        for i := 0 to high(objectsATPA) do
        begin
          mouse(objectsATPA[i].getBounds().getMiddle(), 0);
          wait(250);
          if (validDropMenu()) then
          begin
            dropCount := getDropCount();
            if waitOptionMulti(lootItems, 1000) then
            begin
              dropCount := dropCount - 1;
              state('Drop count:' + toStr(dropCount));
              for i := 0 to dropCount do
              begin
                mouse(Point(265, 230), 0);
                if waitOptionMulti(lootItems, 1000) then
                  wait(750);
              end;
            end;
            exit();
          end else
          begin
            moveMouse(0, 0);
            wait(150);
          end;
        end;
      end;
    end;

    function activateRsClient(firstTime:boolean):boolean;
    var
      processes: TSysProcArr;
      i: integer;
    begin
      result := false;
      processes := GetProcesses();
      if (firstTime) then
        writeln('Scanning for ' , CLIENTNAME , 'Client..');
      for i := 0 to high(processes) do
        if (processes[i].title.contains(CLIENTNAME)) and (processes[i].width = CLIENTWIDTH) and (processes[i].height = CLIENTHEIGHT) then
        begin
          if (firstTime) then
          begin
            writeln('Found client');
            writeln('Target set to: ' , toStr(processes[i]));
          end;
          rsClient := processes[i];
          setTarget(processes[i]);
          ActivateClient();
          exit(true);
        end;
    end;

    function getClientName():string;
    begin
      activateRsClient(false);
      result := rsClient.title;
    end;

    function isLoggedIn():boolean; override;
    begin
      if (USERNAME = '') then
      begin
        writeln('Please enter a username at the top of the script');
        terminateScript();
      end else
        result := getClientName().contains(USERNAME);
    end;

    function loginPlayer():boolean;
    begin
      writeln('logging in player');
    end;

    procedure TRSInventory.interactItem(const slot, Button:Integer);
    begin
      if (self.slotFull(slot)) then
        mouse(boxCenter(self.slots[slot]).x, boxCenter(self.slots[slot]).y, 0, 0, BUTTON);
    end;

    function TRSInventory.DTMExists(const DTM, slot:integer):boolean;
    var
      x, y:integer;
    begin
      result := findDTM(DTM, x, y, self.slots[slot].X1, self.slots[slot].y1, self.slots[slot].x2, self.slots[slot].y2);
    end;

    function TRSInventory.countDTM(const DTMSearch:Integer):Integer;
    var
      i:Integer;
    begin
      for i := 0 to high(self.slots) do
        if (self.DTMExists(dtmSearch, i)) then
          result := result + 1;
    end;

    function TRSInventory.countDTM(const DTMSearch:TIntegerArray):integer; overload;
    var
      i:integer;
    begin
      for i := 0 to high(DTMSearch) do
        result := result + self.countDTM(DTMsearch[i]);
    end;

    function TRSInventory.searchDTM(const DTMSearch:Integer;click, cont:Boolean;button:Integer):Boolean;
    var
      i:Integer;
    begin
      for i := 0 to high(self.slots) do
      begin
        if self.DTMExists(dtmSearch, i) then
        begin
          result := true;
          if click then
            self.interactItem(i, button);
          if not cont then
            exit;
        end;
      end;
    end;

    function TRSInventory.searchDTM(const DTMSearch:Integer;cont:Boolean;button:Integer):Boolean; overload;
    var
      I:Integer;
    begin
      result := false;
      for i := 0 to high(self.slots) do
      begin
      if self.DTMExists(dtmSearch, i) then
        begin
          result := true;
          self.interactItem(i, button);
          if not cont then
            exit;
        end;
      end;
    end;

    function TRSInventory.searchDTM(const DTMSearch:Integer;button:Integer):Boolean; overload;
    var
      I, x, y:Integer;
    begin
      result := false;
      for i := 0 to high(self.slots) do
      begin
        if self.DTMExists(dtmSearch, i) then
        begin
          self.interactItem(i, button);
          exit(true);
        end;
      end;
    end;

    function TRSInventory.searchDTM(const DTMSearch:TIntegerarray;button:Integer):boolean; overload;
    var
      i:integer;
    begin
      for i := 0 to high(DTMSearch) do
        if inventory.searchDTM(DTMSearch[i], true, false, 1) then
          exit(true);
    end;

    function inventoryReady():boolean;
    var
      i:integer;
      prayPotCount:integer;
    begin
      result := inventory.countDTM([antiFireDTM, prayerDTM, attackDTM, strengthDTM, sharkDTM, vialDTM]) = 7;
    end;

    function needEatOrPray():boolean;
    begin
      if (getHealth < EAT_AT) or (getPrayer < DRINK_PRAYER_AT) then
        result := true;
    end;

    function checkHealthPray():boolean;
    begin
      if (getHealth < EAT_AT) then
      begin
        inventory.searchDTM(sharkDTM, 1);
        result := true;
        wait(500);
      end;
      if (getPrayer < DRINK_PRAYER_AT) then
      begin
        result := true;
        inventory.searchDTM(prayerDTM, 1);
      end;
      if (timeFromMark(lastPotion) > 300000) then
      begin
        markTime(lastPotion);
        inventory.searchDTM(attackDTM, 1);
        wait(1000);
        inventory.searchDTM(strengthDTM, 1);
        wait(1200);
        inventory.searchDTM(antiFireDTM, 1);
        wait(350);
      end;
    end;

    function prayOn():boolean;
    var
      x, y:integer;
    begin
      result := findColorTolerance(x, y, 13956822, 720, 108, 733, 125, 2);
    end;

    procedure togglePrayer();
    begin
      mouse(Point(728, 116));
    end;

    procedure initDTMz();
    begin
      antiFireDTM := DTMFromString(antiFireSTRING);
      prayerDTM := DTMFromString(prayerSTRING);
      attackDTM := DTMFromString(attackSTRING);
      strengthDTM := DTMFromString(strengthSTRING);
      sharkDTM := DTMFromString(sharkSTRING);
      vialDTM := DTMFromString(vialSTRING);
    end;

    procedure freememory;
    begin
      freeDTM(antiFireDTM);
      freeDTM(prayerDTM);
      freeDTM(attackDTM);
      freeDTM(strengthDTM);
      freeDTM(sharkDTM);
      freeDTM(vialDTM);
    end;

    function checkHealthPray2():boolean;
    begin
      if (getPrayer < DRINK_PRAYER_AT) then
      begin
        inventory.searchDTM(prayerDTM, 1);
        wait(3000);
      end;
    end;

    procedure loop();
    var
      t, d, sharkAmount, i:integer;
    begin
        if (not isLoggedIn()) then
          exit;
        case getLocation() of
          SWBANK:
          begin
            if prayOn() then
              togglePrayer();
            closeBank();
            if needEatOrPray() then
            begin
              if findBank() then
              begin
                bankAll();
                state('Healing');
                sharkAmount := round((900 - getHealth())/200);
                for i := 0 to sharkAmount do
                begin
                  mouse(Point(364, 139), 1);
                  wait(250);
                end;
                mouse(Point(320, 147), 1);
                wait(400);
                closeBank();
                markTime(t);
                repeat
                  if (getPrayer() < 600) then
                    inventory.searchDTM(prayerDTM, 1)
                  else if (getHealth() < 800) then
                    inventory.searchDTM(sharkDTM, 1)
                  else begin
                    state('Finished healing');
                    break;
                  end;
                until timeFromMark(t) > 10000;
                wait(750);
                inventory.searchDTM(prayerDTM, 1);
                wait(500);
              end;
            end;
            if (inventory.count() > 7) or (not inventoryReady()) then
            begin
              if findBank() then
              begin
                state('Banking items');
                bankAll();
                withdrawItems();
                closeBank();
              end;
            end else if inventoryReady() then
            begin
              state('Teleporting to dungeon');
              teleportTo(DUNGEON);
              walkToSpot;
            end;
            begin
              state('Inventory not ready');
              if findBank() then
              begin
                state('Banking all items');
                bankAll();
                withdrawItems();
                closeBank();
              end;
            end;
          end;
          DUNGEON:
          begin
            if (not prayOn()) then
              togglePrayer();
            if (getHealth() < 200) or (getPrayer() < 100) then
            begin
              state('Low health teleporting to bank');
              teleportTo(SWBANK);
            end
            else if (inventory.count() > 15) then
              teleportTo(SWBANK)
            else if seeDragon() then
            begin
              markTime(d);
              repeat
                if findDragon() then
                begin
                  state('Found dragon');
                  waitFunc(@inCombat, 150, 3500);
                  if getFightingMonster() = 'Steel dragon' then
                  begin
                    state('We are fighting the dragon');
                    markTime(t);
                    while inCombat() do
                    begin
                      state('We will just check if health is low');
                      checkHealthPray;
                      if (timeFromMark(t) > 75000) then
                      begin
                        state('Woah took too long to kill dragon');
                        exit;
                      end;
                    end;
                    inventory.searchDTM(vialDTM, 0);
                    waitOption('rop', 800);
                    if (inventory.Full() or inventory.count = 27) then
                    begin
                      inventory.searchDTM([antiFireDTM, prayerDTM, attackDTM, strengthDTM, sharkDTM, vialDTM], 1);
                      waitOption('rop', 800);
                      wait(350);
                      inventory.searchDTM([antiFireDTM, prayerDTM, attackDTM, strengthDTM, sharkDTM, vialDTM], 1);
                      waitOption('rop', 800);
                    end;
                    pickUpItems();
                    waitOption('rop', 800);
                    writeln('waiting for dragon to spawn');
                    waitFunc(@seeDragon, 40, 15000);
                  end;
                end else
                begin
                  state('Can not find dragon');
                  wait(200);
                end;
              Until (inventory.full()) or (timeFromMark(d) > 10000000);
            end else
            begin
              teleportTo(DUNGEON);
              walkToSpot;
            end;
          end;
          LOST:
          begin
            state('Lost, teleporting to soulwars bank');
            teleportTo(SWBANK);
            wait(3500);
          end;
        end;
    end;

    begin
      initDTMz();
      addOnTerminate('freememory');
      activateRsClient(true);
      wait(1500);
      inventory.bounds := IntTobox(567, 259, 722, 506);
      initInv();
      repeat
        checkHealthPray2();
        wait(2000);
      until false;
      lastPotion := -1000000;
      repeat
        wait(100);
        loop;
      until isKeyDown(113);
    end.

  3. #3
    Join Date
    Jun 2016
    Posts
    23
    Mentioned
    3 Post(s)
    Quoted
    15 Post(s)

    Default

    Thank you for sharing this with me. That will help me a lot!

  4. #4
    Join Date
    Jun 2016
    Posts
    23
    Mentioned
    3 Post(s)
    Quoted
    15 Post(s)

    Default

    Hey, i didnt want to make new thread so ill ask here. I want to make a function "IsInCombat" so the script knows when its attacking, I tried making it with health bar, if green color found then it means its in combat, but it just doesnt work right. I want to make it with XP bar now, when its in combat the last 3 numbers are always changing, i just dont know how to make a function that detects that in the box the numbers are changing. Im using aerolib include.

    EDIT: I have tried using this funcion:

    function IsInCombat: boolean;
    var
    PBox: TBox;
    begin
    PBox := IntToBox(493, 13, 512, 25);
    if (averagePixelShift(PBox, 1000, 3000)) then
    result := true;
    end;
    But whenever it hits 0 and gets 0 xp, it starts to attack other monster. I changed the wait time to 1-5 sec, but even if it hits it will keep trying to attacking other monster. Is there a better function to tell the script that its in combat?
    EDIT: sorted it out
    Last edited by hawkzz; 01-07-2017 at 08:19 PM.

  5. #5
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    Quote Originally Posted by hawkzz View Post
    Hey, i didnt want to make new thread so ill ask here. I want to make a function "IsInCombat" so the script knows when its attacking, I tried making it with health bar, if green color found then it means its in combat, but it just doesnt work right. I want to make it with XP bar now, when its in combat the last 3 numbers are always changing, i just dont know how to make a function that detects that in the box the numbers are changing. Im using aerolib include.

    EDIT: I have tried using this funcion:



    But whenever it hits 0 and gets 0 xp, it starts to attack other monster. I changed the wait time to 1-5 sec, but even if it hits it will keep trying to attacking other monster. Is there a better function to tell the script that its in combat?
    EDIT: sorted it out
    check for green here


    edit; nvm... runique is so crappy it only shows the combat overlay if you click the npc yourself

  6. #6
    Join Date
    Mar 2014
    Posts
    195
    Mentioned
    4 Post(s)
    Quoted
    92 Post(s)

    Default

    Quote Originally Posted by hawkzz View Post
    Hey, i didnt want to make new thread so ill ask here. I want to make a function "IsInCombat" so the script knows when its attacking, I tried making it with health bar, if green color found then it means its in combat, but it just doesnt work right. I want to make it with XP bar now, when its in combat the last 3 numbers are always changing, i just dont know how to make a function that detects that in the box the numbers are changing. Im using aerolib include.

    EDIT: I have tried using this funcion:



    But whenever it hits 0 and gets 0 xp, it starts to attack other monster. I changed the wait time to 1-5 sec, but even if it hits it will keep trying to attacking other monster. Is there a better function to tell the script that its in combat?
    EDIT: sorted it out
    hmm you could just get the pvm points number and then see if it goes up.
    so example:
    Simba Code:
    function incombat:boolean;            
    begin
     //code here
    end;
    function GetPVM:integer;            
    begin
    //code here
    result:= int
    end;
    var
    I:integer;
    begin
     i:= GetPVM;
    if not incombat and  (GetPVM > i) then
    begin
    writeln('out of combat');
    end;
    end.
    prob not the best way of doing it,

    or if your not looting bones,not killing dragons, just have the bone crusher in your invo and check for the chat

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

    Default

    @goodgamescript; @hawkzz;

    Simba Code:
    function getSimpleText(Colors:TIntegerArray;x1, y1, x2, y2:integer;font:string):String;
    var
      textTPA:TPointArray;
      textATPA, textATPAS:T2DPointArray;
      i:integer;
      textStr:string;
    begin
      setLength(textATPAS, length(colors));
      for i := 0 to high(colors) do
        findColors(textATPAS[i], Colors[i], x1, y1, x2, y2);
      textTPA := mergeATPA(textATPAS);
      textATPA := SplitTPAEx(textTPA, 1, 10);
      filtertpasbetween(textatpa, 0, 1);
      SortATPAFromFirstPointX(textATPA, Point(0, 0));
      result := getTextATPA(textATPA, 3, font);
    end;

    function string.getLength():integer;
    begin
      result := length(self);
    end;

    function getFightingMonster():string;
    begin
      result := getSimpleText([16777215], 33, 78, 142, 103, 'UpChars07');
    end;

    function inCombat(monster:string):boolean;
    begin
      result := getFightingMonster() = monster;
    end;

    function inCombat():boolean;overload;
    begin
      result := (getFightingMonster.getLength() > 2)
    end;

    begin
      writeln(inCombat('Skeleton'));
    end.

  8. #8
    Join Date
    Mar 2014
    Posts
    195
    Mentioned
    4 Post(s)
    Quoted
    92 Post(s)

    Default

    Quote Originally Posted by rj View Post
    @goodgamescript; @hawkzz;

    Simba Code:
    function getSimpleText(Colors:TIntegerArray;x1, y1, x2, y2:integer;font:string):String;
    var
      textTPA:TPointArray;
      textATPA, textATPAS:T2DPointArray;
      i:integer;
      textStr:string;
    begin
      setLength(textATPAS, length(colors));
      for i := 0 to high(colors) do
        findColors(textATPAS[i], Colors[i], x1, y1, x2, y2);
      textTPA := mergeATPA(textATPAS);
      textATPA := SplitTPAEx(textTPA, 1, 10);
      filtertpasbetween(textatpa, 0, 1);
      SortATPAFromFirstPointX(textATPA, Point(0, 0));
      result := getTextATPA(textATPA, 3, font);
    end;

    function string.getLength():integer;
    begin
      result := length(self);
    end;

    function getFightingMonster():string;
    begin
      result := getSimpleText([16777215], 33, 78, 142, 103, 'UpChars07');
    end;

    function inCombat(monster:string):boolean;
    begin
      result := getFightingMonster() = monster;
    end;

    function inCombat():boolean;overload;
    begin
      result := (getFightingMonster.getLength() > 2)
    end;

    begin
      writeln(inCombat('Skeleton'));
    end.
    i assume in this code is reading off the status bar, the name of the npc or its health maybe?, although it doesn't pop up on auto retaliate, but you could add in a click, to click the closest npc with the correct npc colors, prob wouldnt work 100% of the time.

    Less complicated then what i was thinking with the bone crusher lol, just try to drink an ovl each kill which would take care of potting up lol , so that chat changes and then you get the bone crusher has granted ... , which would see if the npc was dead.

    hmm another idea just waiting for your hit splat, all the color in a tbox in the middle of the screen, just repeat until it doesn't find it after like 2 sec depending on the attack speed of the npc as they do have a set attack speed i believe.

    so example code.
    Simba Code:
    var
    Hitsplatbox:tbox;
    HitSpeed:integer;
    DidNpcHit: boolean;

    function DidFindDamageHitSplat:boolean;
    begin
    //code if redcolor exists in Hitsplatbox
    result:= true;
    end;

    function DidFindMissHitSplat:boolean;
    begin
    //code if blue color exists in Hitsplatbox
    result:= true;
    end;

    function DidFindHitSplats:boolean;
    begin
    if DidFindMissHitSplat or DidFindDamageHitSplat then
    result:= true;
    end;

    Function GetHitSpeed:integer;
    var
    i:integer
    begin
    repeat
    wait(1);
    until(DidFindHitSplats); //wait for first hitsplat
    //might have to add small wait here for splat to disappear
    repeat
    wait(1)
    inc(i)
    until(DidFindHitSplats); //wait for second hitsplat
    Result:= i + //whatever the small wait is, if it is need;
    end;

    function waitForsplats:boolean;
    begin
     if waitfunc(@DidFindHitSplats,HitSpeed,HitSpeed+300) then
     begin
     DidNpcHit:= true; //added extra var so no need to run code again later in script
     Result:= DidNpcHit;
     end else
     begin
     DidNpcHit:= false;
     Result:= DidNpcHit;
     end;
    end;

    function NotinCombat:boolean;
    begin
    repeat
    if waitForsplats then
    begin
    //code to check hp and eat if needed goes here
    end;
    until(DidNpcHit = false) //used DidNpcHit here so it wouldnt have to wait hitspeed again eg: until(waitForsplats = false) as it would have to re-run again to check for splats
    Result:= true;
    end;


    begin
    Hitsplatbox:= //intToBox on top of players head depending on camera angle.
    HitSpeed:= 2700; //depending on npc attack speed
    //after mobs have become non-aggressive
    //some procedure to click monster
    waitfunc(@DidFindHitSplats,HitSpeed,HitSpeed+600); //wait a bit longer for npc to hit maybe not necessary
    if NotinCombat then writeln('not in combat');

    //to get HitSpeed run writeln(GetHitSpeed); before attacking npc
    end.

    above code not tested just thinking =s
    prob could use a int array for the colors just a basic rough draft


    more brainstorming is needed =p

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

    Default

    Or you could read the XP bar, if you haven't gained XP for ~5 seconds you aren't in combat

  10. #10
    Join Date
    Mar 2014
    Posts
    195
    Mentioned
    4 Post(s)
    Quoted
    92 Post(s)

    Default

    Quote Originally Posted by rj View Post
    Or you could read the XP bar, if you haven't gained XP for ~5 seconds you aren't in combat
    true, but might slow down the xp gain a bit =s and would be a simpler way of doing.

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
  •