Results 1 to 12 of 12

Thread: can some1 help me with script

  1. #1
    Join Date
    Apr 2016
    Posts
    43
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default can some1 help me with script

    hey, i just downloaded simba, and im trying to create a simple bot, that would eat, when at certain hp, or under it, can somebody help me with it, and show me like how to start it or something. thanks!

  2. #2
    Join Date
    Oct 2012
    Posts
    1,258
    Mentioned
    40 Post(s)
    Quoted
    588 Post(s)

    Default

    https://villavu.com/forum/showthread.php?t=58935 A great beginner's guide, highly recommended
    https://villavu.com/forum/showthread.php?t=107757 If you're doing rs3, definitely check this out after getting the basics from that ^

    e: I see section now huehue, no clue where the best osrs guides would be at. @Harrier; did you make any yet? smh

  3. #3
    Join Date
    Apr 2016
    Posts
    43
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Quote Originally Posted by acow View Post
    https://villavu.com/forum/showthread.php?t=58935 A great beginner's guide, highly recommended
    https://villavu.com/forum/showthread.php?t=107757 If you're doing rs3, definitely check this out after getting the basics from that ^

    e: I see section now huehue, no clue where the best osrs guides would be at. @Harrier; did you make any yet? smh
    nah man, doesnt have to be osrs, just rsps or anything, where it clicks a food on certain hp lvl

  4. #4
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    e: if it's an rsps then you'll probably have to write your own. Posting a picture of the HP display will help. If there is a number then reading it should be easy.

    After reading the first guide that acow posted, check out the reflection tutorial if that's the way you want to go.

    With reflection it's as simple as
    Simba Code:
    if (myPlayer.getHeath() < 50) then
    begin
      //do some stuff
    end;
    Last edited by Citrus; 09-26-2016 at 05:28 PM.

  5. #5
    Join Date
    Apr 2016
    Posts
    43
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    e: if it's an rsps then you'll probably have to write your own. Posting a picture of the HP display will help. If there is a number then reading it should be easy.

    After reading the first guide that acow posted, check out the reflection tutorial if that's the way you want to go.

    With reflection it's as simple as
    Simba Code:
    if (myPlayer.getHeath() < 50) then
    begin
      //do some stuff
    end;
    hp bar is like this, https://gyazo.com/b37ed170886ad2c95fe419ed8911c281
    as i said im new tho, i know pretty much nothing about scripting yet. How can i make it like it would know the color of the food, and when its on the certain hp, it would click the color(food), btw do i need to download any plugins for the reflection thingy
    Last edited by scripter1; 09-26-2016 at 05:35 PM.

  6. #6
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Reflection won't work for this, you'll have to use color.

    The HP number should be easy to read. I've written a few scripts for private servers and had no problems reading the text. It's just a matter of knowing which font is used (smallChars maybe?). http://docs.villavu.com/simba/scriptref/ocr.html
    I'm busy today, but I might be able to look at this more tonight. Which RSPS is this?

  7. #7
    Join Date
    Apr 2016
    Posts
    43
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    Reflection won't work for this, you'll have to use color.

    The HP number should be easy to read. I've written a few scripts for private servers and had no problems reading the text. It's just a matter of knowing which font is used (smallChars maybe?). http://docs.villavu.com/simba/scriptref/ocr.html
    I'm busy today, but I might be able to look at this more tonight. Which RSPS is this?
    RuneHD, its same as alotic back in the day, but its a beta server atm. just hmu on this post when ur available to help ?
    Btw, how do i find the color then, what is the command for it, and how do i start the script, like : "Program - var - (FindColor) or something, then If (FindColor) = True - Then (MouseClick) Food ID/Color
    Last edited by scripter1; 09-26-2016 at 06:42 PM.

  8. #8
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Hmm.. Simba isn't able to see the game window properly. This is all it sees, even while in game.
    http://i.imgur.com/wcgUzBb.png

    Anyone know why / how to fix? I know you can use setDesktopAsClient() but that's a pain.

    e: I have it worked out.
    Last edited by Citrus; 09-27-2016 at 05:41 AM.

  9. #9
    Join Date
    Mar 2013
    Posts
    1,010
    Mentioned
    35 Post(s)
    Quoted
    620 Post(s)

    Default

    Quote Originally Posted by acow View Post
    https://villavu.com/forum/showthread.php?t=58935 A great beginner's guide, highly recommended
    https://villavu.com/forum/showthread.php?t=107757 If you're doing rs3, definitely check this out after getting the basics from that ^

    e: I see section now huehue, no clue where the best osrs guides would be at. @Harrier; did you make any yet? smh
    I'm not going to finish writing any of the guides I've started writing for the time been (and I doubt I'll ever restart/finish them off)
    #slack4admin2016
    <slacky> I will build a wall
    <slacky> I will ban reflection and OGL hooking until we know what the hell is going on

  10. #10
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Here's what I threw together. Make sure the client window is fixed size and the entire thing is visible and uncovered.
    Edit eatFood's slots to wherever your food is.

    Simba Code:
    1. program RuneHD_Simple_Eater;
    2.  
    3. const
    4.   mouse_move = 3;
    5.   choose_Option_Text_Color = 9812166;
    6.   choose_Option_Border_Color = 4016722;
    7.   col = $99ff00;
    8.   green_text = 65280;
    9.   yellow_text = 65535;
    10.   orange_text = 2070783;
    11.   red_text = 255;
    12.  
    13. var
    14.   left, top, right, bot: integer;
    15.  
    16. type
    17.   TOption = record
    18.     bounds: TBox;
    19.     str: string;
    20.   end;
    21.  
    22.   TOptionArray = array of TOption;
    23.  
    24. procedure getAndSet();
    25. var
    26.   pp: TSysProcArr;
    27.   i: integer;
    28. begin
    29.   pp := client.getIOManager.getProcesses;
    30.   for i := 0 to high(pp) do
    31.   begin
    32.     if pos('RuneHD', pp[i].title) then
    33.     begin
    34.       setTarget(pp[i]);
    35.       getClientPosition(left, top);
    36.       left += 8;
    37.       top += 30;
    38.       right := left + 764;
    39.       bot := top + 502;
    40.       setDesktopAsClient();
    41.       imageSetClientArea(left, top, right, bot);
    42.       mouseSetClientArea(left, top, right, bot);
    43.       exit();
    44.     end;
    45.   end;
    46.   writeln('RuneHD not found');
    47.   terminateScript();
    48. end;
    49.  
    50. procedure mouse(pnt: TPoint; button: integer);
    51. var
    52.   i, x, y: integer;
    53.   tpa: TPointArray;
    54. begin
    55.   moveMouse(pnt.x, pnt.y);
    56.   if (button = MOUSE_MOVE) then exit();
    57.   wait(22 + random(9));
    58.   holdMouse(pnt.x, pnt.y, button);
    59.   wait(69 + random(69));
    60.   getMousePos(x, y);
    61.   releaseMouse(x, y, button);
    62. end;
    63.  
    64. procedure mouseBox(b: TBox; button: integer);
    65. begin
    66.   mouse(point(b.x1 + random(b.x2 - b.x1), b.y1 + random(b.y2 - b.y1)), button);
    67. end;
    68.  
    69. function isOptionOpen(wait: integer = 0): boolean;
    70. var
    71.   w, h: integer;
    72.   t: longword;
    73. begin
    74.   result := false;
    75.   t := getSystemTime() + wait;
    76.   getClientDimensions(w, h);
    77.   repeat
    78.     result := (countColor(choose_Option_Text_Color, 0, 0, w-1, h-1) > 69);
    79.   until (result or (getSystemTime() > t));
    80. end;
    81.  
    82. procedure getOptionBounds(var box: TBox);
    83. var
    84.   w, h: integer;
    85.   tpa: TPointArray;
    86.   b: TBox;
    87. begin
    88.   if (not isOptionOpen(0)) then exit();
    89.   getClientDimensions(w, h);
    90.   if findColors(tpa, choose_Option_Border_Color, 0, 0, w-1, h-1) then
    91.     box := getTPABounds(tpa);
    92. end;
    93.  
    94. function getOptions(): TOptionArray;
    95. var
    96.   oldT, newT, bmp, w, h, i, n: integer;
    97.   bounds, box: TBox;
    98. begin
    99.   if (not isOptionOpen(0)) then exit();
    100.   oldT := getImageTarget();
    101.   getOptionBounds(bounds);
    102.   bounds.shrink(1);
    103.   bmp := bitmapFromClient(bounds.x1, bounds.y1, bounds.x2, bounds.y2);
    104.   fastReplaceColor(bmp, 9812166, col);
    105.   fastReplaceColor(bmp, 16777215, col);
    106.   fastReplaceColor(bmp, 65280, col);
    107.   fastReplaceColor(bmp, 255, col);
    108.   fastReplaceColor(bmp, 65535, col);
    109.   fastReplaceColor(bmp, 16776960, col);
    110.   fastReplaceColor(bmp, 16744447, col);
    111.   fastReplaceColor(bmp, 28927, col);
    112.   fastReplaceColor(bmp, 25800, col);
    113.   fastReplaceColor(bmp, 4231423, col);
    114.   w := bounds.x2 - bounds.x1;
    115.   h := bounds.y2 - bounds.y1;
    116.   n := floor(h / 16);
    117.   setLength(result, n);
    118.   try
    119.     setTargetBitmap(bmp);
    120.     for i := 0 to n-1 do
    121.     begin
    122.       result[i].str := getTextAtEx(0, (i * 16) + 0, w, min(h-1, (i * 16) + 16), 0, 5, 5, col, 0, 'upCharsEx');
    123.       result[i].bounds := [0, (i * 16) + 1, w, min(h-1, (i * 16) + 16)];
    124.       result[i].bounds.offset(point(bounds.x1, bounds.y1));
    125.       result[i].bounds.shrink(1);
    126.     end;
    127.   finally
    128.     newT := getImageTarget();
    129.     setImageTarget(oldT);
    130.     freeTarget(newT);
    131.     if bitmapExists(bmp) then freeBitmap(bmp);
    132.   end;
    133. end;
    134.  
    135. function selectOption(txt: TStringArray; mouseAction, waitTime: integer): boolean;
    136. var
    137.   opts: TOptionArray;
    138.   i, j, len: integer;
    139.   b: TBox;
    140.   t: longword;
    141. begin
    142.   if (not isOptionOpen(0)) then exit();
    143.   t := getSystemTime() + waitTime;
    144.   opts := getOptions();
    145.   if ((len := length(opts)) > 1) then
    146.   begin
    147.     for j := 0 to high(txt) do
    148.     begin
    149.       for i := 0 to high(opts) do
    150.       begin
    151.         if (getSystemTime() > t) then exit(false);
    152.         if (pos(txt[j], opts[i].str) > 0) then
    153.         begin
    154.           mouseBox(opts[i].bounds, mouseAction);
    155.           exit(true);
    156.         end;
    157.       end;
    158.     end;
    159.   end;
    160. end;
    161.  
    162. function gridBox(slot, columns, rows, w, h, diffX, diffY: integer; startPoint: TPoint): TBox;
    163. begin
    164.   if (slot > (columns * rows)) then
    165.   begin
    166.     writeln('gridBox: Invalid slot: '+toStr(slot));
    167.     exit;
    168.   end;
    169.  
    170.   result.x1 := (startPoint.x + ((slot mod columns) * diffX) - (w div 2));
    171.   result.y1 := (startPoint.y + ((slot div columns) * diffY) - (h div 2));
    172.   result.x2 := (result.x1 + w);
    173.   result.y2 := (result.y1 + h);
    174. end;
    175.  
    176. function grid(columns, rows, w, h, diffX, diffY: integer; starTPoint: TPoint): TBoxArray;
    177. var
    178.   i: integer;
    179. begin
    180.   setLength(result, (columns * rows));
    181.  
    182.   for i := 0 to high(result) do
    183.     result[i] := gridBox(i, columns, rows, w, h, diffX, diffY, starTPoint);
    184. end;
    185.  
    186. procedure TBox.edit(const x1_, y1_, x2_, y2_: integer);
    187. begin
    188.   self.x1 := self.x1 + x1_;
    189.   self.y1 := self.y1 + y1_;
    190.   self.x2 := self.x2 + x2_;
    191.   self.y2 := self.y2 + y2_;
    192. end;
    193.  
    194. procedure TBox.shrink(const size: integer);
    195. begin
    196.   self.edit(+size, +size, -size, -size);
    197. end;
    198.  
    199. procedure TBox.offset(const p: TPoint);
    200. begin
    201.   self.X1 := self.X1 + p.x;
    202.   self.X2 := self.X2 + p.x;
    203.   self.Y1 := self.Y1 + p.y;
    204.   self.Y2 := self.Y2 + p.y;
    205. end;
    206.  
    207. function isItemInSlot(slot: integer): boolean;
    208. var
    209.   b: TBox;
    210. begin
    211.   b := gridBox(slot-1, 4, 7, 38, 35, 42, 36, point(579, 229));
    212.   result := (countColor(131072, b.x1, b.y1, b.x2, b.y2) > 4);
    213. end;
    214.  
    215. function getSlotBox(slot: integer): TBox;
    216. begin
    217.   result := gridBox(slot-1, 4, 7, 38, 35, 42, 36, point(579, 229));
    218. end;
    219.  
    220. function shouldEat(): boolean;
    221. const
    222.   b: TBox = [720, 28, 747, 44];
    223. var
    224.   x, y: integer;
    225. begin
    226.   result := (findColor(x, y, yellow_text, b.x1, b.y1, b.x2, b.y2) or
    227.              findColor(x, y, orange_text, b.x1, b.y1, b.x2, b.y2) or
    228.              findColor(x, y, red_text, b.x1, b.y1, b.x2, b.y2));
    229. end;
    230.  
    231. function eatFood(slots: TIntegerArray = [1..28]): boolean;
    232. var
    233.   i: integer;
    234. begin
    235.   for i := 0 to high(slots) do
    236.   begin
    237.     if isItemInSlot(slots[i]) then
    238.     begin
    239.       mouseBox(getSlotBox(slots[i]), mouse_right);
    240.       if selectOption(['Eat'], mouse_left, 222) then exit(true)
    241.       else mouse(point(-1, -1), mouse_move);
    242.     end;
    243.   end;
    244. end;
    245.  
    246. procedure mainloop();
    247. begin
    248.   if shouldEat() then eatFood([10, 18]); { <-- edit the slots where your food is }
    249.   wait(1234);
    250. end;
    251.  
    252. begin
    253.   getAndSet();
    254.   while true do mainloop();
    255. end.
    Last edited by Citrus; 09-27-2016 at 03:10 PM.

  11. #11
    Join Date
    Apr 2016
    Posts
    43
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    btw how does the scriptwork, it just says "compiled succesfully in 297 ms", when i run it, it just ends there? or does it begin eating the food when at certain hp

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

    Default

    you may be able to borrow stuff from rj's alotic include

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
  •