PDA

View Full Version : SRL Essence Miner v4!



Markus
01-30-2012, 11:07 PM
SRL Essence Miner v4.20
10-year anniversary edition

This script is not flawless but does most of the job! The main bugs are in the aubury location detection

Hiya!
It's that time of the year again. As I'm a member of SRL for more than 10 years now (October 31st 2006 I made my first account here) and Wizzup? released his essence miner almost 10 years ago, it is time for the anniversary edition of the essence miner!
Every year around December/January I spent some hours updating it. The last major update was around 2012-ish, however, that update was so big that 90% of the code still runs in 2017 (with just a few minor changes to allow it to compile, new coordinates, stuff like that).

So without further ado, I proudly present the script!

27961

Features

Mines around 700 rune (and most likely also pure) essence per hour
Handles closed doors near Aubury, have fun legits ;)
Very nice location detection system (for inside the mine). I'm quite proud of it as it is easily the most reliable part of the script Not that good location detection anymore, but because of redundancy it still works!
Multiplayer support
New: SRL-6 support! Using a small wrapper library (included!) it fully supports SRL-6 and RS3. Because of the redundancy, it should be easy to adapt this script to OSR.
Run and rest support. Will rest after banking if the run energy is low
Redundancy: Everything that can fail in the script, is implemented at least twice. Example: two bankfinders, three portal finders, three aubury finders and three door openers. All of those work completely different which can be very useful for when one of them fail.
Also because of above, it uses a lot of different techniques to accomplish stuff. If you are a moderate scripter (like, just got in SRL Members) you might wish to check it out to learn some new techniques! Some things are done really ugly but I'm working on making this a nice overview/showcase script.
New: It's probably one of the oldest scripts around that still sort-of runs in original form!

As you can see nothing too special, but it does the job!

What I changed from Wizzup?'s original miner (http://villavu.com/forum/showthread.php?t=34175):
A LOT! Every release there is less and less of the original code remaining :)

As I'm quite familiar with his scripting style, it wasn't really hard to do at all. I had an updated version already a bit over a year ago, but that was before the randomisation of the ess mine so it is useless now.

I put in quite a bit of effort to fix it, you won't be disappointed I hope!

Changelog
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


Older versions:



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
[/LIST}
3.10

[LIST]
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)
Replaced the bank opening function with something slightly more accurate 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
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


Initial release, see above for things I did
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 ;)

Reason I stuck my name on it: rewrote quite a big part and I went through every function to check and fix it. With permission

Sample report:

----------------------------

Wizzup? and Markus Essence Miner, Version 3.10

Worked for 4 Hours, 14 Minutes and 26 Seconds
Mined 3042 Essence at a rate of 717 essence an hour.

----------------------------

0 : izzup = T; Bank; B: 3042 Essence; M : -1

----------------------------
|====================================|
| ~ SRL ~ |
| Randoms Report |
|????????????????????????????????????|
| |
| Mordaut Solved ~ 1 |
| |
|????????????????????????????????????|
|====================================|


Special thanks

J J for his über portal finder
euphemism for his awesome portal finders
Demisescythe for restoring my faith in DTMs
Wizzup?, for the motivation and awesome starting script
mixster for helping my tired mind out with trig maths
WT-Fakawi for his high-quality feedback


Todo:

Bugfixes
SRL stats?
Better Aubury finder (HoG features are promising..)
Fixing mine to bank
Adding OSR support (the script was written in 2007...)
Add workarounds for when SPS messed up badly



Feedback and bugfixes are always welcome!

Enjoy, Markus

Zyt3x
01-30-2012, 11:08 PM
I'd tap that.

DemiseScythe
01-30-2012, 11:10 PM
60k profit per hour? wow =) very nice.

You mispelled around by the way Mister.

Mat
01-30-2012, 11:11 PM
Yay :)
Mat

kingarabian
01-30-2012, 11:12 PM
If I was a girl I would give it to you.

Markus
01-30-2012, 11:12 PM
60k profit per hour? wow =) very nice.

You mispelled around by the way Mister.

Already noticed that ma'am, thanks for pointing out though :)
If you're bored and want to do me a favour: DTM I can use to walk inside Aubury's magic store, that fixes a few glitches ;) Could use it for door handling then, too.

PatDuffy
01-30-2012, 11:18 PM
Now we just need a rune mysteries runner

weequ
01-30-2012, 11:22 PM
Great release ;)

putonajonny
01-30-2012, 11:26 PM
I posted this thread: http://villavu.com/forum/showthread.php?t=73745 one minute before this was posted, if only I knew you were working on this lol, I wouldn't have bothered

Wizzup?
01-30-2012, 11:27 PM
This is great. I look forwarding to playing with this. :p

P1nky
01-30-2012, 11:28 PM
Lovelaayyyy!

Kasi
01-30-2012, 11:37 PM
Dayme <3 FindPortal <3 i was actually thinking of writing a findportal using pixelshift -.- i feel undermined.

Firefighter_Emt18
01-31-2012, 01:19 AM
Trying it out now will let you know when finished and give you a bug report if any

Overtime
01-31-2012, 01:46 AM
luckily i abused RSBuddy's RuneMysteries runner on 25 accounts

:P

Now all i have to do is set them up at varrock.. when i have time of course!

Good job Markus!

(Btw I'm not a gold farmer! They will probably sit in those accounts for a couple of months!)

Flight
01-31-2012, 02:25 AM
Sweet. Now if only my second account was a Member because I need truckloads of Pure Essence. :S Way to go Markus! Looks fantastic.


Now we just need a rune mysteries runner

Hmm...

PatDuffy
01-31-2012, 02:26 AM
It's not out of the question for a quest runner anymore either...with all of the different somewhat stable walking methods that can all be used as failsafes.

It would take some time to compile all of the paths needed for the script.

Dairiun
02-01-2012, 10:29 PM
Started this and all it did was type my username and password in all chat.

weequ
02-01-2012, 10:36 PM
Started this and all it did was type my username and password in all chat.Umm that's weird. Make sure you are running runescape on safe mode (Press/spam 's' while loading runescape)
Also use the lowest possible graphical details.

maxxfilth
02-01-2012, 11:03 PM
bank pin option?

also, makes me sad it cant find banker...

Dairiun
02-02-2012, 12:14 AM
Umm that's weird. Make sure you are running runescape on safe mode (Press/spam 's' while loading runescape)
Also use the lowest possible graphical details.

Maybe it wasn't on safe mode anymore... Not sure what happened but it seems to work now. It works but it gets stuck really often.

jatex
02-02-2012, 01:18 AM
Seems to work fine, but if the door to Aubury is closed, the script will just trying teleporting to him repeatedly.

Ezio Auditore da Firenze
02-02-2012, 08:23 AM
Um, I have 2 clients of simba running for this script, but for some reason it runs to the blue moon inn and just sits there? IS there a specific way to set up the bot? Thanks

rohit
02-03-2012, 08:13 AM
[Error] (293:7): Unknown identifier 'SMART_ClearCanvas' at line 292

i have this error when i run this script
please help me out with this bro

Markus
02-03-2012, 09:54 PM
Updated to v3.01, check first post for changelog (quite a bit).

WT-Fakawi
02-03-2012, 11:15 PM
Going in the right direction. A couple of comments after the second round :smile:


Aubury Finding: Much improved in 3.01. But clicking on Aubury while standing outside the shop with door closed results in if ( pos('You can't reach that.',GetBlackChatMessage) <> 0 ) then OpenDoor; Implement that.
Aubury Symbol finding: Why dont you just do a simple FindSymbol? The current algorhythm has a tendency towards the dungeon symbol. Hmmm.
Wild clicks away from the aubury symbol should not be allowed. Stay close to the Symbol.
Exiting the mine while the inventory isn't even halve full.
Standing in front of Portal, and not finding it, yet it glows with color.



The main problem with most points is: not properly callibrating to the Aubury door. Below a couple of suggestions for callibration.



http://jaap.wajer.org/SRL/em.jpg


Two solid DDTMs utilising unique colors on the MM can be picked from the bank location:

The brown branch color of the trees (Red DDTM) or
the brown Ladder Color (Green DDTM). And after the first step outside the bank, appears the third possibility:
a large darkish blob (Blue DDTM)



I would go for the red path. Simple and effective. In fact whole HLR is build around a DDTM just like that (http://villavu.com/forum/showthread.php?t=73524) :smile:

Want me to add solid callibration to the script?

YoHoJo
02-04-2012, 12:19 AM
Many why is rune ess so cheap :[.
600 hr * 42gp ea = 25,200gp/hr only!

Anyways, hell yea awesome work, such a wonderful addition to our script database!

kingarabian
02-04-2012, 12:20 AM
Pure ess is supposed to be 50gp each. That is pre removal of the wilderness and free trade.

Markus
02-04-2012, 12:47 AM
@ Fakawi, thanks for the really great feedback, also for the first time :)
Hadn't tought of 'cant reach that' at all, I was actually thinking of doing some distance calculation to the new calibration DDTM (which you probably saw already) but your method is both more practical and way easier to do.
Symbol finding: I have no idea why, that's still Wizzup's code and I think he must have had a really good reason to do it that way. Never saw it having a false positive before except for today so I blamed the usually quite accurate DDTM which was newly added. As you can see in (also new) FindAuburyStore, Symbol overrides DDTM when they differ too much so I have no idea why it clicks that far off, probably because as you said it indeed wrongly detected the symbol.. (wild idea, restore the NewAutocolor it used to have for finding mage symbol more accurately, the DDTM uses that too)
The new DDTM which is used to find Aubury's shop uses both the two red lines, one blue line and one other point in the south-east corner of the varrock bank. For some reason it would give me the wrong location when not using that final one. Adding a bit of Y to the main point should get the accurate calibration below the door done :) Right now the main problem is actually knowing if it should open the door, the code/logic behind that one is flawed atm and also needs a rewrite.
euphemism told me he'd redo the portal finder. My object-finding skills are really bad (as opposed to mapwalking ones) so anyone feel free to submit some kind of portal finder :)
The final thing you found, exiting while inventory is half-full, is one I do not understand. Never witnessed that one and afaik it should either leave when it can't really find the essence or when the inventory is full (as it loops while not InvFull). Any ideas about that one?
As usual, any bugfixes, patches and feedback are highly welcome!

Moni
02-04-2012, 06:26 AM
How about on line SortATPAFromMidPoint(NewATPA, IntToPoint(MSCX, MSCY));

WT-Fakawi
02-04-2012, 03:20 PM
Try this. Stand at Bank. Script performs Step 1 out-of-bank and Step 2 ends-up-right-in-front-of-door. I have tried it 100 times on different worlds with some random rotation....worked 100%.

program AubyTrot;

{$i srl/srl.simba}

var
PlantColor, PlantDTM:Integer;

procedure DeclarePlayers;
begin
HowManyPlayers:= 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := ' ';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := true;
end;

//************************************************** **************************//

procedure SetupScript;
begin
SetUpSRL;
DeclarePlayers;
end;

//************************************************** **************************//

Function GetMyColorTPA(BaseColor, MinSize, MaxSize, x1, y1, x2, y2, // returns unique color defined by boundaries min and max
tol:integer): Integer;
var
TPA: TPointArray;
begin
if FindColorsTolerance(TPA, BaseColor, x1, y1, x2, y2, tol) then
begin
Writeln('Len TPA = ' + IntToStr(High(TPA)));
If (High(TPA) > MinSize) and (High(TPA) < MaxSize) then
begin
Result := GetColor(TPA[0].x, TPA[0].y);
Writeln('Storing Color ' + IntToStr(Result) + '...');
end
else
begin
WriteLn('ERROR: NO COLOR FOUND');
Result := -1;
end
end
else
begin
WriteLn('ERROR: NO COLOR FOUND');
Result := -1;
end;
end;

//************************************************** **************************//

Procedure AssemblePlantDTM; // assembles dynamically the anchorpoint of this script
// uses tree pixels of the three plants in the minimap
var
DTMSubPoints: array[0..3] of TDTMPointDef;
DTMMainPoint: TDTMPointDef;
TempTDTM: TDTM;

begin
Writeln('Assembling PlantDTM...');
DTMMainPoint.x:=MMCx;
DTMMainPoint.y:=MMCy;
DTMMainPoint.areasize:=1;
DTMMainPoint.areashape:=0;
DTMMainPoint.color:=0;
DTMMainPoint.tolerance:=255; // Odd thing with tol. If Tol > 100 then Mainpoint has offset

DTMSubPoints[0].x:=618;
DTMSubPoints[0].y:=104;
DTMSubPoints[0].areasize:=2;
DTMSubPoints[0].areashape:=0;
DTMSubPoints[0].color:=PlantColor;
DTMSubPoints[0].tolerance:=0;

DTMSubPoints[1].x:=618;
DTMSubPoints[1].y:=107;
DTMSubPoints[1].areasize:=2;
DTMSubPoints[1].areashape:=0;
DTMSubPoints[1].color:=PlantColor;
DTMSubPoints[1].tolerance:=0;

DTMSubPoints[2].x:=630;
DTMSubPoints[2].y:=104;
DTMSubPoints[2].areasize:=2;
DTMSubPoints[2].areashape:=0;
DTMSubPoints[2].color:=PlantColor;
DTMSubPoints[2].tolerance:=0;

DTMSubPoints[3].x:=630;
DTMSubPoints[3].y:=107;
DTMSubPoints[3].areasize:=2;
DTMSubPoints[3].areashape:=0;
DTMSubPoints[3].color:=PlantColor;
DTMSubPoints[3].tolerance:=0;


TempTDTM.MainPoint := DTMMainPoint;
TempTDTM.SubPoints := DTMSubPoints;
PlantDTM := AddDTM(TempTDTM);
end;

//************************************************** **************************//

Function Callibrate(Offset:String): Boolean; // Clicks at fixed points relative to Anchor DDTM.
var
Ox, Oy, x,y:Integer;
WhichAngle: Extended;
Begin
case Offset of
'C': // Centre
begin
Ox := 5 + Random(2);
Oy := - 40; // see line 72?
Players[CurrentPlayer].loc :='C'
end;
'Step_1':
begin
Ox := 24 + Random(2);
Oy := 20 + Random(2);
Players[CurrentPlayer].loc :=''
end;
'Step_2':
begin
Ox := 5 + Random(2);
Oy := 50 + Random(2);
Players[CurrentPlayer].loc :=''
end;
end
if FindDtmRotatedSE(PlantDTM, x, y, MMX1, MMY1, MMX2, MMY2, rs_GetCompassAngleRadians-pi, rs_GetCompassAngleRadians+pi, 0.05,
WhichAngle) then
begin
if rs_OnMiniMap(x,y) then
begin
MFF(x + Ox, y + Oy, 1, -1);
Repeat until not IsMoving; // ugly but only for demo now (Flag's off the map :) )
FFlag(0);
Result := True;
writeln('Callibrate ' + Offset + ' Succesful!');
Exit;
end
else
writeln('Coords not on minimap'); // Maybe trunc coords to fit MM?
end
else
begin
Result := False;
writeln(' Couldnt Callibrate -> ' + Offset + ' !');
end;
end;

//************************************************** **************************//

begin
SetupScript;
LoginPlayer;
PlantColor := GetMyColorTPA(3371596, 30, 150, MMCx - 20, MMCy + 10, MMCx + 40, MMCy + 40, 10);
if PlantColor = - 1 then
Begin
Writeln('Couldnt find PlantColor. Terminating Script.');
TerminateScript;
End
Else
Begin
AssemblePlantDTM;
Repeat
// Callibrate('C');
Callibrate('Step_1');
Callibrate('Step_2');
Callibrate('Step_1');
Until(False);
End;
end.

The DDTM consists of four green pixels of the two trees under the bank, mapped in a square, with tol 0 and areasize 2. At script startup I grab this color and construct the DDTM. The Mainpoint is Color 0 with tolerance 255, which oddly gives it a strange offset. Need to look into this more closely.

Also note that the flag "hangs" in the bank (probably deliberate antibot measure). SRL's MouseFlagEx does NOT correct this! (Old Flagroutine did this properly....waited 40 seconds, and if the flag was still visible, it would MFF til flag gone)

Home
02-04-2012, 03:40 PM
function AreaToBoxArray(const AreaX1, AreaY1, AreaX2, AreaY2, Width, Height: Integer): TBoxArray;
var
AreaW, AreaH: Integer;
BoxX, BoxY: Integer;
x, y, i: Integer;
begin
// Calculate the area dimensions
AreaW := AreaX2 - AreaX1 + 1;
AreaH := AreaY2 - AreaY1 + 1;

// Calculate the number of boxes in each dimension
BoxX := AreaW div Width;
if AreaW mod Width <> 0 then Inc(BoxX);
BoxY := AreaH div Height;
if AreaH mod Height <> 0 then Inc(BoxY);

// Set the number of boxes
SetLength(Result, BoxX * BoxY);

// Calculate the boxes
i := 0;
for y := 0 to BoxY - 1 do
for x := 0 to BoxX - 1 do
begin
Result[i] := IntToBox(AreaX1 + x * Width,
AreaY1 + y * Height,
Min(AreaX2, AreaX1 + (x + 1) * Width - 1),
Min(AreaY2, AreaY1 + (y + 1) * Height - 1));
Inc(i);
end;
end;



function FindPortal(var X, Y: Integer): Boolean;
var
TBA: TBoxArray;
TIA: TIntegerArray;
PortalPoint: TPoint;
Hi, I: Integer;
begin
TBA := AreaToBoxArray(MSX1, MSY1, MSX2, MSY2, 13, 17);
TIA := PixelShiftMulti(TBA, 350);
Hi := Length(TBA);
for I := 0 to Hi - 1 do
if TIA[I] > 100 then
begin
PortalPoint := MiddleBox(TBA[I])
MMouse(PortalPoint.X, PortalPoint.Y, 0, 0);
if (CountColorTolerance(14342657, 7, 7, 100, 25, 70) > 50) then
if WaitUpTextMulti(['nter', 'ortal', 'Ent', 'Port', 'P'], 500) then
begin
GetMousePos(X, Y);
Result := True;
Exit;
end;
end;
end;


Basic FindPortal with Via PixelShift.



~Home

Flight
02-04-2012, 03:46 PM
function AreaToBoxArray(const AreaX1, AreaY1, AreaX2, AreaY2, Width, Height: Integer): TBoxArray;
var
AreaW, AreaH: Integer;
BoxX, BoxY: Integer;
x, y, i: Integer;
begin
// Calculate the area dimensions
AreaW := AreaX2 - AreaX1 + 1;
AreaH := AreaY2 - AreaY1 + 1;

// Calculate the number of boxes in each dimension
BoxX := AreaW div Width;
if AreaW mod Width <> 0 then Inc(BoxX);
BoxY := AreaH div Height;
if AreaH mod Height <> 0 then Inc(BoxY);

// Set the number of boxes
SetLength(Result, BoxX * BoxY);

// Calculate the boxes
i := 0;
for y := 0 to BoxY - 1 do
for x := 0 to BoxX - 1 do
begin
Result[i] := IntToBox(AreaX1 + x * Width,
AreaY1 + y * Height,
Min(AreaX2, AreaX1 + (x + 1) * Width - 1),
Min(AreaY2, AreaY1 + (y + 1) * Height - 1));
Inc(i);
end;
end;



function FindPortal(var X, Y: Integer): Boolean;
var
TBA: TBoxArray;
TIA: TIntegerArray;
PortalPoint: TPoint;
Hi, I: Integer;
begin
TBA := AreaToBoxArray(MSX1, MSY1, MSX2, MSY2, 13, 17);
TIA := PixelShiftMulti(TBA, 350);
Hi := Length(TBA);
for I := 0 to Hi - 1 do
if TIA[I] > 100 then
begin
PortalPoint := MiddleBox(TBA[I])
MMouse(PortalPoint.X, PortalPoint.Y, 0, 0);
if (CountColorTolerance(14342657, 7, 7, 100, 25, 70) > 50) then
if WaitUpTextMulti(['nter', 'ortal', 'Ent', 'Port', 'P'], 500) then
begin
GetMousePos(X, Y);
Result := True;
Exit;
end;
end;
end;


Basic FindPortal with Via PixelShift.



~Home

That's awesome.

gobly lucas
02-04-2012, 05:42 PM
its not working for me wont sign in help

Lilgrimm
02-04-2012, 07:40 PM
I am unable to use the script? I dont understand i can't get it started

Players[1].Name :='';
Players[1].Pass :='';
Players[1].Nick :='';
Players[1].Active := True;
Players[1].Loc := 'Bank';
Players[1].Booleans[0] := True; // Is The Pick Equipped?


It highlights this whether i fill it out or not. Then i get
(not filled)
[Hint] (33:4): Variable 'DTMAUBURYMAP' never used at line 32
Compiled successfully in 782 ms.
SRL Compiled in 0 msec
SMART Initialized.
Loaded: Server 52, Members: False, Signed: True, Super Detail: False.
Error: Out Of Range at line 49
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]
(filled)

[Hint] (33:4): Variable 'DTMAUBURYMAP' never used at line 32
Compiled successfully in 781 ms.
SRL Compiled in 0 msec
SMART Initialized.
Loaded: Server 52, Members: False, Signed: True, Super Detail: False.
Error: Out Of Range at line 49
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]
.......
IDK

WT-Fakawi
02-05-2012, 09:13 AM
Script says NumberOfPlayers = 1, yet there are 4 Players declared, thus: Error: Out Of Range at line 49. ange the number of Players to 4 and you should be fine.

euphemism
02-05-2012, 07:58 PM
Markus, here's the new portal finder I wrote for you. Pretty sure it's 100% now. Messed around with using Simba's bitmap filters for this one. :)

http://puu.sh/fQXM

function FindPortal(var X, Y: Integer): Boolean;
var
x1, y1, x2, y2, W, H: Integer;
CTS, ClientBitmap, I, Len: Integer;
GrabBox: TBox;
TPA: TPointArray;
ATPA: T2DPointArray;
Colors: Array of TVariantArray;
ITarget, KMTarget: Integer;
begin

Result := False;
CTS := GetColorToleranceSpeed;
SetColorToleranceSpeed(2);
SetLength(Colors, 3);

Colors[0] := [2585224, 30, 0.13, 1.49];
Colors[1] := [11382909, 29, 1.70, 0.50];
Colors[2] := [14806010, 5, 0.92, 5.72];

//Grabs rectangle around player, something like 7x6 tiles
ClientBitmap := BitmapFromClient(125, 65, 380, 265);
SetBitmapName(ClientBitmap, 'ClientGrab');

//Paints white rectangle around player so the player doesn't mess with finding
TPA := TPAFromBox(IntToBox(115, 80, 147, 121));
for I := 0 to High(TPA) do
FastSetPixel(ClientBitmap, TPA[i].x, TPA[i].y, clBlack);

//Changes Simba's target to the bitmap we just made
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
SetTargetBitmap(ClientBitmap);

GetClientDimensions(W, H);
x1 := 0; y1 := 0; x2 := W - 1; y2 := H - 1;

//Applies bitmap filters to make it easier to single out portal
GetMufasaBitmap(ClientBitmap).Invert(GetMufasaBitm ap(ClientBitmap));
GetMufasaBitmap(ClientBitmap).Brightness(GetMufasa Bitmap(ClientBitmap), 80);
GetMufasaBitmap(ClientBitmap).Contrast(GetMufasaBi tmap(ClientBitmap), 3);


//Paints most of the ground white on bitmap
for I := 0 to 2 do
begin

SetColorSpeed2Modifiers(Colors[i][2], Colors[i][3]);
FindColorsTolerance(TPA, Colors[i][0], x1, y1, x2, y2, Colors[i][1]);
Len := Length(TPA);
for X := 0 to (Len - 1) do
FastSetPixel(ClientBitmap, TPA[X].x, TPA[X].y, clWhite);
end;

//Applies bitmap filters to make it easier to single out portal
GetMufasaBitmap(ClientBitmap).Contrast(GetMufasaBi tmap(ClientBitmap), 1);
GetMufasaBitmap(ClientBitmap).Brightness(GetMufasa Bitmap(ClientBitmap), -100);
GetMufasaBitmap(ClientBitmap).Contrast(GetMufasaBi tmap(ClientBitmap), 10);
GetMufasaBitmap(ClientBitmap).GreyScale(GetMufasaB itmap(ClientBitmap));

//Finds the black of the portal
SetColorToleranceSpeed(0);
FindColorsTolerance(TPA, 5855577, x1, y1, x2, y2, 89);
SplitTPAWrap(TPA, 4, 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);

X := Length(ATPA[i]);

if (not InRange(X, 300, 1150)) then
Continue;
if (not (InRange(W, 25, 40) and InRange(H, 15, 40))) then
Continue;

SetLength(TPA, 1);
TPA[0] := MiddleTPA(ATPA[i]);
OffSetTPA(TPA, IntToPoint(125, 65));

X := TPA[0].x;
Y := TPA[0].y;

MMouse(X, Y, 5, 5);

Result := True;
Break;
end;

//Debug image--------------------
if (I < (Len)) then
begin
Len := Length(ATPA[i]);

if Len > 0 then
for W := 0 to (Len - 1) do
FastSetPixel(ClientBitmap, ATPA[i][W].x, ATPA[i][W].y, clFuchsia);
end;
DisplayDebugImgWindow(255,200);
DrawBitmapDebugImg(ClientBitmap);
//-------------------------------

//Sets Simba's target back to SMART
FreeTarget(GetImageTarget);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);

SetColorToleranceSpeed(CTS);
FreeBitmap(ClientBitmap);
end;


E: Updated for awesomeness.

big ben102
02-06-2012, 08:46 PM
mine is getting stuck at doors and not running to the bank all the time

Vilenueve
02-06-2012, 08:49 PM
flawless !

bloodyclaw32
02-07-2012, 10:39 PM
GUYS I NEED HELP~~~~ i put everthing into the script but when i run it and get on runescape it doesnt do anything!!!?!??!?! all if says is that the script isnt freed and freeying it now HOW DO I FIX THIS PLEASE~!!~~~~~~~~~~~~

xrapidmatz
02-09-2012, 06:29 PM
when i put my user and pass in to the section it comes up with an orange line where i have put the username can i have a solution


thanks

pk master999
02-09-2012, 07:41 PM
SortATPAFromMidPoint(NewATPA, IntToPoint(MSCX, MSCY));
says compiling failed there soooo

xrapidmatz
02-10-2012, 05:44 PM
i dosent work for me it sais this
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]

xrapidmatz
02-10-2012, 06:01 PM
sound got it working it working its quite innacurate with the moving but other than that its good

NickMystre
02-11-2012, 04:28 AM
@euphemism: Seeing your reply to my SPS question reminded me that I want to ask you a question about the essence miner that Markus posted using your portal finder.

Can you give me an overview of how it works ? I would like to understand it if I can ? To my untrained eye, it seems to be over the top - but as I said, that's just my undertrained eye. :) Thanks!

shuego2
02-12-2012, 02:18 AM
it kept running around randomly it dosnt open doors and it dosnt know how to get back needs alot work but close =D :confused:

Godli
02-13-2012, 01:26 AM
Going to have to take a more wider look at the market in runescape right now to decide to risk getting banned by using this bot, not blaming the scripting just the initial spot it self sucks.

maxxfilth
02-13-2012, 04:12 AM
Hey man, fixed it with a pin option and it didnt seem to work when adding the pin so i took out all other players (only one now).
program New;
{$i srl/srl/misc/smart.simba}
{$i srl/srl.simba}
{$ifdef smart}
{$i srl/srl/misc/paintsmart.simba}
{$endif}

Const
NumberOfUsers = 1;
StartPlayer = 0;
Loads = 900;
VersionNumber = '3.01';
FastAubury = True;
SRL_ID = ''; // Stats ID.
SRL_PASS = ''; // Stats Pass.
//SmartPrefix = 'world10';

{Type
EssLoc = Record
Name: String;
Info: Array Of Array Of Integer;
MMClicks, MSEss: TPointArray;
L, ReportIDVar: Integer;
End;
EssLocArray = Array Of EssLoc; }

Var
// EssInfo: EssLocArray;
AubTPA: TPointArray;
NewAutoColorWorked, NoEssFound: Boolean;
EssenceMined, Abyss: Integer;
MiddleDTM1, MiddleDTM2, DTMAuburyMap, DTMAuburyDoor : integer;
//BlackOffset : integer;
//{$DEFINE DEBUG}

Procedure DeclarePlayers;

Begin
NumberOfPlayers( NumberOfUsers );
CurrentPlayer := StartPlayer;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active := True;
Players[0].Loc := 'Bank';
Players[0].Booleans[0] := True; // Is The Pick Equipped?
Players[0].Pin :='';



Writeln( IntToStr ( HowManyPlayers ) + ' Players' );
End;

Procedure FNRWait(ms: Integer);

Var
T: Integer;
Begin
T := GetSystemTime;
While GetSystemTime - T < ms Do
Begin
Wait(200);
FindNormalRandoms;
End;
End;

procedure MFlag;
var
t : integer;
begin
FFlag(0);
t := GetSystemTime;
while (GetSystemTime-t) < 7500 do
if (PixelShift(IntToBox(mmx1, mmy1, mmx2, mmy2), 200)) < 1000 then //1000 should do
break;
end;

Procedure DebugMM(TPA: TPointArray);
{
Var
I, L: Integer;
C: TCanvas; }

Begin
{DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(MMX2-MMX1, MMY2-MMY1);
C := GetDebugCanvas;
CopyCanvas(GetClientCanvas, C, MMX1, MMY1, MMX2, MMY2, 0, 0, MMX2 - MMX1, MMY2 - MMy1);
L := High(tpa);
For I := 0 To L Do
C.Pixels[tpa[i].x - MMX1, tpa[i].y - MMY1] := 255;
DisplayDebugImgWindow(MMX2-MMX1, MMY2-MMY1); }
End;

function BlackOffset : integer; //Inspired by GetMinimapDots
var //18msecs, pretty slow...
TPA : TPointArray;
i : integer;
begin
result := -1;
FindColorsTolerance(TPA, 3699532, mmx1, mmy1, mmx2, mmy2, 20); //should do?
for i := 0 to high(TPA) do
begin
if (GetColor(TPA[I].X, TPA[I].Y) - GetColor(TPA[I].X-1, TPA[I].Y) = (3699532-1196650)) then
begin //a1 //a2 //a1-a2 = dif
Result := 0-((3699532-329220)-GetColor(TPA[I].X, TPA[I].Y));//magic //c1-c2 = dif
//writeln('Black offset: '+ToStr(result)); //c2 = c1-dif
exit;
end;
end;
end;

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
Begin
SetLength(Points, Length(Points) + 1);
Points[High(Points)] := P2[J];
End;
End;
//Points := CombineTPA(Points, P2);
End;
{$IFDEF DEBUG} debugMM(Points); {$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
WriteLn('No Aubury Shop');
End;

function FindAuburyStore(var P : TPoint) : boolean;
var
AuburyMapDDTM : TSDTM;
DTMAuburyMap : integer;
aFound : extended;
P2 : TPoint;
begin
if (BlackOffset = -1) then
begin
result := FindMagicSymbol(P);
exit;
end;

{ Stop here.
Look at this DDTM, it works quite smart imho ^-^.
This uses the old colour relation technique discovered by yours truly in 2007.
The technique is most commonly used for autocoloring stuff, but there are a
few other uses like this one. The black colour is nowadays also 'modified'
(not static), so I use it as an offset. From every colour, the main 'black'
is substracted (the 329220) so it's made for black = 0. Because nowadays in RS
the black is never true black, we add the 'rs black' to it (AtMine sets it).
This way, we can create a DDTM with 100% accurate colors. No false positives.
Note, it has a bit of area tolerance to accomodate for RS ugly rotation.
For some reason, the last point (which is just terrain) didn't work too well
so that one uses regular 15 tol. It's just an anchor point though, the real
uniqueness is point 0 (the tiny bit of black at the the left).
Points 1 and 2 are the two trees south of VEB, behind the fence. }

AuburyMapDDTM.MainPoint.x := 608;
AuburyMapDDTM.MainPoint.y := 107;
AuburyMapDDTM.MainPoint.Color := 13371337; //who cares
AuburyMapDDTM.MainPoint.Tolerance := 500; //tol is high enough
SetLength(AuburyMapDDTM.SubPoints, 4);

with AuburyMapDDTM.SubPoints[0] do
begin
x := 668;
y := 109;
Color := BlackOffset;
areasize := 2;
end;

with AuburyMapDDTM.SubPoints[1] do
begin
x := 606;
y := 48;
Color := 3699532-329220+BlackOffset; //green
Tolerance := 0;
AreaSize := 2;
end;

with AuburyMapDDTM.SubPoints[2] do
begin
x := 615;
y := 49;
Color := 1196650-329220+BlackOffset; //brown
AreaSize := 2;
end;

with AuburyMapDDTM.SubPoints[3] do //This is part of the terrain
begin //probably calculated different or whatever
x := 631;
y := 49;
Color := 2511437-329220+BlackOffset;
AreaSize := 2;
Tolerance := 15;
end;

//After typing this all of this by hand, WHERE THE F@#! IS THE DDTM EDITOR!!!

DTMAuburyMap := AddSDTM(AuburyMapDDTM);
SetDTMName(DTMAuburyMap, 'Aubury Map DDTM');
//For some reason it tried to click @ quest tab?
if FindDTMRotated(DTMAuburyMap, P.x, P.y, mmx1, mmy1, mmx2, mmy2-5, -pi/2, pi/2, pi/60, afound) then
begin //should do some checks here to make sure it isn't too far of from mage symbol..
writeln('Found Aubury store using offset DDTM!');
if (FindMagicSymbol(P2)) then
begin
if Distance(p2.x, p2.y, p.x, p.y) > 15 then //can be tweaked
begin
writeln('Distance too big. Falling back to magic symbol!');
P := P2;
end;
result := true;
end;
FreeDTM(DTMAuburyMap); //Thanks to Wizzup's leak finder, else wouldnt have found this one.
exit;
end;
FreeDTM(DTMAuburyMap);
result := FindMagicSymbol(P); //Fallback
end;


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);
B := GetMiniMapDots('npc');
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 - 5;
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;

Function Randomize(x, Randomness: Integer): Integer;

Begin
Result := RandomRange(X - Randomness, X + Randomness);
End;

Function AtMine: Boolean; //Counts the black to see if we are in the mine

Var
TPA: TPointArray;
Begin
ColorToleranceSpeed(0);
FindColorsTolerance(TPA, 65536, MMX1, MMY1, MMX2, MMY2, 7);
ColorToleranceSpeed(1);
Result := Length(TPA) > 2000;

{ if (result) and (BlackOffset = -1) then
begin //fck this
BlackColors := GetColors(TPA);
ClearSameIntegers(BlackColors);
for i := 0 to high (BlackColors) do
begin
FindColorsTolerance(TPA, BlackColors[i], mmx1, mmy1, mmx2, mmy2, 0);
if (length(TPA) > maxcount) then
begin
BlackOffset := BlackColors[i];
maxcount := Length(TPA);
end;
end;
Writeln('Calculated black offset = '+ToStr(BlackOffset));
end; }
End;

function FindPortal(var cx, cy: Integer): 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;
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;

SetToleranceSpeed2Modifiers(GroundHue, GroundSat);
if not FindColorsTolerance(NewTPA, GroundColor, SearchBox.x1, SearchBox.y1, //Finds ground colours
SearchBox.x2, SearchBox.y2, GroundTol) then
Exit;

SetToleranceSpeed2Modifiers(WallHue, WallSat); //Finds wall colours
FindColorsTolerance(ColorsTPA, WallColor, SearchBox.x1, SearchBox.y1,
SearchBox.x2, SearchBox.y2, WallTol);

ColorsTPA := CombineTPA(ColorsTPA, NewTPA); //Combine both

SetToleranceSpeed2Modifiers(EdgeHue, EdgeSat);
FindColorsTolerance(EdgeTPA, EdgeColor, SearchBox.x1, SearchBox.y1,
SearchBox.x2, SearchBox.y2, EdgeTol);
//Add edge colours, too
AppendTPA(ColorsTPA, EdgeTPA);
NewTPA := ClearTPAFromTPA(SearchTPA, ColorsTPA); //SearchTPA is the entire box we are searching in,
ColorsTPA := ClearTPAFromTPA(NewTPA, CharTPA); //We remove our own character and all other points from it

ResultsATPA := SplitTPA(ColorsTPA, 1);
SetLength(NewATPA, 0);

for I := 0 to High(ResultsATPA) do //This thing is still a miracle to me
begin

AreaBox := GetTPABounds(ResultsATPA[i]);
Area := ((AreaBox.X2 - AreaBox.X1) * (AreaBox.Y2 - AreaBox.Y1));

if (InRange(Area, 500, 1500) and (InRange(Length(ResultsATPA[i]), 250, //Probably filters based on not being too small/large
1200))) then
begin

SetLength(NewATPA, Length(NewATPA) + 1);
NewATPA[Match] := ResultsATPA[i];
Inc(Match);
end;
end;

if Length(NewATPA) = 0 then //When no points left, no point to contine
Exit;

SortATPAFromMidPoint(NewATPA, IntToPoint(MSCX, MSCY));

for I := 0 to High(NewATPA) do //Regular (A)TPA iteration
begin

TestPoint := MiddleTPA(NewATPA[i]);
MMouse(TestPoint.x, TestPoint.y, 5, 5);

if WaitUpTextMulti(['Enter', 'Portal', 'nter', 'ortal', 'er P'], 500) then
begin
{$IfDef SMART}
Smart_DrawDotsEx(True, NewATPA[i], clFuchsia); //Flashes the points, though noone watches it.
Wait(100);
SMART_ClearCanvas;
{$EndIf}
Result := True;

cx := TestPoint.x;
cy := TestPoint.y;
Break;
end;
end;
end;

Function DoorClosedWizzup: Boolean;

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, 3, 3, 515, 336, 8);
//aTPA := TPAToATPAEx(TPA, 50, 50);
aTPA := SplitTPA(TPA, 3);
SortATPAFrom(aTPA, IntToPoint(mscx, mscy)); //noob Wizzup forgot this one -.-'
For I := 0 To High(aTPA) Do
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.X, TP.Y, 0, 0, True);
//FFlag(0);
MFlag;
Break;
End;
End;
ColorToleranceSpeed(c);
SetColorspeed2Modifiers(0.2, 0.2);
End;

function DoorClosedDTM : boolean; //I dont want too many DTMs in here, but Demise likes them so much
var //and if she does the hard work, why would I? ;)
x, y : integer;
aFound : extended;
begin
result := False;
if FindDTMRotated(DTMAuburyDoor, x, y, msx1, msy1, msx2, msy2, -Pi/4, Pi/4, Pi/60, aFound) then
begin
MMouse(x, y, 5, 5);
if IsUpText('pen') and IsUpText('oor') then
begin
Result := True;
ClickMouse2(true);
MFlag;
end;
end;
end;

function DoorClosed : boolean; //'Kapstopfunctie'
begin
writeln('Opening door!');
if DoorClosedDTM then
result := true
else if DoorClosedWizzup then
result := true
else
result := false;
end;

Function FindArrow: Boolean;

Var
x, y: Integer;
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
Result := True;
WriteLn('Succesfully used NewAutoColor for FindArrow');
End; }
If Not Result Then
If FindSymbol(x, y, 'transportation') Then
Result := True;
If Result Then
Begin
Mouse(x, y, 4, 4, True);
Wait(1000);
//FFlag(0);
MFlag;
FNRWait(1000);
End;
End;

Procedure BankToAubury; //need to add a dtm to this, symbol really isnt accurate at all

Var
V: TPoint;
T: Integer;
Begin
FindNormalRandoms;
MFNF(Randomize(640, 4), Randomize(140, 4), -1, -1);
Wait(10000); //Walk is indeed something ike 10, 15 seconds
T := GetSystemTime; //As flag isn't visible, this is the right way to do it
While (GetSystemTime - T < 60000) Do //60 sec killswitch again, he seems to love those
Begin
FindNormalRandoms;
If FindAuburyStore(V) Then //used to be symbol. After the first run, uses DTM.
Break;
Wait(500);
End;
If GetSystemTime - T >= 60000 Then
Begin
WriteLn('BankToAuburyTime');
LogOut;
Exit;
End; //It wanted to click at quest tab, wtf.
Mouse(V.X, min(V.Y + 3,mmy2-5), 0, 0, True); //Coords of mage symbol are found above
Wait(500);
//FFlag(0);
MFlag;
Players[CurrentPlayer].Loc := 'Aubury';
End;

Procedure MineToAubury;

Var
x, y, T, T2, I: Integer;

Begin
FNRWait(1000);

T := GetSystemTime;
While GetSystemTime - T < 60000 Do //1 minute killswitch, again
Begin
If GetSystemTime - T > 30000 Then
MakeCompass('E'); //Change compass after 30 secs, might help with portal finding
If Not AtMine Then
Break;
FindNormalRandoms;
If Not FindArrow Then
Begin
WriteLn('MineToAubury - Could not find the transportation symbol. Exiting');
FNRWait(5000);
Continue;
End;
FindNormalRandoms;
For I := 0 To 5 Do //6 tries to find portal
Begin
If FindPortal(x, y) Then
Begin
Mouse(x, y, 0, 0, True);
T2 := GetSystemTime;
While AtMine And (GetSystemTime - T2 < 10000) Do //We should really be out after 10 secs or so
Begin
//FindTalk;
FNRWait(500);
End;
Break;
End;
Wait(250);
End;
FNRWait(1000);
FindNormalRandoms;
End;
If GetSystemTime - T >= 60000 Then //60 secs for portal finding is already quite long imo
Begin
//LogOut;
WriteLn('No Portal!');
LogOut;
Exit;
End;
MakeCompass('N');
End;

function MageSymbolDistance : integer; //Should be replaced by something that works with Aubury shop middle
var
p : TPoint;
begin
if not FindMagicSymbol(p) then
result := MaxInt
else
result := Distance(p.x, p.y, mmcx, mmcy);
end;

Procedure AuburyToBank; //This entire function needs to be redone. It works, but not perfect.

Var
T: Integer;
P: TPoint;
A: Extended;

Begin
T := GetSystemTime;
While GetSystemTime - T < 120000 Do //We'll try to go to bank for 2 minutes
Begin
FindNormalRandoms;
Mouse(665, 30, 8, 8, True); //magic coords, still working in 2012
Wait(Randomize(6500, 500)); //Small wait, as flag has changed a tiny bit
FindAuburyStore(P);
If (FlagDistance < 40) Or (Not FlagPresent) or (Distance(mmcx, mmcy, P.x, P.y) < 10) Then //Distance needs a bit of tweaking..
Begin //This door handling is still the most crappy thing imaginable.
if (Distance(mmcx, mmcy, P.x, P.y) < 15) then
begin
writeln('Distance to store is close.');
if (BlackOffset <> -1) then //I'll just trust it to use the DDTM then..
begin
Mouse(MMCX, RandomRange(MMCY + 5, MMCY + 10), 4, 0, True);
FNRWait(1500);
if DoorClosed then
writeln('Opened door!')
else
writeln('Could NOT open door!');
end;
end else
begin
writeln('No idea what''s going on now, flag is weird but distance to store..');
Mouse(MMCX, RandomRange(MMCY + 5, MMCY + 15), 4, 0, True);
FNRWait(1500);
DoorClosed;
end;
End
Else
Begin
{ T2 := GetSystemTime;
While GetSystemTime - T2 < 8000 Do
Begin
Wait(1000);
FindMagicSymbol(P);
If Distance(P.x, P.y, MMCX, MMCY) > 30 Then
Break;
End;
FFlag(10); }
FNRWait(8000);
FFlag(10);
FindAuburyStore(P);
If Distance(P.x, P.y, MMCX, MMCY) > 30 Then
Break;
End;
If Not FindAuburyStore(P) Then
Break;
If Distance(P.X, P.Y, MMCX, MMCY) > 30 Then
Break;
End;
WriteLn('Out of shop');
//FFlag(0);
MFlag;
If FindBankers(P, A) Then
Begin
writeln('Found bankers using NPC dots!');
Mouse(P.x, P.y, 0, 0, True);
FNRWait(3000);
//FFlag(0);
MFlag;
End
Else
If FindSymbol(P.x, P.y, 'Bank') Then
Begin
writeln('Found bank using symbol!');
Mouse(P.x, P.y, 0, 0, True);
FNRWait(3000);
//FFlag(0);
MFlag;
End Else
Begin
WriteLn('No Bank');
LogOut;
End;
Players[CurrentPlayer].Loc := 'Bank';
End;

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 IsUpTextMultiCustom(['Talk','lk-to']) then //Remember kids, 'alk' matches both Talk AND Walk
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
Wait(450 + Random(125));
If ChooseOptionMulti(['ele', 'port']) Then
Begin
Result := True;
Exit;
End;
end;
end;
ColorToleranceSpeed(CTS);
end;

Function FindAubury: Boolean; //Not the best!

Var
I, T, cts: Integer;
P: TPoint;
PA: TPointArray;
aPA: T2DPointArray;

Begin
Result := False;
If FindAuburyStore(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);
Wait(1000);
//FFlag(0);
MFlag;
wait(randomize(1200, 200));
End;
End;
If FindAuburyText Then
Begin
Result := True;
Exit;
End;
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsTolerance(PA, 6450290, MSX1, MSY1, MSX2, MSY2, 3); //tolerance seems low
//writeln(inttostr(length(pa))); //but is severly optimized
aPA := TPAToATPA(PA, 50);
SortATPAFrom(aPA, IntToPoint(mscx, mscy)); //Should do MiddlesATPA and then SortTPA (faster)
//writeln(inttostr(length(apa)));
For I := 0 To High(aPA) Do
Begin
//Wait(200);
If AtMine Then
Begin
Result := True;
Break;
End;
If Length(aPA[I]) < 3 Then
Continue;
P := MiddleTPA(aPA[I]);
MMouse(p.X, P.Y, 3, 3);
Wait(150); //Small wait really necessary
writeln('ut: '+rs_GetUpText);
If Not IsUpTextMultiCustom(['bury', 'Talk']) Then //Bug-fix! alk fits 'Walk', too
Continue;
GetMousePos(P.X, P.Y);
Mouse(P.X, P.Y, 0, 0, False);
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;
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, MMX1, MMy1, MMX2, MMY2, 421); //Matches everything besides pure black
ColorToleranceSpeed(cts);
End;

Function ScanMM(Const TPA: TPointArray; SD, ED, MinR, MaxR: Integer): Integer; //Not used anymore with new cool mine handling

Begin
FilterPointsPie(TPA, SD, ED, MinR, MaxR, MMCX, MMCY);
Result := Length(TPA);
{$IFDEF DEBUG} DebugMM(TPA); {$ENDIF}
End;


Function AdeptDegree(CompassAngle: Extended; Degree: Integer): Integer; //idem dito, but I like it

Begin
Result := Round(Abs(CompassAngle + Degree));
While Result > 360 Do
Result := Result - 360;
End;

function AmountOfGaps(ar : TBoolArray) : integer; //Better name: amount of transitions
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;

procedure StartStopGap(ar : tbooleanarray; var start, stop : integer); //Not used.
var //could (in theory) be used for quadrant detection
prevone : boolean;
i : integer;
begin
prevone := ar[0];
for i := 1 to high(ar) do
begin
if ar[i] <> prevone then
begin
start := i;
prevone := ar[i];
break;
end;
end;
for i := i to high(ar) do
begin
if ar[i] <> prevone then
begin
stop := i;
prevone := ar[i];
break;
end;
end;
end;

procedure WalkToMiddleRoom; //No checks, nothing. Just plain clickin'
var
TPA : TPointArray;
p : TPoint;
begin
ColorToleranceSpeed(2); //ACA obviously
SetColorSpeed2Modifiers(1.46, 0.39); //dark grey colour in the mine
FindColorsTolerance(tpa, 10461335, MMX1, MMY1, MMX2, MMY2, 7)
ColorToleranceSpeed(1);
SetColorspeed2Modifiers(0.2, 0.2);
p := MiddleTPA(tpa); //should do
Mouse(p.x, p.y, 4, 4, true);
wait(500);
//FFlag(0);
MFlag;
Wait(500);
end;

function FindEss : Boolean; //ACA love
var
arP : TPointArray;
ararP: T2DPointArray;
arL, i : Integer;
P: TPoint;
// fx, fy : integer;
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.08, 0.17);

if not(FindColorsTolerance(arP, 8618897, MSX1, MSY1, MSX2, MSY2, 29)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(1); //no need to store cts, 1 is always good
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

ararP := SplitTPAEx(arP, 3, 3); //SLLOOOOWWWW, as there are LOTS of points
arL := Min(4, High(ararP)); //and 5 is already a lot, it should find it in 1 try

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(100 + Random(100));
if (IsUpTextMultiCustom(['ine', 'ure', 'ssen'])) then
begin;
Result := True;
ClickMouse2(True); //mine it!
Break;
end;
end;

ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

end;

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
//setupsrl;
ColorToleranceSpeed(0);
FindColorsTolerance(tpa, 0, mmx1, mmy1, mmx2, mmy2, 7); //Find all the black!
ColorToleranceSpeed(1);

for i := 0 to high(tpa) do
BlackArr[tpa[i].x][tpa[i].y] := True;

for radius := 74 downto 50 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
writeln('We are standing in the middle');
if (not(FindDTMRotated(MiddleDTM1, x, y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, Pi/360, aFound))) then //Look what I did here
if (not(FindDTMRotated(MiddleDTM2, x, y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, Pi/360, aFound))) then
begin
writeln('Force-walking to the middle of room..');
WalkToMiddleRoom;
if FindSymbol(x, y, 'transportation') then
begin
writeln('We weren''t in the middle indeed');
//WalkToMiddleRoom;
writeln('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;
writeln('Location detection failed! No middle and no DTMs');
Players[0].Loc := 'NoMine';
result := False;
exit;
end; //else
writeln('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(X, Y, 4, 4, True); //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
begin
NoEssFound := True;
WriteLn('No Essence');
//NoEssenceFound := True;
end;
end;
end else
// if(AmountOfGaps(angles) = 2) then
begin
writeln('We are standing in a room');
writeln('Fortunately we can walk to the middle.');
WalkToMiddleRoom;
writeln('should be in middle of mine now');
if (not(FindEss)) then
begin
NoEssFound := True;
WriteLn('No Essence Corner');
end;
{writeln('We can now determine exct loc') //Useless. Essmine rotates so we should not rely on that
StartStopGap(angles, start, stop);
writeln('START: '+inttostr(start)+', STOP: '+inttostr(stop));
writeln('Location: '+locationnames[(start+stop) div 180]);}
end
end;

Function EssenceCount: Integer;

{Var
I: Integer;
TPA: TPointArray;
B: TBox; }

Begin
{ Result := 0;
For I := 1 To 28 Do
Begin
B := InvBox(I);
FindColorsTolerance(TPA, 65536, B.X1, B.Y1, B.X2, B.Y2, 0);
If Length(TPA) = 82 Then //doesnt work anymore
Result := Result + 1;
End; }
result := InvCount; //Too bad if your pickaxe isnt equipped
End;

Procedure Bank;

Var
I: Integer;
P: TPoint;
A: Extended;
TempEss: Integer;

Begin
//ReportVars[1] := ReportVars[1] + 1; // Banks
Players[CurrentPlayer].Banked := Players[CurrentPlayer].Banked + 1;
For I := 0 To 2 Do
If OpenBankFast('veb') Then
Break
Else
If FindBankers(P, A) Then
Begin
Mouse(p.x, p.y, 0, 0, True);
Wait(4000);
//FFlag(0);
MFlag;
Wait(1500);
End;
If Not BankScreen Or PinScreen Then
Begin
LogOut;
Players[CurrentPlayer].Loc := 'NoBank';
Players[CurrentPlayer].Active := False;
Exit;
End;
TempEss := EssenceCount;
EssenceMined := EssenceMined + TempEss;
//ReportVars[0] := ReportVars[0] + TempEss;
Players[CurrentPlayer].Integers[0] := Players[CurrentPlayer].Integers[0] + TempEss;
If Players[CurrentPlayer].Booleans[0] Then
Deposit(1, 28, True)
Else
Deposit(2, 28, True); //blindly assumes it is in spot 1

if (random(3) = 1) then //no need to close it all the time Wiz
CloseBank;
End;

Procedure PlayerReport;

Var
Active, Rand: string;
I: Integer;

Begin
For I := 0 To High(Players) Do
Begin
If Players[i].Active Then
Active := 'T'
Else
Active := 'F';
If Players[i].Rand <> '' Then
Rand := '; Rand: ' + Players[i].Rand
Else
Rand := '';

WriteLn((IntToStr(I)) + ' : ' + Players[I].Nick + ' = ' +
Active + '; ' + Players[I].Loc + rand + '; B: ' + IntToStr(Players[I].Integers[0])
+ ' Essence;'+ ' M : ' + IntToStr(Players[I].Level[15]));
End;
End;

Procedure ProgressReport;

Begin
WriteLn('----------------------------');
WriteLn('');
WriteLn('Wizzup? and Markus Essence Miner, Version ' + VersionNumber);
WriteLn('');
WriteLn('Worked for '+ TimeRunning);
WriteLn('Mined ' + IntToStr(EssenceMined) + ' Essence');
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('----------------------------');
SRLRandomsReport;
End;

Procedure ScriptTerminate;

Begin
ProgressReport;
End;

Function GetAndSetAnyReferenceColor: Boolean; //if I could get black here, I'd do it.

//Var
// c: integer;

Begin
NewAutoColorWorked := False;
result := False;
Exit;
{
c := AutoColor(srl_RockColor);
If c > 0 Then
Begin
SetAutoColorReference('grey rock', c);
WriteLn('Got the color using the grey rock');
NewAutoColorWorked := True;
Result := True;
Exit;
End; }
End;

Procedure InitPlayer;
{
Var
I: Integer; }
Begin
{For I := 1 To 5 Do
If Not Players[CurrentPlayer].Booleans[I] Then
Begin
Case I Of
1: SetGraphics(4, '', '' ,'', '', '', '', '', '');
2: Retaliate(False);
3: SetAudio(0, 0, 0, Mono);
End;
Players[CurrentPlayer].Booleans[I] := True;
End;}

GetAllLevels;
SetChat('on',1);
SetChat('friends',2);
SetChat('on',3);
SetAngle(SRL_ANGLE_HIGH);
End;

Procedure SetupScript;

//Var
// I: Integer;
Begin
// SRLID := SRL_ID;
//SRLPassword := SRL_PASS;
// For I := 1 To 19 Do
// ReportVars[I] := 0;
//ScriptID := '51';
DeclarePlayers;
LoginPlayer;
InitPlayer;

//BlackOffset := -1;

//Thanks to Demise for restoring my faith in DTMs :)
MiddleDTM1 := DTMFromString('mlwAAAHicY2dgYChhYmCIBuIMIK4B4g4gjg HiOiAOAcr7A7'+
'ELEFsBcTIQxwGxFxD///+fwVyNAwW7aAkyfH79kWECIwMDPwN2zIgHQwEAMRYOKA==');
MiddleDTM2 := DTMFromString('mggAAAHicY2NgYKhiYmAoAOIGIG4H4glAnA PE4UA5JyB2BW'+
'IfIM4G4kwgfvTmHYO9gTCDkQ4XGG/Zuw/Mn8DIwMDPgIkZcWAIAAAOAAyf');

{DTMAuburyMap := DTMFromString('mwQAAAHic42RgYNBlZGBQA2I9IJYF4v9AMW EgHQzEBkCs'+ //Thanks Demise, for this one
'AcS3gWIHofg6ED9kgKh7DMRcQPlNQDop1IwhxpgbjP1ddRg8H Q0YnKxUGb4zMjFEhIcx/P/PySA'+
'JVEcIMxGB4QAAolMSVg==');}

DTMAuburyDoor := DTMFromString('mAAEAAHic42FgYDAGYnkodoVikJgClG0CxE ZAHM8AAfx'+ //Thanks Demise, love you!
'AzAvEAlA2NxBLA7EMEEsBsSZUHcg8USDOjrFgyIoxZyhIsGTI jDJlSI0wZciIMmPIibNkiAs0ZN'+
'DVVGII8dBh0NYRZ6gNlgObSQpmBGImIjAbFCMDAJFbDpI=');

SetDTMName(MiddleDTM1, 'Middle DTM 1');
SetDTMName(MiddleDTM2, 'Middle DTM 2');
SetDTMName(DTMAuburyDoor, 'Aubury door DTM');
End;

Var
T, T2, I:integer;

begin
//Smartsetup(SmartPrefix, true, true, false);
//Settargetdc(smartgetdc);
AubTPA := CreateTPAFromText('isthin', UpCharsEx);
Smart_Server := 52;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupScript;
//LoadLocations;
//SetupNewAutoColor;
GetAndSetAnyReferenceColor;
Repeat

If Players[CurrentPlayer].Loc = 'Bank' Then
BankToAubury;

If Players[CurrentPlayer].Loc = 'Aubury' Then
Begin
T2 := GetSystemTime;
While Not AtMine Do
Begin
If GetSystemTime - T2 > 180000 Then
Begin
Players[CurrentPlayer].Loc := 'NoAubury';
Break;
End;
//DoorClosed; //ffs, walk to the right place first ;)
If FindAubury Then
Begin
T := GetSystemTime;
While (Not AtMine) and (GetSystemTime - t < 10000) Do Wait(250);
If AtMine Then
Break;
End;
Wait(500);
End;
Players[CurrentPlayer].Loc := 'Mine';
End;

If Players[CurrentPlayer].Loc = 'Mine' Then
Begin
Wait(500);
If InAbyss Then
SolveAbyss;

LocateInsideEssMine;
T := GetSystemTime;
T2 := GetSystemTime;
While (GetSystemTime - T < 180000) And (InvCount < 28) Do
Begin
If NoEssFound Then
Begin
WriteLn('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) + 21;
If I = tab_Inv Then I := tab_Stats;
GameTab(I);
Wait(RandomRange(200, 4000));
GameTab(tab_Inv);
T2 := GetSystemTime;
End;

Wait(1000);
If LevelUp Then
Begin
WriteLn('You levelled up, congratulations!'); //Wizzup? wasn't nice here, but I am
Break;
End;
If FindNormalRandoms Then
Begin
T := GetSystemTime;
While GetSystemTime - T < 5000 Do
Begin
Wait(250);
FindNormalRandoms;
End;
End;
End;
MineToAubury;
AuburyToBank;
Bank;
End;

ProgressReport;

If Not LoggedIn Then
Begin
NextPlayer(False);
InitPlayer;
Continue;
End;

If Players[CurrentPlayer].Banked Mod Loads = 0 Then
Begin
NextPlayer(True);
InitPlayer;
Continue;
End;

Until False;
End.

Lateo
02-15-2012, 09:23 PM
Doesn't work..


Could NOT open door!
Found Aubury store using offset DDTM!
Found Aubury store using offset DDTM!
Distance to store is close.
Opening door!
Could NOT open door!
Found Aubury store using offset DDTM!
Found Aubury store using offset DDTM!
Distance to store is close.
Opening door!
Could NOT open door!
Found Aubury store using offset DDTM!
Found Aubury store using offset DDTM!
Distance too big. Falling back to magic symbol!
No idea what's going on now, flag is weird but distance to store..
Opening door!
Found Aubury store using offset DDTM!
Distance too big. Falling back to magic symbol!
Out of shop
No Bank

DeiJaiVui
02-16-2012, 10:30 AM
Currently 67k/hr for pure ess :).

Angecide
02-17-2012, 09:15 AM
How do I run this script??, I downloaded the script and hit run but where do I put my login option so that it can login by itself?? I tried to login by myself but the script don't seem to want to start. please help

The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]

nyancat
02-22-2012, 12:20 AM
is this for essence or pure essence or for both?

kyocera
02-22-2012, 12:43 AM
SMART Initialized.
Loaded: Server 52, Members: False, Signed: True, Super Detail: False.
Error: Out Of Range at line 49
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]
[Hint] (33:4): Variable 'DTMAUBURYMAP' never used at line 32
Compiled successfully in 1123 ms.
SRL Compiled in 0 msec
SMART Initialized.
Loaded: Server 52, Members: False, Signed: True, Super Detail: False.
Error: Out Of Range at line 49
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]
[Hint] (33:4): Variable 'DTMAUBURYMAP' never used at line 32
Compiled successfully in 1108 ms.
SRL Compiled in 0 msec
SMART Initialized.
Loaded: Server 52, Members: False, Signed: True, Super Detail: False.
1 Players
Found Aubury store using offset DDTM!
ut: Talk-to Aubury / 4 more options
10
We are standing in the middle
We are standing at quadrant: 2
FindObject could not find object.
Found Aubury store using offset DDTM!
Distance too big. Falling back to magic symbol!
No idea what's going on now, flag is weird but distance to store..
Opening door!
Found Aubury store using offset DDTM!
Distance too big. Falling back to magic symbol!
Out of shop
Found bank using symbol!
----------------------------

Wizzup? and Markus Essence Miner, Version 3.01

Worked for 2 Minutes and 44 Seconds
Mined 0 Essence

----------------------------

0 : ment = F; NoBank; B: 0 Essence; M : 74

----------------------------
Status: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\
Status: | SRL Randoms Report |
Status: | www.villavu.com |
Status: |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Status: \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/
NextPlayer(False)

lol that was quick...
logged back in to see what the problem was, it was stuck at the door going out. gonna go to a more populated world now.

kingsleyeng
02-22-2012, 09:11 AM
argg how do i fix this

rror: Out Of Range at line 42
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]

Masterstroke
02-22-2012, 01:16 PM
scripts randomly runs around, this script doesn't work :)

Masterstroke
02-22-2012, 01:17 PM
argg how do i fix this

rror: Out Of Range at line 42
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]

change players to 4.
But then again, the script doesn't work as it should.

Sytherix
02-24-2012, 04:00 PM
What's the starting point? I couldn't see it in the details.
LOL it ran straight to the inn.

'Toxin
02-28-2012, 02:30 PM
is this for essence or pure essence or for both?

Is this a joke ... :s

richymul
02-28-2012, 10:32 PM
lol'd ^

stevieisback
02-28-2012, 10:36 PM
Please update does not work..

'Toxin
02-28-2012, 10:37 PM
Please update does not work..

Wait for SRL to update. Game update today messed up with a few internal functions such as the clicking.

nielsie95
03-03-2012, 07:51 PM
----------------------------

Wizzup? and Markus Essence Miner, Version 3.01

Worked for 13 Minutes and 58 Seconds
Mined 58 Essence

----------------------------

0 : rtal = t; bank; B: 58 Essence; M : 1

----------------------------

Ran using Lape. Had trouble finding Aubury and portals. With banking it tended to click the bankers instead of the booth. Also stopped mining when I leveled up? Not sure what of (and if) this was caused by Lape, but it wasn't smooth in my opinion.

10wnu9
03-03-2012, 09:00 PM
No It isn't smooth, It is Terrible quality for a scripter of brilliant standards.

niqje
03-07-2012, 01:23 PM
[Error] (1303:10): Unknown identifier 'InAbyss' at line 1302
Compiling failed.
[Error] (1303:10): Syntax error at line 1302
Compiling failed.

Can't find a way myself to fix since I am not that great of a scripter :P

megapro82
03-07-2012, 09:28 PM
[Error] (1303:10): Unknown identifier 'InAbyss' at line 1302
Compiling failed.
[Error] (1303:10): Syntax error at line 1302
Compiling failed.

i tryed to delete it and it didnt work.

Moni
03-07-2012, 10:29 PM
[Error] (1303:10) : Unknown identifier 'InAbyss; at line 1302
Compiling failed.

klamse
03-08-2012, 02:01 AM
This is what I got too ^^

Mushini
03-10-2012, 09:37 AM
What's this InAbyss problem?

ZooP
03-10-2012, 10:16 PM
I also got this help would be great thanks

[Error] (1303:10): Unknown identifier 'InAbyss' at line 1302
Compiling failed.

http://i.imgur.com/uZsGY.jpg

klamse
03-12-2012, 04:43 AM
I suppose this script is useless. Oh well

brandon8081
03-12-2012, 06:28 AM
You just need to wait for him to update. Be patient!

sfnnlly
03-16-2012, 07:28 PM
[Error] (1303:10): Unknown identifier 'InAbyss' at line 1302
Compiling failed. wont let me open the page..

Flight
03-17-2012, 03:55 AM
function AreaToBoxArray(const AreaX1, AreaY1, AreaX2, AreaY2, Width, Height: Integer): TBoxArray;
var
AreaW, AreaH: Integer;
BoxX, BoxY: Integer;
x, y, i: Integer;
begin
// Calculate the area dimensions
AreaW := AreaX2 - AreaX1 + 1;
AreaH := AreaY2 - AreaY1 + 1;

// Calculate the number of boxes in each dimension
BoxX := AreaW div Width;
if AreaW mod Width <> 0 then Inc(BoxX);
BoxY := AreaH div Height;
if AreaH mod Height <> 0 then Inc(BoxY);

// Set the number of boxes
SetLength(Result, BoxX * BoxY);

// Calculate the boxes
i := 0;
for y := 0 to BoxY - 1 do
for x := 0 to BoxX - 1 do
begin
Result[i] := IntToBox(AreaX1 + x * Width,
AreaY1 + y * Height,
Min(AreaX2, AreaX1 + (x + 1) * Width - 1),
Min(AreaY2, AreaY1 + (y + 1) * Height - 1));
Inc(i);
end;
end;



function FindPortal(var X, Y: Integer): Boolean;
var
TBA: TBoxArray;
TIA: TIntegerArray;
PortalPoint: TPoint;
Hi, I: Integer;
begin
TBA := AreaToBoxArray(MSX1, MSY1, MSX2, MSY2, 13, 17);
TIA := PixelShiftMulti(TBA, 350);
Hi := Length(TBA);
for I := 0 to Hi - 1 do
if TIA[I] > 100 then
begin
PortalPoint := MiddleBox(TBA[I])
MMouse(PortalPoint.X, PortalPoint.Y, 0, 0);
if (CountColorTolerance(14342657, 7, 7, 100, 25, 70) > 50) then
if WaitUpTextMulti(['nter', 'ortal', 'Ent', 'Port', 'P'], 500) then
begin
GetMousePos(X, Y);
Result := True;
Exit;
end;
end;
end;


Basic FindPortal with Via PixelShift.



~Home

Geez took me a while to find this post. Home, you need to add this to the SRL Snippets section man, this has many uses.

Sim Kai Long
03-18-2012, 11:35 AM
Is Markus going to update this anytime soon? It's such a waste that I can't get it to run. :duh:

brandon8081
03-20-2012, 10:23 PM
Is Markus going to update this anytime soon? It's such a waste that I can't get it to run. :duh:

I don't think so. I haven't seen him respond to this thread. It would be great though =D

lol_monkyy
03-21-2012, 05:40 PM
Sucks this script doesn't work properly.. it looks quite good.

xz5268
03-27-2012, 01:56 PM
[Error] (1303:10): Unknown identifier 'InAbyss' at line 1302
Compiling failed.

hlep

psyonity
04-03-2012, 04:53 PM
I wanted a ess miner, but this one didn't work... So I looked at it, thought the color of the symbol was wrong, made a new one, and it worked! So here the script again with the new color and for the others, the inAbyss is commented out.

program New;
{$i srl/srl/misc/smart.simba}
{$i srl/srl.simba}
{$ifdef smart}
{$i srl/srl/misc/paintsmart.simba}
{$endif}

Const
NumberOfUsers = 1;
StartPlayer = 0;
Loads = 5;
VersionNumber = '3.01';
FastAubury = True;
SRL_ID = ''; // Stats ID.
SRL_PASS = ''; // Stats Pass.
//SmartPrefix = 'world10';

{Type
EssLoc = Record
Name: String;
Info: Array Of Array Of Integer;
MMClicks, MSEss: TPointArray;
L, ReportIDVar: Integer;
End;
EssLocArray = Array Of EssLoc; }

Var
// EssInfo: EssLocArray;
AubTPA: TPointArray;
NewAutoColorWorked, NoEssFound: Boolean;
EssenceMined, Abyss: Integer;
MiddleDTM1, MiddleDTM2, DTMAuburyMap, DTMAuburyDoor : integer;
//BlackOffset : integer;
//{$DEFINE DEBUG}

Procedure DeclarePlayers;

Begin
NumberOfPlayers( NumberOfUsers );
CurrentPlayer := StartPlayer;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='gpk';
Players[0].Active := True;
Players[0].Loc := 'Bank';
Players[0].Booleans[0] := False; // Is The Pick Equipped?
// Is The Pick Equipped?

Writeln( IntToStr ( HowManyPlayers ) + ' Players' );
End;

Procedure FNRWait(ms: Integer);

Var
T: Integer;
Begin
T := GetSystemTime;
While GetSystemTime - T < ms Do
Begin
Wait(200);
FindNormalRandoms;
End;
End;

procedure MFlag;
var
t : integer;
begin
FFlag(0);
t := GetSystemTime;
while (GetSystemTime-t) < 7500 do
if (PixelShift(IntToBox(mmx1, mmy1, mmx2, mmy2), 200)) < 1000 then //1000 should do
break;
end;

Procedure DebugMM(TPA: TPointArray);
{
Var
I, L: Integer;
C: TCanvas; }

Begin
{DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(MMX2-MMX1, MMY2-MMY1);
C := GetDebugCanvas;
CopyCanvas(GetClientCanvas, C, MMX1, MMY1, MMX2, MMY2, 0, 0, MMX2 - MMX1, MMY2 - MMy1);
L := High(tpa);
For I := 0 To L Do
C.Pixels[tpa[i].x - MMX1, tpa[i].y - MMY1] := 255;
DisplayDebugImgWindow(MMX2-MMX1, MMY2-MMY1); }
End;

function BlackOffset : integer; //Inspired by GetMinimapDots
var //18msecs, pretty slow...
TPA : TPointArray;
i : integer;
begin
result := -1;
FindColorsTolerance(TPA, 3699532, mmx1, mmy1, mmx2, mmy2, 20); //should do?
for i := 0 to high(TPA) do
begin
if (GetColor(TPA[I].X, TPA[I].Y) - GetColor(TPA[I].X-1, TPA[I].Y) = (3699532-1196650)) then
begin //a1 //a2 //a1-a2 = dif
Result := 0-((3699532-329220)-GetColor(TPA[I].X, TPA[I].Y));//magic //c1-c2 = dif
//writeln('Black offset: '+ToStr(result)); //c2 = c1-dif
exit;
end;
end;
end;

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 := [2595570, 2925567];

SetLength(Points, 0);
For I := 0 To High(MagicSymbolColors) Do
Begin
SetLength(P2, 0);
SetLength(C, 0);
//writeln('U wanted me?');
FindColorsTolerance(P2, MagicSymbolColors[I], MMX1, MMY1, MMX2, MMY2, 10);
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
Begin
SetLength(Points, Length(Points) + 1);
Points[High(Points)] := P2[J];
End;
End;
//Points := CombineTPA(Points, P2);
End;
{$IFDEF DEBUG} debugMM(Points); {$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
WriteLn('No Aubury Shop');
End;

function FindAuburyStore(var P : TPoint) : boolean;
var
AuburyMapDDTM : TSDTM;
DTMAuburyMap : integer;
aFound : extended;
P2 : TPoint;
begin
if (BlackOffset = -1) then
begin
result := FindMagicSymbol(P);
exit;
end;

{ Stop here.
Look at this DDTM, it works quite smart imho ^-^.
This uses the old colour relation technique discovered by yours truly in 2007.
The technique is most commonly used for autocoloring stuff, but there are a
few other uses like this one. The black colour is nowadays also 'modified'
(not static), so I use it as an offset. From every colour, the main 'black'
is substracted (the 329220) so it's made for black = 0. Because nowadays in RS
the black is never true black, we add the 'rs black' to it (AtMine sets it).
This way, we can create a DDTM with 100% accurate colors. No false positives.
Note, it has a bit of area tolerance to accomodate for RS ugly rotation.
For some reason, the last point (which is just terrain) didn't work too well
so that one uses regular 15 tol. It's just an anchor point though, the real
uniqueness is point 0 (the tiny bit of black at the the left).
Points 1 and 2 are the two trees south of VEB, behind the fence. }

AuburyMapDDTM.MainPoint.x := 608;
AuburyMapDDTM.MainPoint.y := 107;
AuburyMapDDTM.MainPoint.Color := 13371337; //who cares
AuburyMapDDTM.MainPoint.Tolerance := 500; //tol is high enough
SetLength(AuburyMapDDTM.SubPoints, 4);

with AuburyMapDDTM.SubPoints[0] do
begin
x := 668;
y := 109;
Color := BlackOffset;
areasize := 2;
end;

with AuburyMapDDTM.SubPoints[1] do
begin
x := 606;
y := 48;
Color := 3699532-329220+BlackOffset; //green
Tolerance := 0;
AreaSize := 2;
end;

with AuburyMapDDTM.SubPoints[2] do
begin
x := 615;
y := 49;
Color := 1196650-329220+BlackOffset; //brown
AreaSize := 2;
end;

with AuburyMapDDTM.SubPoints[3] do //This is part of the terrain
begin //probably calculated different or whatever
x := 631;
y := 49;
Color := 2511437-329220+BlackOffset;
AreaSize := 2;
Tolerance := 15;
end;

//After typing this all of this by hand, WHERE THE F@#! IS THE DDTM EDITOR!!!

DTMAuburyMap := AddSDTM(AuburyMapDDTM);
SetDTMName(DTMAuburyMap, 'Aubury Map DDTM');
//For some reason it tried to click @ quest tab?
if FindDTMRotated(DTMAuburyMap, P.x, P.y, mmx1, mmy1, mmx2, mmy2-5, -pi/2, pi/2, pi/60, afound) then
begin //should do some checks here to make sure it isn't too far of from mage symbol..
writeln('Found Aubury store using offset DDTM!');
if (FindMagicSymbol(P2)) then
begin
if Distance(p2.x, p2.y, p.x, p.y) > 15 then //can be tweaked
begin
writeln('Distance too big. Falling back to magic symbol!');
P := P2;
end;
result := true;
end;
FreeDTM(DTMAuburyMap); //Thanks to Wizzup's leak finder, else wouldnt have found this one.
exit;
end;
FreeDTM(DTMAuburyMap);
result := FindMagicSymbol(P); //Fallback
end;


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);
B := GetMiniMapDots('npc');
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 - 5;
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;

Function Randomize(x, Randomness: Integer): Integer;

Begin
Result := RandomRange(X - Randomness, X + Randomness);
End;

Function AtMine: Boolean; //Counts the black to see if we are in the mine

Var
TPA: TPointArray;
Begin
ColorToleranceSpeed(0);
FindColorsTolerance(TPA, 65536, MMX1, MMY1, MMX2, MMY2, 7);
ColorToleranceSpeed(1);
Result := Length(TPA) > 2000;

{ if (result) and (BlackOffset = -1) then
begin //fck this
BlackColors := GetColors(TPA);
ClearSameIntegers(BlackColors);
for i := 0 to high (BlackColors) do
begin
FindColorsTolerance(TPA, BlackColors[i], mmx1, mmy1, mmx2, mmy2, 0);
if (length(TPA) > maxcount) then
begin
BlackOffset := BlackColors[i];
maxcount := Length(TPA);
end;
end;
Writeln('Calculated black offset = '+ToStr(BlackOffset));
end; }
End;

function FindPortal(var cx, cy: Integer): 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;
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;

SetToleranceSpeed2Modifiers(GroundHue, GroundSat);
if not FindColorsTolerance(NewTPA, GroundColor, SearchBox.x1, SearchBox.y1, //Finds ground colours
SearchBox.x2, SearchBox.y2, GroundTol) then
Exit;

SetToleranceSpeed2Modifiers(WallHue, WallSat); //Finds wall colours
FindColorsTolerance(ColorsTPA, WallColor, SearchBox.x1, SearchBox.y1,
SearchBox.x2, SearchBox.y2, WallTol);

ColorsTPA := CombineTPA(ColorsTPA, NewTPA); //Combine both

SetToleranceSpeed2Modifiers(EdgeHue, EdgeSat);
FindColorsTolerance(EdgeTPA, EdgeColor, SearchBox.x1, SearchBox.y1,
SearchBox.x2, SearchBox.y2, EdgeTol);
//Add edge colours, too
AppendTPA(ColorsTPA, EdgeTPA);
NewTPA := ClearTPAFromTPA(SearchTPA, ColorsTPA); //SearchTPA is the entire box we are searching in,
ColorsTPA := ClearTPAFromTPA(NewTPA, CharTPA); //We remove our own character and all other points from it

ResultsATPA := SplitTPA(ColorsTPA, 1);
SetLength(NewATPA, 0);

for I := 0 to High(ResultsATPA) do //This thing is still a miracle to me
begin

AreaBox := GetTPABounds(ResultsATPA[i]);
Area := ((AreaBox.X2 - AreaBox.X1) * (AreaBox.Y2 - AreaBox.Y1));

if (InRange(Area, 500, 1500) and (InRange(Length(ResultsATPA[i]), 250, //Probably filters based on not being too small/large
1200))) then
begin

SetLength(NewATPA, Length(NewATPA) + 1);
NewATPA[Match] := ResultsATPA[i];
Inc(Match);
end;
end;

if Length(NewATPA) = 0 then //When no points left, no point to contine
Exit;

SortATPAFromMidPoint(NewATPA, IntToPoint(MSCX, MSCY));

for I := 0 to High(NewATPA) do //Regular (A)TPA iteration
begin

TestPoint := MiddleTPA(NewATPA[i]);
MMouse(TestPoint.x, TestPoint.y, 5, 5);

if WaitUpTextMulti(['Enter', 'Portal', 'nter', 'ortal', 'er P'], 500) then
begin
{$IfDef SMART}
Smart_DrawDotsEx(True, NewATPA[i], clFuchsia); //Flashes the points, though noone watches it.
Wait(100);
SMART_ClearCanvas;
{$EndIf}
Result := True;

cx := TestPoint.x;
cy := TestPoint.y;
Break;
end;
end;
end;

Function DoorClosedWizzup: Boolean;

Var
TP: TPoint;
TPA: TPointArray;
aTPA: T2DPointArray;
I, c: Integer;


Begin
Result := False;
c := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.2, 0.5);
FindColorsTolerance(TPA, 3561057, 3, 3, 515, 336, 8);
//aTPA := TPAToATPAEx(TPA, 50, 50);
aTPA := SplitTPA(TPA, 3);
SortATPAFrom(aTPA, IntToPoint(mscx, mscy)); //noob Wizzup forgot this one -.-'
For I := 0 To High(aTPA) Do
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.X, TP.Y, 0, 0, True);
//FFlag(0);
MFlag;
Break;
End;
End;
ColorToleranceSpeed(c);
SetColorspeed2Modifiers(0.2, 0.2);
End;

function DoorClosedDTM : boolean; //I dont want too many DTMs in here, but Demise likes them so much
var //and if she does the hard work, why would I? ;)
x, y : integer;
aFound : extended;
begin
result := False;
if FindDTMRotated(DTMAuburyDoor, x, y, msx1, msy1, msx2, msy2, -Pi/4, Pi/4, Pi/60, aFound) then
begin
MMouse(x, y, 5, 5);
if IsUpText('pen') and IsUpText('oor') then
begin
Result := True;
ClickMouse2(true);
MFlag;
end;
end;
end;

function DoorClosed : boolean; //'Kapstopfunctie'
begin
writeln('Opening door!');
if DoorClosedDTM then
result := true
else if DoorClosedWizzup then
result := true
else
result := false;
end;

Function FindArrow: Boolean;

Var
x, y: Integer;
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
Result := True;
WriteLn('Succesfully used NewAutoColor for FindArrow');
End; }
If Not Result Then
If FindSymbol(x, y, 'transportation') Then
Result := True;
If Result Then
Begin
Mouse(x, y, 4, 4, True);
Wait(1000);
//FFlag(0);
MFlag;
FNRWait(1000);
End;
End;

Procedure BankToAubury; //need to add a dtm to this, symbol really isnt accurate at all

Var
V: TPoint;
T: Integer;
Begin
FindNormalRandoms;
MFNF(Randomize(640, 4), Randomize(140, 4), -1, -1);
Wait(10000); //Walk is indeed something ike 10, 15 seconds
T := GetSystemTime; //As flag isn't visible, this is the right way to do it
While (GetSystemTime - T < 60000) Do //60 sec killswitch again, he seems to love those
Begin
FindNormalRandoms;
If FindAuburyStore(V) Then //used to be symbol. After the first run, uses DTM.
Break;
Wait(500);
End;
If GetSystemTime - T >= 60000 Then
Begin
WriteLn('BankToAuburyTime');
LogOut;
Exit;
End; //It wanted to click at quest tab, wtf.
Mouse(V.X, min(V.Y + 3,mmy2-5), 0, 0, True); //Coords of mage symbol are found above
Wait(500);
//FFlag(0);
MFlag;
Players[CurrentPlayer].Loc := 'Aubury';
End;

Procedure MineToAubury;

Var
x, y, T, T2, I: Integer;

Begin
FNRWait(1000);

T := GetSystemTime;
While GetSystemTime - T < 60000 Do //1 minute killswitch, again
Begin
If GetSystemTime - T > 30000 Then
MakeCompass('E'); //Change compass after 30 secs, might help with portal finding
If Not AtMine Then
Break;
FindNormalRandoms;
If Not FindArrow Then
Begin
WriteLn('MineToAubury - Could not find the transportation symbol. Exiting');
FNRWait(5000);
Continue;
End;
FindNormalRandoms;
For I := 0 To 5 Do //6 tries to find portal
Begin
If FindPortal(x, y) Then
Begin
Mouse(x, y, 0, 0, True);
T2 := GetSystemTime;
While AtMine And (GetSystemTime - T2 < 10000) Do //We should really be out after 10 secs or so
Begin
//FindTalk;
FNRWait(500);
End;
Break;
End;
Wait(250);
End;
FNRWait(1000);
FindNormalRandoms;
End;
If GetSystemTime - T >= 60000 Then //60 secs for portal finding is already quite long imo
Begin
//LogOut;
WriteLn('No Portal!');
LogOut;
Exit;
End;
MakeCompass('N');
End;

function MageSymbolDistance : integer; //Should be replaced by something that works with Aubury shop middle
var
p : TPoint;
begin
if not FindMagicSymbol(p) then
result := MaxInt
else
result := Distance(p.x, p.y, mmcx, mmcy);
end;

Procedure AuburyToBank; //This entire function needs to be redone. It works, but not perfect.

Var
T: Integer;
P: TPoint;
A: Extended;

Begin
T := GetSystemTime;
While GetSystemTime - T < 120000 Do //We'll try to go to bank for 2 minutes
Begin
FindNormalRandoms;
Mouse(665, 30, 8, 8, True); //magic coords, still working in 2012
Wait(Randomize(6500, 500)); //Small wait, as flag has changed a tiny bit
FindAuburyStore(P);
If (FlagDistance < 40) Or (Not FlagPresent) or (Distance(mmcx, mmcy, P.x, P.y) < 10) Then //Distance needs a bit of tweaking..
Begin //This door handling is still the most crappy thing imaginable.
if (Distance(mmcx, mmcy, P.x, P.y) < 15) then
begin
writeln('Distance to store is close.');
if (BlackOffset <> -1) then //I'll just trust it to use the DDTM then..
begin
Mouse(MMCX, RandomRange(MMCY + 5, MMCY + 10), 4, 0, True);
FNRWait(1500);
if DoorClosed then
writeln('Opened door!')
else
writeln('Could NOT open door!');
end;
end else
begin
writeln('No idea what''s going on now, flag is weird but distance to store..');
Mouse(MMCX, RandomRange(MMCY + 5, MMCY + 15), 4, 0, True);
FNRWait(1500);
DoorClosed;
end;
End
Else
Begin
{ T2 := GetSystemTime;
While GetSystemTime - T2 < 8000 Do
Begin
Wait(1000);
FindMagicSymbol(P);
If Distance(P.x, P.y, MMCX, MMCY) > 30 Then
Break;
End;
FFlag(10); }
FNRWait(8000);
FFlag(10);
FindAuburyStore(P);
If Distance(P.x, P.y, MMCX, MMCY) > 30 Then
Break;
End;
If Not FindAuburyStore(P) Then
Break;
If Distance(P.X, P.Y, MMCX, MMCY) > 30 Then
Break;
End;
WriteLn('Out of shop');
//FFlag(0);
MFlag;
If FindBankers(P, A) Then
Begin
writeln('Found bankers using NPC dots!');
Mouse(P.x, P.y, 0, 0, True);
FNRWait(3000);
//FFlag(0);
MFlag;
End
Else
If FindSymbol(P.x, P.y, 'Bank') Then
Begin
writeln('Found bank using symbol!');
Mouse(P.x, P.y, 0, 0, True);
FNRWait(3000);
//FFlag(0);
MFlag;
End Else
Begin
WriteLn('No Bank');
LogOut;
End;
Players[CurrentPlayer].Loc := 'Bank';
End;

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 IsUpTextMultiCustom(['Talk','lk-to']) then //Remember kids, 'alk' matches both Talk AND Walk
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
Wait(450 + Random(125));
If ChooseOptionMulti(['ele', 'port']) Then
Begin
Result := True;
Exit;
End;
end;
end;
ColorToleranceSpeed(CTS);
end;

Function FindAubury: Boolean; //Not the best!

Var
I, T, cts: Integer;
P: TPoint;
PA: TPointArray;
aPA: T2DPointArray;

Begin
Result := False;
If FindAuburyStore(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);
Wait(1000);
//FFlag(0);
MFlag;
wait(randomize(1200, 200));
End;
End;
If FindAuburyText Then
Begin
Result := True;
Exit;
End;
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsTolerance(PA, 6450290, MSX1, MSY1, MSX2, MSY2, 3); //tolerance seems low
//writeln(inttostr(length(pa))); //but is severly optimized
aPA := TPAToATPA(PA, 50);
SortATPAFrom(aPA, IntToPoint(mscx, mscy)); //Should do MiddlesATPA and then SortTPA (faster)
//writeln(inttostr(length(apa)));
For I := 0 To High(aPA) Do
Begin
//Wait(200);
If AtMine Then
Begin
Result := True;
Break;
End;
If Length(aPA[I]) < 3 Then
Continue;
P := MiddleTPA(aPA[I]);
MMouse(p.X, P.Y, 3, 3);
Wait(150); //Small wait really necessary
writeln('ut: '+rs_GetUpText);
If Not IsUpTextMultiCustom(['bury', 'Talk']) Then //Bug-fix! alk fits 'Walk', too
Continue;
GetMousePos(P.X, P.Y);
Mouse(P.X, P.Y, 0, 0, False);
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;
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, MMX1, MMy1, MMX2, MMY2, 421); //Matches everything besides pure black
ColorToleranceSpeed(cts);
End;

Function ScanMM(Const TPA: TPointArray; SD, ED, MinR, MaxR: Integer): Integer; //Not used anymore with new cool mine handling

Begin
FilterPointsPie(TPA, SD, ED, MinR, MaxR, MMCX, MMCY);
Result := Length(TPA);
{$IFDEF DEBUG} DebugMM(TPA); {$ENDIF}
End;


Function AdeptDegree(CompassAngle: Extended; Degree: Integer): Integer; //idem dito, but I like it

Begin
Result := Round(Abs(CompassAngle + Degree));
While Result > 360 Do
Result := Result - 360;
End;

function AmountOfGaps(ar : TBoolArray) : integer; //Better name: amount of transitions
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;

procedure StartStopGap(ar : tbooleanarray; var start, stop : integer); //Not used.
var //could (in theory) be used for quadrant detection
prevone : boolean;
i : integer;
begin
prevone := ar[0];
for i := 1 to high(ar) do
begin
if ar[i] <> prevone then
begin
start := i;
prevone := ar[i];
break;
end;
end;
for i := i to high(ar) do
begin
if ar[i] <> prevone then
begin
stop := i;
prevone := ar[i];
break;
end;
end;
end;

procedure WalkToMiddleRoom; //No checks, nothing. Just plain clickin'
var
TPA : TPointArray;
p : TPoint;
begin
ColorToleranceSpeed(2); //ACA obviously
SetColorSpeed2Modifiers(1.46, 0.39); //dark grey colour in the mine
FindColorsTolerance(tpa, 10461335, MMX1, MMY1, MMX2, MMY2, 7)
ColorToleranceSpeed(1);
SetColorspeed2Modifiers(0.2, 0.2);
p := MiddleTPA(tpa); //should do
Mouse(p.x, p.y, 4, 4, true);
wait(500);
//FFlag(0);
MFlag;
Wait(500);
end;

function FindEss : Boolean; //ACA love
var
arP : TPointArray;
ararP: T2DPointArray;
arL, i : Integer;
P: TPoint;
// fx, fy : integer;
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.08, 0.17);

if not(FindColorsTolerance(arP, 8618897, MSX1, MSY1, MSX2, MSY2, 29)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(1); //no need to store cts, 1 is always good
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

ararP := SplitTPAEx(arP, 3, 3); //SLLOOOOWWWW, as there are LOTS of points
arL := Min(4, High(ararP)); //and 5 is already a lot, it should find it in 1 try

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(100 + Random(100));
if (IsUpTextMultiCustom(['ine', 'ure', 'ssen'])) then
begin;
Result := True;
ClickMouse2(True); //mine it!
Break;
end;
end;

ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

end;

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
//setupsrl;
ColorToleranceSpeed(0);
FindColorsTolerance(tpa, 0, mmx1, mmy1, mmx2, mmy2, 7); //Find all the black!
ColorToleranceSpeed(1);

for i := 0 to high(tpa) do
BlackArr[tpa[i].x][tpa[i].y] := True;

for radius := 74 downto 50 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
writeln('We are standing in the middle');
if (not(FindDTMRotated(MiddleDTM1, x, y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, Pi/360, aFound))) then //Look what I did here
if (not(FindDTMRotated(MiddleDTM2, x, y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, Pi/360, aFound))) then
begin
writeln('Force-walking to the middle of room..');
WalkToMiddleRoom;
if FindSymbol(x, y, 'transportation') then
begin
writeln('We weren''t in the middle indeed');
//WalkToMiddleRoom;
writeln('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;
writeln('Location detection failed! No middle and no DTMs');
Players[0].Loc := 'NoMine';
result := False;
exit;
end; //else
writeln('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(X, Y, 4, 4, True); //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
begin
NoEssFound := True;
WriteLn('No Essence');
//NoEssenceFound := True;
end;
end;
end else
// if(AmountOfGaps(angles) = 2) then
begin
writeln('We are standing in a room');
writeln('Fortunately we can walk to the middle.');
WalkToMiddleRoom;
writeln('should be in middle of mine now');
if (not(FindEss)) then
begin
NoEssFound := True;
WriteLn('No Essence Corner');
end;
{writeln('We can now determine exct loc') //Useless. Essmine rotates so we should not rely on that
StartStopGap(angles, start, stop);
writeln('START: '+inttostr(start)+', STOP: '+inttostr(stop));
writeln('Location: '+locationnames[(start+stop) div 180]);}
end
end;

Function EssenceCount: Integer;

{Var
I: Integer;
TPA: TPointArray;
B: TBox; }

Begin
{ Result := 0;
For I := 1 To 28 Do
Begin
B := InvBox(I);
FindColorsTolerance(TPA, 65536, B.X1, B.Y1, B.X2, B.Y2, 0);
If Length(TPA) = 82 Then //doesnt work anymore
Result := Result + 1;
End; }
result := InvCount; //Too bad if your pickaxe isnt equipped
End;

Procedure Bank;

Var
I: Integer;
P: TPoint;
A: Extended;
TempEss: Integer;

Begin
//ReportVars[1] := ReportVars[1] + 1; // Banks
Players[CurrentPlayer].Banked := Players[CurrentPlayer].Banked + 1;
For I := 0 To 2 Do
If OpenBankFast('veb') Then
Break
Else
If FindBankers(P, A) Then
Begin
Mouse(p.x, p.y, 0, 0, True);
Wait(4000);
//FFlag(0);
MFlag;
Wait(1500);
End;
If Not BankScreen Or PinScreen Then
Begin
LogOut;
Players[CurrentPlayer].Loc := 'NoBank';
Players[CurrentPlayer].Active := False;
Exit;
End;
TempEss := EssenceCount;
EssenceMined := EssenceMined + TempEss;
//ReportVars[0] := ReportVars[0] + TempEss;
Players[CurrentPlayer].Integers[0] := Players[CurrentPlayer].Integers[0] + TempEss;
If Players[CurrentPlayer].Booleans[0] Then
Deposit(1, 28, True)
Else
Deposit(2, 28, True); //blindly assumes it is in spot 1

if (random(3) = 1) then //no need to close it all the time Wiz
CloseBank;
End;

Procedure PlayerReport;

Var
Active, Rand: string;
I: Integer;

Begin
For I := 0 To High(Players) Do
Begin
If Players[i].Active Then
Active := 'T'
Else
Active := 'F';
If Players[i].Rand <> '' Then
Rand := '; Rand: ' + Players[i].Rand
Else
Rand := '';

WriteLn((IntToStr(I)) + ' : ' + Players[I].Nick + ' = ' +
Active + '; ' + Players[I].Loc + rand + '; B: ' + IntToStr(Players[I].Integers[0])
+ ' Essence;'+ ' M : ' + IntToStr(Players[I].Level[15]));
End;
End;

Procedure ProgressReport;

Begin
WriteLn('----------------------------');
WriteLn('');
WriteLn('Wizzup? and Markus Essence Miner, Version ' + VersionNumber);
WriteLn('');
WriteLn('Worked for '+ TimeRunning);
WriteLn('Mined ' + IntToStr(EssenceMined) + ' Essence');
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('----------------------------');
SRLRandomsReport;
End;

Procedure ScriptTerminate;

Begin
ProgressReport;
End;

Function GetAndSetAnyReferenceColor: Boolean; //if I could get black here, I'd do it.

//Var
// c: integer;

Begin
NewAutoColorWorked := False;
result := False;
Exit;
{
c := AutoColor(srl_RockColor);
If c > 0 Then
Begin
SetAutoColorReference('grey rock', c);
WriteLn('Got the color using the grey rock');
NewAutoColorWorked := True;
Result := True;
Exit;
End; }
End;

Procedure InitPlayer;
{
Var
I: Integer; }
Begin
{For I := 1 To 5 Do
If Not Players[CurrentPlayer].Booleans[I] Then
Begin
Case I Of
1: SetGraphics(4, '', '' ,'', '', '', '', '', '');
2: Retaliate(False);
3: SetAudio(0, 0, 0, Mono);
End;
Players[CurrentPlayer].Booleans[I] := True;
End;}

GetAllLevels;
SetChat('on',1);
SetChat('friends',2);
SetChat('on',3);
SetAngle(SRL_ANGLE_HIGH);
End;

Procedure SetupScript;

//Var
// I: Integer;
Begin
// SRLID := SRL_ID;
//SRLPassword := SRL_PASS;
// For I := 1 To 19 Do
// ReportVars[I] := 0;
//ScriptID := '51';
DeclarePlayers;
LoginPlayer;
InitPlayer;

//BlackOffset := -1;

//Thanks to Demise for restoring my faith in DTMs :)
MiddleDTM1 := DTMFromString('mlwAAAHicY2dgYChhYmCIBuIMIK4B4g4gjg HiOiAOAcr7A7'+
'ELEFsBcTIQxwGxFxD///+fwVyNAwW7aAkyfH79kWECIwMDPwN2zIgHQwEAMRYOKA==');
MiddleDTM2 := DTMFromString('mggAAAHicY2NgYKhiYmAoAOIGIG4H4glAnA PE4UA5JyB2BW'+
'IfIM4G4kwgfvTmHYO9gTCDkQ4XGG/Zuw/Mn8DIwMDPgIkZcWAIAAAOAAyf');

{DTMAuburyMap := DTMFromString('mwQAAAHic42RgYNBlZGBQA2I9IJYF4v9AMW EgHQzEBkCs'+ //Thanks Demise, for this one
'AcS3gWIHofg6ED9kgKh7DMRcQPlNQDop1IwhxpgbjP1ddRg8H Q0YnKxUGb4zMjFEhIcx/P/PySA'+
'JVEcIMxGB4QAAolMSVg==');}

DTMAuburyDoor := DTMFromString('mAAEAAHic42FgYDAGYnkodoVikJgClG0CxE ZAHM8AAfx'+ //Thanks Demise, love you!
'AzAvEAlA2NxBLA7EMEEsBsSZUHcg8USDOjrFgyIoxZyhIsGTI jDJlSI0wZciIMmPIibNkiAs0ZN'+
'DVVGII8dBh0NYRZ6gNlgObSQpmBGImIjAbFCMDAJFbDpI=');

SetDTMName(MiddleDTM1, 'Middle DTM 1');
SetDTMName(MiddleDTM2, 'Middle DTM 2');
SetDTMName(DTMAuburyDoor, 'Aubury door DTM');
End;

Var
T, T2, I:integer;

begin
//Smartsetup(SmartPrefix, true, true, false);
//Settargetdc(smartgetdc);
AubTPA := CreateTPAFromText('isthin', UpCharsEx);
Smart_Server := 52;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupScript;
//LoadLocations;
//SetupNewAutoColor;
GetAndSetAnyReferenceColor;
Repeat

If Players[CurrentPlayer].Loc = 'Bank' Then
BankToAubury;

If Players[CurrentPlayer].Loc = 'Aubury' Then
Begin
T2 := GetSystemTime;
While Not AtMine Do
Begin
If GetSystemTime - T2 > 180000 Then
Begin
Players[CurrentPlayer].Loc := 'NoAubury';
Break;
End;
//DoorClosed; //ffs, walk to the right place first ;)
If FindAubury Then
Begin
T := GetSystemTime;
While (Not AtMine) and (GetSystemTime - t < 10000) Do Wait(250);
If AtMine Then
Break;
End;
Wait(500);
End;
Players[CurrentPlayer].Loc := 'Mine';
End;

If Players[CurrentPlayer].Loc = 'Mine' Then
Begin
Wait(500);
// If InAbyss Then
// SolveAbyss;

LocateInsideEssMine;
T := GetSystemTime;
T2 := GetSystemTime;
While (GetSystemTime - T < 180000) And (InvCount < 28) Do
Begin
If NoEssFound Then
Begin
WriteLn('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) + 21;
If I = tab_Inv Then I := tab_Stats;
GameTab(I);
Wait(RandomRange(200, 4000));
GameTab(tab_Inv);
T2 := GetSystemTime;
End;

Wait(1000);
If LevelUp Then
Begin
WriteLn('You levelled up, congratulations!'); //Wizzup? wasn't nice here, but I am
Break;
End;
If FindNormalRandoms Then
Begin
T := GetSystemTime;
While GetSystemTime - T < 5000 Do
Begin
Wait(250);
FindNormalRandoms;
End;
End;
End;
MineToAubury;
AuburyToBank;
Bank;
End;

ProgressReport;

If Not LoggedIn Then
Begin
NextPlayer(False);
InitPlayer;
Continue;
End;

If Players[CurrentPlayer].Banked Mod Loads = 0 Then
Begin
NextPlayer(True);
InitPlayer;
Continue;
End;

Until False;
End.

Hope it works, Psyonity

Abu
04-03-2012, 04:57 PM
Markus, looks like you've done a very good job but.... will this be moved to private once flawless?

Thanks


P.S - if you need help with anything, I'll try :)

xtrapsp
04-08-2012, 11:31 PM
I wanted a ess miner, but this one didn't work... So I looked at it, thought the color of the symbol was wrong, made a new one, and it worked! So here the script again with the new color and for the others, the inAbyss is commented out.

program New;
{$i srl/srl/misc/smart.simba}
{$i srl/srl.simba}
{$ifdef smart}
{$i srl/srl/misc/paintsmart.simba}
{$endif}

Const
NumberOfUsers = 1;
StartPlayer = 0;
Loads = 5;
VersionNumber = '3.01';
FastAubury = True;
SRL_ID = ''; // Stats ID.
SRL_PASS = ''; // Stats Pass.
//SmartPrefix = 'world10';

{Type
EssLoc = Record
Name: String;
Info: Array Of Array Of Integer;
MMClicks, MSEss: TPointArray;
L, ReportIDVar: Integer;
End;
EssLocArray = Array Of EssLoc; }

Var
// EssInfo: EssLocArray;
AubTPA: TPointArray;
NewAutoColorWorked, NoEssFound: Boolean;
EssenceMined, Abyss: Integer;
MiddleDTM1, MiddleDTM2, DTMAuburyMap, DTMAuburyDoor : integer;
//BlackOffset : integer;
//{$DEFINE DEBUG}

Procedure DeclarePlayers;

Begin
NumberOfPlayers( NumberOfUsers );
CurrentPlayer := StartPlayer;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='gpk';
Players[0].Active := True;
Players[0].Loc := 'Bank';
Players[0].Booleans[0] := False; // Is The Pick Equipped?
// Is The Pick Equipped?

Writeln( IntToStr ( HowManyPlayers ) + ' Players' );
End;

Procedure FNRWait(ms: Integer);

Var
T: Integer;
Begin
T := GetSystemTime;
While GetSystemTime - T < ms Do
Begin
Wait(200);
FindNormalRandoms;
End;
End;

procedure MFlag;
var
t : integer;
begin
FFlag(0);
t := GetSystemTime;
while (GetSystemTime-t) < 7500 do
if (PixelShift(IntToBox(mmx1, mmy1, mmx2, mmy2), 200)) < 1000 then //1000 should do
break;
end;

Procedure DebugMM(TPA: TPointArray);
{
Var
I, L: Integer;
C: TCanvas; }

Begin
{DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(MMX2-MMX1, MMY2-MMY1);
C := GetDebugCanvas;
CopyCanvas(GetClientCanvas, C, MMX1, MMY1, MMX2, MMY2, 0, 0, MMX2 - MMX1, MMY2 - MMy1);
L := High(tpa);
For I := 0 To L Do
C.Pixels[tpa[i].x - MMX1, tpa[i].y - MMY1] := 255;
DisplayDebugImgWindow(MMX2-MMX1, MMY2-MMY1); }
End;

function BlackOffset : integer; //Inspired by GetMinimapDots
var //18msecs, pretty slow...
TPA : TPointArray;
i : integer;
begin
result := -1;
FindColorsTolerance(TPA, 3699532, mmx1, mmy1, mmx2, mmy2, 20); //should do?
for i := 0 to high(TPA) do
begin
if (GetColor(TPA[I].X, TPA[I].Y) - GetColor(TPA[I].X-1, TPA[I].Y) = (3699532-1196650)) then
begin //a1 //a2 //a1-a2 = dif
Result := 0-((3699532-329220)-GetColor(TPA[I].X, TPA[I].Y));//magic //c1-c2 = dif
//writeln('Black offset: '+ToStr(result)); //c2 = c1-dif
exit;
end;
end;
end;

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 := [2595570, 2925567];

SetLength(Points, 0);
For I := 0 To High(MagicSymbolColors) Do
Begin
SetLength(P2, 0);
SetLength(C, 0);
//writeln('U wanted me?');
FindColorsTolerance(P2, MagicSymbolColors[I], MMX1, MMY1, MMX2, MMY2, 10);
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
Begin
SetLength(Points, Length(Points) + 1);
Points[High(Points)] := P2[J];
End;
End;
//Points := CombineTPA(Points, P2);
End;
{$IFDEF DEBUG} debugMM(Points); {$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
WriteLn('No Aubury Shop');
End;

function FindAuburyStore(var P : TPoint) : boolean;
var
AuburyMapDDTM : TSDTM;
DTMAuburyMap : integer;
aFound : extended;
P2 : TPoint;
begin
if (BlackOffset = -1) then
begin
result := FindMagicSymbol(P);
exit;
end;

{ Stop here.
Look at this DDTM, it works quite smart imho ^-^.
This uses the old colour relation technique discovered by yours truly in 2007.
The technique is most commonly used for autocoloring stuff, but there are a
few other uses like this one. The black colour is nowadays also 'modified'
(not static), so I use it as an offset. From every colour, the main 'black'
is substracted (the 329220) so it's made for black = 0. Because nowadays in RS
the black is never true black, we add the 'rs black' to it (AtMine sets it).
This way, we can create a DDTM with 100% accurate colors. No false positives.
Note, it has a bit of area tolerance to accomodate for RS ugly rotation.
For some reason, the last point (which is just terrain) didn't work too well
so that one uses regular 15 tol. It's just an anchor point though, the real
uniqueness is point 0 (the tiny bit of black at the the left).
Points 1 and 2 are the two trees south of VEB, behind the fence. }

AuburyMapDDTM.MainPoint.x := 608;
AuburyMapDDTM.MainPoint.y := 107;
AuburyMapDDTM.MainPoint.Color := 13371337; //who cares
AuburyMapDDTM.MainPoint.Tolerance := 500; //tol is high enough
SetLength(AuburyMapDDTM.SubPoints, 4);

with AuburyMapDDTM.SubPoints[0] do
begin
x := 668;
y := 109;
Color := BlackOffset;
areasize := 2;
end;

with AuburyMapDDTM.SubPoints[1] do
begin
x := 606;
y := 48;
Color := 3699532-329220+BlackOffset; //green
Tolerance := 0;
AreaSize := 2;
end;

with AuburyMapDDTM.SubPoints[2] do
begin
x := 615;
y := 49;
Color := 1196650-329220+BlackOffset; //brown
AreaSize := 2;
end;

with AuburyMapDDTM.SubPoints[3] do //This is part of the terrain
begin //probably calculated different or whatever
x := 631;
y := 49;
Color := 2511437-329220+BlackOffset;
AreaSize := 2;
Tolerance := 15;
end;

//After typing this all of this by hand, WHERE THE F@#! IS THE DDTM EDITOR!!!

DTMAuburyMap := AddSDTM(AuburyMapDDTM);
SetDTMName(DTMAuburyMap, 'Aubury Map DDTM');
//For some reason it tried to click @ quest tab?
if FindDTMRotated(DTMAuburyMap, P.x, P.y, mmx1, mmy1, mmx2, mmy2-5, -pi/2, pi/2, pi/60, afound) then
begin //should do some checks here to make sure it isn't too far of from mage symbol..
writeln('Found Aubury store using offset DDTM!');
if (FindMagicSymbol(P2)) then
begin
if Distance(p2.x, p2.y, p.x, p.y) > 15 then //can be tweaked
begin
writeln('Distance too big. Falling back to magic symbol!');
P := P2;
end;
result := true;
end;
FreeDTM(DTMAuburyMap); //Thanks to Wizzup's leak finder, else wouldnt have found this one.
exit;
end;
FreeDTM(DTMAuburyMap);
result := FindMagicSymbol(P); //Fallback
end;


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);
B := GetMiniMapDots('npc');
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 - 5;
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;

Function Randomize(x, Randomness: Integer): Integer;

Begin
Result := RandomRange(X - Randomness, X + Randomness);
End;

Function AtMine: Boolean; //Counts the black to see if we are in the mine

Var
TPA: TPointArray;
Begin
ColorToleranceSpeed(0);
FindColorsTolerance(TPA, 65536, MMX1, MMY1, MMX2, MMY2, 7);
ColorToleranceSpeed(1);
Result := Length(TPA) > 2000;

{ if (result) and (BlackOffset = -1) then
begin //fck this
BlackColors := GetColors(TPA);
ClearSameIntegers(BlackColors);
for i := 0 to high (BlackColors) do
begin
FindColorsTolerance(TPA, BlackColors[i], mmx1, mmy1, mmx2, mmy2, 0);
if (length(TPA) > maxcount) then
begin
BlackOffset := BlackColors[i];
maxcount := Length(TPA);
end;
end;
Writeln('Calculated black offset = '+ToStr(BlackOffset));
end; }
End;

function FindPortal(var cx, cy: Integer): 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;
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;

SetToleranceSpeed2Modifiers(GroundHue, GroundSat);
if not FindColorsTolerance(NewTPA, GroundColor, SearchBox.x1, SearchBox.y1, //Finds ground colours
SearchBox.x2, SearchBox.y2, GroundTol) then
Exit;

SetToleranceSpeed2Modifiers(WallHue, WallSat); //Finds wall colours
FindColorsTolerance(ColorsTPA, WallColor, SearchBox.x1, SearchBox.y1,
SearchBox.x2, SearchBox.y2, WallTol);

ColorsTPA := CombineTPA(ColorsTPA, NewTPA); //Combine both

SetToleranceSpeed2Modifiers(EdgeHue, EdgeSat);
FindColorsTolerance(EdgeTPA, EdgeColor, SearchBox.x1, SearchBox.y1,
SearchBox.x2, SearchBox.y2, EdgeTol);
//Add edge colours, too
AppendTPA(ColorsTPA, EdgeTPA);
NewTPA := ClearTPAFromTPA(SearchTPA, ColorsTPA); //SearchTPA is the entire box we are searching in,
ColorsTPA := ClearTPAFromTPA(NewTPA, CharTPA); //We remove our own character and all other points from it

ResultsATPA := SplitTPA(ColorsTPA, 1);
SetLength(NewATPA, 0);

for I := 0 to High(ResultsATPA) do //This thing is still a miracle to me
begin

AreaBox := GetTPABounds(ResultsATPA[i]);
Area := ((AreaBox.X2 - AreaBox.X1) * (AreaBox.Y2 - AreaBox.Y1));

if (InRange(Area, 500, 1500) and (InRange(Length(ResultsATPA[i]), 250, //Probably filters based on not being too small/large
1200))) then
begin

SetLength(NewATPA, Length(NewATPA) + 1);
NewATPA[Match] := ResultsATPA[i];
Inc(Match);
end;
end;

if Length(NewATPA) = 0 then //When no points left, no point to contine
Exit;

SortATPAFromMidPoint(NewATPA, IntToPoint(MSCX, MSCY));

for I := 0 to High(NewATPA) do //Regular (A)TPA iteration
begin

TestPoint := MiddleTPA(NewATPA[i]);
MMouse(TestPoint.x, TestPoint.y, 5, 5);

if WaitUpTextMulti(['Enter', 'Portal', 'nter', 'ortal', 'er P'], 500) then
begin
{$IfDef SMART}
Smart_DrawDotsEx(True, NewATPA[i], clFuchsia); //Flashes the points, though noone watches it.
Wait(100);
SMART_ClearCanvas;
{$EndIf}
Result := True;

cx := TestPoint.x;
cy := TestPoint.y;
Break;
end;
end;
end;

Function DoorClosedWizzup: Boolean;

Var
TP: TPoint;
TPA: TPointArray;
aTPA: T2DPointArray;
I, c: Integer;


Begin
Result := False;
c := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.2, 0.5);
FindColorsTolerance(TPA, 3561057, 3, 3, 515, 336, 8);
//aTPA := TPAToATPAEx(TPA, 50, 50);
aTPA := SplitTPA(TPA, 3);
SortATPAFrom(aTPA, IntToPoint(mscx, mscy)); //noob Wizzup forgot this one -.-'
For I := 0 To High(aTPA) Do
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.X, TP.Y, 0, 0, True);
//FFlag(0);
MFlag;
Break;
End;
End;
ColorToleranceSpeed(c);
SetColorspeed2Modifiers(0.2, 0.2);
End;

function DoorClosedDTM : boolean; //I dont want too many DTMs in here, but Demise likes them so much
var //and if she does the hard work, why would I? ;)
x, y : integer;
aFound : extended;
begin
result := False;
if FindDTMRotated(DTMAuburyDoor, x, y, msx1, msy1, msx2, msy2, -Pi/4, Pi/4, Pi/60, aFound) then
begin
MMouse(x, y, 5, 5);
if IsUpText('pen') and IsUpText('oor') then
begin
Result := True;
ClickMouse2(true);
MFlag;
end;
end;
end;

function DoorClosed : boolean; //'Kapstopfunctie'
begin
writeln('Opening door!');
if DoorClosedDTM then
result := true
else if DoorClosedWizzup then
result := true
else
result := false;
end;

Function FindArrow: Boolean;

Var
x, y: Integer;
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
Result := True;
WriteLn('Succesfully used NewAutoColor for FindArrow');
End; }
If Not Result Then
If FindSymbol(x, y, 'transportation') Then
Result := True;
If Result Then
Begin
Mouse(x, y, 4, 4, True);
Wait(1000);
//FFlag(0);
MFlag;
FNRWait(1000);
End;
End;

Procedure BankToAubury; //need to add a dtm to this, symbol really isnt accurate at all

Var
V: TPoint;
T: Integer;
Begin
FindNormalRandoms;
MFNF(Randomize(640, 4), Randomize(140, 4), -1, -1);
Wait(10000); //Walk is indeed something ike 10, 15 seconds
T := GetSystemTime; //As flag isn't visible, this is the right way to do it
While (GetSystemTime - T < 60000) Do //60 sec killswitch again, he seems to love those
Begin
FindNormalRandoms;
If FindAuburyStore(V) Then //used to be symbol. After the first run, uses DTM.
Break;
Wait(500);
End;
If GetSystemTime - T >= 60000 Then
Begin
WriteLn('BankToAuburyTime');
LogOut;
Exit;
End; //It wanted to click at quest tab, wtf.
Mouse(V.X, min(V.Y + 3,mmy2-5), 0, 0, True); //Coords of mage symbol are found above
Wait(500);
//FFlag(0);
MFlag;
Players[CurrentPlayer].Loc := 'Aubury';
End;

Procedure MineToAubury;

Var
x, y, T, T2, I: Integer;

Begin
FNRWait(1000);

T := GetSystemTime;
While GetSystemTime - T < 60000 Do //1 minute killswitch, again
Begin
If GetSystemTime - T > 30000 Then
MakeCompass('E'); //Change compass after 30 secs, might help with portal finding
If Not AtMine Then
Break;
FindNormalRandoms;
If Not FindArrow Then
Begin
WriteLn('MineToAubury - Could not find the transportation symbol. Exiting');
FNRWait(5000);
Continue;
End;
FindNormalRandoms;
For I := 0 To 5 Do //6 tries to find portal
Begin
If FindPortal(x, y) Then
Begin
Mouse(x, y, 0, 0, True);
T2 := GetSystemTime;
While AtMine And (GetSystemTime - T2 < 10000) Do //We should really be out after 10 secs or so
Begin
//FindTalk;
FNRWait(500);
End;
Break;
End;
Wait(250);
End;
FNRWait(1000);
FindNormalRandoms;
End;
If GetSystemTime - T >= 60000 Then //60 secs for portal finding is already quite long imo
Begin
//LogOut;
WriteLn('No Portal!');
LogOut;
Exit;
End;
MakeCompass('N');
End;

function MageSymbolDistance : integer; //Should be replaced by something that works with Aubury shop middle
var
p : TPoint;
begin
if not FindMagicSymbol(p) then
result := MaxInt
else
result := Distance(p.x, p.y, mmcx, mmcy);
end;

Procedure AuburyToBank; //This entire function needs to be redone. It works, but not perfect.

Var
T: Integer;
P: TPoint;
A: Extended;

Begin
T := GetSystemTime;
While GetSystemTime - T < 120000 Do //We'll try to go to bank for 2 minutes
Begin
FindNormalRandoms;
Mouse(665, 30, 8, 8, True); //magic coords, still working in 2012
Wait(Randomize(6500, 500)); //Small wait, as flag has changed a tiny bit
FindAuburyStore(P);
If (FlagDistance < 40) Or (Not FlagPresent) or (Distance(mmcx, mmcy, P.x, P.y) < 10) Then //Distance needs a bit of tweaking..
Begin //This door handling is still the most crappy thing imaginable.
if (Distance(mmcx, mmcy, P.x, P.y) < 15) then
begin
writeln('Distance to store is close.');
if (BlackOffset <> -1) then //I'll just trust it to use the DDTM then..
begin
Mouse(MMCX, RandomRange(MMCY + 5, MMCY + 10), 4, 0, True);
FNRWait(1500);
if DoorClosed then
writeln('Opened door!')
else
writeln('Could NOT open door!');
end;
end else
begin
writeln('No idea what''s going on now, flag is weird but distance to store..');
Mouse(MMCX, RandomRange(MMCY + 5, MMCY + 15), 4, 0, True);
FNRWait(1500);
DoorClosed;
end;
End
Else
Begin
{ T2 := GetSystemTime;
While GetSystemTime - T2 < 8000 Do
Begin
Wait(1000);
FindMagicSymbol(P);
If Distance(P.x, P.y, MMCX, MMCY) > 30 Then
Break;
End;
FFlag(10); }
FNRWait(8000);
FFlag(10);
FindAuburyStore(P);
If Distance(P.x, P.y, MMCX, MMCY) > 30 Then
Break;
End;
If Not FindAuburyStore(P) Then
Break;
If Distance(P.X, P.Y, MMCX, MMCY) > 30 Then
Break;
End;
WriteLn('Out of shop');
//FFlag(0);
MFlag;
If FindBankers(P, A) Then
Begin
writeln('Found bankers using NPC dots!');
Mouse(P.x, P.y, 0, 0, True);
FNRWait(3000);
//FFlag(0);
MFlag;
End
Else
If FindSymbol(P.x, P.y, 'Bank') Then
Begin
writeln('Found bank using symbol!');
Mouse(P.x, P.y, 0, 0, True);
FNRWait(3000);
//FFlag(0);
MFlag;
End Else
Begin
WriteLn('No Bank');
LogOut;
End;
Players[CurrentPlayer].Loc := 'Bank';
End;

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 IsUpTextMultiCustom(['Talk','lk-to']) then //Remember kids, 'alk' matches both Talk AND Walk
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
Wait(450 + Random(125));
If ChooseOptionMulti(['ele', 'port']) Then
Begin
Result := True;
Exit;
End;
end;
end;
ColorToleranceSpeed(CTS);
end;

Function FindAubury: Boolean; //Not the best!

Var
I, T, cts: Integer;
P: TPoint;
PA: TPointArray;
aPA: T2DPointArray;

Begin
Result := False;
If FindAuburyStore(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);
Wait(1000);
//FFlag(0);
MFlag;
wait(randomize(1200, 200));
End;
End;
If FindAuburyText Then
Begin
Result := True;
Exit;
End;
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsTolerance(PA, 6450290, MSX1, MSY1, MSX2, MSY2, 3); //tolerance seems low
//writeln(inttostr(length(pa))); //but is severly optimized
aPA := TPAToATPA(PA, 50);
SortATPAFrom(aPA, IntToPoint(mscx, mscy)); //Should do MiddlesATPA and then SortTPA (faster)
//writeln(inttostr(length(apa)));
For I := 0 To High(aPA) Do
Begin
//Wait(200);
If AtMine Then
Begin
Result := True;
Break;
End;
If Length(aPA[I]) < 3 Then
Continue;
P := MiddleTPA(aPA[I]);
MMouse(p.X, P.Y, 3, 3);
Wait(150); //Small wait really necessary
writeln('ut: '+rs_GetUpText);
If Not IsUpTextMultiCustom(['bury', 'Talk']) Then //Bug-fix! alk fits 'Walk', too
Continue;
GetMousePos(P.X, P.Y);
Mouse(P.X, P.Y, 0, 0, False);
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;
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, MMX1, MMy1, MMX2, MMY2, 421); //Matches everything besides pure black
ColorToleranceSpeed(cts);
End;

Function ScanMM(Const TPA: TPointArray; SD, ED, MinR, MaxR: Integer): Integer; //Not used anymore with new cool mine handling

Begin
FilterPointsPie(TPA, SD, ED, MinR, MaxR, MMCX, MMCY);
Result := Length(TPA);
{$IFDEF DEBUG} DebugMM(TPA); {$ENDIF}
End;


Function AdeptDegree(CompassAngle: Extended; Degree: Integer): Integer; //idem dito, but I like it

Begin
Result := Round(Abs(CompassAngle + Degree));
While Result > 360 Do
Result := Result - 360;
End;

function AmountOfGaps(ar : TBoolArray) : integer; //Better name: amount of transitions
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;

procedure StartStopGap(ar : tbooleanarray; var start, stop : integer); //Not used.
var //could (in theory) be used for quadrant detection
prevone : boolean;
i : integer;
begin
prevone := ar[0];
for i := 1 to high(ar) do
begin
if ar[i] <> prevone then
begin
start := i;
prevone := ar[i];
break;
end;
end;
for i := i to high(ar) do
begin
if ar[i] <> prevone then
begin
stop := i;
prevone := ar[i];
break;
end;
end;
end;

procedure WalkToMiddleRoom; //No checks, nothing. Just plain clickin'
var
TPA : TPointArray;
p : TPoint;
begin
ColorToleranceSpeed(2); //ACA obviously
SetColorSpeed2Modifiers(1.46, 0.39); //dark grey colour in the mine
FindColorsTolerance(tpa, 10461335, MMX1, MMY1, MMX2, MMY2, 7)
ColorToleranceSpeed(1);
SetColorspeed2Modifiers(0.2, 0.2);
p := MiddleTPA(tpa); //should do
Mouse(p.x, p.y, 4, 4, true);
wait(500);
//FFlag(0);
MFlag;
Wait(500);
end;

function FindEss : Boolean; //ACA love
var
arP : TPointArray;
ararP: T2DPointArray;
arL, i : Integer;
P: TPoint;
// fx, fy : integer;
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.08, 0.17);

if not(FindColorsTolerance(arP, 8618897, MSX1, MSY1, MSX2, MSY2, 29)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(1); //no need to store cts, 1 is always good
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

ararP := SplitTPAEx(arP, 3, 3); //SLLOOOOWWWW, as there are LOTS of points
arL := Min(4, High(ararP)); //and 5 is already a lot, it should find it in 1 try

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(100 + Random(100));
if (IsUpTextMultiCustom(['ine', 'ure', 'ssen'])) then
begin;
Result := True;
ClickMouse2(True); //mine it!
Break;
end;
end;

ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

end;

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
//setupsrl;
ColorToleranceSpeed(0);
FindColorsTolerance(tpa, 0, mmx1, mmy1, mmx2, mmy2, 7); //Find all the black!
ColorToleranceSpeed(1);

for i := 0 to high(tpa) do
BlackArr[tpa[i].x][tpa[i].y] := True;

for radius := 74 downto 50 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
writeln('We are standing in the middle');
if (not(FindDTMRotated(MiddleDTM1, x, y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, Pi/360, aFound))) then //Look what I did here
if (not(FindDTMRotated(MiddleDTM2, x, y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, Pi/360, aFound))) then
begin
writeln('Force-walking to the middle of room..');
WalkToMiddleRoom;
if FindSymbol(x, y, 'transportation') then
begin
writeln('We weren''t in the middle indeed');
//WalkToMiddleRoom;
writeln('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;
writeln('Location detection failed! No middle and no DTMs');
Players[0].Loc := 'NoMine';
result := False;
exit;
end; //else
writeln('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(X, Y, 4, 4, True); //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
begin
NoEssFound := True;
WriteLn('No Essence');
//NoEssenceFound := True;
end;
end;
end else
// if(AmountOfGaps(angles) = 2) then
begin
writeln('We are standing in a room');
writeln('Fortunately we can walk to the middle.');
WalkToMiddleRoom;
writeln('should be in middle of mine now');
if (not(FindEss)) then
begin
NoEssFound := True;
WriteLn('No Essence Corner');
end;
{writeln('We can now determine exct loc') //Useless. Essmine rotates so we should not rely on that
StartStopGap(angles, start, stop);
writeln('START: '+inttostr(start)+', STOP: '+inttostr(stop));
writeln('Location: '+locationnames[(start+stop) div 180]);}
end
end;

Function EssenceCount: Integer;

{Var
I: Integer;
TPA: TPointArray;
B: TBox; }

Begin
{ Result := 0;
For I := 1 To 28 Do
Begin
B := InvBox(I);
FindColorsTolerance(TPA, 65536, B.X1, B.Y1, B.X2, B.Y2, 0);
If Length(TPA) = 82 Then //doesnt work anymore
Result := Result + 1;
End; }
result := InvCount; //Too bad if your pickaxe isnt equipped
End;

Procedure Bank;

Var
I: Integer;
P: TPoint;
A: Extended;
TempEss: Integer;

Begin
//ReportVars[1] := ReportVars[1] + 1; // Banks
Players[CurrentPlayer].Banked := Players[CurrentPlayer].Banked + 1;
For I := 0 To 2 Do
If OpenBankFast('veb') Then
Break
Else
If FindBankers(P, A) Then
Begin
Mouse(p.x, p.y, 0, 0, True);
Wait(4000);
//FFlag(0);
MFlag;
Wait(1500);
End;
If Not BankScreen Or PinScreen Then
Begin
LogOut;
Players[CurrentPlayer].Loc := 'NoBank';
Players[CurrentPlayer].Active := False;
Exit;
End;
TempEss := EssenceCount;
EssenceMined := EssenceMined + TempEss;
//ReportVars[0] := ReportVars[0] + TempEss;
Players[CurrentPlayer].Integers[0] := Players[CurrentPlayer].Integers[0] + TempEss;
If Players[CurrentPlayer].Booleans[0] Then
Deposit(1, 28, True)
Else
Deposit(2, 28, True); //blindly assumes it is in spot 1

if (random(3) = 1) then //no need to close it all the time Wiz
CloseBank;
End;

Procedure PlayerReport;

Var
Active, Rand: string;
I: Integer;

Begin
For I := 0 To High(Players) Do
Begin
If Players[i].Active Then
Active := 'T'
Else
Active := 'F';
If Players[i].Rand <> '' Then
Rand := '; Rand: ' + Players[i].Rand
Else
Rand := '';

WriteLn((IntToStr(I)) + ' : ' + Players[I].Nick + ' = ' +
Active + '; ' + Players[I].Loc + rand + '; B: ' + IntToStr(Players[I].Integers[0])
+ ' Essence;'+ ' M : ' + IntToStr(Players[I].Level[15]));
End;
End;

Procedure ProgressReport;

Begin
WriteLn('----------------------------');
WriteLn('');
WriteLn('Wizzup? and Markus Essence Miner, Version ' + VersionNumber);
WriteLn('');
WriteLn('Worked for '+ TimeRunning);
WriteLn('Mined ' + IntToStr(EssenceMined) + ' Essence');
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('----------------------------');
SRLRandomsReport;
End;

Procedure ScriptTerminate;

Begin
ProgressReport;
End;

Function GetAndSetAnyReferenceColor: Boolean; //if I could get black here, I'd do it.

//Var
// c: integer;

Begin
NewAutoColorWorked := False;
result := False;
Exit;
{
c := AutoColor(srl_RockColor);
If c > 0 Then
Begin
SetAutoColorReference('grey rock', c);
WriteLn('Got the color using the grey rock');
NewAutoColorWorked := True;
Result := True;
Exit;
End; }
End;

Procedure InitPlayer;
{
Var
I: Integer; }
Begin
{For I := 1 To 5 Do
If Not Players[CurrentPlayer].Booleans[I] Then
Begin
Case I Of
1: SetGraphics(4, '', '' ,'', '', '', '', '', '');
2: Retaliate(False);
3: SetAudio(0, 0, 0, Mono);
End;
Players[CurrentPlayer].Booleans[I] := True;
End;}

GetAllLevels;
SetChat('on',1);
SetChat('friends',2);
SetChat('on',3);
SetAngle(SRL_ANGLE_HIGH);
End;

Procedure SetupScript;

//Var
// I: Integer;
Begin
// SRLID := SRL_ID;
//SRLPassword := SRL_PASS;
// For I := 1 To 19 Do
// ReportVars[I] := 0;
//ScriptID := '51';
DeclarePlayers;
LoginPlayer;
InitPlayer;

//BlackOffset := -1;

//Thanks to Demise for restoring my faith in DTMs :)
MiddleDTM1 := DTMFromString('mlwAAAHicY2dgYChhYmCIBuIMIK4B4g4gjg HiOiAOAcr7A7'+
'ELEFsBcTIQxwGxFxD///+fwVyNAwW7aAkyfH79kWECIwMDPwN2zIgHQwEAMRYOKA==');
MiddleDTM2 := DTMFromString('mggAAAHicY2NgYKhiYmAoAOIGIG4H4glAnA PE4UA5JyB2BW'+
'IfIM4G4kwgfvTmHYO9gTCDkQ4XGG/Zuw/Mn8DIwMDPgIkZcWAIAAAOAAyf');

{DTMAuburyMap := DTMFromString('mwQAAAHic42RgYNBlZGBQA2I9IJYF4v9AMW EgHQzEBkCs'+ //Thanks Demise, for this one
'AcS3gWIHofg6ED9kgKh7DMRcQPlNQDop1IwhxpgbjP1ddRg8H Q0YnKxUGb4zMjFEhIcx/P/PySA'+
'JVEcIMxGB4QAAolMSVg==');}

DTMAuburyDoor := DTMFromString('mAAEAAHic42FgYDAGYnkodoVikJgClG0CxE ZAHM8AAfx'+ //Thanks Demise, love you!
'AzAvEAlA2NxBLA7EMEEsBsSZUHcg8USDOjrFgyIoxZyhIsGTI jDJlSI0wZciIMmPIibNkiAs0ZN'+
'DVVGII8dBh0NYRZ6gNlgObSQpmBGImIjAbFCMDAJFbDpI=');

SetDTMName(MiddleDTM1, 'Middle DTM 1');
SetDTMName(MiddleDTM2, 'Middle DTM 2');
SetDTMName(DTMAuburyDoor, 'Aubury door DTM');
End;

Var
T, T2, I:integer;

begin
//Smartsetup(SmartPrefix, true, true, false);
//Settargetdc(smartgetdc);
AubTPA := CreateTPAFromText('isthin', UpCharsEx);
Smart_Server := 52;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupScript;
//LoadLocations;
//SetupNewAutoColor;
GetAndSetAnyReferenceColor;
Repeat

If Players[CurrentPlayer].Loc = 'Bank' Then
BankToAubury;

If Players[CurrentPlayer].Loc = 'Aubury' Then
Begin
T2 := GetSystemTime;
While Not AtMine Do
Begin
If GetSystemTime - T2 > 180000 Then
Begin
Players[CurrentPlayer].Loc := 'NoAubury';
Break;
End;
//DoorClosed; //ffs, walk to the right place first ;)
If FindAubury Then
Begin
T := GetSystemTime;
While (Not AtMine) and (GetSystemTime - t < 10000) Do Wait(250);
If AtMine Then
Break;
End;
Wait(500);
End;
Players[CurrentPlayer].Loc := 'Mine';
End;

If Players[CurrentPlayer].Loc = 'Mine' Then
Begin
Wait(500);
// If InAbyss Then
// SolveAbyss;

LocateInsideEssMine;
T := GetSystemTime;
T2 := GetSystemTime;
While (GetSystemTime - T < 180000) And (InvCount < 28) Do
Begin
If NoEssFound Then
Begin
WriteLn('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) + 21;
If I = tab_Inv Then I := tab_Stats;
GameTab(I);
Wait(RandomRange(200, 4000));
GameTab(tab_Inv);
T2 := GetSystemTime;
End;

Wait(1000);
If LevelUp Then
Begin
WriteLn('You levelled up, congratulations!'); //Wizzup? wasn't nice here, but I am
Break;
End;
If FindNormalRandoms Then
Begin
T := GetSystemTime;
While GetSystemTime - T < 5000 Do
Begin
Wait(250);
FindNormalRandoms;
End;
End;
End;
MineToAubury;
AuburyToBank;
Bank;
End;

ProgressReport;

If Not LoggedIn Then
Begin
NextPlayer(False);
InitPlayer;
Continue;
End;

If Players[CurrentPlayer].Banked Mod Loads = 0 Then
Begin
NextPlayer(True);
InitPlayer;
Continue;
End;

Until False;
End.

Hope it works, Psyonity

testing now :) Thanks for fix-up

edit: Gets stuck when mining...

justiceouest
04-13-2012, 02:08 AM
nice shot psyonity great fix working well !!

tatsuki
05-06-2012, 06:54 PM
does -Exception in Script: Unable to find file 'srl/srl/misc/smart.simba' used from ''- mean i didnt put in the right offsets or something?


aright ill be honest im a starter just started looking around for bots, can someone give me a complete run down when downloading scripts via a link or just chat would be fine.........

Silen109
05-08-2012, 01:35 AM
Unknown identifier 'InAbyss' at line 1088
Compiling failed.
this error keeps popping up can someone help me please.

nicmoon
05-08-2012, 03:30 AM
Hmmmm all walking seems to go to in incorrect directions as of today (like an hour ago when I had to restart my SMART because of client token). I wonder if they are randomizing colors more to mess with TPAs and DTMs?

Bedders
05-11-2012, 05:41 AM
I wanted a ess miner, but this one didn't work... So I looked at it, thought the color of the symbol was wrong, made a new one, and it worked! So here the script again with the new color and for the others, the inAbyss is commented out.
program New;
{$i srl/srl/misc/smart.simba}
{$i srl/srl.simba}
{$ifdef smart}
{$i srl/srl/misc/paintsmart.simba}
{$endif}
Const
NumberOfUsers = 1;
StartPlayer = 0;
Loads = 5;
VersionNumber = '3.01';
FastAubury = True;
SRL_ID = ''; // Stats ID.
SRL_PASS = ''; // Stats Pass.
//SmartPrefix = 'world10';

{Type
EssLoc = Record
Name: String;
Info: Array Of Array Of Integer;
MMClicks, MSEss: TPointArray;
L, ReportIDVar: Integer;
End;
EssLocArray = Array Of EssLoc; }

Var
// EssInfo: EssLocArray;
AubTPA: TPointArray;
NewAutoColorWorked, NoEssFound: Boolean;
EssenceMined, Abyss: Integer;
MiddleDTM1, MiddleDTM2, DTMAuburyMap, DTMAuburyDoor : integer;
//BlackOffset : integer;
//{$DEFINE DEBUG}

Procedure DeclarePlayers;
Begin
NumberOfPlayers( NumberOfUsers );
CurrentPlayer := StartPlayer;
Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='gpk';
Players[0].Active := True;
Players[0].Loc := 'Bank';
Players[0].Booleans[0] := False; // Is The Pick Equipped?
// Is The Pick Equipped?
Writeln( IntToStr ( HowManyPlayers ) + ' Players' );
End;
Procedure FNRWait(ms: Integer);
Var
T: Integer;
Begin
T := GetSystemTime;
While GetSystemTime - T < ms Do
Begin
Wait(200);
FindNormalRandoms;
End;
End;
procedure MFlag;
var
t : integer;
begin
FFlag(0);
t := GetSystemTime;
while (GetSystemTime-t) < 7500 do
if (PixelShift(IntToBox(mmx1, mmy1, mmx2, mmy2), 200)) < 1000 then //1000 should do
break;
end;

Procedure DebugMM(TPA: TPointArray);
{
Var
I, L: Integer;
C: TCanvas; }

Begin
{DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(MMX2-MMX1, MMY2-MMY1);
C := GetDebugCanvas;
CopyCanvas(GetClientCanvas, C, MMX1, MMY1, MMX2, MMY2, 0, 0, MMX2 - MMX1, MMY2 - MMy1);
L := High(tpa);
For I := 0 To L Do
C.Pixels[tpa[i].x - MMX1, tpa[i].y - MMY1] := 255;
DisplayDebugImgWindow(MMX2-MMX1, MMY2-MMY1); }
End;

function BlackOffset : integer; //Inspired by GetMinimapDots
var //18msecs, pretty slow...
TPA : TPointArray;
i : integer;
begin
result := -1;
FindColorsTolerance(TPA, 3699532, mmx1, mmy1, mmx2, mmy2, 20); //should do?
for i := 0 to high(TPA) do
begin
if (GetColor(TPA[I].X, TPA[I].Y) - GetColor(TPA[I].X-1, TPA[I].Y) = (3699532-1196650)) then
begin //a1 //a2 //a1-a2 = dif
Result := 0-((3699532-329220)-GetColor(TPA[I].X, TPA[I].Y));//magic //c1-c2 = dif
//writeln('Black offset: '+ToStr(result)); //c2 = c1-dif
exit;
end;
end;
end;

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 := [2595570, 2925567];

SetLength(Points, 0);
For I := 0 To High(MagicSymbolColors) Do
Begin
SetLength(P2, 0);
SetLength(C, 0);
//writeln('U wanted me?');
FindColorsTolerance(P2, MagicSymbolColors[I], MMX1, MMY1, MMX2, MMY2, 10);
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
Begin
SetLength(Points, Length(Points) + 1);
Points[High(Points)] := P2[J];
End;
End;
//Points := CombineTPA(Points, P2);
End;
{$IFDEF DEBUG} debugMM(Points); {$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
WriteLn('No Aubury Shop');
End;

function FindAuburyStore(var P : TPoint) : boolean;
var
AuburyMapDDTM : TSDTM;
DTMAuburyMap : integer;
aFound : extended;
P2 : TPoint;
begin
if (BlackOffset = -1) then
begin
result := FindMagicSymbol(P);
exit;
end;

{ Stop here.
Look at this DDTM, it works quite smart imho ^-^.
This uses the old colour relation technique discovered by yours truly in 2007.
The technique is most commonly used for autocoloring stuff, but there are a
few other uses like this one. The black colour is nowadays also 'modified'
(not static), so I use it as an offset. From every colour, the main 'black'
is substracted (the 329220) so it's made for black = 0. Because nowadays in RS
the black is never true black, we add the 'rs black' to it (AtMine sets it).
This way, we can create a DDTM with 100% accurate colors. No false positives.
Note, it has a bit of area tolerance to accomodate for RS ugly rotation.
For some reason, the last point (which is just terrain) didn't work too well
so that one uses regular 15 tol. It's just an anchor point though, the real
uniqueness is point 0 (the tiny bit of black at the the left).
Points 1 and 2 are the two trees south of VEB, behind the fence. }

AuburyMapDDTM.MainPoint.x := 608;
AuburyMapDDTM.MainPoint.y := 107;
AuburyMapDDTM.MainPoint.Color := 13371337; //who cares
AuburyMapDDTM.MainPoint.Tolerance := 500; //tol is high enough
SetLength(AuburyMapDDTM.SubPoints, 4);

with AuburyMapDDTM.SubPoints[0] do
begin
x := 668;
y := 109;
Color := BlackOffset;
areasize := 2;
end;

with AuburyMapDDTM.SubPoints[1] do
begin
x := 606;
y := 48;
Color := 3699532-329220+BlackOffset; //green
Tolerance := 0;
AreaSize := 2;
end;

with AuburyMapDDTM.SubPoints[2] do
begin
x := 615;
y := 49;
Color := 1196650-329220+BlackOffset; //brown
AreaSize := 2;
end;

with AuburyMapDDTM.SubPoints[3] do //This is part of the terrain
begin //probably calculated different or whatever
x := 631;
y := 49;
Color := 2511437-329220+BlackOffset;
AreaSize := 2;
Tolerance := 15;
end;

//After typing this all of this by hand, WHERE THE F@#! IS THE DDTM EDITOR!!!

DTMAuburyMap := AddSDTM(AuburyMapDDTM);
SetDTMName(DTMAuburyMap, 'Aubury Map DDTM');
//For some reason it tried to click @ quest tab?
if FindDTMRotated(DTMAuburyMap, P.x, P.y, mmx1, mmy1, mmx2, mmy2-5, -pi/2, pi/2, pi/60, afound) then
begin //should do some checks here to make sure it isn't too far of from mage symbol..
writeln('Found Aubury store using offset DDTM!');
if (FindMagicSymbol(P2)) then
begin
if Distance(p2.x, p2.y, p.x, p.y) > 15 then //can be tweaked
begin
writeln('Distance too big. Falling back to magic symbol!');
P := P2;
end;
result := true;
end;
FreeDTM(DTMAuburyMap); //Thanks to Wizzup's leak finder, else wouldnt have found this one.
exit;
end;
FreeDTM(DTMAuburyMap);
result := FindMagicSymbol(P); //Fallback
end;


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);
B := GetMiniMapDots('npc');
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 - 5;
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;

Function Randomize(x, Randomness: Integer): Integer;

Begin
Result := RandomRange(X - Randomness, X + Randomness);
End;

Function AtMine: Boolean; //Counts the black to see if we are in the mine

Var
TPA: TPointArray;
Begin
ColorToleranceSpeed(0);
FindColorsTolerance(TPA, 65536, MMX1, MMY1, MMX2, MMY2, 7);
ColorToleranceSpeed(1);
Result := Length(TPA) > 2000;

{ if (result) and (BlackOffset = -1) then
begin //fck this
BlackColors := GetColors(TPA);
ClearSameIntegers(BlackColors);
for i := 0 to high (BlackColors) do
begin
FindColorsTolerance(TPA, BlackColors[i], mmx1, mmy1, mmx2, mmy2, 0);
if (length(TPA) > maxcount) then
begin
BlackOffset := BlackColors[i];
maxcount := Length(TPA);
end;
end;
Writeln('Calculated black offset = '+ToStr(BlackOffset));
end; }
End;

function FindPortal(var cx, cy: Integer): 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;
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;

SetToleranceSpeed2Modifiers(GroundHue, GroundSat);
if not FindColorsTolerance(NewTPA, GroundColor, SearchBox.x1, SearchBox.y1, //Finds ground colours
SearchBox.x2, SearchBox.y2, GroundTol) then
Exit;

SetToleranceSpeed2Modifiers(WallHue, WallSat); //Finds wall colours
FindColorsTolerance(ColorsTPA, WallColor, SearchBox.x1, SearchBox.y1,
SearchBox.x2, SearchBox.y2, WallTol);

ColorsTPA := CombineTPA(ColorsTPA, NewTPA); //Combine both

SetToleranceSpeed2Modifiers(EdgeHue, EdgeSat);
FindColorsTolerance(EdgeTPA, EdgeColor, SearchBox.x1, SearchBox.y1,
SearchBox.x2, SearchBox.y2, EdgeTol);
//Add edge colours, too
AppendTPA(ColorsTPA, EdgeTPA);
NewTPA := ClearTPAFromTPA(SearchTPA, ColorsTPA); //SearchTPA is the entire box we are searching in,
ColorsTPA := ClearTPAFromTPA(NewTPA, CharTPA); //We remove our own character and all other points from it

ResultsATPA := SplitTPA(ColorsTPA, 1);
SetLength(NewATPA, 0);

for I := 0 to High(ResultsATPA) do //This thing is still a miracle to me
begin

AreaBox := GetTPABounds(ResultsATPA[i]);
Area := ((AreaBox.X2 - AreaBox.X1) * (AreaBox.Y2 - AreaBox.Y1));

if (InRange(Area, 500, 1500) and (InRange(Length(ResultsATPA[i]), 250, //Probably filters based on not being too small/large
1200))) then
begin

SetLength(NewATPA, Length(NewATPA) + 1);
NewATPA[Match] := ResultsATPA[i];
Inc(Match);
end;
end;

if Length(NewATPA) = 0 then //When no points left, no point to contine
Exit;

SortATPAFromMidPoint(NewATPA, IntToPoint(MSCX, MSCY));

for I := 0 to High(NewATPA) do //Regular (A)TPA iteration
begin

TestPoint := MiddleTPA(NewATPA[i]);
MMouse(TestPoint.x, TestPoint.y, 5, 5);

if WaitUpTextMulti(['Enter', 'Portal', 'nter', 'ortal', 'er P'], 500) then
begin
{$IfDef SMART}
Smart_DrawDotsEx(True, NewATPA[i], clFuchsia); //Flashes the points, though noone watches it.
Wait(100);
SMART_ClearCanvas;
{$EndIf}
Result := True;

cx := TestPoint.x;
cy := TestPoint.y;
Break;
end;
end;
end;

Function DoorClosedWizzup: Boolean;

Var
TP: TPoint;
TPA: TPointArray;
aTPA: T2DPointArray;
I, c: Integer;


Begin
Result := False;
c := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.2, 0.5);
FindColorsTolerance(TPA, 3561057, 3, 3, 515, 336, 8);
//aTPA := TPAToATPAEx(TPA, 50, 50);
aTPA := SplitTPA(TPA, 3);
SortATPAFrom(aTPA, IntToPoint(mscx, mscy)); //noob Wizzup forgot this one -.-'
For I := 0 To High(aTPA) Do
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.X, TP.Y, 0, 0, True);
//FFlag(0);
MFlag;
Break;
End;
End;
ColorToleranceSpeed(c);
SetColorspeed2Modifiers(0.2, 0.2);
End;

function DoorClosedDTM : boolean; //I dont want too many DTMs in here, but Demise likes them so much
var //and if she does the hard work, why would I? ;)
x, y : integer;
aFound : extended;
begin
result := False;
if FindDTMRotated(DTMAuburyDoor, x, y, msx1, msy1, msx2, msy2, -Pi/4, Pi/4, Pi/60, aFound) then
begin
MMouse(x, y, 5, 5);
if IsUpText('pen') and IsUpText('oor') then
begin
Result := True;
ClickMouse2(true);
MFlag;
end;
end;
end;

function DoorClosed : boolean; //'Kapstopfunctie'
begin
writeln('Opening door!');
if DoorClosedDTM then
result := true
else if DoorClosedWizzup then
result := true
else
result := false;
end;

Function FindArrow: Boolean;

Var
x, y: Integer;
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
Result := True;
WriteLn('Succesfully used NewAutoColor for FindArrow');
End; }
If Not Result Then
If FindSymbol(x, y, 'transportation') Then
Result := True;
If Result Then
Begin
Mouse(x, y, 4, 4, True);
Wait(1000);
//FFlag(0);
MFlag;
FNRWait(1000);
End;
End;

Procedure BankToAubury; //need to add a dtm to this, symbol really isnt accurate at all

Var
V: TPoint;
T: Integer;
Begin
FindNormalRandoms;
MFNF(Randomize(640, 4), Randomize(140, 4), -1, -1);
Wait(10000); //Walk is indeed something ike 10, 15 seconds
T := GetSystemTime; //As flag isn't visible, this is the right way to do it
While (GetSystemTime - T < 60000) Do //60 sec killswitch again, he seems to love those
Begin
FindNormalRandoms;
If FindAuburyStore(V) Then //used to be symbol. After the first run, uses DTM.
Break;
Wait(500);
End;
If GetSystemTime - T >= 60000 Then
Begin
WriteLn('BankToAuburyTime');
LogOut;
Exit;
End; //It wanted to click at quest tab, wtf.
Mouse(V.X, min(V.Y + 3,mmy2-5), 0, 0, True); //Coords of mage symbol are found above
Wait(500);
//FFlag(0);
MFlag;
Players[CurrentPlayer].Loc := 'Aubury';
End;

Procedure MineToAubury;

Var
x, y, T, T2, I: Integer;

Begin
FNRWait(1000);

T := GetSystemTime;
While GetSystemTime - T < 60000 Do //1 minute killswitch, again
Begin
If GetSystemTime - T > 30000 Then
MakeCompass('E'); //Change compass after 30 secs, might help with portal finding
If Not AtMine Then
Break;
FindNormalRandoms;
If Not FindArrow Then
Begin
WriteLn('MineToAubury - Could not find the transportation symbol. Exiting');
FNRWait(5000);
Continue;
End;
FindNormalRandoms;
For I := 0 To 5 Do //6 tries to find portal
Begin
If FindPortal(x, y) Then
Begin
Mouse(x, y, 0, 0, True);
T2 := GetSystemTime;
While AtMine And (GetSystemTime - T2 < 10000) Do //We should really be out after 10 secs or so
Begin
//FindTalk;
FNRWait(500);
End;
Break;
End;
Wait(250);
End;
FNRWait(1000);
FindNormalRandoms;
End;
If GetSystemTime - T >= 60000 Then //60 secs for portal finding is already quite long imo
Begin
//LogOut;
WriteLn('No Portal!');
LogOut;
Exit;
End;
MakeCompass('N');
End;

function MageSymbolDistance : integer; //Should be replaced by something that works with Aubury shop middle
var
p : TPoint;
begin
if not FindMagicSymbol(p) then
result := MaxInt
else
result := Distance(p.x, p.y, mmcx, mmcy);
end;

Procedure AuburyToBank; //This entire function needs to be redone. It works, but not perfect.

Var
T: Integer;
P: TPoint;
A: Extended;

Begin
T := GetSystemTime;
While GetSystemTime - T < 120000 Do //We'll try to go to bank for 2 minutes
Begin
FindNormalRandoms;
Mouse(665, 30, 8, 8, True); //magic coords, still working in 2012
Wait(Randomize(6500, 500)); //Small wait, as flag has changed a tiny bit
FindAuburyStore(P);
If (FlagDistance < 40) Or (Not FlagPresent) or (Distance(mmcx, mmcy, P.x, P.y) < 10) Then //Distance needs a bit of tweaking..
Begin //This door handling is still the most crappy thing imaginable.
if (Distance(mmcx, mmcy, P.x, P.y) < 15) then
begin
writeln('Distance to store is close.');
if (BlackOffset <> -1) then //I'll just trust it to use the DDTM then..
begin
Mouse(MMCX, RandomRange(MMCY + 5, MMCY + 10), 4, 0, True);
FNRWait(1500);
if DoorClosed then
writeln('Opened door!')
else
writeln('Could NOT open door!');
end;
end else
begin
writeln('No idea what''s going on now, flag is weird but distance to store..');
Mouse(MMCX, RandomRange(MMCY + 5, MMCY + 15), 4, 0, True);
FNRWait(1500);
DoorClosed;
end;
End
Else
Begin
{ T2 := GetSystemTime;
While GetSystemTime - T2 < 8000 Do
Begin
Wait(1000);
FindMagicSymbol(P);
If Distance(P.x, P.y, MMCX, MMCY) > 30 Then
Break;
End;
FFlag(10); }
FNRWait(8000);
FFlag(10);
FindAuburyStore(P);
If Distance(P.x, P.y, MMCX, MMCY) > 30 Then
Break;
End;
If Not FindAuburyStore(P) Then
Break;
If Distance(P.X, P.Y, MMCX, MMCY) > 30 Then
Break;
End;
WriteLn('Out of shop');
//FFlag(0);
MFlag;
If FindBankers(P, A) Then
Begin
writeln('Found bankers using NPC dots!');
Mouse(P.x, P.y, 0, 0, True);
FNRWait(3000);
//FFlag(0);
MFlag;
End
Else
If FindSymbol(P.x, P.y, 'Bank') Then
Begin
writeln('Found bank using symbol!');
Mouse(P.x, P.y, 0, 0, True);
FNRWait(3000);
//FFlag(0);
MFlag;
End Else
Begin
WriteLn('No Bank');
LogOut;
End;
Players[CurrentPlayer].Loc := 'Bank';
End;

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 IsUpTextMultiCustom(['Talk','lk-to']) then //Remember kids, 'alk' matches both Talk AND Walk
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
Wait(450 + Random(125));
If ChooseOptionMulti(['ele', 'port']) Then
Begin
Result := True;
Exit;
End;
end;
end;
ColorToleranceSpeed(CTS);
end;

Function FindAubury: Boolean; //Not the best!

Var
I, T, cts: Integer;
P: TPoint;
PA: TPointArray;
aPA: T2DPointArray;

Begin
Result := False;
If FindAuburyStore(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);
Wait(1000);
//FFlag(0);
MFlag;
wait(randomize(1200, 200));
End;
End;
If FindAuburyText Then
Begin
Result := True;
Exit;
End;
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsTolerance(PA, 6450290, MSX1, MSY1, MSX2, MSY2, 3); //tolerance seems low
//writeln(inttostr(length(pa))); //but is severly optimized
aPA := TPAToATPA(PA, 50);
SortATPAFrom(aPA, IntToPoint(mscx, mscy)); //Should do MiddlesATPA and then SortTPA (faster)
//writeln(inttostr(length(apa)));
For I := 0 To High(aPA) Do
Begin
//Wait(200);
If AtMine Then
Begin
Result := True;
Break;
End;
If Length(aPA[I]) < 3 Then
Continue;
P := MiddleTPA(aPA[I]);
MMouse(p.X, P.Y, 3, 3);
Wait(150); //Small wait really necessary
writeln('ut: '+rs_GetUpText);
If Not IsUpTextMultiCustom(['bury', 'Talk']) Then //Bug-fix! alk fits 'Walk', too
Continue;
GetMousePos(P.X, P.Y);
Mouse(P.X, P.Y, 0, 0, False);
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;
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, MMX1, MMy1, MMX2, MMY2, 421); //Matches everything besides pure black
ColorToleranceSpeed(cts);
End;

Function ScanMM(Const TPA: TPointArray; SD, ED, MinR, MaxR: Integer): Integer; //Not used anymore with new cool mine handling

Begin
FilterPointsPie(TPA, SD, ED, MinR, MaxR, MMCX, MMCY);
Result := Length(TPA);
{$IFDEF DEBUG} DebugMM(TPA); {$ENDIF}
End;


Function AdeptDegree(CompassAngle: Extended; Degree: Integer): Integer; //idem dito, but I like it

Begin
Result := Round(Abs(CompassAngle + Degree));
While Result > 360 Do
Result := Result - 360;
End;

function AmountOfGaps(ar : TBoolArray) : integer; //Better name: amount of transitions
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;

procedure StartStopGap(ar : tbooleanarray; var start, stop : integer); //Not used.
var //could (in theory) be used for quadrant detection
prevone : boolean;
i : integer;
begin
prevone := ar[0];
for i := 1 to high(ar) do
begin
if ar[i] <> prevone then
begin
start := i;
prevone := ar[i];
break;
end;
end;
for i := i to high(ar) do
begin
if ar[i] <> prevone then
begin
stop := i;
prevone := ar[i];
break;
end;
end;
end;

procedure WalkToMiddleRoom; //No checks, nothing. Just plain clickin'
var
TPA : TPointArray;
p : TPoint;
begin
ColorToleranceSpeed(2); //ACA obviously
SetColorSpeed2Modifiers(1.46, 0.39); //dark grey colour in the mine
FindColorsTolerance(tpa, 10461335, MMX1, MMY1, MMX2, MMY2, 7)
ColorToleranceSpeed(1);
SetColorspeed2Modifiers(0.2, 0.2);
p := MiddleTPA(tpa); //should do
Mouse(p.x, p.y, 4, 4, true);
wait(500);
//FFlag(0);
MFlag;
Wait(500);
end;

function FindEss : Boolean; //ACA love
var
arP : TPointArray;
ararP: T2DPointArray;
arL, i : Integer;
P: TPoint;
// fx, fy : integer;
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.08, 0.17);

if not(FindColorsTolerance(arP, 8618897, MSX1, MSY1, MSX2, MSY2, 29)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(1); //no need to store cts, 1 is always good
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

ararP := SplitTPAEx(arP, 3, 3); //SLLOOOOWWWW, as there are LOTS of points
arL := Min(4, High(ararP)); //and 5 is already a lot, it should find it in 1 try

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(100 + Random(100));
if (IsUpTextMultiCustom(['ine', 'ure', 'ssen'])) then
begin;
Result := True;
ClickMouse2(True); //mine it!
Break;
end;
end;

ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

end;

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
//setupsrl;
ColorToleranceSpeed(0);
FindColorsTolerance(tpa, 0, mmx1, mmy1, mmx2, mmy2, 7); //Find all the black!
ColorToleranceSpeed(1);

for i := 0 to high(tpa) do
BlackArr[tpa[i].x][tpa[i].y] := True;

for radius := 74 downto 50 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
writeln('We are standing in the middle');
if (not(FindDTMRotated(MiddleDTM1, x, y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, Pi/360, aFound))) then //Look what I did here
if (not(FindDTMRotated(MiddleDTM2, x, y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, Pi/360, aFound))) then
begin
writeln('Force-walking to the middle of room..');
WalkToMiddleRoom;
if FindSymbol(x, y, 'transportation') then
begin
writeln('We weren''t in the middle indeed');
//WalkToMiddleRoom;
writeln('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;
writeln('Location detection failed! No middle and no DTMs');
Players[0].Loc := 'NoMine';
result := False;
exit;
end; //else
writeln('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(X, Y, 4, 4, True); //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
begin
NoEssFound := True;
WriteLn('No Essence');
//NoEssenceFound := True;
end;
end;
end else
// if(AmountOfGaps(angles) = 2) then
begin
writeln('We are standing in a room');
writeln('Fortunately we can walk to the middle.');
WalkToMiddleRoom;
writeln('should be in middle of mine now');
if (not(FindEss)) then
begin
NoEssFound := True;
WriteLn('No Essence Corner');
end;
{writeln('We can now determine exct loc') //Useless. Essmine rotates so we should not rely on that
StartStopGap(angles, start, stop);
writeln('START: '+inttostr(start)+', STOP: '+inttostr(stop));
writeln('Location: '+locationnames[(start+stop) div 180]);}
end
end;

Function EssenceCount: Integer;

{Var
I: Integer;
TPA: TPointArray;
B: TBox; }

Begin
{ Result := 0;
For I := 1 To 28 Do
Begin
B := InvBox(I);
FindColorsTolerance(TPA, 65536, B.X1, B.Y1, B.X2, B.Y2, 0);
If Length(TPA) = 82 Then //doesnt work anymore
Result := Result + 1;
End; }
result := InvCount; //Too bad if your pickaxe isnt equipped
End;

Procedure Bank;

Var
I: Integer;
P: TPoint;
A: Extended;
TempEss: Integer;

Begin
//ReportVars[1] := ReportVars[1] + 1; // Banks
Players[CurrentPlayer].Banked := Players[CurrentPlayer].Banked + 1;
For I := 0 To 2 Do
If OpenBankFast('veb') Then
Break
Else
If FindBankers(P, A) Then
Begin
Mouse(p.x, p.y, 0, 0, True);
Wait(4000);
//FFlag(0);
MFlag;
Wait(1500);
End;
If Not BankScreen Or PinScreen Then
Begin
LogOut;
Players[CurrentPlayer].Loc := 'NoBank';
Players[CurrentPlayer].Active := False;
Exit;
End;
TempEss := EssenceCount;
EssenceMined := EssenceMined + TempEss;
//ReportVars[0] := ReportVars[0] + TempEss;
Players[CurrentPlayer].Integers[0] := Players[CurrentPlayer].Integers[0] + TempEss;
If Players[CurrentPlayer].Booleans[0] Then
Deposit(1, 28, True)
Else
Deposit(2, 28, True); //blindly assumes it is in spot 1

if (random(3) = 1) then //no need to close it all the time Wiz
CloseBank;
End;

Procedure PlayerReport;

Var
Active, Rand: string;
I: Integer;

Begin
For I := 0 To High(Players) Do
Begin
If Players[i].Active Then
Active := 'T'
Else
Active := 'F';
If Players[i].Rand <> '' Then
Rand := '; Rand: ' + Players[i].Rand
Else
Rand := '';

WriteLn((IntToStr(I)) + ' : ' + Players[I].Nick + ' = ' +
Active + '; ' + Players[I].Loc + rand + '; B: ' + IntToStr(Players[I].Integers[0])
+ ' Essence;'+ ' M : ' + IntToStr(Players[I].Level[15]));
End;
End;

Procedure ProgressReport;

Begin
WriteLn('----------------------------');
WriteLn('');
WriteLn('Wizzup? and Markus Essence Miner, Version ' + VersionNumber);
WriteLn('');
WriteLn('Worked for '+ TimeRunning);
WriteLn('Mined ' + IntToStr(EssenceMined) + ' Essence');
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('----------------------------');
SRLRandomsReport;
End;

Procedure ScriptTerminate;

Begin
ProgressReport;
End;

Function GetAndSetAnyReferenceColor: Boolean; //if I could get black here, I'd do it.

//Var
// c: integer;

Begin
NewAutoColorWorked := False;
result := False;
Exit;
{
c := AutoColor(srl_RockColor);
If c > 0 Then
Begin
SetAutoColorReference('grey rock', c);
WriteLn('Got the color using the grey rock');
NewAutoColorWorked := True;
Result := True;
Exit;
End; }
End;

Procedure InitPlayer;
{
Var
I: Integer; }
Begin
{For I := 1 To 5 Do
If Not Players[CurrentPlayer].Booleans[I] Then
Begin
Case I Of
1: SetGraphics(4, '', '' ,'', '', '', '', '', '');
2: Retaliate(False);
3: SetAudio(0, 0, 0, Mono);
End;
Players[CurrentPlayer].Booleans[I] := True;
End;}

GetAllLevels;
SetChat('on',1);
SetChat('friends',2);
SetChat('on',3);
SetAngle(SRL_ANGLE_HIGH);
End;

Procedure SetupScript;

//Var
// I: Integer;
Begin
// SRLID := SRL_ID;
//SRLPassword := SRL_PASS;
// For I := 1 To 19 Do
// ReportVars[I] := 0;
//ScriptID := '51';
DeclarePlayers;
LoginPlayer;
InitPlayer;

//BlackOffset := -1;

//Thanks to Demise for restoring my faith in DTMs :)
MiddleDTM1 := DTMFromString('mlwAAAHicY2dgYChhYmCIBuIMIK4B4g4gjg HiOiAOAcr7A7'+
'ELEFsBcTIQxwGxFxD///+fwVyNAwW7aAkyfH79kWECIwMDPwN2zIgHQwEAMRYOKA==');
MiddleDTM2 := DTMFromString('mggAAAHicY2NgYKhiYmAoAOIGIG4H4glAnA PE4UA5JyB2BW'+
'IfIM4G4kwgfvTmHYO9gTCDkQ4XGG/Zuw/Mn8DIwMDPgIkZcWAIAAAOAAyf');

{DTMAuburyMap := DTMFromString('mwQAAAHic42RgYNBlZGBQA2I9IJYF4v9AMW EgHQzEBkCs'+ //Thanks Demise, for this one
'AcS3gWIHofg6ED9kgKh7DMRcQPlNQDop1IwhxpgbjP1ddRg8H Q0YnKxUGb4zMjFEhIcx/P/PySA'+
'JVEcIMxGB4QAAolMSVg==');}

DTMAuburyDoor := DTMFromString('mAAEAAHic42FgYDAGYnkodoVikJgClG0CxE ZAHM8AAfx'+ //Thanks Demise, love you!
'AzAvEAlA2NxBLA7EMEEsBsSZUHcg8USDOjrFgyIoxZyhIsGTI jDJlSI0wZciIMmPIibNkiAs0ZN'+
'DVVGII8dBh0NYRZ6gNlgObSQpmBGImIjAbFCMDAJFbDpI=');

SetDTMName(MiddleDTM1, 'Middle DTM 1');
SetDTMName(MiddleDTM2, 'Middle DTM 2');
SetDTMName(DTMAuburyDoor, 'Aubury door DTM');
End;

Var
T, T2, I:integer;

begin
//Smartsetup(SmartPrefix, true, true, false);
//Settargetdc(smartgetdc);
AubTPA := CreateTPAFromText('isthin', UpCharsEx);
Smart_Server := 52;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupScript;
//LoadLocations;
//SetupNewAutoColor;
GetAndSetAnyReferenceColor;
Repeat

If Players[CurrentPlayer].Loc = 'Bank' Then
BankToAubury;

If Players[CurrentPlayer].Loc = 'Aubury' Then
Begin
T2 := GetSystemTime;
While Not AtMine Do
Begin
If GetSystemTime - T2 > 180000 Then
Begin
Players[CurrentPlayer].Loc := 'NoAubury';
Break;
End;
//DoorClosed; //ffs, walk to the right place first ;)
If FindAubury Then
Begin
T := GetSystemTime;
While (Not AtMine) and (GetSystemTime - t < 10000) Do Wait(250);
If AtMine Then
Break;
End;
Wait(500);
End;
Players[CurrentPlayer].Loc := 'Mine';
End;

If Players[CurrentPlayer].Loc = 'Mine' Then
Begin
Wait(500);
// If InAbyss Then
// SolveAbyss;

LocateInsideEssMine;
T := GetSystemTime;
T2 := GetSystemTime;
While (GetSystemTime - T < 180000) And (InvCount < 28) Do
Begin
If NoEssFound Then
Begin
WriteLn('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) + 21;
If I = tab_Inv Then I := tab_Stats;
GameTab(I);
Wait(RandomRange(200, 4000));
GameTab(tab_Inv);
T2 := GetSystemTime;
End;

Wait(1000);
If LevelUp Then
Begin
WriteLn('You levelled up, congratulations!'); //Wizzup? wasn't nice here, but I am
Break;
End;
If FindNormalRandoms Then
Begin
T := GetSystemTime;
While GetSystemTime - T < 5000 Do
Begin
Wait(250);
FindNormalRandoms;
End;
End;
End;
MineToAubury;
AuburyToBank;
Bank;
End;

ProgressReport;

If Not LoggedIn Then
Begin
NextPlayer(False);
InitPlayer;
Continue;
End;

If Players[CurrentPlayer].Banked Mod Loads = 0 Then
Begin
NextPlayer(True);
InitPlayer;
Continue;
End;

Until False;
End.
Hope it works, Psyonity
This works as far as actually mining goes, but it has problems with the door to Varrock Rune shop, from East Bank. Apart from that, works ok.
Going to try on a more populated work today, when I get home from work.
Might have to start learning how to script in a couple of weeks, when I'm done with this year of my Degree. I've tried 4 different Essence Miners, and none of them are updated. :(
EDIT:
OK, I have run the script for about 25 minutes, and it gets stuck - sometimes as stated in the first post, when it tries to talk to the Banker and doesn't open the bank booth - it then gets stuck, so I bank my items then restart the script, and whenever it goes from the shop to the bank - it goes to the path to the North-East, then doubles back on itself whilst it searches for the bankers, making it way too obvious I'm using a script.
Is there any way to improve the pathfinding here please?

Markus
05-12-2012, 11:26 AM
If someone actually capable of scripting wants to update this, PM me for some cookies.

mad cow10912
05-13-2012, 11:19 PM
i tried to run and got
[Error] (1303:10): Unknown identifier 'InAbyss' at line 1302
?? help:D im new to this sorry

mahoney
05-13-2012, 11:52 PM
i tried to run and got
[Error] (1303:10): Unknown identifier 'InAbyss' at line 1302
?? help:D im new to this sorry

Look through the previous messages.

NetbookPrice
06-01-2012, 04:57 PM
Wonderful job!

1) Problem clicking the banker to deposit essence. First click activates the dialogue, "How may I help you?" After three seconds, the program clicks the banker again and successfully opens the deposit box.

2) It doesn't reactive running mode after energy has been depleted.

Overall, it's quite nice.

angelodafilipino
06-01-2012, 07:34 PM
I get this error trying to run it: [Error] (1303:10): Unknown identifier 'InAbyss' at line 1302
Compiling failed.

NetbookPrice
06-01-2012, 10:33 PM
I get this error trying to run it: [Error] (1303:10): Unknown identifier 'InAbyss' at line 1302
Compiling failed.

Check post #77. He extricated that and a few other parts.

0seconds
06-24-2012, 05:20 AM
Every time I try to start this I get the following:

The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]
File[C:\Simba\Includes\MSI\Debug Logs\24-06-12 at 05 16 25 PM.txt] has not been freed in the script, freeing it now.

And nothing happens..

henny1324
06-26-2012, 12:04 PM
Getting error at Line 1302: If InAbyss Then

[Error] (1303:10): Unknown identifier 'InAbyss' at line 1302
Compiling failed.

Help much appreciated

Bob The Cat
06-26-2012, 12:08 PM
This is probaly outdated, im not sure though.

legod
08-07-2012, 08:44 AM
hello im new too this and was wondering if anyone can help.
whenever i try start this script, i get this error message


[Error] F:\Simba\Includes\srl/srl/misc/smart.simba(53:19): Invalid number of parameters at line 52
Compiling failed.

lolaller
08-08-2012, 02:13 PM
Working wonderfully, thanks!

fire_burn_00
08-14-2012, 08:37 PM
hello im new too this and was wondering if anyone can help.
whenever i try start this script, i get this error message


[Error] F:\Simba\Includes\srl/srl/misc/smart.simba(53:19): Invalid number of parameters at line 52
Compiling failed.

Same Problem... Anyone?

Leonardo Da Vinci
08-16-2012, 07:33 PM
hello im new too this and was wondering if anyone can help.
whenever i try start this script, i get this error message


[Error] F:\Simba\Includes\srl/srl/misc/smart.simba(53:19): Invalid number of parameters at line 52
Compiling failed.
Same here.:wacko:

Same Problem... Anyone?

NKN
08-16-2012, 08:28 PM
Lololol.

The last like, 10 messages. "I think it's outdated", "same here"

It's obviously outdated, the OP hasn't been changed since January, and the latest fix in the thread was in April, before the big update.
The fix/problem has been posted on almost every script thread so far.

Leonardo Da Vinci
08-16-2012, 08:45 PM
Lololol.

The last like, 10 messages. "I think it's outdated", "same here"

It's obviously outdated, the OP hasn't been changed since January, and the latest fix in the thread was in April, before the big update.
The fix/problem has been posted on almost every script thread so far.

Holy shit, you're right. It's outdated for sure.
I would love to post the fix, but I'm still trying to understand the basics of pascal.

Scorched
08-16-2012, 10:25 PM
Lololol.

The last like, 10 messages. "I think it's outdated", "same here"

It's obviously outdated, the OP hasn't been changed since January, and the latest fix in the thread was in April, before the big update.
The fix/problem has been posted on almost every script thread so far.

After sifting throught threads for scripts that I cannot get to work, I have yet to find a solution. Please forgive my ignorance, but the answer is not obvious to me. Could you possibly post a link to the fix, or give any further information? I would really like to mine some essence.

Markus
10-12-2012, 11:35 AM
Got some great news! I decided to put some effort back again in this script and it is now a lot better than before! As far as I know, all common bugs are fixed. I will release an update in a few days, as soon as Simba 992 and a new SRL are released. Also, Lape compatibility!
Due to the Lape compatibility, you need to wait for Simba 992 and a random new revision of SRL. Wizzup forgot to include a few fixes in the current release but this will be fixed very, very soon.

WT-Fakawi
10-12-2012, 12:25 PM
Got some great news! I decided to put some effort back again in this script and it is now a lot better than before! As far as I know, all common bugs are fixed. I will release an update in a few days, as soon as Simba 992 and a new SRL are released. Also, Lape compatibility!
Due to the Lape compatibility, you need to wait for Simba 992 and a random new revision of SRL. Wizzup forgot to include a few fixes in the current release but this will be fixed very, very soon.

I saw you testing. Got a screenie :) (Won't show it here, but Wizz told me it was you :) )

Markus
10-13-2012, 12:13 PM
Haha yea, he showed me the screenshot. It's one of my better mules, as I paid Rubix a few years ago to do Dragon Slayer on it. And the name is appropriate for a lot of essmine testing isn't it? :p

New version released now! Please give it another run and all feedback is highly appreciated!

Olly
10-13-2012, 01:20 PM
Always nice to see something like this get updated :p

Ashaman88
10-13-2012, 01:32 PM
Congrats on the re-release!

Ian
10-13-2012, 01:47 PM
Congrats! I've noticed two things though: It won't open the door of aubury's shop and tries to teleport without it open. After around 10 minutes of working, it went to the center area and started saying:

No black. Fallback False
Black offset NOT found!
In the debug

Markus
10-13-2012, 01:57 PM
Yea, first it tries to teleport to Auburry, then it checks for the "You can't reach this" in the chatscreen.
But the black offset NOT found is really weird, just as the Fallback false, especially if it's standing near Aubury's store and the trees south of the bank are visible. Or was it inside the mine?
Also, check your graphics settings as I consistently get 1+ hour runs with it (never was able to let it run for longer).

Ian
10-13-2012, 02:06 PM
Yea, first it tries to teleport to Auburry, then it checks for the "You can't reach this" in the chatscreen.
But the black offset NOT found is really weird, just as the Fallback false, especially if it's standing near Aubury's store and the trees south of the bank are visible. Or was it inside the mine?
Also, check your graphics settings as I consistently get 1+ hour runs with it (never was able to let it run for longer).

The black offset not found and Fallback false errors were from inside the mine, at the center area where the four chambers meet.

Markus
10-13-2012, 02:11 PM
Really weird. It calls that function once when walking to Aubury (and when walking back to bank). It shouldn't kick-off when in the mine at all! Please do a rerun, it might just be a weird glitch :)

litoris
10-13-2012, 02:39 PM
Great job, I'm really interested in the DDTM, I have been learning/experimenting with them as an alternative for SPS. Oh look, even nielse posted here :) Fan of the DDTM tool!

J J
10-13-2012, 03:00 PM
Great job, I'm really interested in the DDTM, I have been learning/experimenting with them as an alternative for SPS. Oh look, even nielse posted here :) Fan of the DDTM tool!
I've also been playing around with DDTM's when working on a Molly solver. For anyone interested in DDTM's here is the tool: http://villavu.com/forum/showthread.php?t=25312

While writing this reply I decided to take a look in the script and found this
//After typing this all of this by hand, WHERE THE F@#! IS THE DDTM EDITOR!!!
So there you go...? :P

Looks like there has been put a lot of effort in this over the years :) The functions to find the portal are a bit large I'd say. Should be easier to make? I'll give it a go :)

nokkasiili
10-13-2012, 03:23 PM
I have 5-15 bots to test script they dont have any better to do :)
Need check do they have rune mysteries done

litoris
10-13-2012, 04:04 PM
I didn't now about the offset stuff, I'll definitely use that in my current project. One question though, where can I find the black offset on the minimap? I tried a few black colors from the minimap in game, but they returned 65535. I suppose the black you see in the off-map areas in caves etc. works, but where do I find this black in the overworld? I'm going to use the red from doors or something if there isn't a way, I can still use that for my offset as far as I understand.

Also, does the offset stay the same for main screen objects?

J J
10-13-2012, 04:37 PM
As promised in a few posts ago I worked on detecting the portal :) The code includes comments so you understand what I did and your script is full off comments anyways :garfield:

Includes on screen debugging, commented out the console debugging.
http://imageshack.us/a/img198/2148/essellipse.png

// Enters the portal in the rune essence mine
function EnterPortal: boolean;
var
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 *)
SMART_DrawDotsEx(True, PortalColors, clRed);
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. *)
SMART_DrawDotsEx(False, Splitted[0], clAqua);
SMART_DrawBoxEx(False, False, GetTPABounds(Splitted[0]), clGreen);

// 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) / 10;
ySize := ((biggestY - smallestY) * 4) / 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]);
SMART_DrawEllipse(False, P, xSize, ySize, False, clYellow);
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;
end;

SMART_ClearCanvas;
end;
end;

Constructs an ellipse around the portal and clicks a random point in there. Hope it will be used :stirthepot:

TViYH
10-13-2012, 04:53 PM
Just a got a squeal of fortune ticket...never clicked the essence spot again.

EDIT: Adding the person above me's findPortal function has worked every time, so far.

litoris
10-13-2012, 05:12 PM
Just a got a squeal of fortune ticket...never clicked the essence spot again.

EDIT: Adding the person above me's findPortal function has worked every time, so far.
FindNonInventoryRandoms should be called instead of FindNormalRandoms then.
Also, it's quite funny how JJ's simple color finder works better than all that crazy stuff in the script, maybe just changing the color on that will work too?

euphemism
10-13-2012, 07:03 PM
FindNonInventoryRandoms should be called instead of FindNormalRandoms then.
Also, it's quite funny how JJ's simple color finder works better than all that crazy stuff in the script, maybe just changing the color on that will work too?

Well, I have been running the script for about two hours now, and the portal finder I wrote hasn't failed yet. More than anything, I am surprised that it still works after eight months. :)

E:


Force-walking to the middle of room..
Location detection failed! No middle and no DTMs
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
MineToAubury - Could not find the transportation symbol. Exiting
No Portal!
----------------------------

Wizzup? and Markus Essence Miner, Version 3.10

Worked for 3 Hours, 35 Minutes and 2 Seconds
Mined 2772 Essence at a rate of 773 essence an hour.

----------------------------

Markus
10-14-2012, 01:31 AM
J J: I'll test your portal finder later (just came back from the pub so can't really do it now). If it works just fine I'll add it in as the 3rd portal finder! :p You can never have enough of them. As you can see in the script, I love redundancy and almost everything that can fail is implemented twice.


I didn't now about the offset stuff, I'll definitely use that in my current project. One question though, where can I find the black offset on the minimap? I tried a few black colors from the minimap in game, but they returned 65535. I suppose the black you see in the off-map areas in caves etc. works, but where do I find this black in the overworld? I'm going to use the red from doors or something if there isn't a way, I can still use that for my offset as far as I understand.

Also, does the offset stay the same for main screen objects?

It is the 'black' for overworld yea. In Varrock it is visible as a small black square/tile directly east of Aubury's store. And yes, red from doors should still work, as long as you are consistent on which colour you use, you could also use rocks or whatever, plain terrain isn't too accurate though. as that one seems to be modified in a different way.
And no, according to my really small quick tests it doesn't work for mainscreen objects :'(

@euph: pretty weird... any chance it was stuck in a random or so? Seems really weird to me..

Also, I got some other good news! Before I left for the pub, I invented the most genius doorfinder ever made by mankind. It uses the integral of the colours to determine the area on the mainscreen with the highest complexity. This is because the door has the same colours as the floor (even at tolerance zero). The solution is to use the fact that a door is way more 'complex' than a floor (not a really smooth gradient), so it can semi-accurately determine the door.
Quote for self:

function CalcColorDistance(c1, c2 : integer) : integer; //cts1
var //This calculates the difference between the colours. You can say, the differential =)
r1, g1, b1, r2, g2, b2 : integer;
begin
ColorToRGB(c1, r1, g1, b1);
ColorToRGB(c2, r2, g2, b2);
result := round(sqrt(Sqr(r1-r2)+sqr(b1-b2)+sqr(g2-g1)));
end;

function GetTPAColorIntegral(tpa : TPointArray) : Integer; //More of a Riemann sum though
var //Sums above differences, so basically it differentiates then integrates
cols : TIntegerArray;
i : integer;
begin
result := 0;
cols := GetColors(tpa);
for i := 1 to high(cols) do
result := result + CalcColorDistance(cols[i-1], cols[i]);
end;

function DoorClosedGenius : boolean;
var
CharBox : TBox;
CharTPA : TPointArray;
TPA : TPointArray;
ATPA : T2DPointArray;
begin
ColorToleranceSpeed(2); //Find the colours of ground/door
SetColorSpeed2Modifiers(0.09, 0.06);
FindColorsTolerance(TPA, 3494494, 3, 3, 515, 336, 15);

CharBox := IntToBox(MSCX - 25, MSCY - 21, MSCX + 15, MSCY + 20);
CharTPA := TPAFromBox(CharBox);
TPA := ClearTPAFromTPA(TPA, CharTPA); //Clear our own character from the TPA

aTPA := TPAToATPAEx(TPA, 15, 15); //Split it into squares (15x15 is semi-arbitrary)

for i := 0 to high(atpa) do
begin
k := GetTPAColorIntegral(atpa[i]);
writeln(k);
{ if (k > j) then
begin
j := k;
p := MiddleTPA(atpa[i]);
end;}
if (k < 1000) then //Clear all points with not enough 'variance' in colour
tpa := ClearTPAFromTPA(tpa, atpa[i]);
end;

ATPA := splittpa(TPA, 3); //Split the TPA up again

SetLength(tpa, 0);
SetLength(tpa, length(atpa));

for i:= 0 to high(atpa) do //Calculate middles
tpa[i] := MiddleTPA(atpa[i]);

For I := 0 To High(TPA) Do //And iterate them!
Begin
MMouse(TPA[i].X, TPA[i].Y, 0, 0);
Wait(200);
If IsUpText('pen') And IsUpText('oor') Then
Begin
Result := True;
ClickMouse2(true);
m_debug('Door opened with the genius doorfinder.');
MFlag;
Break;
End;
End;
end;


If you are bored, please test it! It might need one or two mouse movements but overall it should work pretty well :)

nokkasiili
10-14-2012, 02:26 PM
Found Aubury store using offset DDTM!
----------------------------

Wizzup? and Markus Essence Miner, Version 3.10

Worked for 7 Hours, 50 Minutes and 11 Seconds
Mined 5236 Essence at a rate of 668 essence an hour.

----------------------------

0 : = T; Aubury; B: 1932 Essence; M : -1
1 : = T; Bank; B: 1400 Essence; M : -1
2 : = T; Bank; B: 532 Essence; M : -1
3 : = T; Bank; B: 252 Essence; M : -1
4 : = F; NoBank; B: 1120 Essence; M : -1

cached offset = 3
cached offset = 3
cached offset = 3
cached offset = 3
cached offset = 3
cached offset = 3
cached offset = 3
cached offset = 3
Exception in Script: Failed to create new thread, code:8
The following DTMs were not freed: [0, SRL - Lamp bitmap, Aubury door DTM, Middle DTM 2, Middle DTM 1]
The following bitmaps were not freed: [SRL - NavBar Bitmap, SRL - Flag bitmap, 4, SRL - Mod bitmap, SRL - Admin bitmap]


Works fine except the doorfinder. I may try the new finder nextday:spot:

Markus
10-14-2012, 04:06 PM
Aw, code 8. That's a really bad pascalscript problem which I could work around but sure is a lot of work to do so...
I'll release a new version in a couple of days with the new doorfinder, portal finder and a couple of other bugfixes / tweaks!

zertunami
10-14-2012, 04:41 PM
Wow, I remember this script from forever ago, I'll post a proggy once I find time to run it

euphemism
10-14-2012, 05:35 PM
Ran it again, got a code 8 like nokkasiili


Wizzup? and Markus Essence Miner, Version 3.10

Worked for 4 Hours, 39 Minutes and 47 Seconds
Mined 3584 Essence at a rate of 769 essence an hour.

----------------------------

0 : Drag = T; Bank; B: 3584 Essence; M : -1

----------------------------
|====================================|
| ~ SRL ~ |
| Randoms Report |
|────────────────────────────────────|
| |
| |
|────────────────────────────────────|
|====================================|
cached offset = 65536
cached offset = 65536
cached offset = 65536
cached offset = 65536
cached offset = 65536
DDTM not found, using magic symbol!
store found? True
cached offset = 65536
cached offset = 65536
cached offset = 65536
cached offset = 65536
ut: Walk here
10
We are standing in the middle
Force-walking to the middle of room..
Exception in Script: Failed to create new thread, code:8

Markus
10-14-2012, 08:50 PM
Hmm, code 8 turns out to be a bit more prevailing than I originally thought it would be..
There are two fixes around it: one is by using Lape. The other is by using the wrappers which were made specifically to evade Pascalscript's code 8 bug. There doesn't happen to be an include with those wrappers, is there?

euphemism
10-14-2012, 09:03 PM
As far as I know, SplitTPAWrap, ClearTPAFromTPAWrap and the like are all in Simba for you to use, you just need to swap them in your script.

Markus
10-14-2012, 09:39 PM
yeayea I know, but an include that would do like this would be easier as there are a LOT of TPA functions used:

function SplitTPA(t : TPointArray; i : integer) : TPointArray;
begin
SplitTPAWrap(t, i, result);
end;

iirc the bug only occurs with exported functions, not with in-script ones. Resolving it like above and then {$i fixstupidpascalscriptbugs.simba} would also fix it in SRL etc.

edit:
above {$i srl/srl.simba} add this line. Please try and report if it fixes code 8 :) (if script still runs after 10 hours then yea it is fixed).

{$IFDEF RAYMONDPOWNS} {DONT TOUCH THIS LINE, IT FIXES CODE 8. The define is an undocumented define for Pascalscript as there is no documented one.} function SplitTPA(arr : TPointArray; dist : Integer) : T2DPointArray; begin SplitTPAWrap(arr, dist, result); end; function SplitTPAEx(arr : TPointArray; w, h : integer) : T2DPointArray; begin SplitTPAExWrap(Arr, w, h, result); end; function ClearTPAFromTPA(arP, ClearPoints : TPointArray) : TPointArray; begin ClearTPAFromTPAWrap(arP, ClearPoints, result); end; function TPAToATPAEx(arP : TPointArray; w, h : integer) : T2DPointArray; begin TPAtoATPAExWrap(arP, w, h, result); end; function TPAToATPA(arP : TPointArray; dist : Integer) : T2DPointArray; begin TPAtoATPAWrap(arP, dist, result); end; function FindGapsTPA(TPA : TPointArray; MinPixels : integer) : T2DPointArray; begin FindGapsTPAWrap(tpa, MinPixels, result); end; {$ENDIF}

Markus
10-18-2012, 02:46 PM
Updated! Now with a good doorfinder, SRL Stats support, yet another portal finder and lots of other goodies including a code 8 fix!
This script should be pretty rock-solid now :) Please give it another run and report back your results.
Also, I added some pretty nice explanation of the location detection inside the mine which can be found at lines 1840-1927. I'm sure even WT-Fakawi should now be able to understand how it works :)

With this script sorta finished, time to work on some other project. It will be a multi-skiller in a dungeon and will use some creative stuff like a SPS web-walker! (Which is, in fact, the only functioning part of the script right now). I'm quite excited about this one as it'll be made from scratch, something which I usually don't do.

WT-Fakawi
10-18-2012, 03:11 PM
I'm sure even WT-Fakawi should now be able to understand how it works :) Hmmm? Brilliant! I already gave the previous version a testrun, which went well, even with Remove Roof off! Mine crashed after a couple of runs on some smart drawing issue. Not sure what happened, never had that. But i never draw on smart and hardly ever run anyone elses script.

I'll give it a go and I'll try to grasp your explanation.

Olly
10-18-2012, 03:29 PM
With this script sorta finished, time to work on some other project. It will be a multi-skiller in a dungeon and will use some creative stuff like a SPS web-walker! (Which is, in fact, the only functioning part of the script right now). I'm quite excited about this one as it'll be made from scratch, something which I usually don't do.

Why so secret on what it is haha :P

Markus
10-18-2012, 04:52 PM
Everything related to smart-drawing should catch exceptions. Else it can be handled quite easily by using Lape (together with the right Simba), which doesn't support drawing :)

litoris
10-18-2012, 04:54 PM
Everything related to smart-drawing should catch exceptions. Else it can be handled quite easily by using Lape (together with the right Simba), which doesn't support drawing :)

What about you put all drawing functions in a try..except... etc loops? Would at least keep the script from screwing up.
E::duh: fatal error at line 1

euphemism
10-18-2012, 05:02 PM
What about you put all drawing functions in a try..except... etc loops? Would at least keep the script from screwing up.


should catch exceptions.


Congrats on the release, Markus.

partyboyrawr
10-24-2012, 01:00 AM
hi sorry to bother you guys i get this error when I press the play button.
Unable to find file 'srl/srl/misc/smartgraphics.simba'.

Markus
10-24-2012, 06:40 AM
Please update your Simba and SRL then :)

partyboyrawr
10-25-2012, 09:41 AM
im sorry to bother again. I've updated simba and srl but i get this error now
[Error] C:\Users\Derp\Downloads\SRL Essence Miner 3.11.simba(2103:3): Invalid number of parameters at line 2102
Compiling failed.

Markus
10-25-2012, 10:33 AM
Oops, small mistake! You can delete that line.

partyboyrawr
10-25-2012, 10:54 AM
after i delete that line. It says error to the next few lines ;\

Markus
10-25-2012, 11:59 AM
Please redownload and try again! Should be all fixed now :)

partyboyrawr
10-25-2012, 12:39 PM
thanks Markus, its working again:) so sorry to bother you D:

Markus
10-25-2012, 01:37 PM
No problem! It was quite a stupid mistake on my behalf.

partyboyrawr
10-25-2012, 08:45 PM
haha its fine :) I was learning how to script but had to stop due to school and exams coming up :\ might start again soon when its all finish :D

reyesonline
10-30-2012, 12:49 PM
why did I always got
No black. Fallback False everytime I run this script?

Panama
11-03-2012, 11:58 AM
I just came to say that atleast to me its bugging like hell, opening other doors etc

Markus
11-03-2012, 12:17 PM
Yea, door opening is glitchy at best.. At least it opens *something* now, it used to glitch for 5 mins then log out. Pretty detectable. If you can think of some way to fix it, go ahead xD

CephaXz
11-13-2012, 09:37 PM
Brilliant script! Reading and learning right now. Was thinking of how can I script for randomized positions like ess mine and abyss. Thanks for the script!

viciouskitten1337
11-14-2012, 01:26 AM
i'm like, an uber noob. i have no idea how to set this up, and i'm just not getting it. i'm so lost it's pathetic. :/ someone please helpp?

http://us3.memecdn.com/I-Have-No-Idea-What-Im-Doing_o_99475.jpg

Ashaman88
11-14-2012, 03:58 AM
i'm like, an uber noob. i have no idea how to set this up, and i'm just not getting it. i'm so lost it's pathetic. :/ someone please helpp?

http://us3.memecdn.com/I-Have-No-Idea-What-Im-Doing_o_99475.jpg

Have you had a look through this?

http://villavu.com/forum/showthread.php?t=47714

Ryelander5
11-14-2012, 11:20 PM
Every time i run the script, it logs into my account but it either sits there or it runs somewhere off course and logs out of my account and then does it again and it loops logging in and out. is there any way to fix this and get it working properly?

And this error always shows up :"The following DTMs were not freed: [Aubury door DTM, Middle DTM 2, Middle DTM 1]"

anyway to fix that?

cycrosism
12-18-2012, 10:54 PM
Sometimes the script clicks on the wrong doors such as the door to the left and right of the magic shop. But it always manages to correct itself.

Here is my progress report


----------------------------

Wizzup? and Markus Essence Miner, Version 3.11

Worked for 6 Hours, 23 Minutes and 34 Seconds
Mined 4266 Essence at a rate of 667 essence an hour.

----------------------------

0 : = F; NoBank; B: 648 Essence; M : -1
1 : = T; Aubury; B: 648 Essence; M : -1
2 : = F; NoBank; B: 702 Essence; M : -1
3 : = T; Bank; B: 972 Essence; M : -1
4 : = T; Bank; B: 648 Essence; M : -1
5 : = T; Bank; B: 648 Essence; M : -1

----------------------------
|====================================|
| ~ SRL ~ |
| Randoms Report |
|────────────────────────────────────|
| |
| |
|────────────────────────────────────|
|====================================|
NextPlayer(True)
SwitchToPlayer(PlayerNo: 4, Active: True);
Welcome to Runescape.
'Game session expired.'
SRL Compiled in 0 msec
Loading SMART: http://world49.runescape.com/f2515589324563683045
It has been 3 minutes and Runescape is not yet ready... Terminating.
Successfully executed.
The following DTMs were not freed: [Middle DTM 1, Middle DTM 2, Aubury door DTM]

Removed usernames for obvious reasons

EDIT BELOW

Second time running the script


----------------------------

Wizzup? and Markus Essence Miner, Version 3.11

Worked for 4 Hours, 24 Minutes and 24 Seconds
Mined 2821 Essence at a rate of 640 essence an hour.

----------------------------

0 : = T; Aubury; B: 648 Essence; M : -1
1 : = T; Aubury; B: 0 Essence; M : -1
2 : = T; Bank; B: 643 Essence; M : -1
3 : = T; Bank; B: 567 Essence; M : -1
4 : = T; Aubury; B: 315 Essence; M : -1
5 : = T; Bank; B: 648 Essence; M : -1

----------------------------
|====================================|
| ~ SRL ~ |
| Randoms Report |
|────────────────────────────────────|
| |
| |
|────────────────────────────────────|
|====================================|
cached offset = 0
cached offset = 0
cached offset = 0
cached offset = 0
cached offset = 0
DDTM not found, using magic symbol!
store found? True
cached offset = 0
cached offset = 0
cached offset = 0
cached offset = 0
ut: Walk here
2
We are standing in a room
Fortunately we can walk to the middle.
should be in middle of mine now
FindObject could not find object.
No Essence Corner
We did not find any essence...
Math error at line 650
The following DTMs were not freed: [SRL - Lamp bitmap, 1, Middle DTM 1, Middle DTM 2, Aubury door DTM]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap, SRL - NavBar Bitmap, 4]

the merr
12-28-2012, 04:59 AM
fixed problem, it was the client, reinstalled

the merr
12-28-2012, 06:04 AM
double post sorry.

the merr
12-28-2012, 06:07 AM
Few problems/fixes/possible solutions

The door genius opens the wrong door from time to time (directly to the right), i think that it does this because another miner opens Aubrey's door before it determines the door it needs to open, so it opens the door closest to it to resolve the door genius. Perhaps delay this action a bit? The offset DDTM also triggers this. I found that about 7/10 times the DDTM didn't click into Aubrey's but rather one or two squares to the right of the door, triggering the door genius even though the door was open.

Idk if you can do this but i think i can "tell" who is also using this script (movements,pause, same as me) anyway to randomize this a bit?

Also, what would really set this script apart from the crowd and make it look more "legit" would be the ability to the bank directly from Aubrey's, eliminating the pause as you walk halfway. Adding a break feature would be great, either between accounts if using multiple or just one.

Also, I received a squeal of fortune spin, it used it almost right away, but didn't start mining again, I found that if it gets interrupted it doesn't really "check" or click to mine again.

it also banks upon leveling up, idk if this is intentional or to check for the next pickaxe, if it can even do that. Guess I'll know im the am when I wake up with 41 mining+

Ilm1
01-06-2013, 08:42 PM
Few problems/fixes/possible solutions

The door genius opens the wrong door from time to time (directly to the right), i think that it does this because another miner opens Aubrey's door before it determines the door it needs to open, so it opens the door closest to it to resolve the door genius. Perhaps delay this action a bit? The offset DDTM also triggers this. I found that about 7/10 times the DDTM didn't click into Aubrey's but rather one or two squares to the right of the door, triggering the door genius even though the door was open.

Idk if you can do this but i think i can "tell" who is also using this script (movements,pause, same as me) anyway to randomize this a bit?

Also, what would really set this script apart from the crowd and make it look more "legit" would be the ability to the bank directly from Aubrey's, eliminating the pause as you walk halfway. Adding a break feature would be great, either between accounts if using multiple or just one.

Also, I received a squeal of fortune spin, it used it almost right away, but didn't start mining again, I found that if it gets interrupted it doesn't really "check" or click to mine again.

it also banks upon leveling up, idk if this is intentional or to check for the next pickaxe, if it can even do that. Guess I'll know im the am when I wake up with 41 mining+

It's not only the door to the right, but also the door to the left. More often, however, when it opens the door to the right it goes inside that building and then doesn't know what to do. Another thing it does is it stops working randomly and goes to the next player occasionally?
PS. Gets somehow stuck and spams progress reports, reason unknown.

sammyslucket
01-11-2013, 06:40 PM
Wizzup? and Markus Essence Miner, Version 3.11

Worked for 10 Hours, 24 Minutes and 6 Seconds
Mined 2558 Essence at a rate of 246 essence an hour.

----------------------------

0 : = F; Login Failed; B: 2558 Essence; M : 1

----------------------------
|====================================|
| ~ SRL ~ |
| Randoms Report |
|────────────────────────────────────|
| |
| |
|────────────────────────────────────|
|====================================|

No complaints, thanks!

Crusade
01-13-2013, 11:42 PM
great script, however my account is a 3 lvl skiller, so could you make an option to not bank my rune pickaxe everytime? Cause it's using the apickaxe I got in my toolbelt, which is bronze at mining lvl 77 lol

Ilm1
01-14-2013, 12:06 AM
great script, however my account is a 3 lvl skiller, so could you make an option to not bank my rune pickaxe everytime? Cause it's using the apickaxe I got in my toolbelt, which is bronze at mining lvl 77 lol
line 115, I believe

Dynam0
01-18-2013, 09:44 AM
Thanks for this, I just have two questions, hope you don't mind answering them.

1. How do I change the script, so it doesn't open the SMART Runescape Client? I'm trying to use it on a RSPS client.
2. Does it matter where i place my character when I click Start? Should I be stood in the bank, etc.

Sjoe
01-18-2013, 10:00 AM
Thanks for this, I just have two questions, hope you don't mind answering them.

1. How do I change the script, so it doesn't open the SMART Runescape Client? I'm trying to use it on a RSPS client.
2. Does it matter where i place my character when I click Start? Should I be stood in the bank, etc.

uncommon out the first line // {$idefine Smart8} (won't start smart then)
When u get errors, u probably have to uncommon other lines out as well since they are used for smart.
(Don't know if this script will run on RSPS though)

And for your second question, just test it out :)

Ashaman88
01-18-2013, 02:13 PM
Thanks for this, I just have two questions, hope you don't mind answering them.

1. How do I change the script, so it doesn't open the SMART Runescape Client? I'm trying to use it on a RSPS client.
2. Does it matter where i place my character when I click Start? Should I be stood in the bank, etc.

It def won't work with an rsps

M_Back
01-20-2013, 10:59 AM
At my first try the script couldn´t open the door at all. The door to the left was opened several times before my acc wandered off and got lost.
Second run I managed to run the script for 13 minutes, after I manually opened the door. After 13 min the door closed and my acc could not get out of Auburys house.
So, for me the door opening is pretty messed up. Am I doing something wrong, or has jagex updated something?

Fridder
01-21-2013, 04:00 PM
Says:

smartremote32.exe - System Error
The program can't start because MSVCR71.dll is missing from your computer. Try reinstalling the program to fix this problem.

BauceJohnson
01-21-2013, 06:47 PM
can we get a non-smart version? my smart never works.

kyleinkman
01-21-2013, 08:42 PM
awsome :D

Kyle Undefined
01-21-2013, 08:46 PM
Make sure you're following the Simba install guide, and everything will work :)

The Mayor
01-25-2013, 08:43 PM
Wizzup? and Markus Essence Miner, Version 3.11

Worked for 2 Hours, 31 Minutes and 3 Seconds
Mined 1728 Essence at a rate of 686 essence an hour.

----------------------------

0 : ven = F; NoBank; B: 1728 Essence; M : -1


Worked for 3 Hours, 1 Minutes and 33 Seconds
Mined 1998 Essence at a rate of 660 essence an hour.

----------------------------

0 : ho s = F; NoBank; B: 1998 Essence; M : -1

It has trouble finding the door sometimes.

Sjoe
01-25-2013, 08:56 PM
It has trouble finding the door sometimes.

Yeah common problem, don't think OP is going to update this script.

Sir Fly Buzzington
02-03-2013, 03:34 AM
It's a grand shame that this script probably isn't going to get updated. Besides the door finding issue, it seems to work fairly flawlessly.

Oh well. S'pose I'll have to patch it up myself!

TViYH
02-04-2013, 02:24 PM
How difficult would it be to use SMART functions to open the door as opposed to color-based functions?

John
02-11-2013, 07:42 AM
You could hover the door and get the up-text to check if the door is open or not..

zarryan
03-05-2013, 04:00 AM
What program do i use to run the script?

Ian
03-05-2013, 04:10 AM
What program do i use to run the script?

Simba. Read this thread, it will tell you everything :) http://villavu.com/forum/showthread.php?t=47714

thetennthtenn
03-06-2013, 05:14 AM
hey guys sorry to be a bother but i am running the script and as soon as i am running towards aubruys shop i get this
"cached offset = 328967
cached offset = 328967
cached offset = 328967
cached offset = 328967
cached offset = 328967
Found Aubury store using offset DDTM!
No Aubury Shop Symbol"

any help would be nice thanks guys

ozzypoo
03-06-2013, 10:33 PM
Err, I know I'm leecher scum for asking this, but it says Black offset false something


I may be a leecher noob, but if you could point me in the direction where I can learn to fix it myself, or at least tell me if it's anti leech or anythign like that, I'd really appreciate it

thetennthtenn
03-07-2013, 03:21 AM
nvm i fixed it i just changed all the symbols to FindStoreDDTM and it works it just uses the same variable for both.........man this is so different from c++ and i added the double check part just in case and cleaned up the m_debug out put (there was way too much) but the door opener thing keeps on fucking up and wanting to open a door even if auburys door is open? hasent made me crash yet but it take a few seconds to do.

and btw really nice bot thanks for the comments man they HELPED SO MUCH!

mikeywae
03-09-2013, 04:13 PM
Exception in Script: Operator expected at line 453, column 93 in file "C:\Simba\Includes\SRL\SRL\core\gametab.simba"

any help please im so new its not even funny

thetennthtenn
03-11-2013, 05:26 AM
Exception in Script: Operator expected at line 453, column 93 in file "C:\Simba\Includes\SRL\SRL\core\gametab.simba"

any help please im so new its not even funny

hey so have you tried updating A) your client or B) srl and have you enabled srl?

mikeywae
03-11-2013, 01:42 PM
hey so have you tried updating A) your client or B) srl and have you enabled srl?

Yeah, ive got both srl and the client updated, srl is enabled as well idk whats up with it):

thebob142
03-17-2013, 04:30 AM
Black offset: 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
cached offset = 67073
Found Aubury store using offset DDTM!
cached offset = 67073
cached offset = 67073

pretty much just kept repeating this what happened help me please

walle123
03-19-2013, 07:59 PM
smartremote32.exe - unable to locate component
The program can't start because MSVCR100.dll is missing from your computer. Try reinstalling the program to fix this problem.

Phasmatys
04-19-2013, 08:56 AM
cached offset = 262148
cached offset = 262148
cached offset = 262148
cached offset = 262148
cached offset = 262148
Found Aubury store using offset DDTM!
No Aubury Shop Symbol
cached offset = 262148
cached offset = 262148
cached offset = 262148
cached offset = 262148
cached offset = 262148
Found Aubury store using offset DDTM!
No Aubury Shop Symbol

Huh?

It walks up just nw of the shop and says this, then i tried to go inside the essence mine and test it and this came up

Black offset NOT found!
No black. Fallback False
Black offset NOT found!
No black. Fallback False
Black offset NOT found!
No black. Fallback False
Black offset NOT found!
No black. Fallback False
Black offset NOT found!
No black. Fallback False
Black offset NOT found!
No black. Fallback False
Black offset NOT found!
No black. Fallback False
Black offset NOT found!
No black. Fallback False

Is this script out of date or something now is there a fix for this please let me know =D

2007
04-24-2013, 02:22 AM
I can't open .simba?

Auss
04-24-2013, 03:53 AM
Im trying to find a solution for this too.. I know a few people.

idownloadwarez
04-25-2013, 10:32 PM
I keep getting this message.

Found Aubury store using offset DDTM!
No Aubury Shop Symbol

How do I fix this? Ive downloaded the most recent script.

xMudkips
05-27-2013, 05:05 AM
The following DTMs were not freed: [SRL - Lamp bitmap, 1, Middle DTM 1, Middle DTM 2, Aubury door DTM]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap, SRL - NavBar Bitmap, SRL - Options Bitmap, 5]

I get this on top of the spamming of the DDTM and Aubury.

Itankbots
05-27-2013, 07:47 AM
The following DTMs were not freed: [SRL - Lamp bitmap, 1, Middle DTM 1, Middle DTM 2, Aubury door DTM]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap, SRL - NavBar Bitmap, SRL - Options Bitmap, 5]

I get this on top of the spamming of the DDTM and Aubury.

This hasn't been updated for months, Most likely way out-dated.

xMudkips
05-27-2013, 06:14 PM
Ah alright, wouldn't think something would be outdated in just a few months. Haven't been on RS in forever, but I've used this before and thought I'd give it a go again.

Markus
05-29-2013, 01:20 PM
Well, the actual script was more like six years old ;) Just hacked it a bit up to get it working and rewrote quite a few parts to make them more readable.
Atm I really don't have the time to update it again (because of a bit more active social life, new job, actually getting credits at college etc.). The main "problem" in the script is the part after he walks to the shop, mainly the Aubury finding which is pretty whacky and the door opening. If anyone wants to have a challenge, go ahead ;) I think the code is decently documented now so if you know what you're doing, it shouldn't be too hard :)

Markus
12-29-2015, 03:51 PM
Found an old big update from march 2015 in my Dropbox. I fixed it slightly and there's a good base now! Script works 50% fine.

Merry belated christmas and a happy 2016!

Hyper Insomnia
02-11-2016, 10:57 PM
Seems like it could be a great script. I am just experiencing a few bugs. First one is that it has problems finding the door and opening it/knowing if its open. There is the obvious finding the teleporter problem. It seems to constantly log out and then log back in which im not sure if that is intentional or not. And the some banking issues as well.

I dont know if these will be fixed or if anyone reads/works on this anymore just expressing what ive experienced.

KeepBotting
02-12-2016, 12:18 AM
Seems like it could be a great script. I am just experiencing a few bugs. First one is that it has problems finding the door and opening it/knowing if its open. There is the obvious finding the teleporter problem. It seems to constantly log out and then log back in which im not sure if that is intentional or not. And the some banking issues as well.

I dont know if these will be fixed or if anyone reads/works on this anymore just expressing what ive experienced.

This still works? o_O

acow
02-12-2016, 12:19 AM
This still works? o_O

read 1 post up:garfield:

Hyper Insomnia
02-12-2016, 12:48 AM
haha ya sorta. I need to find some good bot scripts and have no idea where to look. You guys know of a good ess miner that works?

blastfable9
03-26-2016, 03:53 PM
God damn dank. Dem pure ess gains are awesome. Thanks for the script ^^

Markus
01-10-2017, 09:00 AM
It's that time of the year again. As I'm a member of SRL for more than 10 years now (October 31st 2006 I made my first account here) and Wizzup? released his essence miner almost 10 years ago, it is time for the anniversary edition of the essence miner!
Every year around December/January I spent some hours updating it. The last major update was around 2012-ish, however, that update was so big that 90% of the code still runs in 2017 (with just a few minor changes to allow it to compile, new coordinates, stuff like that).

This time, it took me around 15 minutes to get the script running and I spent around an hour for some bugfixes. Amazingly, it still works! It's full of outdated techniques (no reflection, ogl, directx, almost no DDTMs, basically everything we had in 2008/2009 is what I use as I don't know any newer).

Please run and let me know how broken it really is. It mined a few hundred essence on my test mule.

Laquisha
01-10-2017, 10:36 AM
It's that time of the year again. As I'm a member of SRL for more than 10 years now (October 31st 2006 I made my first account here) and Wizzup? released his essence miner almost 10 years ago, it is time for the anniversary edition of the essence miner!
Every year around December/January I spent some hours updating it. The last major update was around 2012-ish, however, that update was so big that 90% of the code still runs in 2017 (with just a few minor changes to allow it to compile, new coordinates, stuff like that).

This time, it took me around 15 minutes to get the script running and I spent around an hour for some bugfixes. Amazingly, it still works! It's full of outdated techniques (no reflection, ogl, directx, almost no DDTMs, basically everything we had in 2008/2009 is what I use as I don't know any newer).

Please run and let me know how broken it really is. It mined a few hundred essence on my test mule.

Gotta be the most hack up piece of code on the forums haha. You can easily see old school SRL throughout the script. A few functions are now actually in SRL6 in one form or another (e.g. SPS.isInPolygon; bankScreen.open, minimap.getBlackPercent, etc.). Could probably be cleaned up a whole lot, but I guess there is a stack of history in the script.

Markus
01-11-2017, 08:56 AM
Gotta be the most hack up piece of code on the forums haha. You can easily see old school SRL throughout the script. A few functions are now actually in SRL6 in one form or another (e.g. SPS.isInPolygon; bankScreen.open, minimap.getBlackPercent, etc.). Could probably be cleaned up a whole lot, but I guess there is a stack of history in the script.

Sure is! The last 'clean' update was version 3.11, everything after that was just hacking it all together, most of it to make it compile at newer SRL/Simba versions. Script itself hardly needs any updates.

Sample proggie:


Wizzup? and Markus Essence Miner, Version 5.00 beta, on RS3
10-year anniversary edition!

Worked for 21 Minutes and 35 Seconds
Mined 280 Essence at a rate of 778 essence an hour.

rkroxpunk
01-12-2017, 09:33 AM
Sure is! The last 'clean' update was version 3.11, everything after that was just hacking it all together, most of it to make it compile at newer SRL/Simba versions. Script itself hardly needs any updates.

Sample proggie:


Wizzup? and Markus Essence Miner, Version 5.00 beta, on RS3
10-year anniversary edition!

Worked for 21 Minutes and 35 Seconds
Mined 280 Essence at a rate of 778 essence an hour.


Sorry my comment has no real substance other than this is awesome! Not the script, cos I haven't actually tested it (soz) but just the fact you're still maintaining it. I remember when I was in high school and frequenting this place, Wizzup?'s essence miner was the script that got me hooked and blew me away, crazy that it's still going in some form. Thanks for the nostalgia trip!

Markus
01-13-2017, 10:50 PM
It's a funny thing to do on those rainy cold winter days once every other year :) This is like the only script I still know pretty much by heart how it works and the code is too resilient not to do it!
January 25th is the big surprise day btw, mark the date.

Small sneak preview:


----------------------------

Wizzup? and Markus Essence Miner, Version 5.00 beta, on OSRS
10-year anniversary edition!

Worked for 1 Hours, 1 Minutes and 5 Seconds
Mined 476 Essence at a rate of 468 essence an hour.

----------------------------

Wu-Tang Clan
01-15-2017, 08:46 PM
Here you are let me know if you want something else put in
27972
http://www.megafileupload.com/csjV/LumbToVarrock.png
http://www.fast-files.com/getfile.aspx?file=130544
https://ufile.io/bede2
I noticed the upload was in jpg and you need png

let me know if any of those work

Markus
01-22-2017, 08:52 AM
Version 5 released! Both RS3 and OSRS!

https://villavu.com/forum/showthread.php?t=117079