Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 8.62 KB | None | 0 0
  1. program CHOPdaBOB;
  2. (*******************************************************************************
  3.                             C H O P   D A   B O B
  4.                        A Falador Yew Cutter by Markus
  5.   Q: MARKUS WHY DID YOU MAKE THIS?!?!?! HOW ABOUT THE WONDERFUL MSI????
  6.   A: I couldn't get MSI to work and in the 20 mins I used it got really fed up
  7.      with some bugs: WHY can't it detect my location. WHY does it think I'm
  8.      powerskilling? WHY do i have to enter a fckn 0 every time in the form
  9.      or else the script will hang? Not even the crappiest RSBot script wants that.
  10.      Oh and I really couldn't be bothered to mess the code around good enough to
  11.       get it working. And it hated my scriptrecord so much that I was like,
  12.      I can do this better and it'll be quicker if I do it from scratch.
  13.      TL;DR: I'm a lazy fuck and couldn't get it to work.
  14.   Q: So, such a nice script, how long did it take to write you?
  15.   A: It took me one hour to make it do it's first bank run :) And another hour
  16.      to fix some bugs and have it do yewhopping between yew one and two.
  17.      After that yet another two hours to rewrite some parts and make it
  18.      'stateless': which means anything can happen and it'll just work fine
  19.      because of extreme fault tolerance.
  20. *******************************************************************************)
  21. {$i srl/srl/misc/smart.scar}
  22. {$i srl/srl.scar}
  23. {$i reflection/reflection.simba}
  24. //Yew ID: 1309
  25. //Yew STUMP: 7402
  26. //Cutting anim: 867
  27.  
  28.  
  29. procedure DeclarePlayers;
  30. begin
  31.   HowManyPlayers := 1;
  32.   NumberOfPlayers(HowManyPlayers);
  33.   CurrentPlayer := 0;
  34.  
  35.   with Players[0] do  //ripped this from bobzilla without permission
  36.   begin
  37.     Name := '';           //Username
  38.     Pass := '';           //Password
  39.     Nick := '';           //3-4 non uppercase, number, or space characters on your username
  40.     Pin := '';            //Bank Pin (Blank if none)er
  41.     Active := True;       //Player Active?
  42.     Integers[2] := 10;    //how long to work for in minutes
  43.   end;
  44. end;
  45.  
  46. const
  47.   id_YEW_TREE = 1309;
  48.   id_YEW_STUMP= 7402;
  49.   id_ANIM_CUT =  867;
  50.  
  51. const
  52.   CdB_YewCount=    2; //This might be useful later for other locations
  53.                       //In fact, it shouldn't be too hard to modify this script
  54.                       //in order to use it at other locations/skills. Maybe
  55.                       //I can even add some kind of "Scritp Record" so it's easy
  56.                       //to make it do multiple skills in multiple locations? :o
  57.  
  58. const     //To be used in the future
  59.   CdB_TO_YEWS     = 1337; //Besides, the exact numbers don't really matter
  60.   CdB_CUT_YEWS    = 1338;
  61.   CdB_SWITCH_YEWS = 1339;
  62.   CdB_TO_BANK     = 1340;
  63.   CdB_CLEAR_INV   = 1341;
  64.   CdB_CAN_CUT     = 1342;
  65.  
  66.  
  67. var
  68.   YewTimeStamps : array [0..CdB_YewCount-1] of integer;
  69.   YewTiles   : array [0..CdB_YewCount-1] of TTile;
  70.   BankToYews : TTileArray;
  71.   YewsToBank : TTileArray;
  72.   CurrentYew : Integer;
  73.   Breakout : Boolean;
  74.  
  75. ////////////////////////////////////////////////////////////////////////////////
  76.  
  77. function CdB_ObjectInReach(objID, MaxDist : integer;) : boolean;
  78. var
  79.   tempObject : TRSObject;
  80. begin
  81.   result := False;
  82.   tempObject := GetObjectByID(id_YEW_TREE, OBJECT_TYPE_INTERACTABLE, MaxDist);
  83.   if (DistanceFrom(tempObject.Tile) < MaxDist) then
  84.     result := true;
  85. end;
  86.  
  87. ////////////////////////////////////////////////////////////////////////////////
  88.  
  89.  
  90. function FindYew : boolean;
  91. var
  92.   FoundObjs : TRSObjectArray;
  93.   YewPoint : TPoint;
  94.   TimeMark : Integer;
  95.   Tries : Integer;
  96. begin
  97.   Result := False;
  98.   FoundObjs := GetObjectsByID(id_YEW_TREE, OBJECT_TYPE_INTERACTABLE, 10);  //First try to find a yew
  99.   if length(FoundObjs) = 0 then
  100.   begin
  101.       FoundObjs := GetObjectsByID(id_YEW_STUMP, OBJECT_TYPE_INTERACTABLE, 10);
  102.       if length(FoundObjs) = 0 then
  103.       begin
  104.         writeln('There is no fckn yew, and no fckn stump of a yew!');
  105.         BreakOut := True;
  106.         exit;
  107.       end else
  108.       writeln('we found a stump -.-''');
  109.       //writeln(FoundObjs);
  110.       result := False;
  111.   end else
  112.   begin
  113.     writeln('WE found a yew tree!');
  114.     writeln('We found itat : '+ ToStr(FoundObjs[0].Tile)+' to be precise');
  115.     writeln('WE are at: '+ToStr(GetMyPos));
  116.     if GetAnimation <> id_ANIM_CUT then
  117.     begin
  118.       While(Tries < 10) do
  119.       begin
  120.         writeln('and were gonna cut it!');
  121.         if InvFull then
  122.         begin
  123.           writeln('wait we are not, as our inventory is full');
  124.           result := True; //to follow main loop logic
  125.           Exit;
  126.         end;
  127.         YewPoint := TileToMS(FoundObjs[random(9)].Tile, random(500));
  128.         MMouse(YewPoint.x, YewPoint.y, 5, 5);
  129.         if IsUpText('hop') then
  130.         begin
  131.           GetMousePos(YewPoint.x, YewPoint.y);
  132.           if Random(2) = 1 then
  133.             Mouse(YewPoint.x, YewPoint.y, 0, 0, true)
  134.           else begin
  135.             Mouse(YewPoint.x, YewPoint.y, 0, 0, false);
  136.             ChooseOption('hop');
  137.           end;
  138.           R_Flag;
  139.           TimeMark := GetSystemTime;
  140.           While ((GetSystemTime-TimeMark) < 5000) do
  141.           begin
  142.             if GetAnimation = id_ANIM_CUT then
  143.             begin
  144.               writeln('We iz cuttin and we r done');
  145.               Result := True;
  146.               Exit;
  147.             end;
  148.           end;
  149.         end;
  150.         Inc(Tries);
  151.       end;
  152.     end else
  153.     begin
  154.       writeln('we are already cutting it');
  155.       Result := True;
  156.     end;
  157.   end;
  158. end;
  159. (*
  160. Typical script-loop:
  161. Walk from bank to yews            TO_YEWS
  162.   cut a yew                       CUT_YEWS
  163.   switch yew                      SWITCH_YEWS
  164. Invfull: walk back to bank        TO_BANK
  165. at bank: deposit stuff            CLEAR_INV
  166. *)
  167.  
  168.  
  169.  
  170. function SwitchYews : boolean;
  171. var
  172.   i, j, k : integer;
  173. begin
  174.  if FindYew then exit; //No need to switch, there's a yew in front of us
  175.  j := MaxInt;
  176.  for i := 0 to high(YewTimeStamps) do //Find out which yew to go
  177.  begin
  178.    if (YewTimeStamps[i] < j) then
  179.    begin
  180.      j := YewTimeStamps[i];
  181.      k := i;
  182.    end;
  183.  end;
  184.  if i > high(yewtimestamps) then i := random(length(yewtimestamps));
  185.  writeln('we are switching to yew: '+inttostr(i)+'@'+ToStr(yewtiles[i]));
  186.  if (r_WebWalk(YewTiles[i])) then
  187.  begin
  188.    writeln('we iz at the right yew!');
  189.    writeln('Yew: '+tostr(i)+' @ '+ToStr(yewtiles[i]));
  190.    R_Flag;
  191.  end;
  192. end;
  193.  
  194. function ScriptState : integer; //Not used atm, I want to make this script stateless
  195. var
  196.   MyPos : TTile;
  197. begin
  198.   Result := -1; //aka middleofnowhere
  199.   MyPos := GetMyPos;
  200.  
  201.   if InvFull {and position is like ..} then
  202.   begin
  203.     result := CdB_TO_BANK; //Hey, the inventory is full ;)
  204.   end;
  205.  
  206.   //Check if we are chopping
  207.   if CdB_ObjectInReach(id_YEW_TREE, 5) then //1 should do actually
  208.   begin
  209.     if (GetAnimation = id_ANIM_CUT) then
  210.       result  := CdB_CUT_YEWS
  211.     else
  212.       result := CdB_CAN_CUT; //Might do some check for axes here
  213.   end;
  214. end;
  215.  
  216. procedure LoadArrays;
  217. begin
  218.   BankToYews := TPointArray([Point(3012, 3355), Point(3006, 3348),
  219.                             Point(3006, 3334), Point(3006, 3323),
  220.                             Point(3019, 3318)]);
  221.   YewsToBank := TPointArray([Point(3012, 3355), Point(3006, 3348),
  222.                             Point(3006, 3334), Point(3006, 3323),
  223.                             Point(3019, 3318)]);
  224.   InvertPath(YewsToBank);
  225.   YewTiles[0].x := 2995+random(6);
  226.   YewTiles[0].y := 3310+random(6);
  227.   YewTiles[1].x := 3018+random(6);
  228.   YewTiles[1].y := 3314+random(6);
  229. end;
  230.  
  231. begin
  232.   Smart_Members := True;
  233.   Smart_Server := 52;
  234.   Smart_Signed := True;
  235.   Smart_SuperDetail := False;
  236.   setupsrl;
  237.   SetupReflection;
  238.   DeclarePlayers;
  239.   LoadArrays;
  240.   repeat
  241.    { case ScriptStatus of
  242.       TO_YEWS:      WalkPath(BankToYews);
  243.       TO_BANK:      WalkPath(YewsToBank);
  244.       CUT_YEWS:     FindYew;
  245.       SWITCH_YEWS:  SwitchYews;
  246.       CLEAR_INV:    DepositStuff; //c-c-c-c-c-COOOMBO BREAKER =D
  247.     end else
  248.     begin
  249.       writeln('Uhm, IDK wtf ur trying to do, but I can tell you one thing and'+
  250.       ' that''s that it just doesn''t work');
  251.       TerminateScript;
  252.     end;     }
  253.     BreakOut := False;
  254.     WalkPath(BankToYews);
  255.     CurrentYew := 1; //cus of walkpath
  256.     repeat
  257.       FindNormalRandoms;
  258.       if FindYew then
  259.       begin
  260.         repeat
  261.           if random(500) = 1 then BoredHuman;
  262.           wait(50+random(200));
  263.           if InvFull then break;
  264.         until not FindYew;
  265.         YewTimeStamps[currentyew] := GetSystemTime;
  266.       end;
  267.       if not invfull then SwitchYews;
  268.     until InvFull;
  269.     WalkPath(YewsToBank);
  270.     OpenBankFast('feb');
  271.     DepositAll;
  272.   until false;
  273.   writeln('markus u r s00 leet');
  274. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement