Inspirations
2010-10-12 16:34:41
How Long have You Played Runescape?
3 Year(s)
Are you affilated in anyway with Jagex LTD?
No
Were you Referred to SRL?
N/A
What is your general programming knowledge?
I have a basic knowledge of Java
Are you a member of any other communities?
I have an account at RSBot, but I am not active there
Tell us about yourself…
Please show us one (or multiple) of your scripts.
3 Year(s)
Are you affilated in anyway with Jagex LTD?
No
Were you Referred to SRL?
N/A
What is your general programming knowledge?
I have a basic knowledge of Java
Are you a member of any other communities?
I have an account at RSBot, but I am not active there
Tell us about yourself…
From: Inspirations
Hi, my name is Steven Wright, I am 18 years old (almost 19) in college, with lots of free time. I stumbled upon Villavu after getting back into runescape and found scripting for Simba was quite enjoyable. I am majoring in Political Science and minoring in History, although I wish I could take a computer class or two :/
Um I think that's all there is, feel free to ask me questions I'll try to get on IRC more often again, I haven't been there in a while.
Please show us one (or multiple) of your scripts.
{
My script is "completed" in the sense that it runs and compiles,
however not all fish types have been tested,
neither have I really had the ability to run the script for a long period of time.
I hope to release it to the public in the near future.
Also Credit it due to Blumblebee, I never took any functions specifically but the overall script idea and make I followed.
}
program Al_Kharid;
{$i SRL/SRL.scar}
{$i SRL/SRL/Misc/Debug.scar}
type
TItemInfo = Record
ColorList: TIntegerArray;
BlackCount: Integer;
end;
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);
with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Strings[0] := 'Trout';
BoxRewards := ['mote', 'ostume', 'XP', 'Gem', 'ithril', 'oal'];
Active := True;
end;
end;
var
GlobalCount: Integer;
GlobalColor: Integer;
GlobalIndex: Integer;
const
{MM Colors}
BorderOutline = 16316401;
CactusColor = 3829071;
KebabSymbol = 2698232;
BankerColor = 195836;
{MS Colors}
RangeColor = 1647797;
BankBoothColor = 3751490;
BankBottomColor = 10932726;
{MI Colors}
BlackColor = 131072;
{MC Colors}
RedText = 128;
procedure SetGlobalColor;
begin
case lowercase(Players[CurrentPlayer].Strings[0]) of
'shrimp':
begin
GlobalColor := 7043476;
GlobalCount := 141;
end;
'sardine':
begin
GlobalColor := 6536803;
GlobalCount := 44;
end;
'herring':
begin
GlobalColor := 11315895;
GlobalCount := 71;
end;
'anchovies':
begin
GlobalColor := 9004904;
GlobalCount := 141;
end;
'trout':
begin
GlobalColor := 11381429;
GlobalCount := 77;
end;
'salmon':
begin
GlobalColor := 5925813;
GlobalCount := 77;
end;
'tuna':
begin
GlobalColor := 11382461;
GlobalCount := 82;
end;
'lobster':
begin
GlobalColor := 1589627;
GlobalCount := 119;
end;
'swordfish':
begin
GlobalColor := 11891117;
GlobalCount := 77;
end;
end;
end;
function FindCactus: TPoint;
var
ATPA: T2DPointArray;
TPA: TPointArray;
t, tolerance: Integer;
begin
t := getsystemtime;
while Length(TPA) <= 0 do
begin
FindColorsTolerance(TPA, CactusColor, MMx1, MMy1, MMx2, MMy2, 8+tolerance);
if getsystemtime-t > 2500 then
Exit;
inc(tolerance);
end;
ATPA := SplitTPAex(TPA, 15, 15);
writeLn('Found '+IntToStr(Length(ATPA))+' instances of cacti');
sortATPAFrom(ATPA, point(MMcx-25, MMy1));
Result := MiddleTPA(ATPA[0]);
end;
function LocateRoom: TBox;
var
TP: TPoint;
tempColor, I: Integer;
begin
TP := FindCactus;
if TP = point(-1, -1) then
Exit;
for I := 0 to 50 do
begin
tempColor := GetColor(TP.x+I, TP.y);
if SimilarColors(tempColor, BorderOutline, 25) then
begin
writeLn('Found Wall at: point('+IntToStr(TP.x+I)+', '+IntToStr(TP.y)+')');
Result.x1 := TP.x+(I+5);
Result.y1 := TP.y+2;
Result.x2 := TP.x+(I+8);
Result.y2 := TP.y+6;
Exit;
end;
end;
WriteLn('Did not find wall. Resorting to different location method');
end;
function WalkToCookingArea: Boolean;
var
TB: TBox;
begin
TB := LocateRoom;
if TB.x1 = 0 then
Exit;
MouseBox(TB.x1+7, TB.y1, TB.x2, TB.y2, 1);
wait(500+Random(250));
if FlagPresent then
begin
Result := True;
Flag;
Exit;
end;
end;
function WalkToBankingArea: Boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
TP: TPoint;
begin
FindColorsTolerance(TPA, BankerColor, MMx1, MMcy, MMcx, MMy2, 8);
if Length(TPA) <= 0 then
Exit;
ATPA := SplitTPAex(TPA, 5, 10);
sortATPAFrom(ATPA, point(611, 139));
TP := MiddleTPA(ATPA[0]);
Mouse(TP.x+5, TP.y, 5, 5, true);
wait(250+random(500));
if FlagPresent then
begin
result := true;
FFlag(15);
while IsMoving do
wait(100+random(250));
Exit;
end;
end;
function FindRange: Boolean;
var
ATPA: T2DPointArray;
TPA: TPointArray;
T, P, TP: TPoint;
I, tol: Integer;
x, y: Integer;
begin
while IsMoving do
wait(250+random(150));
while Length(TPA) <= 0 do
begin
if Tol > 20 then
begin
FindNormalRandoms;
Exit;
end;
FindColorsTolerance(TPA, RangeColor, MSx1, MSy1, MSx2, MSy2, Tol+8);
Tol := Tol+1;
end;
ATPA := SplitTPAEx(TPA, 25, 25);
SortATPAFrom(ATPA, Point(MScx-50, MScy));
T := MiddleTPA(ATPA[0]);
SortATPASize(ATPA, true);
P := MiddleTPA(ATPA[0]);
if T = P then
begin
writeLn('100% Instance Match. Both Points match');
TP := T
end else
begin
writeLn('Did not get a match. Guessing Points...');
TP := P;
end;
MMouse(TP.x, TP.y, 5, 5);
if waitUpText('ang', 500) then
begin
Result := True;
getMousePos(x, y);
Mouse(x, y, 0, 0, random(5) <> 1);
waitOption('aw', 500);
Exit;
end;
for I := 0 to high(ATPA) do
begin
TP := MiddleTPA(ATPA[I]);
MMouse(TP.x, TP.y, 5, 5);
if waitUpText('ang', 500) then
begin
Result := True;
Mouse(x, y, 0, 0, random(5) <> 1);
waitOption('aw', 500);
Exit;
end;
end;
end;
function CollectItemVariables(I: Integer): TItemInfo;
var
TPA: TPointArray;
Slot: TBox;
begin
if ExistsItem(I) then
begin
Slot := InvBox(I);
with Result do
begin
FindColorsTolerance(TPA, 0, Slot.x1, Slot.y1, Slot.x2, Slot.y2, 422);
ColorList := GetColors(TPA);
ClearSameIntegers(ColorList);
SetArrayLength(TPA, 0);
BlackCount := CountColorTolerance(BlackColor, Slot.x1, Slot.y1, Slot.x2,
Slot.y2, 2);
end;
end;
end;
function WatchItem(ItemCompared: TItemInfo): boolean;
var
CurrentItem: TItemInfo;
I, II, saved: Integer;
Percentage: Extended;
Positive, count: Integer;
timer: Integer;
begin
timer := getSystemtime;
repeat
wait(150+random(250));
for I := 28 downto 1 do
begin
if ExistsItem(I) then
begin
CurrentItem := CollectItemVariables(I);
Break;
end;
end;
if Length(ItemCompared.ColorList) = Length(CurrentItem.ColorList) then
continue;
for I := 0 to high(CurrentItem.ColorList) do
begin
for II := 0 to high(ItemCompared.ColorList) do
begin
if CurrentItem.ColorList[I] = ItemCompared.ColorList[II] then
begin
Positive := Positive+1;
break;
end;
end;
end;
Percentage := ((Positive*100)/Length(CurrentItem.ColorList));
Positive := 0;
count := count+1;
if (Length(CurrentItem.ColorList) <> saved) or (count mod 10 = 0) then
begin
ClearDebug;
saved := Length(CurrentItem.ColorList);
writeLn('Old Length | New Length');
writeLn('-----------------------');
writeLn(' '+IntToStr(Length(ItemCompared.ColorList))+padr(' ', 7)+'| '+
IntToStr(Length(CurrentItem.ColorList)));
writeLn('-----------------------');
writeLn('Positive matches = '+IntToStr(Positive));
WriteLn('Colors match '+IntToStr(Round(Percentage))+'%');
end;
if Percentage > 75 then
continue
else
break;
if getsystemtime-timer > 120000+(random(50000)) then
break;
until False;
result := true;
end;
function OpenBankBooth: Boolean;
var
ATPA: T2DPointArray;
TPA: TPointArray;
TP: TPoint;
H, I: Integer;
x, y: Integer;
begin
if BankScreen then
begin
result := true;
Exit;
end;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MScx-25, MMcy, TPA, BankBoothColor, MSx1, MSy1, MSx2, MSy2, 10);
ColorToleranceSpeed(1);
if Length(TPA) <= 0 then
Exit;
ATPA := FloodFillTPA(TPA);
SortATPAFrom(ATPA, point(MScx-15, MScy));
// DebugATPA(ATPA, '');
if High(ATPA) < 3 then
H := High(ATPA)
else
H := 3;
for I := 0 to H do
begin
TP := MiddleTPA(ATPA[I]);
MMouse(TP.x, TP.y, 5, 5);
if waitUpTextMulti(['ooth', 'ank'], 500) then
begin
getMousePos(x, y);
Mouse(x, y, 0, 0, false);
Result := waitOption('ick', 500);
Exit;
end;
end;
end;
function WithdrawBank: Boolean;
var
TPA: TPointArray;
Area: TBox;
I, L, II: Integer;
Index: TIntegerArray;
BlackCount: Integer;
TP: TPoint;
x, y: Integer;
begin
for I := 1 to 25 do
begin
SetArrayLength(TPA, 0);
Area := BankIndexToMSBox(I);
BlackCount := CountColor(BlackColor, Area.x1, Area.y1+5, Area.x2,
Area.y2);
writeLn('Slot['+IntToStr(I)+']: BlackCount = '+IntToStr(BlackCount));
if InRange(BlackCount, GlobalCount-10, GlobalCount+10) then
begin
L := GetArrayLength(Index);
SetArrayLength(Index, L+1);
Index[L] := I;
end;
end;
writeLn('Length Index = '+IntToStr(Length(Index)));
if Length(Index) = 0 then
Exit;
for II := 0 to high(Index) do
begin
if GlobalIndex <> 0 then
if Index[II] <> GlobalIndex then
continue;
Area := BankIndexToMSBox(Index[II]);
FindColorsTolerance(TPA, GlobalColor, Area.x1, Area.y1, Area.x2, Area.y2, 5);
if Length(TPA) > 0 then
begin
TP := BankIndexToMSPoint(Index[II]);
MMouse(TP.x+5, TP.y+10, 5, 5);
getMousePos(x, y);
if waitUpTextMulti(['aw', 'Raw', 'awr'], 500) then
begin
writeLn('Found '+Capitalize(Players[CurrentPlayer].Strings[0])+
' at Bank Index '+IntToStr(Index[II]));
Mouse(x, y, 0, 0, false);
result := WaitOption('All', 500);
if result then
Exit;
end;
end;
end;
end;
function ClickItem: Boolean;
var
I: Integer;
begin
for I := 1 to 28 do
begin
if ExistsItem(I) then
begin
InvMouse(I, 1);
Result := True;
Exit;
end;
end;
end;
function SelectCook: Boolean;
var
Count: Integer;
t: Integer;
begin
t := getsystemtime;
repeat
Count := CountColor(RedText, MCx1, MCy1, MCx2, MCy2);
if InRange(Count, 750, 850) then
begin
Result := True;
Exit;
end;
until getsystemtime-t > 10000;
end;
function CookAll: Boolean;
begin
Mouse(MCcx, MCcy, 15, 15, false);
result := WaitOption('All', 750);
end;
var
t: Integer;
FirstSlot: TItemInfo;
begin
SetUpSRL;
DeclarePlayers;
ActivateClient;
repeat
if not LoggedIn then
LogInPlayer;
SetGlobalColor;
SetAngle(True);
SetRun(True);
repeat
if not OpenBankBooth then
begin
writeLn('Could not open Bank, NextPlayer');
NextPlayer(False);
Break;
end;
t := GetSystemTime;
while GetSystemTime-t < 5000 do
begin
if BankScreen then
Break;
FindNormalRandoms;
Wait(random(500));
end;
Wait(300+Random(250));
Deposit(1, 28, True);
if not WithdrawBank then
begin
writeLn('Failed to withdraw items, NextPlayer');
NextPlayer(False);
Break;
end;
if not WalkToCookingArea then
begin
writeLn('Walking to Cooking Area Failed. NextPlayer');
NextPlayer(False);
Break;
end;
FirstSlot := CollectItemVariables(1);
t := getsystemtime;
if ClickItem then
begin
if not FindRange then
begin
writeLn('Could not find Range, NextPlayer');
NextPlayer(False);
Break;
end;
while not SelectCook do
begin
wait(random(250));
FindNormalRandoms;
if getsystemtime-t > 5000 then
Exit;
end;
CookAll;
WatchItem(FirstSlot);
if not WalkToBankingArea then
begin
writeLn('Could not walk to Bank, NextPlayer');
NextPlayer(False);
break;
end;
end;
until Players[CurrentPlayer].Active = False;
until AllPlayersInactive;
end.
