Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program New;
- //Below here you are free to touch.
- //{$define smart} //Comment this line to use the script with regular browser
- //{$DEFINE RS3} //Comment this line to use the script on Old-School RuneScape
- {$IfDef RS3}
- {$i srl-6/srl.simba}
- {$i sps/lib/sps-rs3.simba}
- {$Else}
- {$i aerolib/aerolib.simba}
- {$I RSWalker/Walker.simba}
- {$endif}
- {$ifdef smart}
- {$ifndef lape}
- {$i srl/srl/misc/smartgraphics.simba}
- {$define SMARTDRAW}
- {$endif}
- {$endif}
- { Changelog
- 5.00: Real Anniversary Edition!
- * Backported script to Old-School RuneScape!
- - Added Aerolib and RSWalker compatibility
- - Backported some SRL-6 stuff to Aerolib for compatibility
- - Changed colors and stuff to be constants instead of inline
- - Compiler directives handle different naming between SRL/AL
- - Used some portal finders from version 3.11 (last SRL-5 version of the Essence miner)
- Overall it should be pretty good! Let me know of any bugs you find
- * Added sanity checks for SPS as it can be quite inaccurate. Also used these for RSW (OSRS)
- * Script more accurately detects when the door needs to be opened. it can also ignore door-opening now if it's already opened;
- * Middle-of-mine-walking now has adaptive tolerance (helps for OSRS, but RS3 as well)
- * 'Deathwalking'! You can start the script from anywhere and it'll get you there (RS3 Only)
- This should also help when the script is lost. It'll just home tele instead of logging out.
- * Tweaked RS3 Aubury finding, should be less shit now but is still not as good as I want it to be
- * Fixed essence counting! It now actually counts essence, instead of assuming full inventory
- * There was an infinite loop in bank opening! Shame on me. Fixed of course.
- * Added a maximum run timer: if you only want to bot for 20 minutes, that's possible now
- 4.20:
- * 10-year anniversary edition! This script just refuses to die
- * Fixed a few compilation bugs for SRL 1300+
- * Small bug in portal finding fixed (small offset added)
- * Fixed a bug in doorfinding which caused it to never actually open the door
- * Changed tolerance in Aubury color finding
- * Few other random bug fixes I can't remember, mostly minor
- 4.10:
- * Fixed portal finder 2 crashing script
- * Fixed magic coords (messed up a minus-sign)
- * Added some stats
- * More stability and bug fixes and other cool stuff.
- 4.01:
- * Updated again to compile with Simba 1100 and SRL-6
- * Small changes to Aubury mine handling
- * There seem to be a few more portal finders from the competition. Can't recall which ones I used though..
- 4.00: (Unreleased)
- * Updated sript to work with SRL-6.
- * Updated script to work with RS3
- * Disabled lots of stuff that didn't work
- * Changed some TPA segmentation stuff in the ess finder
- * Very wacky Aubury finding added
- * New symbol finder cause SRL's have bad performance
- * New detection if we are in store, using polygons!
- * Reimplemented part of the door finding
- * Fixed an old bug which has been there for 7 years in the mainloop
- 3.11:
- * Added a new portal finder by J J, it is easy and should be more accurate. Thanks! Modified it slightly to accomodate both the script and Lape.
- * Added a new doorfinder, 'DoorClosedGenius'. It uses quite a clever way to distinguish the door from the floor at Aubury's store. I'd say, check it out! :)
- * Improved the caching of the BlackOffset. Now it doesn't need black but it also works with the tree visible
- * Added some wrappers for the wrappers to wrap around the code 8 error. Uses 100% undocumented features.
- * Added SRL Stats support! Please fill in your username/password
- * Fixed the bug that it would not continue mining if it got a random
- * Fixed a very rare bug in the location detection where it would mess up
- 3.10:
- * LAPE compatibility! Simba 992+ SRL 1513+ required. Seems to 'lag' a bit more in Lape though..
- * Six hour fix enabled! I don't think the script gets 6 hour runs but if it does, it can handle it
- * Fixed blackoffset, so the DDTM should work again (more accuracy @ mapwalk)
- * The BlackOffset(R) is now properly cached. (increases speed)
- * Re-enabled the old portal finder as backup as it's not bad at all! (increases durability)
- * [strike]Replaced the bank opening function with something slightly more accurate[/strike] nope: all of SRL's bankfinding is crap...
- * Added a wait so it waits until the character is fully standing, (improves bankfinding, less detectable)
- * Added tons of SMART debugging stuff, though I really don't know how to use it.. (makes it easier to fix bugs)
- * Better Aubury to bank walking - read: trashed Wizzup's old function (more accuracy, no blue moon inn, increases durability)
- * Added 'Freeze' for Aubury store finding, works better with the rotating DTM ;) (better aubury store finding)
- * Also added 'Freeze' for the black offset. (idem)
- * Extremely ugly/effective portal hack: logout/login for when it's desperate for finding the portal. (increase durability)
- * Added essence/hour counter. (looks nice at proggies)
- * Fixed doorfinding! New DTM and new Minimap shizzles, tweaked Uptext checking so it actually works most of the time (increases durability)
- * Moved script comments around to accomodate users of archaic 80-character terminals (decreases Wizzup complaints)
- * More accurate counting of mined ess when pickaxe not equipped
- * If the script couldn't find ess, instead of exitting and walking back to the bank,
- now it will exit and try to get back to mine for a retry (increases speed, less detectable)
- * Added some more random finding here and there (increases durability)
- * For extra bonus points: added running+resting.
- 3.01:
- * Tweaked Aubury finding, should work better (faster)
- * Also fixed a bug in Aubury finding so it looks for Talk, not (W)alk
- * Spiral sort in all object finders now, Wizzup? forgot those >.<
- * New magic store detection, accuracy increased a lot! Take a look at lines 114-130 and 179+ if you want to see how it works, quite proud of it
- * Commented a LOT throughout the entire script so it's now way easier to understand
- * Fixed one small edge case with inside mine handling, should be perfect now
- * New doorfinder, uses mainscreen DTM (thanks Demise!). Uses old one as fallback
- * Should open doors semi-correctly now when walking Aubury->Bank, tweaked the code behind that a bit
- * Added a few range checks so it doesn't click a few pixels outside of minimap when walking bank->Aubury
- * Added a bit of waiting, but still likes to mess up by clicking bankers instead of booths
- * Doesn't close bank booth all the time now, just 1 in 3 times
- * Added a bit of debug lines, too. Can't turn those off yet
- * Few other minor tweaks here and there
- 3.00:
- * Removed (deprecated) stats system
- * Tweaked Aubury and bank finding
- * Brand new ess finder
- * Great system for walking inside the mine
- * Removed newautocolor support
- * New Flag function, uses pixelshift for better accuracy
- * New portal finder, thanks euphemism!
- * Trashed abyss solver
- * The script is now polite and congratulates you when levelling up ;-)
- }
- { TODO
- * Fix door opening (it finds the door but glitches a bit)
- * Get rid of weird mouse movements
- * Fix Aubury finding RS3
- }
- { Credits:
- As I'm a lazy scripter, here some people who helped out in no particular order:
- - Wizzup? As this script started out as his back in '07
- - WT-Fakawi for his excellent feedback for v3+ and some DDTM code
- - J J; euphemism and Brandon for their awesome portal finders
- - mixster for some mathematics help at essence location detection
- - Wu-Tang Clan for the SPS map used
- Several others!
- }
- Const
- StartPlayer = 0;
- Loads = 12; //Loads before banking/switching players
- VersionNumber = '5.00 beta';
- TIME_TO_RUN = -1;// Amount of minutes to run script before terminatng
- // Set to -1 if you don't care.
- SRL_User = ''; //Your SRL Stats username
- SRL_Pass = ''; //Your SRL Stats password
- Var
- // EssInfo: EssLocArray;
- AubTPA: TPointArray;
- NoEssFound: Boolean;
- EssenceMined, Abyss: Integer;
- MiddleDTM1, MiddleDTM2, DTMAuburyDoor : integer;
- EssenceDTM : integer;
- MageSymbolBMP, TransportSymbolBMP : integer;
- AuburyShopPolygon : TPointArray;
- AuburyCenter : TPoint;
- T3 : Integer; //Aubury shop timer
- DeathWalkPath : TPointArray;
- {$IfDef RS3}
- DWSPS : TSPSArea;
- {$EndIf}
- {$IfDef Aerolib}
- var
- RSW : TRSWalker;
- {$endif}
- //{$DEFINE DEBUG}
- Procedure DeclarePlayers;
- Begin
- {$IfDef RS3}
- currentPlayer := 0;
- setLength(players, 1);
- {$EndIf}
- with {$IfDef RS3} players[0] {$Else} Me {$EndIf} do
- begin
- {$IfNDef RS3} setLength(booleans, 100); setLength(strings,100); setlength(integers,100);{$endif}
- {$IfDef RS3}loginName{$Else}Name{$EndIf} := '';
- {$Ifdef RS3}password{$Else}pass{$EndIf} := '';
- {$IfDef RS3}isActive{$Else}Active{$EndIf} := True;
- {$IfDef RS3}location{$Else}strings[42]{$EndIf} := 'Bank'; //'Bank' if at VEB, 'Lost' if anywhere else
- Booleans[0] := True; //True if pick equipped or in toolbelt; Note: nothing else supported atm!
- end;
- //players.Setup(['wizzup'], PLAYER_FILE); //Replace 'wizzup' by your own character(s)
- //Players[0].Booleans[0] := True; // Is The Pick Equipped or in toolbelt or whatever?
- {
- Players[1].Name :='';
- Players[1].Pass :='';
- Players[1].Nick :=F'';
- Players[1].Active := True;
- Players[1].Loc := 'Bank';
- Players[1].Booleans[0] := True; // Is The Pick Equipped?
- Players[2].Name :='';
- Players[2].Pass :='';
- Players[2].Nick :='';
- Players[2].Active := True;
- Players[2].Loc := 'Bank';
- Players[2].Booleans[0] := True; // Is The Pick Equipped?}
- {
- Players[3].Name :='';
- Players[3].Pass :='';
- Players[3].Nick :='';
- Players[3].Active := True;
- Players[3].Loc := 'Bank';
- Players[3].Booleans[0] := True; // Is The Pick Equipped? }
- //Writeln( IntToStr ( length(players) ) + ' Players' );
- End;
- // Note: the first ~800 lines or so are just wrappers for other functions in the script
- // Don't worry about them, it's just laziness from my side to properly update it
- // They are ugly, unnecessary and overall just bad coding practice.
- {$ifdef RS3}
- (******************************************************************************)
- { SRL 5 compatibility library for use with SRL 6. For updating legacy scripts }
- var
- {mmx1, mmx2, mmy1, mmy2, }msx1, msy1, msx2, msy2, mmcx, mmcy, mscx, mscy,
- clickLeft, clickRight, __angle_i : integer;
- var
- SineArray, Cosearray: array[0..360] of Extended;
- pi_const : extended;
- function FindNormalRandoms : boolean; //Placeholder. Can be used for anything
- begin
- exitTreasure();
- //claimTicket();
- result := false;
- end;
- procedure FFlag(dist : integer);
- begin
- minimap.waitFlag(dist); //cbf to rewrite 90% of the script
- end;
- procedure MMouse(x, y, randomx, randomy : integer);
- begin
- Mouse(x, y, randomx, randomy, mouse_move);
- end;
- Procedure FNRWait(ms: Integer);
- Var
- T: Integer;
- Begin
- T := GetSystemTime;
- While GetSystemTime - T < ms Do
- Begin
- Wait(200);
- FindNormalRandoms;
- End;
- End;
- function IntToPoint(const px, py : integer) : tpoint;
- begin
- result.x := px;
- result.y := py;
- end;
- procedure SortATPAFrom(var a: T2DPointArray; const fx, fy : integer); overload;
- begin
- SortATPAFrom(a, IntToPoint(fx, fy));
- end;
- {
- function GetUpText : string; //I hope UpText is MouseOverText..
- begin
- result := getMouseOverText;
- end;
- }
- function WaitUpTextMulti(text : TStringArray; waittime : integer) : boolean;
- begin
- result := isMouseOverText(text, waittime);
- end;
- procedure ClickMouse2(left : boolean);
- begin
- if left then
- fastClick(mouse_left)
- else
- fastclick(mouse_right);
- end;
- function WaitOptionEx(action1, action2 : string; clickit, waittime : integer) : boolean;
- begin
- result := chooseOption.select([action1, action2], waittime);
- end;
- {
- function IsUptext(str : string) : boolean;
- begin
- result := isMouseOverText([str]);
- end;
- }
- function isFlagPresent : boolean;
- begin
- result := minimap.isFlagPresent;
- end;
- function MouseFlagEx(X, Y, rX, rY, Xmod, Ymod, FlagDist: Integer; //copied from srl 5.
- CheckForFlag, CheckForRoadColor: Boolean): Boolean;
- var
- I: Integer;
- P: TPoint;
- begin
- Result := False;
- if (minimap.isFlagPresent) then
- if (CheckForFlag) or (minimap.getFlagDistance <= FlagDist) then exit;
- P := Point(X - Xmod, Y - Ymod);
- Xmod := Max(Xmod, 3);
- Ymod := Max(Ymod, 3);
- for I := 0 to 4 do
- begin
- IncEx(P.X, Xmod + Random(rX));
- IncEx(P.Y, Ymod + Random(rY));
- if not pointInBox(P, minimap.GetBounds) then Continue;
- Mouse(P.X, P.Y, 0, 0, mouse_left);
- Result := WaitFunc(@isFlagPresent, 50, 3000);
- if (Result) then break;
- end;
- if (FlagDist > -1) then
- minimap.waitFlag(FlagDist);
- end;
- function MFF(X, Y, Xmod, Ymod: Integer): Boolean;
- begin
- Result := MouseFlagEx(X, Y, 3, 3, Xmod, Ymod, -1, True, False);
- end;
- function FindSymbol(var x, y : integer; symbolnumber : integer) : boolean; //Small change, not backwards compatible
- var
- p : tpoint;
- begin
- result := minimap.findSymbol(p, symbolnumber, minimap.getbounds());
- x := p.x;
- y := p.y;
- end;
- function FindSymbol(var p : tpoint; symbolnumber : integer) : boolean; overload;
- begin
- result := minimap.findSymbol(p, symbolnumber, minimap.getbounds());
- end;
- function InvCount : integer;
- begin
- result := tabBackpack.count;
- end;
- procedure LogOut;
- begin
- players[currentPlayer].logout();
- end;
- procedure Deposit(startslot, endslot : integer; depositall : boolean);
- var
- i : integer;
- bleuh : tintegerarray;
- begin
- setlength(bleuh, endslot-startslot+1);
- for i := startslot to endslot do
- bleuh[i-startslot] := i;
- bankscreen.deposit(bleuh, [], not depositall);
- end;
- procedure CloseBank;
- begin
- bankscreen.close();
- end;
- function InvFull : boolean;
- begin
- result := tabbackpack.isFull;
- end;
- procedure SetRun(run : boolean);
- begin
- minimap.toggleRun(run);
- end;
- function MFNF(X, Y, Xmod, Ymod: Integer): Boolean;
- begin
- Result := MouseFlagEx(X, Y, 3, 3, Xmod, Ymod, -1, False, False);
- end;
- procedure MakeCompass(direction : string);
- begin
- case lowercase(direction) of
- 'n': minimap.setAngle(MM_DIRECTION_NORTH);
- 'e': minimap.setAngle(MM_DIRECTION_EAST);
- 's': minimap.setAngle(MM_DIRECTION_SOUTH);
- 'w': minimap.setAngle(MM_DIRECTION_WEST);
- end;
- end;
- procedure LoginPlayer;
- begin
- players[currentplayer].login;
- end;
- function loggedin : boolean;
- begin
- result := isLoggedIn;
- end;
- function IsUpTextMultiCustom(text : tstringarray) : boolean;
- begin
- result := isMouseOverText(text);
- end;
- function IsUpTextMulti(text : tstringarray) : boolean;
- begin
- result := isMouseOverText(text);
- end;
- function ChooseOptionMulti(text : tstringarray) : boolean;
- begin
- result := chooseoption.select(text);
- end;
- function Cose(Degrees: Integer): Extended;
- begin
- Result := cosearray[Trunc(FixD(Degrees))];
- end;
- function Sine(Degrees: Integer): Extended;
- begin
- Result := sinearray[Trunc(FixD(Degrees))];
- end;
- procedure SRLRandomsReport;
- begin
- writeln('Thank you for using the SRL-5 compatibility library!');
- end;
- function CreateTPAFromText(Txt: string; Chars: string) : TPointArray;
- var
- w,h : integer;
- begin;
- result := TPAFromText(Txt,Chars,w,h);
- end;
- procedure NextPlayer(active : boolean);
- begin
- players.next(active);
- end;
- function FindColorsTolerance(var pts: TPointArray; col, x1, y1, x2, y2, tol: Integer; setts : tcolorsettings): Boolean; overload;
- begin
- result := findcolorstolerance(pts, col, inttobox(x1, y1, x2, y2), tol, setts);
- end;
- procedure Mouse(x, y, rx, ry : integer; left : boolean); overload;
- var
- clickityclick : integer;
- begin
- if left then
- clickityclick := MOUSE_LEFT
- else
- clickityclick := MOUSE_RIGHT;
- Mouse(x, y, rx, ry, clickityclick);
- end;
- procedure Mouse(p : Tpoint; rx, ry, mtype : integer); overload;
- begin
- Mouse(p.x, p.y, rx, ry, mtype);
- end;
- const //sorry but else my essminer doesnt work as it NEEDS these to be constants
- mmx1 = 577;
- mmy1 = 12;
- mmx2 = 798;
- mmy2 = 200;
- begin
- msx1 := mainscreen.getbounds.x1;
- msy1 := mainscreen.getbounds.y1;
- msx2 := mainscreen.getbounds.x2;
- msy2 := mainscreen.getbounds.y2;
- {mmx1 := minimap.getbounds.x1;
- mmy1 := minimap.getbounds.y1;
- mmx2 := minimap.getbounds.x2;
- mmy2 := minimap.getbounds.y2;}
- //mmcx := minimap.getcenterpoint.x;
- //mmcy := minimap.getcenterpoint.y;
- mmcx := 688;
- mmcy := 106;
- mscx := mainscreen.getcenterpoint.x;
- mscy := mainscreen.getcenterpoint.y;
- clickLeft := MOUSE_LEFT;
- clickRight := MOUSE_RIGHT;
- pi_const := Pi; // not necessary, but might as well.
- for __angle_i := 0 to 360 do
- begin
- Sinearray[__angle_i] := Sin(__angle_i * pi_const / 180.0);
- Cosearray[__angle_i] := Cos(__angle_i * pi_const / 180.0);
- end;
- end;
- { End of SRL-5 compatibility library. Hacked together by Markus }
- (******************************************************************************)
- {$endif}
- {$ifdef Aerolib}
- (******************************************************************************)
- { Aerolib SRL-6 Compatibility layer. Hacked together by Markus. }
- { Useful for backporting scripts from SRL-6 back to Aerolib. }
- function getColor(var p: TPoint): integer; overload;
- begin
- result := getColor(p.x, p.y);
- end;
- function getPixelShift(b: TBox; time: integer): integer; overload;
- begin
- result := PixelShift(b, time);
- end;
- procedure MMouse(x, y, randomx, randomy : integer);
- begin
- Mouse(IntToPoint(x, y), randomx, randomy, mouse_move);
- end;
- function getMouseOverText : string;
- begin
- result := getUpText;
- end;
- function isMouseOverText(st : TStringArray; t : integer) : boolean;
- begin
- result := waitUpTextMulti(st, t);
- end;
- procedure ClickMouse2(left : boolean);
- begin
- if left then
- fastClick(mouse_left)
- else
- fastclick(mouse_right);
- end;
- function FNRWait(WaitTime: Integer): Boolean; // ez
- begin
- result := WaitEx(waitTime);
- end;
- function FindNormalRandoms : boolean; //Placeholder. Can be used for anything
- begin
- result := foundRandoms();
- end;
- procedure LogOut; //seriously, why was this renamed >.<
- begin
- LogoutPlayer;
- end;
- function InvFull : boolean;
- begin
- result := isInvFull();
- end;
- procedure SetRun(run : boolean);
- begin
- toggleRunning(run);
- end;
- function MakeCompass(Direction: Variant): Boolean; //srsly why did you rename this.
- begin //Honestly, what are we doing here. Cheating or just random namechanges?
- result := setCompass(Direction);
- end;
- function loggedin : boolean;
- begin
- result := isLoggedIn;
- end;
- function InvCount : integer;
- begin
- result := getInvCount;
- end;
- function findDeformedBitmapToleranceIn(bmp: integer; var x, y: integer; searchBox: TBox; tolerance: integer; range: integer; allowPartialAccuracy: boolean; var accuracy: extended): boolean; overload;
- begin
- result := findDeformedBitmapToleranceIn(bmp, x, y, searchBox.x1, searchBox.y1, searchBox.x2, searchBox.y2, tolerance, range, allowPartialAccuracy, accuracy);
- end;
- procedure gaussBox(out p: TPoint; box: TBox); overload;
- begin
- gaussBox(p.x, p.y, box.x1, box.y1, box.x2, box.y2);
- end;
- function distance(pnt1, pnt2: TPoint): integer; overload;
- begin
- result := distance(pnt1.x, pnt1.y, pnt2.x, pnt2.y);
- end;
- //from srl-6, needed for portal finder
- procedure mouseOval(cx, cy, rx, ry, mouseAction: Integer = MOUSE_MOVE);
- var
- a: single;
- p: TPoint;
- begin
- a := randomE() * PI * 2;
- p.x := cx + round(cos(a) * randomRange(-rx, rx));
- p.y := cy + round(sin(a) * randomRange(-ry, ry));
- mouse(p, 0,0, mouseAction);
- end;
- procedure mouseOval(P: Tpoint; rx, ry, mouseAction: Integer = MOUSE_MOVE); overload;
- begin
- mouseOval(P.X, P.Y, rx, ry, mouseAction);
- end;
- function MouseFlagEx(X, Y, rX, rY, Xmod, Ymod, FlagDist: Integer; //copied from srl 5.
- CheckForFlag, CheckForRoadColor: Boolean): Boolean;
- var
- I: Integer;
- P: TPoint;
- begin
- Result := False;
- if (flagPresent) then
- if (CheckForFlag) or (flagDistance <= FlagDist) then exit;
- P := Point(X - Xmod, Y - Ymod);
- Xmod := Max(Xmod, 3);
- Ymod := Max(Ymod, 3);
- for I := 0 to 4 do
- begin
- IncEx(P.X, Xmod + Random(rX));
- IncEx(P.Y, Ymod + Random(rY));
- if not pointInBox(P, AREA_MM) then Continue;
- Mouse(P, 0, 0, mouse_left);
- Result := WaitFunc(@flagPresent, 50, 3000);
- if (Result) then break;
- end;
- if (FlagDist > -1) then
- FFlag(FlagDist);
- end;
- function MFF(X, Y, Xmod, Ymod: Integer): Boolean;
- begin
- Result := MouseFlagEx(X, Y, 3, 3, Xmod, Ymod, -1, True, False);
- end;
- function MFNF(X, Y, Xmod, Ymod: Integer): Boolean;
- begin
- Result := MouseFlagEx(X, Y, 3, 3, Xmod, Ymod, -1, False, False);
- end;
- (*
- Color.simba copied verbatim from SRL-6
- All credits to original developers
- *)
- (*
- type TColorSettings
- ~~~~~~~~~~~~~~~~~~~
- A record that provides easy access to the Simba CTS settings.
- *)
- type
- TColorSettings = record
- CTS: Integer;
- modifier: record
- hue, saturation, sensitivity: Extended;
- end;
- end;
- function colorSetting(_CTS:Integer): TColorSettings;
- var
- cs: TColorSettings;
- begin
- cs.CTS := _CTS;
- Result := cs;
- end;
- function colorSetting(_CTS:Integer; _hueModifier, _saturationModifier: Extended): TColorSettings; overload;
- var
- cs: TColorSettings;
- begin
- cs.create(_CTS, _hueModifier, _saturationModifier);
- Result := cs;
- end;
- function colorSetting(_CTS:Integer; _sensitivityModifier: Extended): TColorSettings; overload;
- var
- cs: TColorSettings;
- begin
- cs.create(_CTS, _sensitivityModifier);
- Result := cs;
- end;
- procedure TColorSettings.create(_CTS: Integer; _hueModifier, _saturationModifier: Extended);
- begin
- Self.CTS := _CTS;
- Self.modifier.hue := _hueModifier;
- Self.modifier.saturation := _saturationModifier;
- end;
- procedure TColorSettings.create(_CTS: Integer; _sensitivityModifier: Extended); overload;
- begin
- Self.CTS := _CTS;
- Self.modifier.sensitivity := _sensitivityModifier;
- end;
- procedure TColorSettings.retrieve();
- begin
- Self.CTS := GetToleranceSpeed();
- Self.modifier.sensitivity := GetToleranceSpeed3Modifier();
- GetToleranceSpeed2Modifiers(Self.modifier.hue, Self.modifier.saturation);
- end;
- procedure TColorSettings.apply();
- begin
- try
- SetColorToleranceSpeed(Self.CTS);
- SetToleranceSpeed2Modifiers(Self.modifier.hue, Self.modifier.saturation);
- SetToleranceSpeed3Modifier(Self.modifier.sensitivity);
- except
- writeln('failed setting CTS');
- end;
- end;
- function findColorTolerance(var x, y: integer; color: integer; searchBox: TBox; tolerance: integer): boolean; overload;
- begin
- result := FindColorTolerance(x, y, color, searchBox.x1, searchBox.y1, searchBox.x2, searchBox.y2, tolerance);
- end;
- function findColorTolerance(var x, y: Integer; color: integer; searchBox: TBox; tol: Integer; settings: TColorSettings): Boolean; overload;
- var
- cs: TColorSettings;
- begin
- cs.retrieve();
- settings.apply();
- Result := findColorTolerance(x, y, color, searchBox, tol);
- cs.apply();
- end;
- function findColorsTolerance(var points : TPointArray; const color : Integer; const searchBox: TBox; const tolerance : Integer): Boolean; overload;
- begin
- result := findColorsTolerance(points, color, searchBox.x1, searchBox.y1, searchBox.x2, searchBox.y2, tolerance);
- end;
- function findColorsTolerance(var points: TPointArray; color: integer; searchBox: TBox; tol: Integer; settings: TColorSettings): Boolean; overload;
- var
- cs: TColorSettings;
- begin
- cs.retrieve();
- settings.apply();
- Result := findColorsTolerance(points, color, searchBox, tol);
- cs.apply();
- end;
- function findColorSpiralTolerance(var x, y: integer; color: integer; searchBox: TBox; tol: integer): boolean; overload;
- begin
- result := findColorSpiralTolerance(x, y, color, searchBox.x1, searchBox.y1, searchBox.x2, searchBox.y2, tol);
- end;
- function findColorSpiralTolerance(var x, y: Integer; color: integer; searchBox: TBox; tol: Integer; settings: TColorSettings): Boolean; overload;
- var
- cs: TColorSettings;
- begin
- cs.retrieve();
- settings.apply();
- Result := findColorSpiralTolerance(x, y, color, searchBox, tol);
- cs.apply();
- end;
- function findColorsSpiralTolerance(var x, y: integer; var points: tpointarray; color: integer; searchBox: TBox; tolerance: integer): boolean; overload;
- begin
- result := findColorsSpiralTolerance(x, y, points, color, searchBox.x1, searchBox.y1, searchBox.x2, searchBox.y2, tolerance);
- end;
- function findColorsSpiralTolerance(x, y: Integer; var points: TPointArray; color: integer; searchBox: TBox; tol: Integer; settings: TColorSettings): Boolean; overload;
- var
- cs: TColorSettings;
- begin
- cs.retrieve();
- settings.apply();
- Result := findColorsSpiralTolerance(x, y, points, color, searchBox, tol);
- cs.apply();
- end;
- function countColorTolerance(Color: integer; searchBox: TBox; tol: integer): integer; overload;
- begin
- Result := CountColorTolerance(color, searchBox.x1, searchBox.y1, searchBox.x2, searchBox.y2, tol);
- end;
- function countColorTolerance(color: integer; searchBox: TBox; tol: Integer; settings: TColorSettings): integer; overload;
- var
- cs: TColorSettings;
- begin
- cs.retrieve();
- settings.apply();
- Result := countColorTolerance(color, searchBox, tol);
- cs.apply();
- end;
- function findBitmapTolerance(const bmp: integer; var x, y: integer; const tolerance: integer): boolean;
- var
- w, h: integer;
- begin
- getClientDimensions(w, h);
- result := findBitmapToleranceIn(bmp, x, y, 0, 0, w-1, h-1, tolerance);
- end;
- function findBitmapTolerance(const bmp: integer; var x, y: integer; const tolerance: integer; settings: TColorSettings): boolean; overload;
- var
- cs: TColorSettings;
- begin
- cs.retrieve();
- settings.apply();
- result := findBitmapTolerance(bmp, x, y, tolerance);
- cs.apply();
- end;
- function findDTMRotated(DTM: Integer; var x, y: integer; searchBox: TBox; sAngle, eAngle, aStep: extended; out aFound: extended): boolean; overload;
- begin
- result := FindDTMRotated(DTM, x, y, searchBox.x1, searchBox.y1, searchBox.x2, searchBox.y2, sangle, eangle, astep, afound);
- end;
- {$EndIf}
- ////////////////////////////////////////////////////////////////////////////////
- // Below here, the script itself starts. There should be no reason to touch //
- ////////////////////////////////////////////////////////////////////////////////
- //Constants. All colors etc. are constant so we can easily swap between RS3/OSRS
- const
- DOOR_DENSITY = 0.4; //tweakme
- SPS_MAP_DL_LINK = 'http://i.imgur.com/qDG7TSu.png';
- SPS_DWMAP_DL_LINK = 'http://i.imgur.com/fpJEeqj.png';
- SMARTDEBUGLINES = 7; //Amount of lines -1 you want at your screen.
- MAX_DIST_DIFF_SPS_Sym = 20; // How much difference do we allow SPS to have?
- AUBURY_DIST_TH = 18; // How much until we are out of store?
- BANKER_CLICK_TH = 5; //When do we click bankers?
- // You better leave these alone, they are important
- SHOP_WALK_INSIDE = $DEADBEEF;
- SHOP_WALK_OUTSIDE = 1337;
- SHOP_WALK_NOT = 42;
- { Bank booth in VEB }
- BOOTH_COLOUR = 1394024;
- BOOTH_TOL = 3;
- BOOTH_HUE = 0.13;
- BOOTH_SAT = 2.11;
- { Banker NPC in VEB (purple ones) }
- BANKER_COLOUR = 5517369;
- BANKER_TOL = 12;
- BANKER_HUE = 0.20;
- BANKER_SAT = 0.48;
- { Door Aubury }
- DOOR_COLOR = 3164257;
- DOOR_TOL = 10;
- DOOR_CTS = 2;
- DOOR_MOD1 = 0.11;
- DOOR_MOD2 = 0.82;
- {$IfDef RS3}
- MIDDLE_MINE_COLOR = 7369063;
- BANK_AUBURY_WAITTIME = 2000;
- { Pretty clear what these are, right? }
- MAGE_SYMBOL_COLOR = 13456947;
- TRANSPORT_SYMBOL_COLOR = 1805019;
- { Aubury himself }
- // Note: these are pretty bad at RS3. FIXME
- {AUBURY_NPC_COLOR = 10328226;
- AUBURY_NPC_TOL = 12;
- AUBURY_NPC_CTS = 2;
- AUBURY_NPC_MOD1 = 1.16;
- AUBURY_NPC_MOD2 = 0.36;}
- ESS_OBJ_COLOR = 10329774;
- ESS_OBJ_CTS = 2;
- ESS_OBJ_MOD1 = 0.15;
- ESS_OBJ_MOD2 = 0.40;
- AUBURY_NPC_COLOR = 10657196;
- AUBURY_NPC_TOL = 32;
- AUBURY_NPC_CTS = 0;
- AUBURY_NPC_MOD1 = 0.40;
- AUBURY_NPC_MOD2 = 0.48;
- AUBURY_MIN_RATIO = 0.5;
- AUBURY_MAX_RATIO = 2.0;
- AUBURY_MIN_POINTS = 3;
- {$Else}
- MIDDLE_MINE_COLOR = 8487563;
- BANK_AUBURY_WAITTIME = 12000;
- MAGE_SYMBOL_COLOR = 1714669; // grabbed from Aerolib
- TRANSPORT_SYMBOL_COLOR = 2779884;
- ESS_OBJ_COLOR = 8618897;
- ESS_OBJ_CTS = 2;
- ESS_OBJ_MOD1 = 0.08;
- ESS_OBJ_MOD2 = 0.17;
- AUBURY_NPC_COLOR = 1686228; //Need to optimize this
- AUBURY_NPC_TOL = 10;
- AUBURY_NPC_CTS = 1;
- AUBURY_NPC_MOD1 = 0.2; //dont matter for cts1 but included for syntax compat.
- AUBURY_NPC_MOD2 = 0.2;
- {$EndIf}
- var
- m_DebugLine : array [0..SMARTDEBUGLINES] of string;
- lostReasons : TStringArray;
- procedure m_DrawSmartLines;
- {$IFDEF SMARTDRAW}
- var i : integer;
- begin
- for i := 0 to SMARTDEBUGLINES do
- SMART_DrawTextEx(false,15,(SMARTDEBUGLINES-i)*18+50, SmallChars, m_DebugLine[i], clLime);
- {$ELSE}
- begin
- {$ENDIF}
- end;
- procedure m_Debug(s : string);
- var i : integer;
- begin
- {$IFDEF SMARTDRAW}
- for i := SMARTDEBUGLINES downto 1 do
- m_DebugLine[i] := m_DebugLine[i-1];
- m_DebugLine[0] := s;
- if (not SMART_DebugSetup) then
- SMART_SetupDebug;
- SMART_ClearCanvas;
- m_DrawSmartLines;
- {$ENDIF}
- writeln(s);
- end;
- //SRL's flag procedure isn't great IMO, this function uses pixelshift to check
- // when we stopped moving.
- procedure MFlag; //Working
- var
- t : integer;
- begin
- FFlag(5);
- t := GetSystemTime;
- while (GetSystemTime-t) < 7500 do
- if (getPixelShift({$ifdef rs3}minimap.getBounds{$else} AREA_MM {$endif}, 200)) < 1000 then //1000 should do
- break;
- end;
- // The function will return True if the point x,y is inside the polygon, or
- // False if it is not.
- //
- // Original C code: http://www.visibone.com/inpoly/inpoly.c.txt
- //
- // Translation from C by Felipe Monteiro de Carvalho
- //
- // License: Public Domain
- // Sourced from: http://wiki.freepascal.org/Geometry_in_Pascal
- function IsPointInPolygon(A : TPoint; APolygon: array of TPoint): Boolean;
- var
- xnew, ynew: Cardinal;
- xold,yold: Cardinal;
- x1,y1: Cardinal;
- x2,y2: Cardinal;
- i, npoints: Integer;
- inside: Integer = 0;
- begin
- Result := False;
- npoints := Length(APolygon);
- if (npoints < 3) then Exit;
- xold := APolygon[npoints-1].X;
- yold := APolygon[npoints-1].Y;
- for i := 0 to npoints - 1 do
- begin
- xnew := APolygon[i].X;
- ynew := APolygon[i].Y;
- if (xnew > xold) then
- begin
- x1:=xold;
- x2:=xnew;
- y1:=yold;
- y2:=ynew;
- end
- else
- begin
- x1:=xnew;
- x2:=xold;
- y1:=ynew;
- y2:=yold;
- end;
- if (((xnew < A.X) = (A.X <= xold)) // edge "open" at left end
- and ((A.Y-y1)*(x2-x1) < (y2-y1)*(A.X-x1))) then
- begin
- inside := not inside;
- end;
- xold:=xnew;
- yold:=ynew;
- end;
- Result := inside <> 0;
- end;
- function MiddlesTPA(atpa : TPointArrayArray) : TPointArray;
- var
- i : integer;
- begin
- setlength(result, length(atpa));
- for i := 0 to high(atpa) do
- result[i] := MiddleTPA(atpa[i]);
- end;
- //Lape already exports a Randomize. I don't like that one so let's abuse one of Lape's features:
- //overload allows you to define functions with the same name but different parameters
- Function Randomize(x, Randomness: Integer): Integer; {$ifdef lape} overload; {$endif}
- Begin
- Result := RandomRange(X - Randomness, X + Randomness);
- End;
- function getPlayerStatus : string;
- begin
- result := {$IfDef RS3} players[currentPlayer].location {$else} Me.strings[42]; {$EndIf}
- end;
- procedure setPlayerStatus(state : string; lostreason : string = '');
- begin
- {$IfDef RS3} players[currentplayer].location {$else} Me.strings[42] {$EndIf} := state;
- if lostreason <> '' then
- begin
- setLength(lostReasons, length(LostReasons)+1);
- lostReasons[high(lostReasons)] := lostreason;
- end;
- end;
- //Working RS3, OSRS
- //Of all of Wizzup's functions in this script, this one changed the least: just one line.
- Function FindBankers(Var Bank: TPoint; Var Angle: Extended): Boolean;
- Var
- I: Integer;
- B, gB: TPointArray;
- aTPA: T2DPointArray;
- Begin
- Result := False;
- //FindColorsSpiralTolerance(MMCX, MMY2, B, 785125, MMX1, MMY1, MMX2, MMY2, 0);
- {$IfDef RS3}
- B := minimap.getDots(MM_DOT_NPC, minimap.getbounds); //Use SRL function = better :) This is the only line I changed.
- {$Else}
- B := getMiniMapDots('NPC');
- {$EndIf}
- aTPA := SplitTPA(B, 10);
- SortATPASize(aTPA, True);
- If Length(aTPA) = 0 Then
- Exit;
- B := aTPA[0];
- For I := 0 To High(B) - 1 Do
- Begin
- If (Abs(B[I].Y - B[I + 1].Y) < 15) And (Abs(B[I].X - B[I + 1].X) < 60) Then
- Begin
- SetLength(gB, Length(gB) + 1);
- gB[High(gB)] := B[I];
- If High(gB) > 3 Then // 4 bankers.
- Begin
- Bank := MiddleTPA(gB);
- Bank.Y := Bank.Y - 8; //second changed line, 5 to 8.
- Angle := Degrees(ArcTan2(gB[0].y - gB[High(gB)].y, gB[0].x - gB[High(gB)].x)) + 90;
- If Angle < 0 Then
- Angle := 90 - (Angle * -1) + 270;
- Result := True;
- Exit;
- End;
- End
- Else
- SetLength(gB, 0);
- End;
- End;
- //Working RS3
- //Based on SRL's getSymbolColor
- function MarkusFindSymbol(var p : tpoint; symbolbmp, symbolcolor : integer) : boolean;
- var
- acc : extended;
- c : integer;
- begin
- if (findDeformedBitmapToleranceIn(symbolbmp, p.x, p.y, {$ifdef rs3}minimap.getbounds(){$else}inttobox(mmx1,mmy1+5,mmx2,mmy2){$endif}, 70, 0, true, acc)) then
- begin
- if (acc > {$ifdef rs3}minimap.{$endif}symbolAccuracy) then
- repeat
- c := c + 5;
- // look for the symbol's color in a small box around where the bitmap was found
- if (findColorTolerance(p.x, p.y, symbolcolor, p.x, p.y, p.x + 15, p.y + 5, c)) then
- begin
- result := getColor(p.x, p.y);
- if (result > 0) then
- begin
- m_debug('Found symbol at '+toStr(p));
- result := true;
- exit;
- end;
- end;
- until(c > 70); // max tolerance
- end;
- end;
- //Working RS3
- {$IfDef RS3}
- function FindMagicSymbol(var p : TPoint) : boolean;
- begin
- result := MarkusFindSymbol(p, MageSymbolBMP, MAGE_SYMBOL_COLOR);
- end;
- {$Else}
- // Taken from Essence miner 3.11; Should be rock solid
- // Magic symbol finder from SRL-5/Aerolib is pretty crap
- Function FindMagicSymbol(Var P: TPoint): Boolean;
- //Could do something nice with the black offset here...
- Var
- I, J, cts: Integer;
- Points, P2: TPointArray;
- aTPA: T2DPointArray;
- MagicSymbolColors, C: TIntegerArray;
- H, S, L: Extended;
- Begin
- cts := GetColorToleranceSpeed;
- ColorToleranceSpeed(2);
- SetColorSpeed2Modifiers(0.20, 2.0);
- Result := False;
- MagicSymbolColors := [2326527, 2925567];
- SetLength(Points, 0);
- For I := 0 To High(MagicSymbolColors) Do
- Begin
- SetLength(P2, 0);
- SetLength(C, 0);
- FindColorsTolerance(P2, MagicSymbolColors[I], MMX1, MMY1, MMX2, MMY2, 18);
- C := GetColors(P2);
- For J := 0 To High(C) Do
- Begin
- ColorToHSL(C[J], H, S, L);
- //If ((H > 8.5) And (H < 9.5)) Or ((H > 5.5) And (H < 7.5)) Then
- If (((H > 5.5) And (H < 10.0)) Or (H < 1.0)) And (S > 85.0) Then //HSL autocolouring
- Begin
- SetLength(Points, Length(Points) + 1);
- Points[High(Points)] := P2[J];
- End;
- End;
- //Points := CombineTPA(Points, P2);
- End;
- {$IFDEF SMARTDRAW} try SMART_DebugTPA(false, Points); except end; {$ENDIF}
- ColorToleranceSpeed(cts);
- aTPA := SplitTPA(Points, 5);
- SortATPASize(aTPA, True);
- If Length(aTPA) = 0 Then
- Exit;
- Result := Length(aTPA[0]) > 2;
- P := MiddleTPA(aTPA[0]);
- If Not Result Then
- m_Debug('No Aubury Shop Symbol');
- End;
- {$EndIf}
- //Working RS3, OSRS
- function FindTransportSymbol(var p : TPoint) : boolean;
- begin
- {$ifdef rs3}
- result := MarkusFindSymbol(p, TransportSymbolBMP, TRANSPORT_SYMBOL_COLOR);
- {$else}
- result := findSymbol(p, SYMBOL_Transportation);
- {$endif}
- end;
- //Working RS3, OSRS
- Function AtMine: Boolean; //Counts the black to see if we are in the mine
- Var
- TPA: TPointArray;
- Begin
- FindColorsTolerance(TPA, 65536, {$ifdef rs3}minimap.getbounds{$else} AREA_MM {$endif}, 7, colorSetting(0));
- Result := Length(TPA) > 2000;
- End;
- //Working RS3, OSRS
- function InAuburyStore : boolean;
- begin
- result := false;
- if (AtMine) then
- exit;
- {$ifdef rs3}
- result := IsPointInPolygon(sps.getplayerpos, AuburyShopPolygon);
- {$else}
- result := IsPointInPolygon(RSW.getMyPos(), AuburyShopPolygon);
- {$EndIf}
- end;
- //Broken
- Function DoorClosedWizzup: Boolean;
- //Note, this doorfinder is the shittiest mankind has ever invented, it only works
- // 1% of the time, IF you are lucky.
- Var
- TP: TPoint;
- TPA: TPointArray;
- aTPA: T2DPointArray;
- I, c: Integer;
- Begin
- Result := False;
- //c := GetColorToleranceSpeed;
- //ColorToleranceSpeed(2);
- //SetColorspeed2Modifiers(0.2, 0.5);
- FindColorsTolerance(TPA, 5208714, inttobox(3, 3, 515, 336), 8, colorSetting(2, 0.2, 0.5));
- //aTPA := TPAToATPAEx(TPA, 50, 50);
- aTPA := SplitTPA(TPA, 3);
- SortATPAFrom(aTPA, IntToPoint(mscx, mscy)); //noob Wizzup forgot this one -.-'
- For I := 0 To {min(15, }High(aTPA) Do // (dont) limit amount of clicks
- Begin
- If Length(aTPA[I]) < 320 Then
- Continue;
- TP := MiddleTPA(aTPA[I]);
- MMouse(TP.X, TP.Y, 0, 0);
- Wait(200);
- If IsUpText('pen') And IsUpText('oor') Then
- Begin
- Result := True;
- Mouse(TP, 0,0, mouse_left);
- m_debug('Door opened with Wizzup? doorfinder. Call the news.');
- //FFlag(0);
- MFlag;
- Break;
- End;
- End;
- //ColorToleranceSpeed(c);
- //SetColorspeed2Modifiers(0.2, 0.2);
- End;
- //Working RS3, sort-of working OSRS
- //Wrote a new one for 4.0
- //Not as genius anymore, but effective.
- function DoorClosedGenius : boolean;
- var
- TPABox, SearchBox : TBox;
- CharTPA : TPointArray;
- TPA : TPointArray;
- ATPA : T2DPointArray;
- i, k : integer;
- t : Integer;
- begin
- MFlag;
- wait(1500+random(500)); //it missed the door once
- {$IfDef RS3}
- SearchBox.x1 := (Mainscreen.getBounds().x2-Mainscreen.getBounds().x1) div 4 +
- MainScreen.getbounds.x1;
- SearchBox.x2 := Mainscreen.getBounds.x2 - (Mainscreen.getBounds().x2-Mainscreen.getBounds().x1) div 4;
- SearchBox.y1 := Mainscreen.getBounds.y1+5;
- SearchBox.y2 := mainscreen.getBounds.y2-5;
- {$Else}
- SearchBox := IntToBox( (MSX2-MSX1) div 4 + MSX1, MSY1, MSX2 - ((MSX2-MSX1) div 4), MSY2-5);
- {$EndIf}
- t := GetSystemTime;
- FindColorsTolerance(TPA, DOOR_COLOR, SearchBox, DOOR_TOL, colorSetting(DOOR_CTS, DOOR_MOD1, DOOR_MOD2));
- aTPA := SpliTTPA(TPA, 4); //split it baby
- for i := 0 to high(atpa) do //Calculate TPA density
- begin
- TPABox := atpa[i].getbounds;
- if ((Extended(length(atpa[i])) / Extended(1+((TPABox.x2-TPAbox.x1) * (TPABox.y2 - TPABox.y1)))) < DOOR_DENSITY) then
- begin
- //Density too low!
- tpa := ClearTPAFromTPA(tpa, atpa[i]);
- end;
- end;
- ATPA := splittpa(TPA, 5); //Now with all invalid points, split the TPA in actual groups
- m_debug('Found around '+ToStr(length(ATPA))+' candidates.');
- SetLength(tpa, 0);
- SetLength(tpa, length(atpa));
- for i:= 0 to high(atpa) do //Calculate middles
- tpa[i] := MiddleTPA(atpa[i]);
- m_Debug('Finding, calculating and filtering took '+tostr(GetSystemTime-t)+' ms.'); //Usually < 700ms Pascalscript. Lape probably way faster
- SortTPAFrom(TPA, {$IfDef RS3}mainscreen.getcenterpoint {$Else} MSCP {$EndIf});
- For I := 0 To min(High(TPA), 5) Do //And interate them!
- Begin
- MMouse(TPA[i].X, TPA[i].Y, 0, 0);
- Wait(200+random(50));
- writeln('UT: '+getMouseOverText);
- If isMouseOverText(['Door'], 250) Then
- begin
- m_debug('Door found, is it closed?');
- If isMouseOverText(['pen'], 0) then
- Begin
- Result := True;
- ClickMouse2(true);
- m_debug('Door opened with the genius2 doorfinder.');
- MFlag;
- exit;
- End else //Else, the door is already closed
- begin
- writeln('not open bcz: '+getMouseOverText);
- m_debug('door already open so not clicked genius2');
- result := true;
- exit;
- end;
- end;
- End;
- end;
- // Broken RS3, OSRS
- function DoorClosedDTM : boolean;
- //I dont want too many DTMs in here, but Demise likes them so much
- //and if she does the hard work, why would I? ;)
- // 2012-10-12:I made my own DTM so I did the hard work xD Pretty accurate though (IF it finds it).
- var
- x, y : integer;
- aFound : extended;
- begin
- result := False;
- exit; //It does't work anyways
- if FindDTMRotated(DTMAuburyDoor, x, y, msx1, msy1, msx2, msy2, -Pi/4, Pi/4, Pi/60, aFound) then
- begin
- MMouse(x, y, 5, 5);
- if WaitUpTextMulti(['Open', 'Door', 'pen D', 'oor'], 500) then //Some small tweaks
- begin
- Result := True;
- ClickMouse2(true);
- m_debug('Door opened with DTM!');
- //Ok, now I need something that puts text in checkbox
- //ExamineInv; //Inventory is empty lololol
- MFlag;
- exit;
- end;
- end;
- m_debug('Door DTM (MS) not found.');
- end;
- //Working OSRS, srsly shit at RS3 (thanks SPS)
- function CalibrateDoor : boolean;
- var
- p, p2: TPoint;
- begin
- m_debug('Calibrating door.');
- result := False;
- {$IfDef RS3}
- if SPS_PosToMM(Point(281, 236), sps.GetPlayerPos, p) then
- if FindMagicSymbol(p2) then
- if (distance(p, p2) > 44) then //44 = 11 tiles
- begin
- result := True;
- m_debug('Calibrated using magic symbol cause distanc is like '+toStr(distance(p, p2)));
- Mouse(Point(p2.x, p2.y+15), mouse_Left);
- MFlag;
- exit;
- end
- result := sps.WalkToPos(Point(281, 236));
- {$Else}
- result := RSW.WalkPath([Point(4820, 2857)]);
- {$EndIf}
- MFlag;
- end;
- //Working RS3, OSRS
- Function FindArrow: Boolean;
- Var
- p : tpoint;
- Begin
- Result := False;
- { If NewAutoColorWorked Then //always returns false
- If FindColor(x, y, srl_AutoGetColor('transport'), MMX1, MMY1, MMX2, MMY2) Then //Kicked new autocolor out
- Begin //Note to self: USE THE BLACK =)
- Result := True;
- WriteLn('Succesfully used NewAutoColor for FindArrow');
- End; }
- If Not Result Then
- If FindTransportSymbol(p) Then
- Result := True;
- If Result Then
- Begin
- Mouse(IntToPoint(p.x, p.y{$ifdef rs3}+15{$endif}), 4, 4, mouse_Left); //rs3 needs small offset
- Wait(1000);
- //FFlag(0);
- MFlag;
- FNRWait(1000);
- End;
- End;
- Function EssenceCount: Integer;
- {$IfNDef RS3}
- var
- essence : TItem;
- {$EndIf}
- Begin
- {$IfDef RS3}
- result := tabBackpack.countDTM(EssenceDTM);
- {$Else}
- essence.DTM := EssenceDTM;
- result := essence.getAmount(true);
- {$EndIf}
- End;
- //Working RS3, OSRS
- function mayorObjectFinder(excludeSmall: boolean; hue, sat: extended; W, H, colour, tolerance, clickType: Integer; mouseOverText, chooseOptions: array of string): boolean;
- var
- i, x, y: integer;
- p: TPoint;
- TPA: TPointArray;
- ATPA: T2DPointArray;
- begin
- if not isLoggedIn() then
- exit;
- findColorsSpiralTolerance(x, y, TPA, colour, {$IfDef RS3}mainScreen.getBounds(){$Else} AREA_MS {$EndIf}, tolerance, colorSetting(2, hue, sat));
- if (Length(TPA) < 1) then exit;
- ATPA := TPAtoATPAEx(TPA, W, H);
- SortATPAFromMidPoint(ATPA,{$IfDef RS3}mainscreen.playerPoint {$Else} MSCP {$EndIf});
- {$ifdef smartdraw}
- smartImage.debugATPA(ATPA);
- {$endif}
- for i := 0 to high(ATPA) do
- begin
- if excludeSmall then
- if length(ATPA[i]) < W then
- continue;
- mouse(MiddleTPA(ATPA[i]), 0,0, MOUSE_MOVE);
- if isMouseOverText(mouseOverText, 500) then
- begin
- fastClick(ClickType);
- if clickType = MOUSE_LEFT then
- begin
- {$ifdef smartdraw}
- smartImage.clearArea(mainscreen.getBounds());
- {$endif}
- exit(true);
- end;
- if {$ifdef rs3}chooseOption.select(chooseOptions) {$else} chooseOptionMulti(chooseOptions) {$endif} then
- begin
- {$ifdef smartdraw}
- smartImage.clearArea(mainscreen.getBounds());
- {$endif}
- exit(true);
- end else
- begin
- gaussBox(p, {$IfDef RS3}mainscreen.getBounds(){$Else} AREA_MS {$EndIf});
- mmouse(p.x, p.y,0,0);
- end;
- end;
- end;
- end;
- //Working RS3, OSRS
- function FindAuburyStore(var p : tpoint) : boolean;
- var
- p2 : TPoint;
- begin
- {$IfDef RS3}
- result := SPS_PosToMM(AuburyCenter, sps.GetPlayerPos, p);
- {$Else}
- result := RSW.PointToMM(RSW.getMyPos(), AuburyCenter, p);
- {$EndIf}
- if (not(result)) then
- result := FindMagicSymbol(p)
- else
- if FindMagicSymbol(p2) then
- begin
- p2.y := p2.y + 10;
- if distance(p, p2) > MAX_DIST_DIFF_SPS_Sym then
- begin
- p := p2; // I trust magic symbol more than
- m_debug('sps fucked up so we used magic symbol');
- end;
- end;
- {$IfNDef RS3}
- if P.y < 15 then
- result := false;
- {$EndIf}
- end;
- //"Working" RS3, OSRS (sort-of)
- function DoorClosed(walk : integer = SHOP_WALK_NOT) : boolean;
- var
- openedDoor : boolean;
- //'Kapstopfunctie'
- var
- p : TPoint;
- begin
- result := False;
- openedDoor := false; // to fix a bug.
- m_Debug('Opening door!');
- if not CalibrateDoor then
- begin
- m_Debug('No calibrate door! but trying regardless because why not.');
- //exit;
- end;
- if DoorClosedDTM then //Most accurate, no weird mouse movements, never works though
- openedDoor := True
- else if DoorClosedGenius then //Very high success rate but takes one or two mouse movements
- openedDoor := True
- else if DoorClosedWizzup then //utter crap
- openedDoor := True;
- result := openedDoor;
- writeln('Door opener result', result);
- if (openedDoor) then
- if (walk = SHOP_WALK_INSIDE) then
- if FindAuburyStore(p) then
- begin
- m_debug('Walking inside');
- mouse(p, 4, 4, mouse_Left);
- MFlag;
- end else
- begin
- m_debug('We are supposed to walk in the store but could not find it.');
- end;
- end;
- //Working RS3, OSRS
- function openBankMayor() : boolean; //If he uses Wizzup's banker NPC finder (uncredited), I can use his bankfinder right? ;)
- var
- bankTimer: {$IfDef RS3}TTimeMarker{$Else}Timer{$EndIf};
- p: TPoint;
- angle: extended;
- begin
- bankTimer.start();
- result := false;
- m_debug('Opening Varrock East Bank');
- repeat
- if (not isLoggedIn) or {$ifdef rs3}bankScreen.isOpen(){$else} isBankOpen{$endif} or {$ifdef RS3} pinScreen.isOpen() {$Else} Interfaces[PINSCREEN].isVisible() {$EndIf} then
- exit;
- {$IfDef RS3}minimap.waitFlag(5);
- minimap.waitPlayerMoving(350);
- {$Else}
- FFlag(5);
- walkingToFlag(350);
- {$EndIf}
- if mayorObjectFinder(true, BOOTH_HUE, BOOTH_SAT, 45, 33, BOOTH_COLOUR, BOOTH_TOL, MOUSE_LEFT, ['ooth', 'ank boo'], ['ank Bank']) then
- if {$ifdef RS3}(bankScreen.isOpen(5000)) or (pinScreen.isOpen(5000)) {$else} Interfaces[PINSCREEN].waitVisible(5000) or Interfaces[BANKSCREEN].waitVisible(5000) {$endif} then
- begin
- result := true;
- exit;
- end;
- if mayorObjectFinder(true, BANKER_HUE, BANKER_SAT, 20, 20, BANKER_COLOUR, BANKER_TOL, MOUSE_RIGHT, ['anker', 'ank Ban'], ['ank Bank']) then
- if {$ifdef RS3}(bankScreen.isOpen(5000)) or (pinScreen.isOpen(5000)) {$else} Interfaces[PINSCREEN].waitVisible(5000) or Interfaces[BANKSCREEN].waitVisible(5000) {$endif} then
- begin
- result := true;
- exit;
- end;
- if findBankers(p, angle) then
- if distance(p, point(mmcx, mmcy)) > BANKER_CLICK_TH then
- mouse(p,0,0, MOUSE_LEFT)
- else
- begin
- {$IfDef RS3}
- minimap.setAngle(randomRange(35, 50));
- {$Else}
- setAngle(randomRange(35,50));
- {$EndIf}
- end;
- until ({$ifdef rs3}bankTimer.getTime(){$else} bankTimer.timeElapsed(){$endif} > 120000) or (not isLoggedIn());
- result := false;
- end;
- //Working RS3, OSRS
- //Semi-working, needs a small difference
- Procedure Bank(attempts : integer = 0);
- Var
- I: Integer;
- P: TPoint;
- A: Extended;
- TempEss: Integer;
- Begin
- //ReportVars[1] := ReportVars[1] + 1; // Banks
- if getPlayerStatus = 'Aubury' then
- exit;
- if (attempts > 8) then
- begin
- setPlayerStatus('Lost', 'No open bank');
- exit;
- end;
- MFlag;
- wait(1200+random(700)); //Small wait is worth it: makes it not misclick the bankers
- //Players[CurrentPlayer].Banked := Players[CurrentPlayer].Banked + 1;
- For I := 0 To 2 Do
- If OpenBankMayor Then //All of SRL's bankfinding is crap but I don't feel like making my own
- Break
- Else
- If FindBankers(P, A) Then
- Begin
- Mouse(p, 0, 0, mouse_left);
- //Wait(4000);
- //FFlag(0);
- MFlag;
- Wait(1500);
- End;
- m_debug('Bank opened!');
- if FindNormalRandoms then
- if (not({$ifdef rs3}bankScreen.isOpen(){$else} isBankOpen{$endif} or {$ifdef RS3} pinScreen.isOpen() {$Else} Interfaces[PINSCREEN].isVisible() {$EndIf})) then
- begin
- Bank(attempts+1); //RECURSION! :p
- exit;
- end;
- If Not {$ifdef rs3}bankScreen.isOpen(){$else} isBankOpen{$endif} or {$ifdef RS3} pinScreen.isOpen() {$Else} Interfaces[PINSCREEN].isVisible() {$EndIf} Then
- Begin
- //LogOut;
- setPlayerStatus('Lost', 'No Bank');
- //{$ifdef rs3}Players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'NoBank';
- //{$ifdef rs3}Players[CurrentPlayer].isActive {$else} Players[CurrentPlayer].Active {$endif} := False;
- Exit;
- End;
- //if PinScreen.isOpen then //fuck bankpins, not supported from now on.
- // PinScreen.enter(players[0].bankPin);
- TempEss := EssenceCount; //Move this one
- EssenceMined := EssenceMined + TempEss;
- {$IfDef RS3}
- Players[CurrentPlayer].Integers[0] := Players[CurrentPlayer].Integers[0] + TempEss;
- bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
- Inc(Players[CurrentPlayer].Integers[69]);
- {$Else}
- Me.Integers[0] := Me.Integers[0] + TempEss;
- quickDeposit('inv');
- Inc(Me.Integers[69]);
- {$EndIf}
- //if (random(3) = 1) then //RS3 makes it necessary to close it all the time
- {$IfDef RS3}
- CloseBank;
- {$Else}
- closeInterface();
- {$EndIf}
- End;
- // Working RS3, OSRS
- Procedure BankToAubury; //need to add a dtm to this, symbol really isnt accurate at all
- Var
- V: TPoint;
- T: Integer;
- S : String;
- Begin
- if (InvFull) then
- Bank;
- FindNormalRandoms;
- T := getsystemtime;
- {$IfDef RS3}
- //if (minimap.getrunenergy() < 40) then //too bad!
- // RestUntil(85+random(16));
- // No resting in SRL-6??
- {$EndIf}
- SetRun(True);
- {$IfDef RS3}
- if (not(sps.walkToPos(AuburyCenter))) then
- {$Else}
- if (RSW.PointToMM(RSW.GetMyPos(), AuburyCenter, V)) then
- RSW.walkPath([AuburyCenter])
- else
- {$EndIf}
- begin
- m_debug('Could not walk to store using SPS/RSW.'); //Expected for OSRS btw.
- T := GetSystemTime;
- MFNF(Randomize(mmcx+6, 4), Randomize(mmcy+140-85, 4), -1, -1);
- MFlag;
- //Walk is indeed something ike 10, 15 seconds
- //As flag isn't visible, this is the right way to do it
- Wait(BANK_AUBURY_WAITTIME);
- MFlag;
- While (GetSystemTime - T < 60000) Do
- Begin
- FindNormalRandoms;
- //If the store is found we can exit.
- If FindAuburyStore(V) Then
- begin
- MFNF(Randomize(V.x, 4), Randomize(V.y, 4), -1, -1);
- Break;
- end else
- m_debug('Could not find store after click to Aubury...');
- Wait(500);
- End;
- end;
- //60 sec killswitch again, he seems to love those
- MFlag;
- If GetSystemTime - T >= 60000 Then
- Begin
- WriteLn('BankToAuburyTime');
- //{$ifdef rs3} players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'Lost';
- setPlayerStatus('Lost', 'Bank to Aubury');
- //LogOut;
- Exit;
- End;
- MFlag;
- //{$ifdef rs3} Players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'NearAubury';
- setPlayerStatus('NearAubury');
- T3 := GetSystemTime;
- End;
- // Portal Finders
- //DISABLED
- //NKN
- {
- SetSymbol is the lower portion of the minimap symbol. Looks like a down arrow, the very bottom tip of it.
- This simply sets a ddtm.
- }
- function SetSymbol: Integer;
- var
- dtmMainPoint: TSDTMPointDef;
- dtmSubPoints: TSDTMPointDefArray;
- TempTDTM: TSDTM;
- begin
- //result := 0;
- //exit;
- //DISABLED
- SetArraylength(dtmSubPoints,5);
- dtmMainPoint.x := 2803;
- dtmMainPoint.y := 375;
- dtmMainPoint.AreaSize := 0;
- dtmMainPoint.AreaShape := 0;
- dtmMainPoint.Color := 12552820;
- dtmMainPoint.Tolerance := 40;
- dtmSubPoints[0].x := 2803;
- dtmSubPoints[0].y := 375;
- dtmSubPoints[0].AreaSize := 0;
- dtmSubPoints[0].AreaShape := 0;
- dtmSubPoints[0].Color := 12552820;
- dtmSubPoints[0].Tolerance := 40;
- dtmSubPoints[1].x := 2796;
- dtmSubPoints[1].y := 368;
- dtmSubPoints[1].AreaSize := 0;
- dtmSubPoints[1].AreaShape := 0;
- dtmSubPoints[1].Color := 14461071;
- dtmSubPoints[1].Tolerance := 40;
- dtmSubPoints[2].x := 2809;
- dtmSubPoints[2].y := 367;
- dtmSubPoints[2].AreaSize := 0;
- dtmSubPoints[2].AreaShape := 0;
- dtmSubPoints[2].Color := 14724755;
- dtmSubPoints[2].Tolerance := 40;
- dtmSubPoints[3].x := 2804;
- dtmSubPoints[3].y := 365;
- dtmSubPoints[3].AreaSize := 0;
- dtmSubPoints[3].AreaShape := 0;
- dtmSubPoints[3].Color := 1805019;
- dtmSubPoints[3].Tolerance := 40;
- dtmSubPoints[4].x := 2802;
- dtmSubPoints[4].y := 358;
- dtmSubPoints[4].AreaSize := 0;
- dtmSubPoints[4].AreaShape := 0;
- dtmSubPoints[4].Color := 15254443;
- dtmSubPoints[4].Tolerance := 40;
- TempTDTM.MainPoint := dtmMainPoint;
- TempTDTM.SubPoints := dtmSubPoints;
- Result := AddSDTM(TempTDTM);
- end;
- // By NKN
- {
- It was a pain writing multiple SimilarColor statements in a if statement, so this checks multiple.
- }
- function SimilarColorMulti(color,tolerance:integer; colors:TIntegerArray):boolean;
- var
- i:integer;
- begin
- for i := 0 to high(colors) do
- begin
- if(similarColors(color,colors[i],tolerance)) then
- exit(1);
- end;
- end;
- // Portal finders are bit too specific as they got big updates
- {$IfDef RS3}
- {
- Returns the point it finds the portal at.
- }
- //Working RS3 (and it works like a beauty!)
- //FIXME MouseFindFlag (force flag for symbol)
- function FindPortal3():boolean;
- var
- tpa,final:TpointArray;
- mmLocation, symbolPoint:TPoint;
- symbol,x,y,dist,i:integer;
- colors,clear:TIntegerArray;
- {$IfDef RS3}
- marker:TTimeMarker;
- {$Else}
- marker:Timer;
- {$EndIf}
- box:TBox;
- angle:extended;
- pnt : TPoint;
- begin
- try
- marker.start;
- m_debug('Beginning portal detection');
- symbol := setSymbol; //Sets the DDTM;
- if(FindDTMRotated(symbol,x,y, Minimap.getBounds,-Pi,Pi,Pi/60,Angle)) then
- //if (false = true) then//ie. never
- begin
- SymbolPoint := Point(x,y+5); //We want to detect under the point, as the portal is a few pixels below it.
- m_debug('Symbol position at: '+ToStr(symbolPoint));
- //print('Player position at: ' + ToStr(minimap.getCenterPoint),TDebug.DEBUG);
- dist := Distance(symbolPoint,{$IfDef RS3}minimap.getCenterPoint{$Else}MMCP{$EndIf}); //Calculate the distance between the portal and you.
- //print('Distance between the two points is: ' + ToStr(dist), TDebug.DEBUG);
- if(dist > 25) then //If you're too far away, you'll move.
- begin
- Mouse(inttopoint(x,y),4,4,MOUSE_LEFT);
- {$IfDef RS3}
- minimap.waitFlag();
- minimap.waitPlayerMoving(250);
- {$Else}
- FFlag(0);
- walkingToFlag(250);
- {$EndIf}
- if(FindDTMRotated(symbol,x,y,Minimap.getBounds,-Pi,Pi,Pi/60,Angle)) then //Have to reset the position of the point to calculate a mainscreen point.
- begin
- m_debug('Corrected player position: '+toStr(symbolPoint));
- symbolPoint := Point(x,y+5);
- end else
- begin
- print('Moved onto DTM. Using center point.',TDebug.Warning); //If you cover the tip and the DTM won't work, this'll work instead.
- symbolPoint := Point(minimap.getCenterPoint.x,minimap.getCenterPoint.y+5);
- end;
- end;
- mmLocation := minimap.pointToMainscreen(symbolPoint); //Convert the point to a mainscreen point.
- box := IntToBox(mmLocation.x - 35, mmLocation.y - 35, mmLocation.x + 35, mmLocation.y+25); //Make a small box surrounding it.
- {$IFDEF SMARTDRAW}
- smartImage.drawBox(box,false,clPurple);
- {$ENDIF}
- tpa := tpafrombox(box); //Creates a TPA from every point in the box
- for i := 0 to high(tpa) do
- if(not(similarColorMulti(GetColor(tpa[i]),18,[10722453,9604741,12105129,8091505,14735566,12564912,13353915,16777215,12498100,16248301,7565161]))) then //In the array are the colors of the floor/walls around it. Add more if it becomes unreliable.
- Insert(tpa[i],final);
- pnt := MiddleTPA(final); //Middle of the tpa is our return point.
- Mouse(pnt,4,4, MOUSE_MOVE);
- if (isMouseOverText(['rtal'], 50)) Then
- begin
- Result := true;
- fastClick(MOUSE_LEFT);
- exit;
- end;
- {$IFDEF SMARTDRAW}
- smartImage.debugTPA(final);
- smartImage.drawCross(pnt,5,clRed);
- {$ENDIF}
- //print('Finished finding the portal in: '+ToStr(marker.getTime)+'ms',TDebug.Footer);
- end;
- except
- writeln('SHITTY EXCEPTION BLABLA');
- finally
- FreeDTM(symbol);
- end;
- end;
- //Works crap
- Function FindPortal2(): boolean; //Brandon
- var
- TPA, TPA2, TPA3, TPA4: TPointArray;
- ATPA: T2DPointArray;
- CTS, I: Integer;
- P: TPoint;
- MSBox: TBox;
- Begin
- result := false;
- exit; //it causes crashes
- MSBox := {$IfDef RS3}mainscreen.getbounds();{$Else} AREA_MS; {$EndIf}
- CTS := GetToleranceSpeed;
- SetColorToleranceSpeed(2);
- SetToleranceSpeed2Modifiers(1.59, 0.22);
- FindColorsTolerance(TPA, 8228993, MSBox.X1, MSBox.Y1, MSBox.X2, MSBox.Y2, 19);
- SetToleranceSpeed2Modifiers(0.08, 0.24);
- FindColorsTolerance(TPA2, 8422037, MSBox.X1, MSBox.Y1, MSBox.X2, MSBox.Y2, 22);
- SetToleranceSpeed2Modifiers(3.34, 5.11);
- FindColorsTolerance(TPA3, 14349274, MSBox.X1, MSBox.Y1, MSBox.X2, MSBox.Y2, 10);
- SetToleranceSpeed2Modifiers(0.07, 0.61);
- FindColorsTolerance(TPA4, 12563629, MSBox.X1, MSBox.Y1, MSBox.X2, MSBox.Y2, 10);
- try
- TPA := CombineTPA(CombineTPA(TPA, TPA2), CombineTPA(TPA3, TPA4));
- TPA := ReturnPointsNotInTPA(TPA, MSBox); //not sure the difference between this and InvertTPA(TPA);
- ATPA := TPAToATPAEx(TPA, 38, 38);
- except exit; end;
- SortATPAFromFirstPoint(ATPA, MiddleBox(MSBox));
- For I := 0 To min(4, High(ATPA)) Do
- Begin
- P := MiddleTPA(ATPA[I]);
- Mouse(P, 0,0,MOUSE_MOVE);
- if (isMouseOverText(['rtal'], 50)) Then
- begin
- Result := true;
- fastClick(MOUSE_LEFT);
- exit;
- end;
- End;
- {$IFDEF SMARTDRAW}
- DebugATPA(ATPA);
- {$ENDIF}
- SetColorToleranceSpeed(CTS);
- SetToleranceSpeed2Modifiers(0.2, 0.2);
- End;
- //placeholder
- function FindPortal : boolean;
- begin
- result := False;
- end;
- {$Else}
- //copied these from 3.11 no idea how well they work
- // Enters the portal in the rune essence mine
- //Works semi-decently
- function FindPortal3() : boolean; //By J J, thanks!
- var
- x, y : integer;
- PortalColors: TPointArray;
- Splitted: T2DPointArray;
- P: TPoint;
- i, smallestX, smallestY, biggestX, biggestY, xSize, ySize: Integer;
- begin
- // Attempts to find the portal colors
- ColorToleranceSpeed(2);
- SetColorSpeed2Modifiers(4.71, 2.55);
- if FindColorsSpiralTolerance(MSCX, MSCY, PortalColors, 13489057, MSX1, MSY1, MSX2, MSY2, 10) then
- begin
- (* Colors have been found, they will be drawn on SMART in the color red
- After that it will get splitted into an ATPA with a distance of 3 *)
- {$IFDEF SMARTDRAW} try
- SMART_DrawDotsEx(True, PortalColors, clRed); except end;
- {$ENDIF}
- Splitted := SplitTPA(PortalColors, 3);
- SortATPASize(Splitted, True);
- (* ATPA has been sorted on size, large to small. The biggest one will get
- drawn on SMART in the color cyan. A box around will also be drawn. *)
- {$IFDEF SMARTDRAW} try
- SMART_DrawDotsEx(False, Splitted[0], clAqua);
- SMART_DrawBoxEx(False, False, GetTPABounds(Splitted[0]), clGreen); except end;
- {$ENDIF}
- // Calculating the X and Y size of our best TPA
- smallestX := MSX2;
- smallestY := MSY2;
- for i:=0 to high(Splitted[0]) do
- begin
- // Check if the X is bigger or smaller than our extreme values
- if Splitted[0][i].x < smallestX then
- smallestX := Splitted[0][i].x
- else
- if Splitted[0][i].x > biggestX then
- biggestX := Splitted[0][i].x;
- // Check if the Y is bigger or smaller than our extreme values
- if Splitted[0][i].y < smallestY then
- smallestY := Splitted[0][i].y
- else
- if Splitted[0][i].y > biggestY then
- biggestY := Splitted[0][i].y;
- end;
- (* Calculating the actual size. We take 40% of the size because the outline
- of a circle is two times the radius. To be sure we click on a clickable
- part we take 40% instead of 50%. *)
- //writeln('bigggestX : ' + IntToStr(biggestX) + ' en smallestX: ' + IntToStr(smallestX));
- //writeln('bigggestY : ' + IntToStr(biggestY) + ' en smallestY: ' + IntToStr(smallestY));
- xSize := ((biggestX - smallestX) * 4) div 10;
- ySize := ((biggestY - smallestY) * 4) div 10;
- (* The middle of the biggest TPA will get calculated and we will move the
- mouse to a spot around the middle. We draw this oval on SMART. *)
- P := MiddleTPA(Splitted[0]);
- {$IFDEF SMARTDRAW} try
- SMART_DrawEllipse(False, P, xSize, ySize, False, clYellow); except end;
- {$ENDIF}
- MouseOval(P.x, P.y, xSize, ySize, 2);
- // Checking if the uptext is correct
- if WaitUpTextMulti(['nter', 'ortal', 'Enter', 'Portal', 'tal', 'ter'], 500) then
- begin
- (* The uptext is correct, the portal has been detected! We perform a
- left mouse click and wait until we have stopped moving. Result = true *)
- //ClickMouse2(1);
- //FFlag(0);
- //while IsMoving do
- // Wait(RandomRange(100, 200));
- Result := True;
- x := P.x; //Small modification to account for the rest of the script
- y := P.y;
- ClickMouse2(true);
- m_Debug('Portal found with FindPortal3!');
- end;
- end;
- end;
- //Biggest piece of shit on earth
- function FindPortal2(force : boolean): Boolean; //by euphemism, thanks!
- var
- Area, ColorSpeed, EdgeColor, EdgeTol, GroundColor, GroundTol, I, Match,
- WallColor, WallTol: Integer;
- TestPoint: TPoint;
- EdgeHue, EdgeSat, GroundHue, GroundSat, WallHue, WallSat: Extended;
- CharBox, AreaBox, SearchBox: TBox;
- CharTPA, ColorsTPA, NewTPA, EdgeTPA, SearchTPA: TPointArray;
- ResultsATPA, NewATPA: T2DPointArray;
- var cx, cy: Integer;
- begin
- ColorSpeed := GetColorToleranceSpeed;
- ColorToleranceSpeed(2);
- SetToleranceSpeed2Modifiers(0.37, 1.57);
- Match := 0;
- Result := False;
- CharBox := IntToBox(MSCX - 14, MSCY - 21, MSCX + 12, MSCY + 16);
- CharTPA := TPAFromBox(CharBox);
- //SearchBox := IntToBox(MSX1, MSY1, MSX2, MSY2);
- //SearchBox := IntToBox(201, 123, 320, 231); //FASTER, BUT THIS ONLY WORKS IF YOU ARE ADJACENT TO THE PORTAL
- SearchBox := IntToBox(MSCX - 80, MSCY - 80, MSCX + 80, MSCY + 80);
- SearchTPA := TPAFromBox(SearchBox);
- GroundColor := 7047023; GroundHue := 0.72; GroundSat := 0.22; GroundTol := 43;
- WallColor := 16180721; WallHue := 3.42; WallSat := 7.34; WallTol := 4;
- EdgeColor := 10391949; EdgeHue := 0.16; EdgeSat := 0.23; EdgeTol := 28;
- //Find ground colours
- SetToleranceSpeed2Modifiers(GroundHue, GroundSat);
- if not FindColorsTolerance(NewTPA, GroundColor, SearchBox.x1, SearchBox.y1,
- SearchBox.x2, SearchBox.y2, GroundTol) then
- Exit;
- //Find wall colours
- SetToleranceSpeed2Modifiers(WallHue, WallSat);
- FindColorsTolerance(ColorsTPA, WallColor, SearchBox.x1, SearchBox.y1,
- SearchBox.x2, SearchBox.y2, WallTol);
- //Finds wall colours
- ColorsTPA := CombineTPA(ColorsTPA, NewTPA);
- //Add edge colours, too
- SetToleranceSpeed2Modifiers(EdgeHue, EdgeSat);
- FindColorsTolerance(EdgeTPA, EdgeColor, SearchBox.x1, SearchBox.y1,
- SearchBox.x2, SearchBox.y2, EdgeTol);
- //SearchTPA is the entire box we are searching in,
- //We remove our own character and all other points from it
- AppendTPA(ColorsTPA, EdgeTPA);
- NewTPA := ClearTPAFromTPA(SearchTPA, ColorsTPA);
- ColorsTPA := ClearTPAFromTPA(NewTPA, CharTPA);
- ResultsATPA := SplitTPA(ColorsTPA, 1);
- SetLength(NewATPA, 0);
- //This thing is still a miracle to me (Markus)
- for I := 0 to High(ResultsATPA) do
- begin
- AreaBox := GetTPABounds(ResultsATPA[i]);
- Area := ((AreaBox.X2 - AreaBox.X1) * (AreaBox.Y2 - AreaBox.Y1));
- //Probably filters based on not being too small/large, portals arent big
- if (InRange(Area, 500, 1500) and (InRange(Length(ResultsATPA[i]), 250,
- 1200))) then
- begin
- SetLength(NewATPA, Length(NewATPA) + 1);
- NewATPA[Match] := ResultsATPA[i];
- Inc(Match);
- end;
- end;
- //When no points left, no point to contine
- if Length(NewATPA) = 0 then
- Exit;
- SortATPAFromMidPoint(NewATPA, IntToPoint(MSCX, MSCY));
- //Regular (A)TPA iteration
- for I := 0 to High(NewATPA) do
- begin
- TestPoint := MiddleTPA(NewATPA[i]);
- {$IfDef SMARTDRAW} try
- //Flashes the points, though noone watches it.
- Smart_DrawDotsEx(True, NewATPA[i], clFuchsia);
- m_DrawSmartLines;
- except end;
- {$EndIf}
- MMouse(TestPoint.x, TestPoint.y, 5, 5);
- writeln('P2: '+GetUpText);
- if WaitUpTextMulti(['Enter', 'Portal', 'nter', 'ortal', 'er P'], 500) then
- begin
- Result := True;
- m_debug('Portal found with FindPortal2!');
- cx := TestPoint.x;
- cy := TestPoint.y;
- clickmouse2(true);
- Break;
- end else
- if force then
- begin
- ClickMouse2(false);
- if waitOptionExistsMulti(['eleport', 'all'], 500) then
- begin
- chooseOptionMulti(['eleport', 'all']);
- cx := TestPoint.x;
- cy := TestPoint.y;
- result := true;
- break;
- end
- end;
- end;
- end;
- //by euphemism, try #2
- //Works okay at OSRS after I fixed Euph's bugs
- function FindPortal(): Boolean;
- var
- x1, y1, x2, y2, W, H: Integer;
- CTS, ClientBitmap, I, Len: Integer;
- GrabBox: TBox;
- TPA: TPointArray;
- ATPA: T2DPointArray;
- ITarget, KMTarget: Integer;
- var X, Y: Integer; force : boolean
- begin
- Result := False;
- CTS := GetColorToleranceSpeed;
- SetColorToleranceSpeed(2);
- //Grabs rectangle around player, something like 7x6 tiles
- ClientBitmap := BitmapFromClient(125, 65, 380, 265);
- SetBitmapName(ClientBitmap, 'ClientGrab');
- //Changes Simba's target to the bitmap we just made
- KMTarget := GetKeyMouseTarget;
- ITarget := GetImageTarget;
- SetTargetBitmap(ClientBitmap);
- SetBitmapName(ClientBitmap, 'ClientBitmap');
- //Applies bitmap filters to make it easier to single out portal
- {$IfDef LAPE} //defines could be removed, but this just works.
- InvertBitmap(ClientBitmap);
- PosterizeBitmap(ClientBitmap, 15);
- ContrastBitmap(ClientBitmap, 1);
- BrightnessBitmap(ClientBitmap, 15);
- {$Else}
- GetMufasaBitmap(ClientBitmap).Invert(GetMufasaBitmap(ClientBitmap));
- GetMufasaBitmap(ClientBitmap).Posterize(GetMufasaBitmap(ClientBitmap), 15);
- GetMufasaBitmap(ClientBitmap).Contrast(GetMufasaBitmap(ClientBitmap), 1);
- GetMufasaBitmap(ClientBitmap).Brightness(GetMufasaBitmap(ClientBitmap), 15);
- {$EndIf}
- GetClientDimensions(W, H);
- x1 := 0; y1 := 0; x2 := W - 1; y2 := H - 1;
- //Filters out most of the ground, painting it white on bitmap
- SetColorSpeed2Modifiers(0.30, 0.58);
- FindColorsTolerance(TPA, 5135981, x1, y1, x2, y2, 29);
- Len := Length(TPA);
- for I := 0 to (Len - 1) do
- FastSetPixel(ClientBitmap, TPA[i].x, TPA[i].y, clWhite);
- //Filters out most of rocks and trees, painting them white on bitmap
- SetColorSpeed2Modifiers(1.25, 0.21);
- FindColorsTolerance(TPA, 9344658, x1, y1, x2, y2, 20);
- Len := Length(TPA);
- for I := 0 to (Len - 1) do
- FastSetPixel(ClientBitmap, TPA[i].x, TPA[i].y, clWhite);
- //Turns bitmap to greyscale and ups contrast, making portal more or less black, and most everything left a lighter grey
- {$IfDef LAPE}
- GreyScaleBitmap(ClientBitmap);
- ContrastBitmap(ClientBitmap, 4);
- {$Else}
- GetMufasaBitmap(ClientBitmap).GreyScale(GetMufasaBitmap(ClientBitmap));
- GetMufasaBitmap(ClientBitmap).Contrast(GetMufasaBitmap(ClientBitmap), 4);
- {$EndIf}
- //Finds the black of the portal
- SetColorToleranceSpeed(0);
- if not FindColorsTolerance(TPA, 2236962, x1, y1, x2, y2, 34) then
- begin
- SetImageTarget(ITarget);
- SetKeyMouseTarget(KMTarget);
- FreeBitmap(ClientBitmap);
- Exit;
- end;
- SetImageTarget(ITarget);
- SetKeyMouseTarget(KMTarget);
- FreeBitmap(ClientBitmap);
- SplitTPAWrap(TPA, 5, ATPA);
- SortATPASize(ATPA, True);
- Len := Length(ATPA);
- //Loops through black groups to find one with correct dimensions
- for I := 0 to (Len - 1) do
- begin
- GrabBox := GetTPABounds(ATPA[i]);
- W := (GrabBox.x2 - GrabBox.x1);
- H := (GrabBox.y2 - GrabBox.y1);
- if (not (InRange(W, 25, 38) and InRange(H, 15, 38))) then
- Continue;
- TPA[0] := MiddleTPA(ATPA[i]);
- OffSetTPA(TPA, IntToPoint(125, 65));
- X := TPA[0].x;
- Y := TPA[0].y;
- MMouse(x, y, 5, 5);
- m_debug('P1: '+GetUpText);
- if (not(WaitUpTextMulti(['nter', 'ortal', 'Ent', 'Port', 'er P'], 500))) then
- begin
- if force then
- begin
- ClickMouse2(false);
- if not chooseOptionMulti(['eleport', 'all']) then
- continue;
- end;
- end else
- begin
- Result := True;
- m_debug('Portal found with FindPortal!');
- ClickMouse2(true);
- Break;
- end;
- end;
- end;
- {$EndIf}
- procedure WalkToMiddleRoom; forward; //quick 'n dirty
- // Half-working
- Procedure MineToAubury;
- Var
- x, y, T, T2, I: Integer;
- Begin
- FNRWait(1000);
- T := GetSystemTime;
- //1 minute killswitch, again
- // Increased to 2 minutes for login/logout hack
- While GetSystemTime - T < 120000 Do
- Begin
- If GetSystemTime - T > 60000 Then
- begin
- //SetAngle(SRL_ANGLE_LOW); //made it only less accurate
- //Change compass after 60 secs, might help with portal finding
- MakeCompass('E');
- end;
- If Not AtMine Then
- Break;
- FindNormalRandoms;
- If Not FindArrow Then
- Begin
- m_debug('MineToAubury - Could not find the transportation symbol. Force Middle walking');
- WalkToMiddleRoom;
- //FNRWait(5000);
- Continue;
- End;
- FindNormalRandoms;
- //12 tries to find portal, should do.
- //FIXME login/logout hax vs makecompass
- For I := 0 To 3 Do
- Begin
- m_debug('Finding portal 3');
- If FindPortal3() then
- begin
- T2 := GetSystemTime;
- //We should really be out after 10 secs or so
- While AtMine And (GetSystemTime - T2 < 10000) Do
- Begin
- //FindTalk;
- FNRWait(500);
- End;
- Break;
- end;
- m_debug('Finding portal 2');
- If FindPortal2({$IfNDef RS3}(I mod 2 = 1){$EndIf}) Then
- Begin
- T2 := GetSystemTime;
- //We should really be out after 10 secs or so
- While AtMine And (GetSystemTime - T2 < 10000) Do
- Begin
- //FindTalk;
- FNRWait(500);
- End;
- Break;
- End;
- If FindPortal() Then
- Begin
- T2 := GetSystemTime;
- While AtMine And (GetSystemTime - T2 < 10000) Do
- Begin
- //FindTalk;
- FNRWait(500);
- End;
- Break;
- End;
- Wait(250);
- if (i = 3) then
- begin
- {$ifdef rs3}
- //m_Debug('Have you tried logging off and on again? ;-)'); //You get the referrence? Do you? You do? :D
- //logout;
- //LogInPlayer;
- mainscreen.setAngle(MS_ANGLE_HIGH);
- {$else}
- //loginPlayer(false);
- {$endif}
- break;
- end;
- End;
- FNRWait(1000);
- FindNormalRandoms;
- End;
- //120 secs for portal finding is already quite long imo
- If GetSystemTime - T >= 120000 Then
- Begin
- //LogOut;
- if (AtMine) then
- begin
- m_debug('No Portal!');
- //{$ifdef rs3}Players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'No Portal';
- //LogOut;
- setPlayerStatus('Lost', 'No Portal');
- Exit;
- end
- End;
- MakeCompass('N');
- End;
- {
- //Should be replaced by something that works with Aubury shop middle
- function MageSymbolDistance : integer;
- var
- p : TPoint;
- begin
- if not FindMagicSymbol(p) then
- result := MaxInt
- else
- result := Distance(p.x, p.y, mmcx, mmcy);
- end;
- }
- //Working RS3, OSRS
- function FindVEBMM : boolean;
- var
- p : tpoint; a : extended;
- begin
- If FindBankers(P, A) Then
- Begin
- m_debug('Found bankers using NPC dots!');
- Mouse(P, 0, 0, mouse_left);
- FNRWait(3000);
- //FFlag(0);
- MFlag;
- result := true;
- End
- Else
- If FindSymbol(P, {$IfDef RS3}MM_SYMBOL_BANK{$Else} SYMBOL_bank{$EndIf}) Then
- Begin
- m_debug('Found bank using symbol!');
- {$ifdef RS3}
- p.y := p.y + 10;
- {$endif}
- Mouse(P, 0, 0, mouse_left);
- FNRWait(3000);
- //FFlag(0);
- MFlag;
- result := true;
- End Else
- Begin
- m_debug('No Bank :(');
- //{$ifdef rs3}Players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'No Bank';
- //LogOut;
- setPlayerStatus('Lost', 'No Bank MM FindVEBMM');
- result := false;
- End;
- end;
- //working RS3, OSRS
- procedure AuburyToBank;
- var
- T : Integer;
- P : TPoint;
- begin
- t := GetSystemTime; //For the 'killswitch'
- FindNormalRandoms;
- if (not(loggedin)) then
- exit;
- m_debug('AuburyToBank procedure started!');
- if (InvCount < 14) then //14 is more than enough.
- if (not(AtMine)) then
- if (FindAuburyStore(P)) then
- begin
- setPlayerStatus('Aubury');
- //{$ifdef rs3}Players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'Aubury'; //This is so the banking won't kick in and it'll go back in
- exit; //Probably couldn't find ess so we exit.
- end;
- while (GetSystemTime-T < 2*60*1000) do //2 minutes
- begin
- //fixme?
- m_debug('Magic Mouse Click');
- Mouse(IntToPoint(MMCX+(15), MMCY-(85-30)), 8, 8, mouse_left); //magic coords, still working in 2016 after updating
- Wait(Randomize(5500, 500)); //Small wait, as flag has changed a tiny bit
- MFlag;
- FindNormalRandoms;
- if (FindAuburyStore(P)) then
- begin
- m_debug('Aubury store found! Distance is '+ToStr(Distance(mmcx,mmcy,p.x,p.y)));
- if (Distance(mmcx,mmcy,p.x,p.y) < AUBURY_DIST_TH) or InAuburyStore then
- begin
- m_debug('The threshold distance to store is too small.. Door closed??');
- if (DoorClosed(SHOP_WALK_INSIDE)) then
- begin
- m_debug('Should have opened door succesfully.');
- end else
- m_Debug('No door opened. Retry walking to bank though.');
- continue;
- end else
- if (FindVEBMM) then
- begin
- m_Debug('Bank found! Should be inside now.');
- //{$ifdef rs3}Players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'Bank';
- setPlayerStatus('Bank');
- exit;
- end;
- end else
- begin
- if (FindVEBMM) then
- begin
- m_Debug('Bank found.. Should be inside now.');
- setPlayerStatus('Bank');
- //{$ifdef rs3}Players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'Bank';
- //[DONTDOTHISFUCKTHEBANKFINDING]
- wait(750+random(500));
- //[/dont do this]
- exit;
- end;
- end;
- end;
- end;
- //Working! RS3 (probably OSRS too)
- Function FindAuburyText: Boolean; //Hard to test this one, or shall we get legits to say
- var // FindTalk but modded. //Senventior Disthine Molenko? =)
- TPA,Matches : TPointArray;
- TempATPA : T2DPointArray;
- I,CTS,x,y : integer;
- Box : TBox;
- begin;
- //CTS := GetColorToleranceSpeed;
- //ColorToleranceSpeed(1);
- FindColorsTolerance(TPA, 65535, 3, 3, 515, 336, 0);
- if FindTPAinTPA(aubtpa ,TPA,Matches) then //Length check inside the function ;)
- For I := 0 to High(Matches) do //This is all real magic to me..
- begin;
- FindColorsTolerance(TPA,65535,3, Matches[I].y - 1,516,Matches[I].y + 14,0);
- if High(TPA) < 0 then
- Continue;
- TempATPA := FindGapsTPA(TPA,10);
- if Length(TempATPA) > 1 then
- begin;
- SetLength(TPA,Length(TempATPA));
- For x := 0 to High(TempATPA) do
- begin;
- Box := GetTPABounds(TempATPA[x]);
- TPA[x] := Point((Box.x2 + Box.x1) shr 1, Box.y2);
- end;
- SortTPAFrom(TPA,Point(Matches[I].x,Matches[I].y));
- x := TPA[0].x;
- y := TPA[0].y;
- end else
- begin;
- Box := GetTPABounds(TempATPA[0]);
- x := (Box.x2 + Box.x1) shr 1;
- y := Box.y2;
- end;
- y := y + 8;
- MMouse(x, y, 0, 0);
- Wait(100 + Random(50));
- if IsUpTextMulti(['Talk','lk-to']) then //Remember kids, 'alk' matches both 'Talk-to Aubury' AND 'Walk Here'
- begin
- GetMousePos(x, y);
- Mouse(IntToPoint(x, y), 0, 0, mouse_right);
- Wait(450 + Random(125));
- If ChooseOptionMulti(['ele', 'port']) Then
- Begin
- Result := True;
- Exit;
- End;
- end;
- end;
- //ColorToleranceSpeed(CTS);
- end;
- //Working RS3, OSRS
- Function FindAubury: Boolean; //Not the best!
- Var
- I, T, cts: Integer;
- P: TPoint;
- PA: TPointArray;
- aPA: T2DPointArray;
- Middles : TPointArray;
- {$IfDef RS3}
- auburybox : TBox;
- debugATPAS : TPointArrayArray;
- {$EndIf}
- Begin
- Result := False;
- if not loggedin then
- exit;
- //{$ifdef rs3} //FIXME
- //if not(InAuburyStore) then
- // if not(DoorClosed(SHOP_WALK_INSIDE)) then
- // exit;
- //{$endif}
- {
- If sps.SPS_PosToMM(AuburyShopMiddle, sps.getPlayerPos, P) Then //This part locates inside his shop
- Begin
- If (Distance(P.x, P.y, MMCX, MMCY) > 15) Or (Random(20) = 0) Then
- Begin
- //Mouse(P.x + 3, P.y + 10, 2, 2, True);
- DoorClosed; //Just open the door in case we are off
- Wait(1000);
- //FFlag(0);
- MFlag;
- wait(randomize(1200, 200));
- End;
- End;}
- If FindAuburyText Then
- Begin
- Result := True;
- Exit;
- End;
- m_debug('Not found aubury text so lets try with color');
- FindColorsTolerance(PA, AUBURY_NPC_COLOR, {$ifdef rs3}mainscreen.getbounds(){$else}AREA_MS{$endif}, AUBURY_NPC_TOL, colorsetting(AUBURY_NPC_CTS, AUBURY_NPC_MOD1, AUBURY_NPC_MOD2));
- writeln('Pixelz found: '+inttostr(length(pa)));
- aPA := SplitTPA(PA, 5);
- {$IfDef RS3}
- SortATPASize(aPA, true);
- for i := 0 to high(aPA) do
- begin
- auburybox := aPA[i].getBounds();
- //if (auburybox.getWidth() < AUBURY_MAX_WIDTH) and (auburybox.getHeight() < AUBURY_MAX_HEIGHT) then
- if (length(aPA[i]) > 25) then
- if inRange( extended(auburybox.getWidth()) / (auburybox.getHeight()+0.00001), AUBURY_MIN_RATIO, AUBURY_MAX_RATIO) then
- begin
- //setlength(debugATPAS, length(debugATPAS)+1);
- //debugATPAS[high(debugATPAS)] := (aPA[i]);
- Middles.append(MiddleTPA(aPA[i]));
- end;
- end;
- SortTPAFrom(Middles, {$IfDef RS3}mainscreen.getcenterpoint{$Else} MSCP {$EndIf});
- //try debugTPA(Middles); except end;
- {$Else}
- Middles := MiddlesTPA(aPA);
- SortTPAFrom(PA, {$IfDef RS3}mainscreen.getcenterpoint{$Else} MSCP {$EndIf});
- {$EndIf}
- //SortATPAFrom(aPA, mainscreen.getcenterpoint); //Should do MiddlesATPA and then SortTPA (faster)
- writeln('Clusters: '+inttostr(length(apa)));
- For I := 0 To min(4,High(Middles)) Do //Aubury moves too fast, 5 tries is PLENTY
- Begin
- //Wait(200);
- If AtMine Then
- Begin
- Result := True;
- Break;
- End;
- {If Length(aPA[I]) < 3 Then
- begin
- m_debug('ATPA '+inttostr(I)+'/'+inttostr(length(aPA))+' too short! Continuing');
- Continue;
- end;}
- MMouse(Middles[i].X, Middles[i].Y, 3, 3);
- //Wait(150); //Small wait really necessary
- //writeln('ut: '+getMouseOverText);
- If Not WaitUpTextMulti(['bury', 'Talk'], 250) Then //Bug-fix! alk fits 'Walk', too
- Continue; //instead of wait, use Wait until
- clickmouse2(false);
- m_debug('Aubury Uptext matches!');
- Wait(50);
- //writeln('here');
- // writeln(GetChooseOptions('All'));
- If Not ChooseOptionMulti(['elep', 'ort', 'Tel']) Then //Here, this fixes some glitching
- begin
- Continue;
- end;
- T := GetSystemTime;
- While GetSystemTime - T < 15000 Do
- Begin
- Wait(500);
- If AtMine Or (Not FindMagicSymbol(P)) Then //Good enough, it's just location checking
- Break;
- if {$IfNDef RS3} (pos('reach that', GetBlackChatMessage) <> 0) then{$Else}
- chatbox.findtext(['reach that']) <> 0 then //handle door?
- {$EndIf}
- begin
- m_debug('According to chat text, door might be closed.');
- DoorClosed(SHOP_WALK_INSIDE);
- result := False;
- //ColorToleranceSpeed(1);
- exit;
- end;
- End;
- Result := GetSystemTime - T < 10500;
- If AtMine Then
- Result := True;
- If Result Then
- Break;
- End;
- //ColorToleranceSpeed(cts);
- End;
- Function GetCurrentTPA: TPointArray;
- Var
- cts: Integer;
- Begin
- //cts := GetColorToleranceSpeed;
- //ColorToleranceSpeed(1);
- FindColorsTolerance(Result, clWhite, IntToBox(MMX1, MMy1, MMX2, MMY2), 421, colorsetting(1)); //Matches everything besides pure black
- //ColorToleranceSpeed(cts);
- End;
- function AmountOfGaps(ar : TBoolArray) : integer; //Better name: amount of zero-crossings
- var
- prevone : boolean;
- i : integer;
- begin
- prevone := ar[0];
- result := 0;
- for i := 1 to high(ar) do
- begin
- if ar[i] <> prevone then
- inc(result);
- prevone := ar[i];
- end;
- result := result;
- end;
- //Working RS3, OSRS
- procedure WalkToMiddleRoom; //No checks, nothing. Just plain clickin'
- var
- TPA : TPointArray;
- atpa : tpointarrayarray;
- p : TPoint;
- tol : integer;
- begin
- tol := 14;
- while (tol < 50) do
- begin
- FindColorsTolerance(tpa, MIDDLE_MINE_COLOR, IntToBox(MMX1, MMY1, MMX2, MMY2), tol, colorsetting(2, 0.75, 0.05));
- atpa := splittpa(tpa, 3); // ^ dark grey colour in the mine
- sortatpasize(atpa, true);
- IncEx(tol, 5);
- if (length(atpa) = 0) then //should never happen but to prevent AV
- continue; //ok it does happen in osrs..
- p := MiddleTPA(atpa[0]); //should do
- m_debug('Middle walking using tol: '+inttostr(tol-5));
- Mouse(p,0,0, mouse_left);
- wait(500);
- MFlag;
- Wait(500);
- exit;
- end;
- end;
- //Working RS3, FIXME OSRS (needs few tweaks in colors)
- function FindEss : Boolean; //ACA love
- var
- arP : TPointArray;
- ararP: T2DPointArray;
- arL, i : Integer;
- P: TPoint;
- // fx, fy : integer;
- begin
- if not(FindColorsTolerance(arP, ESS_OBJ_COLOR, {$IfDef RS3}mainscreen.getbounds(){$Else} AREA_MS{$EndIf}, 11, colorsetting(ESS_OBJ_CTS, ESS_OBJ_MOD1, ESS_OBJ_MOD2))) then
- begin
- m_debug('Failed to find the ess color, no object found.');
- Exit;
- end;
- ararP := TPAtoATPA(arP, 50); //No Split TPA here, for a good reason!
- arL := Min(10, High(ararP));//and 5 is already a lot, it should find it in 1 try
- //Changed to 10 due to uptext crap
- SortATPASize(ararP, true); //hey, I did this line of code myself, not ACA
- for i := 0 to arL do
- begin
- if (Length(ararP[i]) < 10) then Continue;
- P := MiddleTPA(ararP[i]);
- MMouse(P.x, P.y, 5, 5);
- Wait(500 + Random(100));
- if (WaitUpTextMulti(['ine', 'ure', 'ssen'], 250)) then
- begin;
- Result := True;
- ClickMouse2(True); //mine it!
- //mainscreen.setangle(MS_ANGLE_HIGH);
- Break;
- end;
- end;
- //ColorToleranceSpeed(1);
- //SetColorSpeed2Modifiers(0.2, 0.2);
- if (i = arL + 1) then
- begin
- Writeln('FindEss could not find ess mine.');
- Exit;
- end;
- end;
- { Explanation of the location detection.
- N
- ,,.--'''''`--._
- -----.XXXXXXXXXXXX`-.
- ,,' `.XXXXXXXXXXXXX`.
- ,' :XXXXXXXXXXXXXX`.
- / ;XXXXXXXXXXXXXXXX\
- / ;XXXXXXXXXXXXXXXXX'/
- |' |XXXXXXXXXXXXXXXXX/|
- | :XXXXXX,-.XXXXXXX/ |
- | `----' `-----' |
- W +---. . ,| E
- '.XXX\ ,'X`. # ,--+
- \.XXX`--'XXXXX`. ,'XX/
- \.XXXXXXXXXXXXX: $ ;XXX,'
- `.XXXXXXXXXXXX; |X,''
- `..XXXXXXXX/ |,'
- '-._XXX,' ,XXX=--
- '`-'..../,XX'
- S
- This is the minimap of the mine when you are teleported into the middle.
- Our own player is the depicted with a #. The $ is middle of the essmine.
- What the script does, it draws a broad-bordered circle around our and then
- sorta rolls it out. What happens here is that you get something like this:
- XXXXXXXXXXXXXXXXXXXXX------XXXXXXX--XXXX---XXXXXXXXXXXXX-----------XXXXXXX
- 0 360
- What then happens is, it counts the 'gaps' in the black, or rather, the amount
- of transisitions. That happens like this:
- XXXXXXXXXXXXXXXXXXXXX------XXXXXXX--XXXX---XXXXXXXXXXXXX-----------XXXXXXX
- 1 2 3 4 5 6 7 8
- As you can see, 8 transisitions between black and white.
- If we are detected to be inside the middle. we use one out of the two DTMs
- (as there are 2 different kinds of essmines with 4 rotations = 8 mines) to
- find the middle. After that the angle between $ and # is determined. In the
- pic above, you can see that is around 330 degrees. 330 div 90 = 3, so we are
- standing in the fourth quadrant. The script will then click somewhere at an
- angle of 310 and 330 degrees here. (3*90 + randomrange(40, 50)) to enter.
- But why does this work? Well, lets take a look at if we were teleported to
- the inside of a room:
- N
- ,,.--'''''`--._
- ,,''XXXXXXXXXXXXXX`-.
- ,,'XXXXXXXXXX/\XXXXXXXX`.
- ,'XXXXXXXXXX,' `-----.XXX`.
- /XXXXXXXXXXX; `-.XX\
- /XXXXXXXXXXXX; \X'.
- |'XXXXXXXXXXX( :X|
- |XXXXXXXXXXXXX: ;XX|
- W |XXXXXXXXXXXXX| ,--'XXX| E
- |XXXXXXXXXXXXX; /XXXXXX,|
- '.,----.XXXXX/ # ;XXXXXXX|
- X. `---' |XXXXXX/
- \. ,---. +-XXXX,'
- `. /XXXXX`--'XXXX,''
- `.. (XXXXXXXXXXXX_,'
- '-._ \XXXXXXXX_.'
- '`--.\...,--'
- S
- The border would now look something like this:
- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX---------------XXXXXXXXXXXXXXXXXX
- 1 2
- As you can see, just two transitions! So this way, we can pretty accurately
- determine if we are already standing in a room or not.
- Of course there is the corner case. What if we are standing in the 'hallway'
- between the room and the middle? Then we will have around 8 transitions, but
- the DTM of the middle of the mine can obviously not be found.
- The trick then is to just pretend we are inside a room and walk to the middle
- of the room (which uses the darker-grey on the minimap). As usually most of
- the room will be visible on the minimap, that just works :)
- ASCII art created with JavE, ain't doing that by hand!
- }
- //Working RS3, ddtm a bit broken but sometimes works
- //Semi-broken OSRS but workaround works.
- function LocateInsideEssMine : boolean; //returns true if @ mine
- var //VERY BAD CODING PRACTICE INSIDE!!!!
- BlackArr : array [mmx1..mmx2] of array [mmy1..mmy2] of boolean;
- Angles : array[0..359] of boolean;
- i : integer;
- radius, angle : integer;
- tpa : TPointArray;
- p : TPoint;
- x, y : integer;
- aFound : extended;
- begin
- if (not(AtMine)) then
- begin
- FindNormalRandoms;
- if (not(AtMine)) then
- begin
- m_debug('Not inside essmine, exitting...');
- exit;
- //!!!! should handle it here !!!!
- end;
- end;
- //ColorToleranceSpeed(0);
- FindColorsTolerance(tpa, 0, IntToBox(mmx1, mmy1, mmx2, mmy2), 7, colorsetting(0)); //Find all the black!
- //ColorToleranceSpeed(1);
- writeln('found: '+inttostr(length(tpa))+' black');
- for i := 0 to high(tpa) do
- BlackArr[tpa[i].x][tpa[i].y] := True;
- for radius := 70 downto 40 do //Minimap is 75 radius. 50 was determined experimentally
- for angle := 0 to 359 do
- begin
- x := round(Cose(angle-90)*radius+mmcx); //cose and sine use lookup tables, so pretty quick
- y := round(Sine(angle-90)*radius+mmcy);
- if (BlackArr[x][y]) then //Reason for using if, we don't want to set it to false, only to true
- Angles[angle] := True;
- end;
- writeln(AmountOfGaps(angles));
- if(AmountOfGaps(angles) > 4) then //Only then can it really be middle..
- begin
- m_debug('We are standing in the middle');
- if (not(FindDTMRotated(MiddleDTM1, x, y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, Pi/360, aFound))) then //DTMs are broken!
- if (not(FindDTMRotated(MiddleDTM2, x, y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, Pi/360, aFound))) then
- begin
- m_debug('Force-walking to the middle of room..');
- WalkToMiddleRoom;
- if FindTransportSymbol(p) then
- begin
- m_debug('We weren''t in the middle indeed');
- //WalkToMiddleRoom;
- m_debug('should be in middle of mine now');
- if (not(FindEss)) then
- begin
- NoEssFound := True;
- WriteLn('No Essence Fake Middle');
- end else
- Result := True; //best thing is, wizzup's code doesnt even use this result
- exit;
- end;
- m_debug('Location detection failed! No middle and no DTMs');
- m_debug('Commencing login/logout hax. Not!');
- LogOut;
- LoginPlayer{$ifndef rs3}(False){$endif};
- FindNormalRandoms;
- {$IfDef RS3}
- mainscreen.setAngle(MS_ANGLE_HIGH);
- {$EndIf}
- //Players[0].Loc := 'NoMine';
- result := LocateInsideEssMine; //I <3 Recursion
- exit;
- end; //else
- m_debug('We are standing at quadrant: '+inttostr(((Trunc(FixD(ArcTan2(y - mmcy, x - mmcx) * 180.0 / pi) / 90.0))+3)mod 4)); //thanks to mixster
- x := Round(Cose((((Trunc(FixD(ArcTan2(y - mmcy, x - mmcx) * 180.0 / pi) / 90.0))+2)mod 4)*90+RandomRange(40,50))*randomrange(48,53))+mmcx; //this will randomize like wtf xd
- y := Round(Sine((((Trunc(FixD(ArcTan2(y - mmcy, x - mmcx) * 180.0 / pi) / 90.0))+2)mod 4)*90+RandomRange(40,50))*randomrange(48,53))+mmcy; //x and y are both randomly generated
- Mouse(IntToPoint(X, Y), 4, 4, mouse_left); //random random random
- Wait(2000);
- //FFlag(0);
- MFlag;
- Wait(500);
- if(not(FindEss)) then //Does at most 5 "wacky" movements, low cost to pay compared to clicking minimap and waiting 5 seconds
- begin
- WalkToMiddleRoom; //Usu
- //Wait(Randomize(750, 250)); //should work with this, too
- if (not(FindEss)) then //Might try changing compass angle
- begin
- NoEssFound := True;
- m_debug('No Essence');
- end;
- end;
- end else
- begin
- m_debug('We are standing in a room');
- m_debug('Fortunately we can walk to the middle.');
- WalkToMiddleRoom;
- m_debug('should be in middle of mine now');
- result := true;
- if (not(FindEss)) then
- begin
- NoEssFound := True;
- m_debug('No Essence Corner');
- result := false;
- end;
- end
- end;
- function DeathWalk : boolean;
- begin
- {$IfDef RS3}
- result := false;
- if (players[currentplayer].integers[12] > 3) then
- begin
- writeln('Maximum amount of deathwalk attempts reached!');
- writeln('Logging out');
- result := False;
- logout;
- players[currentplayer].isactive := false;
- exit;
- end;
- inc(players[currentplayer].integers[12]);
- writeln('Going to walk back to Varrock!');
- if not lodestoneScreen.teleportTo(LOCATION_VARROCK, true) then
- if not lodestoneScreen.teleportTo(LOCATION_LUMBRIDGE, true) then
- exit;
- if not DWSPS.walkPath(DeathWalkPath) then
- //if not DWSPS.blindWalk(DeathWalkPath) then
- exit;
- result := FindVEBMM();
- if (result) then
- begin
- setPlayerStatus('Bank');
- players[currentplayer].integers[12] := 0;
- end;
- //players[currentplayer].location := 'Bank';
- {$Else}
- writeln('No deathwalk in OSRS yet :(');
- result := false; //No deathwalk for OSRS
- LogOut;
- {$EndIf}
- end;
- Procedure PlayerReport;
- Var
- Active, Rand, line: string;
- I: Integer;
- Begin
- {$IfDef RS3}
- For I := 0 To High(Players) Do
- Begin
- If Players[i].isActive Then
- Active := 'T'
- Else
- Active := 'F';
- //If Players[i].Rand <> '' Then
- // Rand := '; Rand: ' + Players[i].Rand
- //Else
- Rand := '';
- WriteLn((IntToStr(I)) + ' : ' + Players[I].NickName + ' = ' +
- Active + '; ' + Players[I].location + rand + '; B: ' + IntToStr(Players[I].Integers[0])
- + ' Essence;'+ ' M : ' + IntToStr(Players[I].skillLevel[SKILL_MINING])); //mining level doesnt seem accurate
- End;
- {$EndIf}
- End;
- Procedure ProgressReport; overload;
- Begin
- WriteLn('----------------------------');
- WriteLn('');
- WriteLn('Wizzup? and Markus Essence Miner, Version ' + VersionNumber {$IfDef RS3}+', on RS3'{$Else}+', on OSRS'{$EndIf});
- Writeln(' 10-year anniversary edition!');
- WriteLn('');
- WriteLn('Worked for '+ TimeRunning);
- WriteLn('Mined ' + IntToStr(EssenceMined) + ' Essence at a rate of '+
- inttostr(Round(Extended(EssenceMined)*60.0*60000/GetTimeRunning))+' essence an hour.'); //Float because of overflow
- If Abyss > 0 Then WriteLn('Solved ' + IntToStr(Abyss) + ' abyssal random events.');//and it will never solve them cause the solver was removed ^-^
- WriteLn('');
- WriteLn('----------------------------');
- WriteLn('');
- PlayerReport;
- WriteLn('');
- WriteLn('----------------------------');
- //stats_Commit;
- //SRLRandomsReport;
- End;
- Procedure ScriptTerminate; //Not used in Simba afaik?
- Begin
- ProgressReport;
- End;
- Procedure InitPlayer;
- Begin
- //GetAllLevels; //Doesnt seem to work?
- {SetChat('on',1);
- SetChat('friends',2);
- SetChat('on',3);}
- MakeCompass('N');
- {$IfDef RS3}mainscreen.SetAngle(MS_ANGLE_HIGH);{$Else}setAngle(ANGLE_HIGH);{$EndIf}
- FindNormalRandoms;
- End;
- procedure DownloadSPSMap;
- var
- MapFile : integer;
- begin
- try
- if not fileExists(IncludePath+'SPS/img/runescape_other/VEM_03.png') then
- begin
- MapFile := createFile(IncludePath+'SPS/img/runescape_other/VEM_03.png');
- closeFile(MapFile);
- MapFile := rewriteFile(IncludePath+'SPS/img/runescape_other/VEM_03.png', false);
- writeFileString(MapFile, getPage(SPS_MAP_DL_LINK));
- m_debug('SPS map has been downloaded!');
- end;
- if not fileExists(IncludePath+'SPS/img/runescape_other/bede2-lumbtovarrock.png') then
- begin
- MapFile := createFile(IncludePath+'SPS/img/runescape_other/bede2-lumbtovarrock.png');
- closeFile(MapFile);
- MapFile := rewriteFile(IncludePath+'SPS/img/runescape_other/bede2-lumbtovarrock.png', false);
- writeFileString(MapFile, getPage(SPS_DWMAP_DL_LINK));
- m_debug('SPS map has been downloaded!');
- end;
- finally
- if (MapFile > 0) then
- closeFile(MapFile);
- end;
- end;
- Procedure SetupScript;
- Begin
- //SetupSRLStats(653, SRL_User, SRL_Pass)
- DeclarePlayers;
- LoginPlayer{$ifndef rs3}(false){$endif};
- InitPlayer;
- AubTPA := CreateTPAFromText('isthin', UpCharsEx); //Selventior Disthine Molenko!
- //CacheBlackOffset := -1; //VERY IMPORTANT DO NOT REMOVE!!
- //DO remove its broken
- //Thanks to Demise for restoring my faith in DTMs :) These two are fully mine
- MiddleDTM1 := DTMFromString('mlwAAAHicY2dgYChhYmCIBuIMIK4B4g4gjgHiOiAOAcr7A7'+ //They are broken though
- 'ELEFsBcTIQxwGxFxD///+fwVyNAwW7aAkyfH79kWECIwMDPwN2zIgHQwEAMRYOKA==');
- MiddleDTM2 := DTMFromString('mggAAAHicY2NgYKhiYmAoAOIGIG4H4glAnAPE4UA5JyB2BW'+
- 'IfIM4G4kwgfvTmHYO9gTCDkQ4XGG/Zuw/Mn8DIwMDPgIkZcWAIAAAOAAyf');
- DTMAuburyDoor := DTMFromString('mAAEAAHic42FgYDAGYnkodoVikJgClG0CxEZAHM8AAfx'+ //Thanks Demise, love you!
- 'AzAvEAlA2NxBLA7EMEEsBsSZUHcg8USDOjrFgyIoxZyhIsGTIjDJlSI0wZciIMmPIibNkiAs0ZN'+
- 'DVVGII8dBh0NYRZ6gNlgObSQpmBGImIjAbFCMDAJFbDpI='); // }
- //Sorry, made my own! But thanks for the inspiration :)
- // Hmm maybe the old one works better on OSRS; idk
- //DTMAuburyDoor := DTMFromString('mlwAAAHicY2dgYHgOxLeA+B0QPwPi21D2USDuYWRgaIHi'+
- //'NiDuheJ6IE4MNWOICTRhyE2wZShOdQCzk8PNGfr7OxlAQASIpYBYEg0z4sDMDHAAACheEeg=');
- SetDTMName(MiddleDTM1, 'Middle DTM 1');
- SetDTMName(MiddleDTM2, 'Middle DTM 2');
- SetDTMName(DTMAuburyDoor, 'Aubury door DTM');
- {$IfDef RS3}
- MageSymbolBMP := BitmapFromString(10, 9, 'meJwtic1KAlEARhe9hZdmmDsuxGQ' +
- '0Hb3K6DTCTGGFP2X+KyKI0cIHSFr2BLVs7UqkKIaEpFUPIPhAHSg4' +
- 'i/OdzzDsqJmXMuta2e3wFBD5H3OmVIiuH79c+5/tE0A0LfXXDcPmi' +
- 'pvWplt+O7cBYRK54tK6Lap1wwmrauXGAGFOnTzXsn/2Ma5fFG9mGf' +
- 'ex0wSESeTazxvvo8uSah3oNW/xBAiTyBX2/N1d9WdSea0XvPtnQJh' +
- 'ELl0kHnwnHATfo+DrSgHCJGqRIyHSQqS0w6SXyLTSNiBMItcvr29T' +
- 'zA==');
- TransportSymbolBMP := BitmapFromString(11, 8, 'meJxzsHdwdnZ2c3Hx9PQEMozLV1j' +
- '3HXDwDQayHewd2gpTgAxnVw8n3winkGT70DT92q1qk+4bTz1rm1bt' +
- '6O6VGRvm6BviktNvUbHXsPGSbuct1e670l23FSbfVZt2RSdvYlxog' +
- 'GflJKOiHfIZF6Qyz0gVnpSquwBUINV5WbZirYFnWHSAt2VOp1rUVE' +
- 'W3Gg0Lf20DU/nYfsmak3LJk/StnW1sbKIDfY3Cc3XMXUxNzezt7W1' +
- 'tbbTCqtSDS0wsrG1tbYGuiwv207NztjC3ALLdgcDN3cHNx97B0cnJ' +
- 'yRkM4oJ8TU1N7ezsgJKeYODu7gHytZuHi4srkBEb6A0A0/NYPw==');
- EssenceDTM := DTMFromString('mlwAAAHicY2dgYOhiYWCYDsSTWSDsaiBuAOIpQDybkYFhFhBPBOIeIJ4OxMuBeAkQe7i6AnUzYcUgeVyAEQ+GAgBPowm2');
- AuburyShopPolygon := [inttopoint(267, 224), inttopoint(275, 232),
- inttopoint(283, 232), inttopoint(290, 224),inttopoint(291, 217),
- inttopoint(285, 209), inttopoint(275, 209), inttopoint(275, 217),
- inttopoint(267, 217)];
- AuburyCenter := IntToPoint(278, 223);
- DeathWalkPath := [[628, 1232], [591, 1179], [574, 1136], [558, 1094], [554, 1044],
- [551, 1005], [498, 992], [438, 970], [371, 941], [374, 882], [384, 830],
- [379, 771], [389, 711], [391, 653], [430, 599], [484, 583],
- [540, 580], [546, 506], [539, 432], [546, 377], [588, 355], [639, 350],
- [699, 351], [724, 388]];
- {$Else}
- //Copied from Aerolib
- MageSymbolBMP := BitmapFromString(8, 7, 'meJxT1/9/8NhJdf3/qkv/L1y2UqHi' +
- 'vzpYBMIAkkBxOBuoAMKAiMOlIBrhgnApuHpkQVbt60BxIAk3CiLIz' +
- 'nMSKC6X+xTIAHIhIhBBIAIA+c9XNA==');
- TransportSymbolBMP := BitmapFromString(5, 4, 'meJxLiHVNQELWeuZABOdqZb0BIrjU' +
- 'lsVrgFyIGiADAGjAFTg=');
- EssenceDTM := DTMFromString('m1gAAAHic42JgYGhlYWBoAeJ+IJ4ExO1AXA7FNUBcB8S9QOzKyMBgAcR2QOwBxMFA7APEDkBsBcRBQBwAxHEREUBTGQniJSCKCEDYJAhGAABxMwnn');
- AuburyShopPolygon := [[4816, 2830], [4823, 2830], [4832, 2839], [4832, 2848], [4824, 2855],
- [4816, 2855], [4806, 2847], [4806, 2837], [4816, 2837]];
- AuburyCenter := IntToPoint(4819, 2843);
- DeathWalkPath := [[4697, 3576], [4739, 3575], [4757, 3545], [4794, 3545], [4835, 3537],
- [4845, 3490], [4829, 3459], [4814, 3429], [4811, 3390], [4795, 3354],
- [4764, 3319], [4763, 3270], [4769, 3231], [4797, 3196],
- [4825, 3158], [4861, 3152], [4894, 3125], [4938, 3118], [4987, 3108],
- [5006, 3069], [5007, 3023], [4986, 2981], [4983, 2929], [4975, 2874],
- [4971, 2827], [4960, 2788], [4944, 2748], [4910, 2735],
- [4872, 2734], [4831, 2736], [4823, 2765]];
- {$EndIf}
- SetDTMName(EssenceDTM, 'Essence DTM');
- {$IfDef RS3}
- DownloadSPSMap;
- sps.setup('VEM_03', RUNESCAPE_OTHER);
- DWSPS.setup('bede2-lumbtovarrock', RUNESCAPE_OTHER);
- {$Else}
- RSW.init('world.png');
- {$EndIf}
- End;
- procedure MainLoop(timeToRun : integer);
- Var
- T, T2, I:integer;// p : tpoint;
- startTime : integer;
- begin
- startTime := GetSystemTime;
- Repeat
- if getPlayerStatus = 'Lost' then
- DeathWalk;
- if getPlayerStatus = 'Bank' then
- BankToAubury;
- If getPlayerStatus = 'NearAubury' then
- begin
- If ((GetSystemTime - T3) > 20000) or InAuburyStore then //Just go for it
- setPlayerStatus('Aubury')
- else
- begin
- m_debug('We zijn godverdomme niet in die winkel maar er wel vlakbij');
- if DoorClosed(SHOP_WALK_INSIDE) then
- begin
- m_debug('We were not in store, so opened the door and walked in');
- end;
- end;
- end;
- If getPlayerStatus = 'Aubury' Then
- Begin
- T2 := GetSystemTime;
- While Not AtMine Do
- Begin
- If GetSystemTime - T2 > 180000 Then
- Begin
- setPlayerStatus('Lost', 'No Aubury');
- Break;
- End;
- //FIXME set angle high if not found after x sec.
- If FindAubury Then
- Begin
- writeln('found aubury..');
- T := GetSystemTime;
- While (Not AtMine) and (GetSystemTime - t < 10000) Do Wait(250);
- If AtMine Then
- Break
- End;
- Wait(500);
- End;
- if AtMine then
- setPlayerStatus('Mine');
- //{$IfDef RS3}Players[CurrentPlayer].location{$Else}players[currentplayer].strings[42]{$EndIf} := 'Mine';
- End;
- If getPlayerStatus = 'Mine' Then
- Begin
- Wait(500);
- If FindNormalRandoms Then
- if (not(loggedin)) then
- begin
- setPlayerStatus('Random Lost');
- //{$IfDef RS3}Players[CurrentPlayer].location{$Else}players[currentplayer].strings[42]{$EndIf} := 'Random lost';
- continue; //Not really what I want, GOTO would be useful but oh well, this works :)
- end;
- LocateInsideEssMine;
- T := GetSystemTime;
- T2 := GetSystemTime;
- While (GetSystemTime - T < 180000) And (InvCount < 28) Do
- Begin
- If NoEssFound Then
- Begin
- m_debug('We did not find any essence...');
- NoEssFound := NoEssFound xor NoEssFound; //wizzup's way of saying = false;
- Break;
- End;
- If GetSystemTime - T2 > 60000 Then
- Begin
- I := Random(14){$IfNDef RS3} + 21 {$EndIf}; //Seems srl 6 removed the (ugly, but necessary) tab hack
- If I = {$IfDef RS3}TAB_BACKPACK{$Else} TAB_INV{$EndIf} Then I := tab_Stats; //BUT AEROLIB STILL HAS IT HAHAHHAHAHAHA (c) Me.
- {$IfDef RS3}
- GameTabs.openTab(I);
- Wait(RandomRange(500, 4000));
- GameTabs.openTab(tab_backpack);
- {$Else}
- GameTab(I);
- Wait(RandomRange(500, 4000));
- GameTab(tab_inv);
- {$EndIf}
- T2 := GetSystemTime;
- End;
- Wait(1000);
- {$ifndef rs3}
- //aerolib only looks for the black chat text.
- if clickContinueEx(true) then
- If LevelUp Then
- Begin
- WriteLn('You levelled up, congratulations!'); //Wizzup? wasn't nice here, but I am
- Break;
- End;
- {$endif}
- If FindNormalRandoms Then //The good observer sees that this is dead code on RS3
- Begin
- {T := GetSystemTime; //WTF is this.
- While GetSystemTime - T < 5000 Do
- Begin
- Wait(250);
- FindNormalRandoms;
- End;}
- FindEss;
- continue;
- End;
- End;
- MineToAubury;
- AuburyToBank;
- Bank;
- End;
- ProgressReport;
- If Not LoggedIn Then
- Begin
- {$IfDef RS3} //srl-6 does support multiplayer lolz
- NextPlayer(False);
- InitPlayer;
- Continue;
- {$Else}
- writeln('AeroLib does not seem to support > 1 player so we gotta give up');
- writeln('Thanks for using Essence Miner, bye!');
- TerminateScript;
- {$EndIf}
- End;
- If ({$IfDef RS3} Players[CurrentPlayer].integers[69] {$Else} Me.Integers[69] {$EndIf} Mod Loads = 0) and (getPlayerStatus = 'Bank') Then
- Begin
- {$IfDef RS3}
- NextPlayer(True);
- InitPlayer;
- {$EndIf}
- Continue;
- End;
- { if (timeToRun > 1) then
- if ((GetSystemTime - startTime) > (timeToRun*60000)) then
- begin
- ProgressReport;
- writeln('Script stopping due to time constraint!');
- writeln('Thanks for running the Essence Miner!');
- end; }
- Until False;
- end;
- begin
- {$IfDef SMART}
- //SRL_SixHourFix:= true;
- //SMART_FIXSPEED := True;
- {$EndIf}
- ActivateClient;
- {$IfDef RS3}
- writeln('Running script on RuneScape 3');
- SetupSRL;
- {$Else}
- writeln('Running script on Old-School RuneScape');
- initAL;
- {$EndIf}
- SetupScript;
- MainLoop(TIME_TO_RUN);
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement