SRL Archive - RS3 Outdated / Broken Scripts

TomTuff's Giant Spider Killer


TomTuff

2010-11-22 19:57:26

TomTuff's Giant Spider Killer
Revision 1


What the script does:
This script kills giant spiders in the large room on the 3rd floor of the stronghold of security. This is great exp for both mains and pures (I make 60k/hr with level 85 strength and a saradomin sword) (mains will be a bit more effective with food, though). It supports the use of Attack potions, Strength Potions, Defence Potions, Super Attack Potions, Super Strength Potions, and Super Defence Potions. As for food, it supports lobsters, swordfish, monkfish, and sharks. It uses the varrock teleport to get back to varrock (N.B.: It doesn't matter if you've done the Varrock Acheivement diary and ergo teleport to the GE entrance - the script will detect this and act accordingly).

Player setup:
Start the player in Varrock west bank. In your bank, have Law runes, Air runes, Fire runes, potions, and food in their own tab. Have this tab active. Do not have any items that look alike to any of these items as the icon for any other tabs (e.g. don't have lobsters for food and have raw lobsters as another tab's icon). Do not use the infinity tab, that way the script doesn't see extra items and confuse them with the items you want. Have 1 extra item (I use a talsiman) in the first slot of the tab you're using. Here's a picture of a good player setup:
Stat requirements:
25 magic (varrock teleport)
Minimum stat reccomendations:
50 attack/defence/strength/hp (low xp + high consumption at this level!)
Recommended stats:
60 attack/defence/strength/hp (good exp, medium consumption now).

Script setup:
fill out smart constants and debug settings in the constants (lines 55-59). For each player, fill out name (RS name), Pass (RS password), Nick (3-4 non capitalized letters in the player's RS name), And Pin (leave it as '' if you don't have one). Leave Active as "true". in strings, place either lobster, swordfish, shark, monkfish (this is the food you will eat). Integers[0] is the % HP you would like to eat at. Arrays[0] is a bit complicated - it's for potion setup. The numbers are relative, in order, to the following potion types: Attack potion, Strength potion, Defence potion, Super attack, Super strength, Super defence. Do not have it set up to bring 2 of the same types of potions (e.g. 2 super attacks and 2 attack potions). Here are some examples of proper potion setups:
Arrays[0] := [0, 0, 0, 0, 0, 0]//this will bring no potions
Arrays[0] := [0, 0, 0, 2, 2, 0]//this will bring 2 super attacks and 2 super strengths. This is what I use ;)
Here are some examples of BAD potion setups:
Arrays[0] := [1, 2, 0, 2, 0, 0]//NO!
Arrays[0] := [1, 1, 1, 1, 1, 1]//NO!
You will need the latest versions of Simba, SRL, and Reflection.

Bugs:
Potion drinking isn't working atm - leave Arrays[0] as [0, 0, 0, 0, 0, 0] for now!




*please post progress reports! Post the debugging as well! Please leave Debugging ON for now!*

Many credits to cstrike for his gaussian function and GetTempLevel!

xSaintias

2010-11-22 20:05:19

first!!
woah two killers in one day :D
oh glorious day!!!
expect proggies….
EDIT: actually im doing something right now, so expect proggies alot latter
D: sorry

Camaro'

2010-11-22 20:09:41

This looks nice! I will try getting my virtual machine to work so I can give this a run.

How reliable is the

Teleporting to varrock and then coming back to the spiders?

TomTuff

2010-11-22 20:13:23

[QUOTE=Camaro';751373]This looks nice! I will try getting my virtual machine to work so I can give this a run.

How reliable is the

Teleporting to varrock and then coming back to the spiders?[/QUOTE]

Yeah that's what it does. It's pretty reliable, I think. It's hard to test all by my lonesome, but i've refined it to the point that banking is perfect and getting to the spiders works 99% of the time. The only reason it's failed me is because i've recompiled SMART too many times so it gets laggy. It's difficult to test the fight loop since i can last 1.5hrs + at the spiders.

EDIT: Also, why do you need a vm for this?

Camaro'

2010-11-22 20:30:48

From: TomTuff
Yeah that's what it does. It's pretty reliable, I think. It's hard to test all by my lonesome, but i've refined it to the point that banking is perfect and getting to the spiders works 99% of the time. The only reason it's failed me is because i've recompiled SMART too many times so it gets laggy. It's difficult to test the fight loop since i can last 1.5hrs + at the spiders.

EDIT: Also, why do you need a vm for this?


Wine doesn't seem to run simba to well for me.

Overtime

2010-11-22 20:51:31

Not working for me :/


> WithdrawRunes
> Setting up rune bitmaps
> found law rune bitmap
> valid law rune uptext!
> found fire rune bitmap
> valid fire rune uptext!
> found air rune bitmap
> valid air rune uptext!
> Withdrawing air rune #1
> Withdrawing air rune #2
> Withdrawing air rune #3
> WithDrawPotion(WhichType: 1)
> the amount for potion type 1 was 0 - we must not be using this type of potion.
> WithDrawPotion(WhichType: 2)
> the amount for potion type 2 was 0 - we must not be using this type of potion.
> WithDrawPotion(WhichType: 3)
> the amount for potion type 3 was 0 - we must not be using this type of potion.
> WithDrawPotion(WhichType: 4)
> the amount for potion type 4 was 0 - we must not be using this type of potion.
> WithDrawPotion(WhichType: 5)
> the amount for potion type 5 was 0 - we must not be using this type of potion.
> WithDrawPotion(WhichType: 6)
> the amount for potion type 6 was 0 - we must not be using this type of potion.
> WithdrawFood
> setting up bitmap


logging out player eea because the food bitmap was not found


Error: Out Of Range at line 331

The Error: Out Of Range at line 331 opens up MMwalk.

and the food im using is 'lobster'

E: Tried running again i got


> WithdrawRunes
> Setting up rune bitmaps
> found law rune bitmap
> valid law rune uptext!
> found fire rune bitmap


logging out player eea because the uptext on the supposed fire rune was invalid

TomTuff

2010-11-22 21:15:46

i think i just need to update the bitmaps… i'll do it later :P if anyone wants to make bitmaps, go ahead.

EDIT: Squancy i know why it isn't working :o it's because i couldn't get my hands on a lobster when i made the bitmap, so i just used the grand exchange database image hoping it would work. For now you could make a new bitmap or wait about an hour until i can do it my self.

Camaro'

2010-11-22 21:19:56

From: TomTuff
i think i just need to update the bitmaps… i'll do it later :P if anyone wants to make bitmaps, go ahead.


Why release a script that has outdated bitmaps?

TomTuff

2010-11-22 21:27:30

patched to work with lobsters sorry about that :o

Camaro'

2010-11-22 21:29:11

From: TomTuff
patched to work with lobsters sorry about that :o


:spot:


I will be running this script a lot so I'll be able to post progress reports often.

TomTuff

2010-11-22 21:36:59

[QUOTE=Camaro';751409]:spot:


I will be running this script a lot so I'll be able to post progress reports often.

YAY! :) I hope to get potions working soon. There's something up with reflection… i might just use bitmaps, but i'll need 4 bitmaps for each potion type :(

Overtime

2010-11-22 21:46:56


logging out player eea because we could not find good uptext when going down ladder 1

Camaro'

2010-11-22 22:02:49

From: TomTuff
YAY! :) I hope to get potions working soon. There's something up with reflection… i might just use bitmaps, but i'll need 4 bitmaps for each potion type :(



I don't think you would need four bitmaps for each potion, just make the bitmap of the potion itself (bottom part of the potion) I don't think that changes regardless if its been drank already. Even color finding should work fine TBH.

TomTuff

2010-11-22 22:18:22

[QUOTE=Camaro';751415]I don't think you would need four bitmaps for each potion, just make the bitmap of the potion itself (bottom part of the potion) I don't think that changes regardless if its been drank already. Even color finding should work fine TBH.

shouldn't it try to drink the lowest variety of potion (e.g. drink a potion (1) before a potion (4))?

Squancy, you muse be on a slower-ish computer. Did you see if it moused over the ladder? Because if it did and you still got that error, then i need to increase wait times for people with laggy computers.

Camaro'

2010-11-22 22:23:16

From: TomTuff
YAY! :) I hope to get potions working soon. There's something up with reflection… i might just use bitmaps, but i'll need 4 bitmaps for each potion type :(


From: TomTuff
shouldn't it try to drink the lowest variety of potion (e.g. drink a potion (1) before a potion (4))?

Squancy, you muse be on a slower-ish computer. Did you see if it moused over the ladder? Because if it did and you still got that error, then i need to increase wait times for people with laggy computers.


Yes, then maybe my bitmap idea wont work, but if you made a color finding function for the potions then it would be simple to drink(1) first. Make a TPA of the inventory, and get which slots the potions (you want to drink) are in (by using some sort method), then get the one with the lowest color count (out of those items).

TomTuff

2010-11-22 22:37:52

[QUOTE=Camaro';751421]Yes, then maybe my bitmap idea wont work, but if you made a color finding function for the potions then it would be simple to drink(1) first. Make a TPA of the inventory, and get which slots the potions (you want to drink) are in (by using some sort method), then get the one with the lowest color count (out of those items).[/QUOTE]

Great idea! That's more efficient on code, too!

Overtime

2010-11-22 22:40:50

From: TomTuff
shouldn't it try to drink the lowest variety of potion (e.g. drink a potion (1) before a potion (4))?

Squancy, you muse be on a slower-ish computer. Did you see if it moused over the ladder? Because if it did and you still got that error, then i need to increase wait times for people with laggy computers.


I dont have a laggy computer.

What it did was miss clicked the ladder.

I suggest right click option. or add that as a failsafe. to try and click on the ladder again.

Im running now finally made it to spiders. Woot.

E: Yea, this isnt going to go far, if it doesn't relocate to another spot.


[===============================================================]
[ TomTuff's Giant Spider Killer ]
[ Revision 1 ]
[===============================================================]
[ Time Ran: 15 Minutes and 29 Seconds ]
[ Total XP Gained: 5820 ]
[ Times banked: 1 ]
[===============================================================]
[ Player 0: ean ]
[ Worked: 13m 30s ]
[ Times Banked: 1 ]
[ Strength XP Gained: 5820 ]
[===============================================================]
Error: Out Of Range at line 613

line 613


if ((Spiders[i].Name = 'Giant spider') and (Spiders[i].Fighting = False)) then

Seems if there is no spiders in the area it just terminates. Should add click in center.
Because this was near the doors. And then there were no more spiders.

Runescape Pro

2010-11-23 01:49:35

I know you must be busy with all the fixing with this script plus adding more failsafes but if you got the time, I suggest you add range support. ;)

TomTuff

2010-11-23 03:33:26

Alright, sorry guys, it's worse than i thought. I'll be doing a major makeover of this script tomorrow, as all i have to do for the day is sit down and be by my lonesome. Get ready for it ;)

Runescape Pro, what would need to be added for range support? All i can think of off the top of my head is to add in the calculations for range exp in the proggie

Bonfield

2010-11-23 03:35:24

checks for ammo, bow, text when out of ammo, arrow pick up thats all i can think of atm

Runescape Pro

2010-11-23 03:55:44

Basically, everything Bonfield said.

I didn't check out the code yet but if you use your own progress report, you could do something similar to this:

procedure proggy;
begin
//Everything before the xp.
If (UseMelee = True) then
Writeln(melee xp stuff);
end else
begin
Writeln(range xp stuff);
end;

Maybe make a constant labeled "UseMelee"?
If UseMelee = False then you are ranging. Just an idea.

As for the ammo, use Ref item ids. The ones i suggest are: Knives(Bronze-Steel), Darts(Bronze-Addy), Bolts(Bronze-Rune(possibly with the different gems/enchantments)), Arrows(Bronze-Rune). Support for every bow(long and shot) and crossbow would be cool too. ;)

TomTuff

2010-11-23 04:51:23

From: Runescape Pro
Basically, everything Bonfield said.

I didn't check out the code yet but if you use your own progress report, you could do something similar to this:

procedure proggy;
begin
//Everything before the xp.
If (UseMelee = True) then
Writeln(melee xp stuff);
end else
begin
Writeln(range xp stuff);
end;

Maybe make a constant labeled "UseMelee"?
If UseMelee = False then you are ranging. Just an idea.

As for the ammo, use Ref item ids. The ones i suggest are: Knives(Bronze-Steel), Darts(Bronze-Addy), Bolts(Bronze-Rune(possibly with the different gems/enchantments)), Arrows(Bronze-Rune). Support for every bow(long and shot) and crossbow would be cool too. ;)


I'd rather do it as a boolean (e.g. Players.Booleans[1]).

I'll consider it, though :)

Camaro'

2010-11-23 06:12:36

If you have any questions when you remake the script, you can definitely ask me on msn.
(Squany has like the most time run on the SRL-Stats I think (IIRC))

[email]aarondawg14@yahoo.com[/email]

Overtime

2010-11-23 09:54:54

[QUOTE=Camaro';751466]If you have any questions when you remake the script, you can definitely ask me on msn.
(Squany has like the most time run on the SRL-Stats I think (IIRC))

[email]aarondawg14@yahoo.com[/email][/QUOTE]
I do but im going to be gone for 1 week. So no botting for me :(

I was hoping to level up some combat before i left, but eh oh well. I had to study anyway.

Hopefully next monday all the mess is sorted out.

It's a really nice script, just needs a few tweaks.

TomTuff

2010-11-23 20:03:32

alright, so i'm working with some ideas camaro` has given me. Here's what i have done thus far:
http://pastebin.com/WKnqqTqb
I'm rewriting the entire portion to get to the spiders, redoing the fight loop, and setting it up so that it can do room jumping.

I'll probably work on it more much later tonight.

Camaro'

2010-11-25 13:18:16

From: TomTuff
alright, so i'm working with some ideas camaro` has given me. Here's what i have done thus far:
http://pastebin.com/WKnqqTqb
I'm rewriting the entire portion to get to the spiders, redoing the fight loop, and setting it up so that it can do room jumping.

I'll probably work on it more much later tonight.


Any more progress?

TomTuff

2010-11-25 16:38:23

No, decided not to work on it since SRL is/was down, and it's thanksgiving here today so i'm not gonna stress myself.

TomTuff

2010-11-29 21:29:41

So I'm rewriting this in color (as you may have noticed from various posts/my sig), surely but slowly. I'm probably still going to use reflection for walking. I want to use an enumeration state setup (not sure what to call it, but it detects what to do based on where it is). I could do one of two things for the enumeration getter: InTileBox(), or various color functions. InTileBox works of course, and i can use the variable stored in TUser (Players[CurrentPlayer].Loc = 'vwb'). Potion drinking might not be in the first "REVamped" release, simply because i have a feeling that not many people who use this script will use that feature and i want to get it out there for testing (I WILL add potion drinking, though, as I use them myself for effective cb training).

Any ideas, requests, etc.?

Nikize

2010-11-30 06:20:05

Well, you could add following things, as this is in my opinion the first proper "trainer" in a while:

-If HP low and no more Food - > RUN one level up in the stornghold, then teleport

-For Members you could add support of using seals, this would be perfect for those who dont want to use magic on their accounts ( my pure would definately need this )

-Train for example attack and strength untill certain levels are reached like attack untill 60, then switch to other combat styles like strength, untill the strength level is 80 and train it for the rest of the time

I like where this script is going, i hope you will succeed :)

TomTuff

2010-11-30 09:49:57

From: Nikize
Well, you could add following things, as this is in my opinion the first proper "trainer" in a while:

-If HP low and no more Food - > RUN one level up in the stornghold, then teleport

-For Members you could add support of using seals, this would be perfect for those who dont want to use magic on their accounts ( my pure would definately need this )

-Train for example attack and strength untill certain levels are reached like attack untill 60, then switch to other combat styles like strength, untill the strength level is 80 and train it for the rest of the time

I like where this script is going, i hope you will succeed :)


It wouldn't need to go one level up, just out of the room to the "air lock" formed by the sets of doors.

What are seals? You mean teleport tabs?

And as for the 3rd thing, that shouldn't be too hard to manage.

Thanks for the ideas :)

EDIT:
for anyone curious as to where I'm at, here's what i have thus far:
http://pastebin.com/nTYkqR75

Nikize

2010-12-02 09:11:33

Yeah, i ment teleportation tabs, sorry for being unclear, i wrote my suggestions in a hurry, glad you liked :)

I have began reading guides from the tutorial island again, and i read your script, and liked it. Did you remove the procedure which withdraws/drinks potions? I was curious to read how you wrote that part but couldnt find it in the code.

TomTuff

2010-12-02 10:03:19

From: Nikize
Yeah, i ment teleportation tabs, sorry for being unclear, i wrote my suggestions in a hurry, glad you liked :)

I have began reading guides from the tutorial island again, and i read your script, and liked it. Did you remove the procedure which withdraws/drinks potions? I was curious to read how you wrote that part but couldnt find it in the code.


It's not in the revised edition [yet]. The actual drinking in the reflection edition (the one in the original post) was quite simple, it was just determining which pots to drink/when.

Sorry this is taking so long, i've been up until 2 am every night doing hw… =\

wondersueak

2010-12-04 20:11:10

I'm back! haha

This will be amazing to see in color. I've been waiting for forever for a giant spider killer that banks.

TomTuff

2010-12-04 22:55:21

I've worked on it today some. I would pastebin it, but it's currently on an external HDD (I just reinstalled windows to my new Raid 0 array with two 500 GB HDDs) that i don't have plugged in yet.

TPAs are very, very fun :D

Edit: http://pastebin.com/Dpvkthe5

TomTuff

2010-12-08 22:08:10

Due to time constraints placed upon me by real life, I can't work on this much more (not until winter break). We have 8 furlough days this year in my school district (8 less school days, teachers don't get payed, no one attends school, etc.) so some of my teachers are trying to cram in these last 2 weeks before winter break with as much work as possible. I'm going to post the code if anyone wants to work on this. The banking procedure could be refined a bit, it still needs a proggy, and nothing having to do with the spiders themselves has been complete. However, if i may say so myself, all the other procedures are quite nice :D

here's the code, do as you wish:

program GiantSpiderKiller;
{$i SRL\SRL.scar}
{$i SRL\SRL\misc\debug.scar}


const
DebugTPAs = True; //Show TPA Debugging? *NOTE*: must check the box under View -> Debug Image!!


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

with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Pin := '';
Active := true;
Strings[0] := ''; //food
end;
end;


const
BSX1 = 26;
BSY1 = 85;
BSX2 = 478;
BSY2 = 290;


function CP: Byte;
begin
Result := CurrentPlayer;
end;


procedure Die(Reason: string);
begin
if FindNormalRandoms then
Exit;
Writeln('logging out player ' + Players[CP].Nick + ' because ' + Reason);
if BankScreen then
WaitFunc(@CloseBank, 10 + Random(25), 2000);
Logout;
Players[CP].Active := False;
end;


function LoadAttackTypes: TStringArray; //xs,ys,xe,ye's need to be redone.
var
T: Integer;
begin
if not LoggedIn then
Exit;
SetLength(Result, 4);
GameTab(tab_Combat);

MMouse(602, 273, 20, 20);
MarkTime(T);
repeat
Wait(10 + Random(15));
until(CountColorTolerance(10551295, 610, 326, 620, 336, 4) > 40) or (TimeFromMark(T) > 3000);
if FindTextTpa(0, 4, 570, 336, 640, 352, 'ttack', 'StatChars', Nothing) then
Result[0] := 'attack';
if FindTextTpa(0, 4, 570, 336, 640, 352, 'rength', 'StatChars', Nothing) then
Result[0] := 'strength';
if FindTextTpa(0, 4, 570, 336, 640, 352, 'fenc', 'StatChars', Nothing) then
Result[0] := 'defence';
if FindTextTpa(0, 4, 570, 336, 640, 352, 'hared', 'StatChars', Nothing) then
Result[0] := 'shared';
Wait(600 + Random(60));

MMouse(685, 273, 20, 20);
MarkTime(T);
repeat
Wait(10 + Random(15));
until(CountColorTolerance(10551295, 695, 320, 705, 330, 4) > 40) or (TimeFromMark(T) > 3000);
if FindTextTpa(0, 4, 520, 434, 598, 450, 'ttack', 'StatChars', Nothing) then
Result[1] := 'attack';
if FindTextTpa(0, 4, 520, 434, 598, 450, 'rength', 'StatChars', Nothing) then
Result[1] := 'strength';
if FindTextTpa(0, 4, 520, 434, 598, 450, 'fenc', 'StatChars', Nothing) then
Result[1] := 'defence';
if FindTextTpa(0, 4, 520, 434, 598, 450, 'hared', 'StatChars', Nothing) then
Result[1] := 'shared';
Wait(600 + Random(60));

MMouse(574, 311, 30, 50);
MarkTime(T);
repeat
Wait(10 + Random(15));
until(CountColorTolerance(10551295, 605, 375, 615, 385, 4) > 40) or (TimeFromMark(T) > 3000);
if FindTextTpa(0, 4, 570, 385, 643, 404, 'ttack', 'StatChars', Nothing) then
Result[2] := 'attack';
if FindTextTpa(0, 4, 570, 385, 643, 404, 'rength', 'StatChars', Nothing) then
Result[2] := 'strength';
if FindTextTpa(0, 4, 570, 385, 643, 404, 'fenc', 'StatChars', Nothing) then
Result[2] := 'defence';
if FindTextTpa(0, 4, 570, 385, 643, 404, 'hared', 'StatChars', Nothing) then
Result[2] := 'shared';
Wait(600 + Random(60));

MMouse(657, 310, 30, 40);
MarkTime(T);
repeat
Wait(10 + Random(15));
until(CountColorTolerance(10551295, 695, 370, 705, 380, 4) > 40) or (TimeFromMark(T) > 3000);
if FindTextTpa(0, 4, 652, 388, 595, 502, 'ttack', 'StatChars', Nothing) then
Result[3] := 'attack';
if FindTextTpa(0, 4, 652, 388, 595, 502, 'rength', 'StatChars', Nothing) then
Result[3] := 'strength';
if FindTextTpa(0, 4, 652, 388, 595, 502, 'fenc', 'StatChars', Nothing) then
Result[3] := 'defence';
if FindTextTpa(0, 4, 652, 388, 595, 502, 'hared', 'StatChars', Nothing) then
Result[3] := 'shared';
if (Result[3] = '') then
Result[3] := 'null';
Wait(600 + Random(60));
end;


function WalkToPortal1: Boolean;
begin
Result := RadialWalk(3553595, 120, 135, 30, 1, 1);
end;


function WalkToPortal2: Boolean;
begin
Result := RadialWalk(6065304, 200, 230, 30, 1, 1);
end;


function OpenBanker: Boolean;
var
x, y, i, CTS, h: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
if BankScreen then
Exit;
SetAngle(true);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.1476, 1.6836);
if not FindColorsTolerance(TPA, 3809322, MSX1, MSY1, MSX2, MSY2, 10) then
Exit;
ATPA := TPAtoATPAEx(TPA, 20, 30);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
if DebugTPAs then
DebugATPABounds(ATPA);
H := High(ATPA);
for i := 0 to H do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 3, 5);
if WaitUptext('anker', 600) then
begin
ClickMouse2(False);
WaitOption('ank Ba', 600);
Result := WaitFunc(@BankScreen, 10 + Random(15), 6000);
end;
if Result then
Break;
end;
end;


function WithdrawRunes: Boolean;
var
TPA: TPointArray;
x, y, i, c: Integer;
ATPA: Array of TPointArray;
begin
if not LoggedIn then Exit;
if not BankScreen then
if not Openbanker then
Exit;
if not FindColorsTolerance(TPA, 13882589, BSX1, BSY1, BSX2, BSY2, 3) then
Logout;
if not LoggedIn then
Exit;
ATPA := SplitTPAEx(TPA, 10, 10);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 5, 5);
if WaitUptext('ir run', 600) then
begin
case Random(2) of
0, 2:
begin
repeat
GetMousePos(x, y);
Mouse(x, y, 1, 1, true);
Wait(300 + Random(30));
inc(c);
until(c = 3);
Result := True;
end;
1:
begin
ClickMouse2(False);
if not WaitOption('draw-3', 600) then
begin
MMouse(x, y, 50, 50);
MMouse(x, y, 5, 5);
ClickMouse2(False);
if WaitOption('draw-X', 600) then
begin
Wait(800 + Random(80));
TypeSend('3');
end;
end;
Result := True;
end;
end;
end;
if Result then
Break;
end;
if not FindColorsTolerance(TPA, 14033951, BSX1, BSY1, BSX2, BSY2, 3) then
Logout;
if not LoggedIn then
Exit;
ATPA := SplitTPAEx(TPA, 10, 10);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 5, 5);
if WaitUptext('aw run', 600) then
begin
case Random(2) of
0, 2:
begin
ClickMouse2(True);
Result := True;
end;
1:
begin
ClickMouse2(False);
Result := WaitOption('draw-1', 600);
end;
end;
end;
if Result then
Break;
end;
if not FindColorsTolerance(TPA, 1450140, BSX1, BSY1, BSX2, BSY2, 3) then
Logout;
if not LoggedIn then
Exit;
ATPA := SplitTPAEx(TPA, 10, 10);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 5, 5);
if WaitUptext('re run', 600) then
begin
case Random(2) of
0, 2:
begin
ClickMouse2(True);
Result := True;
end;
1:
begin
ClickMouse2(False);
Result := WaitOption('draw-1', 600);
end;
end;
end;
if Result then
Break;
end;
end;


function WithdrawFood: Boolean;
var
FoodColor, x, y, i: Integer;
FoodUptext: string;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
case lowercase(Players[CP].Strings[0]) of
'monkfish':
begin
FoodColor := 8027295;
FoodUptext := 'kf';
end;
'shark':
begin
FoodColor := 3162454;
FoodUptext := 'har';
end;
'lobster':
begin
FoodColor := 1993428;
FoodUptext := 'obst';
end;
'swordfish':
begin
FoodColor := 8804991;
FoodUptext := 'rdfi';
end;
end;
if not FindColorsTolerance(TPA, FoodColor, BSX1, BSY1, BSX2, BSY2, 2) then
Logout;
if not loggedIn then
Exit;
ATPA := SplitTPAEx(TPA, 10, 10);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 3, 3);
if WaitUptext(FoodUptext, 600) then
begin
ClickMouse2(False);
Result := WaitOption('draw-All', 600);
end;
if Result then
Exit;
end;
end;


function SpellsSortedByLevel: Boolean;
begin
if not LoggedIn then
Exit;
if not GameTab(TAB_MAGIC) then
logout;
if not LoggedIn then
Exit;
Result := (CountColorTolerance(16711422, 670, 438, 695, 461, 4) > 70);
end;


function SortByLevel: Boolean;
var
x, y, T: Integer; //x and y are just filler for FindTextTpaEx
begin
if not LoggedIn then
Exit;
if not GameTab(tab_Magic) then
Logout;
if not LoggedIn then
Exit;
if SpellsSortedByLevel then
Exit;
MouseBox(677, 444, 689, 458, 3);
MarkTime(T);
repeat
Result := FindTextTpaEx(0, 4, 614, 396, 735, 425, x, y, 'ort by lev', 'StatChars' , nothing);
if Result then
Break;
Wait(10 + Random(15));
until(TimeFromMark(T) >= 2000) or Result;
ClickMouse2(True);
Result := WaitFunc(@SpellsSortedByLevel, 10 + Random(25), 1300);
end;


function ScrolledUp: Boolean; //Tells if the scroll bar on the magic screen is scrolled all the way up
begin
if not LoggedIn then
Exit;
if not GameTab(TAB_MAGIC) then
Logout;
if not LoggedIn then
Exit;
Result := (CountColorTolerance(2041131, 722, 240, 724, 248, 4) < 10);
end;


function ScrollUp: Boolean;
var x, y: Integer;
begin
if not LoggedIn then
Exit;
if not GameTab(tab_Magic) then
Logout;
if not LoggedIn or ScrolledUp then
Exit;
MouseBox(723, 210, 731, 220, 3);
GetMousePos(x, y);
HoldMouse(x, y, mouse_Left);
repeat Wait(10 + Random(15)) until WaitFunc(@ScrolledUp, 10 + Random(25), 2000);
ReleaseMouse(x, y, mouse_Left);
Result := ScrolledUp;
end;


function TeleportToVarrock: Boolean;
var
x, y, i: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
if not GameTab(TAB_MAGIC) then
Logout;
if not LoggedIn then
Exit;
if not SpellsSortedByLevel then
if not SortByLevel then
Logout;
if not ScrolledUp then
if not ScrollUp then
Logout;
if not FindColorsTolerance(TPA, 7221328, MIX1, MIY1, MIX2, MIY2, 4) then
Logout;
if not LoggedIn then
Exit;
ATPA := SplitTPAEx(TPA, 19, 19);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 3, 3);
if WaitUpText('rock', 800) then
begin
ClickMouse2(True);
Result := True;//need better method here; no crosshairs after clicking teleport
end;
if Result then
Break;
end;
end;


function WarnScreen: Boolean;
begin
Result := FindTextTPA(2070783, 3, 233, 44, 302, 66, 'rning', 'UpChars', Nothing);
end;


function AbleToDisable: Boolean; //checks if you can tell it not to warn you about entering dungeons again
begin
Result := FindTextTPA(2070783, 3, 199, 222, 338, 243, 'on''t ask me this again', 'SmallChars', Nothing);
end;


function BoxChecked: Boolean;
begin
if not LoggedIn then
Exit;
Result := (CountColorTolerance(1052924, 111, 222, 132, 241, 4) > 9);
end;


function CheckDisableBox: Boolean;
var
TPA: TPointArray;
x, y: Integer;
begin
if not LoggedIn or not WarnScreen or not AbleToDisable or BoxChecked then
Logout;
if not LoggedIn then
Exit;
if not FindColorsTolerance(TPA, 4414313, 110, 222, 131, 243, 4) then
Logout;
if not LoggedIn then
Exit;
MiddleTPAEx(TPA, x, y);
MMouse(x, y, 3, 3);
if WaitUptext('ff', 660) then
begin
ClickMouse2(True);
Result := WaitFunc(@BoxChecked, 10 + Random(25), 4000);
end else
Result := False;
end;


function ExitWarnScreen: Boolean;
var
x, y: Integer;
TPA: TPointArray;
begin
if not LoggedIn or not WarnScreen then
Exit;
if not FindColorsTolerance(TPA, 1383457, 405, 43, 429, 66, 4) then
Logout;
if not LoggedIn then
Exit;
MiddleTPAEx(TPA, x, y);
MMouse(x, y, 3, 3);
if WaitUptext('lose', 660) then
begin
ClickMouse2(True);
Result := True;
end else
Result := False;
end;


function HandleWarnScreen: Boolean;
begin
if WarnScreen then
begin
if AbleToDisable then
begin
CheckDisableBox;
WaitFunc(@BoxChecked, 10 + Random(15), 8000);
end;
ExitWarnScreen;
end;
Result := not(WarnScreen);
end;


function EnteredFirstFloor: Boolean;
begin
if not LoggedIn then
Exit;
MakeCompass('n');
SetAngle(true);
Result := (CountColorTolerance(4144962, 254, 213, 264, 220, 12) > 50);
end;


function EnterEntrance: Boolean;
var
x, y, i, CTS, H: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.0084, 0.0817);
if not FindColorsTolerance(TPA, 6650498, MSX1, MSY1, MSX2, MSY2, 20) then
Logout;
ColorToleranceSpeed(CTS);
if not LoggedIn then
Exit;
ATPA := TPAtoATPAEx(TPA, 50, 50);
if DebugTPAs then
DebugATPABounds(ATPA);
H := High(ATPA)
for i := 0 to H do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 3, 3);
if WaitUpText('down', 600) then
begin
case Random(2) of
0, 2:
begin
ClickMouse2(True);
Result := True;
end;
1:
begin
ClickMouse2(False);
Result := WaitOption('imb-down', 600);
end;
end;
end;
if Result then
Break;
end;
Result := WaitFunc(@EnteredFirstFloor, 10 + Random(15), 12000);
end;


function EnteredPortal1: Boolean; //EnteredPortal1/EnteredPortal2 are ~seperate~ for ease of use in WaitFunc
begin
if not LoggedIn then
Exit;
MakeCompass('n');
SetAngle(True);
Result := (CountColorTolerance(5592921, 248, 195, 266, 209, 5) > 50);
end;


function EnteredPortal2: Boolean; //EnteredPortal1/EnteredPortal2 are ~seperate~ for ease of use in WaitFunc
begin
if not LoggedIn then
Exit;
MakeCompass('n');
SetAngle(True);
Result := (CountColorTolerance(6465968, 248, 195, 266, 209, 5) > 50);
end;


function EnterPortal(which: Integer): Boolean;
var
x, y, i, c, PortalColor, CTS: Integer;
Hue, Sat: Extended;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
case which of
1:
begin
PortalColor := 7639186;
Hue := 0.0215;
Sat := 1.0040;
end;
2:
begin
PortalColor := 10409947;
Hue := 0.0806;
Sat := 0.9318;
end;
end;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Hue, Sat);
repeat
Result := FindColorsTolerance(TPA, PortalColor, MSX1, MSY1, MSX2, MSY2, 10);
if Result then
Break;
Wait(200 + Random(20));
inc(c);
until(C >= 6);
ColorToleranceSpeed(CTS);
if not Result then
Logout;
if not LoggedIn then
Exit;
ATPA := TPAtoATPAEx(TPA, 40, 50);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
if DebugTPAs then
DebugATPABounds(ATPA);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 4, 4);
if WaitUpText('nter', 600) then
begin
case Random(2) of
0, 2:
begin
ClickMouse2(True);
Result := True;
end;
1:
begin
ClickMouse2(False);
Result := WaitOption('nter', 600);
end;
end;
end;
if Result then
Break;
end;
case Which of
1: Result := WaitFunc(@EnteredPortal1, 10 + Random(15), 6000);
2: Result := WaitFunc(@EnteredPortal2, 10 + Random(15), 6000);
end;
end;


function EnteredSecondFloor: Boolean;
begin
if not LoggedIn then
Exit;
MakeCompass('n');
SetAngle(True);
Result := (CountColorTolerance(5408917, 248, 195, 266, 209, 5) > 30);
end;


function EnteredThirdFloor: Boolean;
begin
if not LoggedIn then
Exit;
MakeCompass('n');
SetAngle(True);
Result := (CountColorTolerance(2655335, 282, 157, 306, 174, 1) > 80);
end;


function GoDownLadder1: Boolean;
var
x, y, i, H: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
if not FindColorsTolerance(TPA, 3552824, MSX1, MSY1, MSX2, MSY2, 10) then
Exit;
ATPA := TPAToATPAEx(TPA, 40, 40);
//DebugATPA(ATPA, '');
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
//DebugATPABounds(ATPA);
H := High(ATPA);
for i := 0 to H do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 3, 3);
if WaitUptext('limb-down', 600) then
begin
case Random(6) of
1, 3, 5:
begin
ClickMouse2(True);
Result := True;
end;
0, 2, 4, 6:
begin
ClickMouse2(False);
Result := WaitOption('limb-down', 600);
end;
end;
end;
if Result then
Break;
end;
if not Result then
Logout;
Result := WaitFunc(@EnteredSecondFloor, 10 + random(15), 6000);
end;


function GoDownLadder2: Boolean;
var
x, y, i, H: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
if not FindColorsTolerance(TPA, 4818341, MSX1, MSY1, MSX2, MSY2, 10) then
Exit;
ATPA := TPAToATPAEx(TPA, 40, 40);
//DebugATPA(ATPA, '');
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
if DebugTPAs then
DebugATPABounds(ATPA);
H := High(ATPA);
for i := 0 to H do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 3, 3);
if WaitUptext('limb-down', 600) then
begin
case Random(6) of
1, 3, 5:
begin
ClickMouse2(True);
Result := True;
end;
0, 2, 4, 6:
begin
ClickMouse2(False);
Result := WaitOption('limb-down', 600);
end;
end;
end;
if Result then
Break;
end;
if not Result then
Logout;
Result := WaitFunc(@EnteredThirdFloor, 10 + random(15), 6000);
end;


function WalkToLadder1: Boolean;
var
TPA: TPointArray;
x, y: Integer;
begin
if not LoggedIn then
Exit;
MakeCompass('n');
Result := FindColorsTolerance(TPA, 340312, 569, 77, 587, 98, 6);
if not Result then
Logout;
if not LoggedIn then
Exit;
MiddleTPAEx(TPA, x, y);
Mouse(x, y, 3, 3, true);
FFlag(0);
end;


function WalkToLadder2: Boolean;
var
TPA: TPointArray;
x, y: Integer;
begin
if not LoggedIn then
Exit;
MakeCompass('n');
Result := FindColorsTolerance(TPA, 797789, 641, 100, 655, 115, 45);
DebugTPA(TPA, '');
if not Result then
Logout;
if not LoggedIn then
Exit;
MiddleTPAEx(TPA, x, y);
Mouse(x, y, 3, 3, true);
FFlag(0);
end;


function EatFood: Boolean;
var i: Integer;
begin
for i := 4 to 28 do
begin
if ExistsItem(i) then
MouseItem(i, false);
if WaitUptext('Eat', 600) then
begin
ClickMouse2(True);
Result := True;
end;
if Result then
Break;
end;
end;


function OpenDoor: Boolean;
var
x, y, H, i, CTS: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
MakeCompass('s');
SetAngle(True);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(1.2313, 8.6071);
Result := FindColorsTolerance(TPA, 1533821, MSX1, MSY1, MSX2, 200, 5);
ColorToleranceSpeed(CTS);
if not Result then
Logout;
if not(LoggedIn) then
Exit;
ATPA := TPAtoATPAEx(TPA, 40, 40);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
if DebugTPAs then
//DebugATPABounds(ATPA);
DebugATPABounds(ATPA);
H := High(ATPA);
for i := 0 to H do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 3, 3);
if WaitUptext('ozing barr', 600) then
begin
ClickMouse2(False);
Result := WaitOption('pen', 600);
end else
Result := False;
if Result then
Break;
end;
end;


begin
SetupSRL;
DeclarePlayers;
ActivateClient;
LoginPlayer;
OpenDoor;
end.