Results 1 to 5 of 5

Thread: NearReality Magic Tree Chopper

  1. #1
    Join Date
    Dec 2015
    Posts
    2
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default NearReality Magic Tree Chopper

    I wanted to know if it was possible to create a script that would either power chop the magic trees or bank them. I know banking will be more complicated so probably start out powerchopping. I don't know if this is possible on this server. Even if you could just point me in the right direction I would greatly appreciate it. I wanted to know if i can create such a simple script and learn whats needed in about 20-30 hours; im willing to put in that many hours to hopefully create my first rsps script and to get me started scripting on private servers. A lot of the guides seem outdated on this forum. I have read https://villavu.com/forum/showthread.php?t=94909 tutorial but the script cant find the colors or just doesn't click them. Also I looked at similar threads like this one (https://villavu.com/forum/showthread.php?t=112052) asking for help and I couldn't even get their script working either.

  2. #2
    Join Date
    Sep 2014
    Location
    C:\Simba\
    Posts
    565
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default

    Well to start of, you have definetly come to the right place. Simba is suited for many different environments, and you can undoubtedly make this script even include banking.

    So to get a good grasp on how things work around here you should read this and perhaps this. (Take into consideration that the latter one is RS3 specific, and some functions will not work.) From reading this you should get a general idea of how to script with Simba.

    I know it's a lot to read, but I assure it will be time well spent. Given you read these you should be able to create your script for this RSPS of yours
    Feel free to ask me any questions, I will do my best to answer them!

    Previously known as YouPee.

  3. #3
    Join Date
    Nov 2015
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by Flamez42 View Post
    I wanted to know if it was possible to create a script that would either power chop the magic trees or bank them. I know banking will be more complicated so probably start out powerchopping. I don't know if this is possible on this server. Even if you could just point me in the right direction I would greatly appreciate it. I wanted to know if i can create such a simple script and learn whats needed in about 20-30 hours; im willing to put in that many hours to hopefully create my first rsps script and to get me started scripting on private servers. A lot of the guides seem outdated on this forum. I have read https://villavu.com/forum/showthread.php?t=94909 tutorial but the script cant find the colors or just doesn't click them. Also I looked at similar threads like this one (https://villavu.com/forum/showthread.php?t=112052) asking for help and I couldn't even get their script working either.
    I am also interested in this... Powerchopping is the way to go to be honest

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

    Default

    I'm going to look into this.

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

    Default

    I've never played on a RSPS before and I don't really get it. Does anything in this game have value?

    Anyway, try this:
    Simba Code:
    1. program Citrus_Magic_Chop_Drop_NR;
    2. //wow no include. such fast compile
    3. const
    4.   MOUSE_MOVE = 3;
    5.   choose_Option_Text_Color = 9812166;
    6.   invx1 = 519;
    7.   invx2 = 763;
    8.   invy1 = 205;
    9.   invy2 = 500;
    10.   MSX2 = 517;
    11.   MSY2 = 337;
    12.   mscx = 258;
    13.   mscy = 168;
    14.   col = tcolor($99ff00);
    15.  
    16.   //tree trunk
    17.   T_COLOR = 3364446;
    18.   T_TOL = 6;
    19.   T_HUE = 0.07;
    20.   T_SAT = 0.25;
    21.  
    22. type
    23.   TOption = record
    24.     bounds: TBox;
    25.     str: string;
    26.   end;
    27.  
    28.   TOptionArray = array of TOption;
    29.  
    30. procedure mouse(pnt: TPoint; button: integer);
    31. var
    32.   i, x, y: integer;
    33.   tpa: TPointArray;
    34. begin
    35.   moveMouse(pnt.x, pnt.y);
    36.   if (button = MOUSE_MOVE) then exit();
    37.   wait(22 + random(9));
    38.   holdMouse(pnt.x, pnt.y, button);
    39.   wait(69 + random(69));
    40.   getMousePos(x, y);
    41.   releaseMouse(x, y, button);
    42. end;
    43.  
    44. procedure mouseBox(b: TBox; button: integer);
    45. begin
    46.   mouse(point(b.x1 + random(b.x2 - b.x1), b.y1 + random(b.y2 - b.y1)), button);
    47. end;
    48.  
    49. function isLoggedIn(): boolean;
    50. var
    51.   x, y: integer;
    52. begin
    53.   result := findColor(x, y, 65536, 740, 0, 760, 25);
    54. end;
    55.  
    56. function getActiveBox(): TBox;
    57. var
    58.   x, y: integer;
    59. begin
    60.   getMousePos(x, y);
    61.   if (inRange(x, invx1, invx2) and inRange(y, invy1, invy2)) then result := [invx1, invy1, invx2, invy2]
    62.   else result := [0, 0, msx2, msy2];
    63. end;
    64.  
    65. function isOptionOpen(wait: integer = 0): boolean;
    66. var
    67.   x, y: integer;
    68.   t: longword;
    69. begin
    70.   result := false;
    71.   t := getSystemTime() + wait;
    72.   getMousePos(x, y);
    73.   repeat
    74.     result := (countColor(choose_Option_Text_Color, 0, 0, 760, 500) > 69);
    75.   until (result or (getSystemTime() > t));
    76. end;
    77.  
    78. procedure getOptionBounds(var box: TBox);
    79. var
    80.   x, y: integer;
    81.   tpa: TPointArray;
    82.   b: TBox;
    83. begin
    84.   if (not isOptionOpen(0)) then exit();
    85.   b := getActiveBox();
    86.   getMousePos(x, y);
    87.   if findColors(tpa, 0, b.x1, b.y1, b.x2, b.y2) then
    88.     box := getTPABounds(tpa);
    89. end;
    90.  
    91. function getOptions(): TOptionArray;
    92. var
    93.   oldT, newT, bmp, w, h, i, n: integer;
    94.   bounds, box: TBox;
    95. begin
    96.   if (not isOptionOpen(0)) then exit();
    97.   oldT := getImageTarget();
    98.   getOptionBounds(bounds);
    99.   bmp := bitmapFromClient(bounds.x1, bounds.y1, bounds.x2, bounds.y2);
    100.   fastReplaceColor(bmp, 16777215, col);
    101.   fastReplaceColor(bmp, 65280, col);
    102.   fastReplaceColor(bmp, 255, col);
    103.   fastReplaceColor(bmp, 65535, col);
    104.   fastReplaceColor(bmp, 16776960, col);
    105.   fastReplaceColor(bmp, 16744447, col);
    106.   fastReplaceColor(bmp, 28927, col);
    107.   fastReplaceColor(bmp, 25800, col);
    108.   w := bounds.x2 - bounds.x1;
    109.   h := bounds.y2 - bounds.y1;
    110.   n := floor(h / 15);
    111.   setLength(result, n);
    112.   try
    113.     setTargetBitmap(bmp);
    114.     for i := 0 to n-1 do
    115.     begin
    116.       result[i].str := getTextAtEx(0, (i * 15) + 1, w, min(h-1, (i * 15) + 15), 0, 5, 5, col, 0, 'upChars07_s');
    117.       result[i].bounds := [0, (i * 15) + 1, w, min(h-1, (i * 15) + 15)];
    118.       result[i].bounds.offset(point(bounds.x1, bounds.y1));
    119.       result[i].bounds.shrink(1);
    120.     end;
    121.   finally
    122.     newT := getImageTarget();
    123.     setImageTarget(oldT);
    124.     freeTarget(newT);
    125.     if bitmapExists(bmp) then freeBitmap(bmp);
    126.   end;
    127. end;
    128.  
    129. function selectOption(txt: TStringArray; mouseAction, waitTime: integer): boolean;
    130. var
    131.   opts: TOptionArray;
    132.   i, j, len: integer;
    133.   b: TBox;
    134.   t: longword;
    135. begin
    136.   if (not isOptionOpen(0)) then exit();
    137.   t := getSystemTime() + waitTime;
    138.   opts := getOptions();
    139.   if ((len := length(opts)) > 1) then
    140.   begin
    141.     for j := 0 to high(txt) do
    142.     begin
    143.       for i := 0 to high(opts) do
    144.       begin
    145.         if (getSystemTime() > t) then exit(false);
    146.         if (pos(txt[j], opts[i].str) > 0) then
    147.         begin
    148.           mouseBox(opts[i].bounds, mouseAction);
    149.           exit(true);
    150.         end;
    151.       end;
    152.     end;
    153.   end;
    154. end;
    155.  
    156. function gridBox(slot, columns, rows, w, h, diffX, diffY: integer; startPoint: TPoint): TBox;
    157. begin
    158.   if (slot > (columns * rows)) then
    159.   begin
    160.     writeln('gridBox: Invalid slot: '+toStr(slot));
    161.     exit;
    162.   end;
    163.  
    164.   result.x1 := (startPoint.x + ((slot mod columns) * diffX) - (w div 2));
    165.   result.y1 := (startPoint.y + ((slot div columns) * diffY) - (h div 2));
    166.   result.x2 := (result.x1 + w);
    167.   result.y2 := (result.y1 + h);
    168. end;
    169.  
    170. function grid(columns, rows, w, h, diffX, diffY: integer; starTPoint: TPoint): TBoxArray;
    171. var
    172.   i: integer;
    173. begin
    174.   setLength(result, (columns * rows));
    175.  
    176.   for i := 0 to high(result) do
    177.     result[i] := gridBox(i, columns, rows, w, h, diffX, diffY, starTPoint);
    178. end;
    179.  
    180. procedure TBox.edit(const x1_, y1_, x2_, y2_: integer);
    181. begin
    182.   self.x1 := self.x1 + x1_;
    183.   self.y1 := self.y1 + y1_;
    184.   self.x2 := self.x2 + x2_;
    185.   self.y2 := self.y2 + y2_;
    186. end;
    187.  
    188. procedure TBox.shrink(const size: integer);
    189. begin
    190.   self.edit(+size, +size, -size, -size);
    191. end;
    192.  
    193. procedure TBox.offset(const p: TPoint);
    194. begin
    195.   self.X1 := self.X1 + p.x;
    196.   self.X2 := self.X2 + p.x;
    197.   self.Y1 := self.Y1 + p.y;
    198.   self.Y2 := self.Y2 + p.y;
    199. end;
    200.  
    201. function isItemInSlot(slot: integer): boolean;
    202. var
    203.   b: TBox;
    204. begin
    205.   b := gridBox(slot-1, 4, 7, 34, 34, 42, 36, point(578, 229));
    206.   result := (countColor(65536, b.x1, b.y1, b.x2, b.y2) > 4);
    207. end;
    208.  
    209. function getSlotBox(slot: integer): TBox;
    210. begin
    211.   result := gridBox(slot-1, 4, 7, 34, 34, 42, 36, point(578, 229));
    212. end;
    213.  
    214. function countPixelShift(box: TBox; time: integer): integer;
    215. var
    216.   bmp1, bmp2, w, h, i: integer;
    217.   orig, curr, dif: T2DIntegerArray;
    218. begin
    219.   w := box.x2 - box.x1 - 1;
    220.   h := box.y2 - box.y1 - 1;
    221.   bmp1 := bitmapfromclient(box.x1, box.y1, box.x2, box.y2);
    222.   wait(time);
    223.   bmp2 := bitmapfromclient(box.x1, box.y1, box.x2, box.y2);
    224.   result := calculatePixelShift(bmp1, bmp2, [0, 0, w, h]);
    225.   freebitmap(bmp1);
    226.   freebitmap(bmp2);
    227. end;
    228.  
    229. function countPixelShiftAverage(box: TBox; time, n: integer): integer;
    230. var
    231.   t: integer;
    232. begin
    233.   t := time div n;
    234.   for 1 to n do
    235.     result += countPixelShift(box, t);
    236.   result := result div n;
    237. end;
    238.  
    239. function isPlayerMoving(): boolean;
    240. var
    241.   c: integer;
    242.   b: TBox;
    243. begin
    244.   b := [mscx, mscy, mscx, mscy];
    245.   b.shrink(-30);
    246.   c := countPixelShiftAverage(b, 444 + random(222), 4);
    247.   result := (c > 333);
    248. end;
    249.  
    250. procedure dropInv(slots: TIntegerArray = [1..28]);
    251. var
    252.   i: integer;
    253.   b: Tbox;
    254. begin
    255.   for i := 0 to high(slots) do
    256.   begin
    257.     if isItemInSlot(slots[i]) then
    258.     begin
    259.       b := getSlotBox(slots[i]); b.shrink(4);
    260.       mouseBox(b, MOUSE_RIGHT);
    261.       selectOption(['rop', 'Dro'], MOUSE_LEFT, 444);
    262.     end;
    263.   end;
    264.   mouse(point(-1, 0), MOUSE_MOVE);
    265. end;
    266.  
    267. function clickTree(): boolean;
    268. var
    269.   i: integer;
    270.   tpa: TPointArray;
    271.   atpa: T2DPointArray;
    272. begin
    273.   result := false;
    274.   if isItemInSlot(27) then dropInv([1..24]);
    275.   setColorToleranceSpeed(2);
    276.   setToleranceSpeed2Modifiers(T_HUE, T_SAT);
    277.   if findColorsTolerance(tpa, T_COLOR, 0, 140, msx2, msy2, T_TOL) then
    278.   begin
    279.     atpa := clusterTPA(tpa, 2);
    280.     filterTPAsBetween(atpa, 0, 100);
    281.     for i := 0 to high(atpa) do
    282.     begin
    283.       mouse(medianTPA(atpa[i]), MOUSE_RIGHT);
    284.       if selectOption(['hop', 'own Mag'], MOUSE_LEFT, 444) then
    285.       begin
    286.         mouse(point(-1, 0), MOUSE_MOVE);
    287.         wait(2345);
    288.         exit(true);
    289.       end;
    290.       mouse(point(-1, 0), MOUSE_MOVE);
    291.     end;
    292.   end;
    293. end;
    294.  
    295. procedure mainloop();
    296. begin
    297.   if clickTree() then while isPlayerMoving() do dropInv([1..24]);
    298. end;
    299.  
    300. begin
    301.   while isLoggedIn() do mainloop;
    302. end.

    View like this:


    Max brightness, fixed client, simplest graphics, etc.

    update: ran overnight. works well enough. now what do I do with this 2b?
    Last edited by Citrus; 12-07-2015 at 06:06 PM.

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
  •