Home
2011-03-19 14:33:30
Hello as some of you knows my GuildRanger, for myself it works just fine but for many people it just stops.. Terminates itself.. I have no idea how is that possible. I don't Exit MainLoop at any moment (At least that's what i think) Please help..
And tell me if there is some stupid mistakes or anything!
Big thanks!
~Home
And tell me if there is some stupid mistakes or anything!
program Mining_Guild_Ranger;
{$I srl/srl/misc/smart.scar}
{$I srl/srl.scar}
{$I Reflection/Reflection.simba}
{ No Need To Touch }
const
TARGET_ID = 2513;
COMPETITION_JUDGE_ID = 693;
COINS_ID = 995;
ARCHERY_TICKET_ID = 1463;
B_ARROWS_ID = 882;
LADDER_UP_ID = 2511;
LADDER_DOWN_ID = 2512;
Ver = '0.5';
{ Proggress Report Variables }
var
TempXP, Sst: Integer;
{ Fill These ! }
procedure DeclarePlayers;
begin
HowManyPlayers := 1; //How many players in the script.
CurrentPlayer := 0; //Current player in the Players array.
NumberOfPlayers(HowManyPlayers); //Don't change.
with Players[0] do
begin
Name := ''; {Player Username}
Pass := ''; {Player Password}
Integers[1] := 50; {Min Wait Time Before Clicking Target Again?}
Integers[2] := 150; {Max Wait Time Before Clicking Target Again?}
Integers[3] := 13; {MouseSpeed? + Random 2 Added.}
Active := True; {Use This Player?}
end;
end;
procedure SpamMouse(var x, y: Integer; Rx, Ry: Integer; Time: Integer);
begin
HoldMouse(x, y, mouse_left);
Wait(Round(Time / 2));
ReleaseMouse(x, y, mouse_left);
Wait(Time);
end;
function GetCoins: Integer;
var
Item: TInvItem;
begin
if not R_LoggedIn then Exit;
if (R_ItemExists(COINS_ID, Item)) then
Result := Item.Stacksize;
end;
function EnoughCoins: Boolean;
begin
if not R_LoggedIn then Exit;
Result := GetCoins > RandomRange(600, 1200);
end;
function R_ClickWield(TheVar: Integer): boolean;
var
item: TInvItem;
begin
if not R_LoggedIn then Exit;
if R_ItemExists(TheVar, Item) then begin
if (Item = NULL_INVITEM) then Exit;
case Random(2) of
0:
begin
MouseItem(Item.Slot, True);
Result := True;
end;
1:
begin
MouseItem(Item.Slot, False);
Result := R_WaitOption('Wield', RandomRange(150, 300));
end;
end;
end;
end;
function ScaryScreen: Boolean;
begin
Result := ValidInterface(564);
end;
function UpdatePos: Boolean;
begin
if not R_LoggedIn then Exit;
R_FindRandoms;
if (not TileOnMM(Point(2671, 3418))) then
Exit;
if (DistanceFrom(Point(2671, 3418)) > 3) then
begin
Result := True;
WalkToTile(Point(2671, 3418), 0, 0);
R_Flag;
end;
end;
function ClimbLadder(ID: Integer; MM: Boolean): Boolean;
var
Ladder: TRSObject;
TP: TPoint;
Counter, x, y: Integer;
begin
Counter := 0;
repeat
if not R_LoggedIn then Exit;
Inc(Counter);
R_FindRandoms;
Result := False;
Ladder := GetObjectByID(ID, OBJECT_TYPE_INTERACTABLE, 15);
if MM then begin
TP := TileToMM(Ladder.RealTile);
Mouse(TP.x, TP.y, 2, 2, True);
R_Flag;
end;
TP := TileToMS(Ladder.RealTile, 0);
MMouse(TP.x, TP.y, 4, 4);
if R_WaitUpTextMulti(['Climb', 'limb', 'Tower'], RandomRange(250, 350))
then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
end;
if (Counter > RandomRange(10, 15)) then begin
LogOut;
Exit;
end;
until (R_WaitOptionMulti(['Climb', 'limb'], RandomRange(200, 350)));
Result := True;
R_Flag;
end;
function InTower: Boolean;
begin
Result := ValidNPC('Tower');
end;
function OutTower: Boolean;
begin
Result := ValidNPC('Armour salesman');
end;
procedure HandleFight;
begin
SetRun(True);
while not WaitFunc(@InTower, 10 + Random(15), 4750) do begin
ClimbLadder(LADDER_UP_ID, True);
if not R_LoggedIn then Exit;
R_FindRandoms;
if WaitFunc(@ScaryScreen, 10 + Random(15), 3750) then
Mouse(261, 169, 10, 3, True);
end;
if InTower then Wait(RandomRange(2500, 5000));
while not WaitFunc(@OutTower, 10 + Random(15), 4750) do begin
ClimbLadder(LADDER_DOWN_ID, False);
if not R_LoggedIn then Exit;
R_FindRandoms;
Wait(RandomRange(250, 550));
UpdatePos;
end;
end;
function BuyTicket: Boolean;
begin
Result := FindNPCText('Pay 200 coins to enter the competition?');
end;
// Modded.
function H_ChooseOptionMultiEx(Texts: TStringArray; TextType: string; Action: fnct_ActionOptions): Boolean;
var
B, OptionBox: TBox;
TPA, TPA1, TPA2, TextTPA: TPointArray;
aTPA: T2DPointArray;
I, H, HH, ii, L: Integer;
Colors, SearchCols: TIntegerArray;
begin
Result := False;
GetClientDimensions(B.X2, B.Y2);
B.X1 := 0;
B.Y1 := 0;
Dec(B.X2);
Dec(B.Y2);
FindColorsTolerance(TPA1, 4343893, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(TPA2, 3950929, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := CombineTPA(TPA1, TPA2);
if Length(TPA) < 10 then
Exit;
B.X2 := 0;
B.Y2 := 0;
aTPA := SplitTPAEx(TPA, 20, 20);
SortATPASize(aTPA, True);
B := GetTPABounds(aTPA[0]);
Colors := [13034990, 4231423, 2070783, 65535, 16776960, 9812166, 16777215];
TextType := LowerCase(TextType);
case TextType of
'action', 'player': SearchCols := [0, 5, 6];
'item': SearchCols := [1, 2];
'npc': SearchCols := [3];
'object': SearchCols := [4];
else
SearchCols := [0, 1, 2, 3, 4, 5, 6];
end;
L := High(SearchCols);
SetLength(aTPA, l + 1);
for i := 0 to l do
FindColorsTolerance(aTPA[I], Colors[SearchCols[I]], B.X1, B.Y1, B.X2, B.Y2, 3);
TPA := MergeATPA(aTPA);
aTPA := SplitTPAEx(TPA, 15, 1);
L := High(aTPA);
H := High(Texts);
SortATPAFromFirstPoint(ATPA, Point(OptionBox.X1, optionbox.y1));
for I := 0 to H do
begin
TextTPA := LoadTextTPA(Texts[i], UpChars, HH);
for ii := 0 to L do
if FindTextTPAInTPA(HH, TextTPA, aTPA[ii], TPA) then
begin
Result := True;
case Action of
ClickLeft: MouseBoxEx(B.x1 + 5, TPA[0].Y, B.x2 - 5, TPA[0].Y + 5, 5, 1);
Move: MouseBoxEx(B.x1 + 5, TPA[0].Y, B.x2 - 5, TPA[0].Y + 5, 5, 3);
Nothing: begin end;
else
srl_warn('ChooseOptionMultiEx', 'ClickRight not a valid click for RS menus!', warn_AllVersions);
end;
Exit;
end;
end;
end;
procedure HandleJudge;
var
a, b, C, TempC: integer;
T: TPoint;
NPCs: TNPC;
begin
if not R_LoggedIn then Exit;
C := 0;
CloseWindow;
UpdatePos;
TempC := GetCoins;
NPCs := GetNULLNPC(COMPETITION_JUDGE_ID);
if not TileOnMS(NPCs.Tile, 0) then
begin
if not TileOnMM(NPCs.Tile) then Exit;
T := TileToMM(NPCs.Tile);
Mouse(T.x, T.y, 2, 2, True);
Flag;
HandleJudge;
end;
T := TileToMS(NPCs.Tile, 0);
Mouse(T.x, T.y - RandomRange(15, 60), 1, 1, False);
wait(RandomRange(450, 550));
if not H_ChooseOptionMultiEx(['Compete', 'ompete'], 'all', ClickLeft) then
begin
if H_ChooseOptionMultiEx(['Competition', 'ompetit'], 'all', Move) then
begin
GetMousePos(a, b);
MMouse(a + 150, b, 1, 1);
ChooseOptionMulti(['Compete', 'ompete']);
Flag;
end;
end;
if WaitFunc(@BuyTicket, 10 + Random(15), 1750) then begin
Mouse(257, 402, 4, 3, True);
while TempC = GetCoins do begin
Inc(C);
Wait(RandomRange(10, 50));
R_FindRandoms;
if (C > 100) then Break;
end;
end;
end;
procedure PlayerStats;
var
NowXP, Wet, Wst, Cst, Srt, Tih, Tim, Tis, Awt, Sec: Integer;
begin
NowXP := R_GetSkillExperience(Skill_Range) - TempXp;
Cst := GetSystemTime;
Srt := (cst - sst) / 1000;
Tih := srt / 3600;
tim := (srt / 60) - tih * 60;
Tis := srt - tim * 60 - tih * 3600;
Awt := wet - wst
Sec := GetTimeRunning div 1000 + 1;
Writeln('+++++++++++++++++++++++++++++++++++++++++++++++++++++++');
Writeln(' Home'#39's Guild Ranger ' + (Ver));
Writeln('+++++++++++++++++++++++++++++++++++++++++++++++++++++++');
writeln('Name : ' + Capitalize(Players[CurrentPlayer].Name));
Writeln('Xp / Hour : ' + IntToStr(Round(3600 * NowXP / Sec)));
Writeln('Xp Gained : ' + IntToStr(NowXP));
Writeln('Worked : ' + inttostr(tih) + ' Hours, ' + inttostr(tim) + ' Mins, ' + inttostr(tis) + ' Secs');
Writeln('Active : ' + BoolToStr(Players[CurrentPlayer].Active));
Writeln('Time : ' + TheTime)
Writeln('-------------------------------------------------------');
end;
procedure ProgressReport;
begin
SRLRandomsReport;
Writeln(' ');
PlayerStats;
end;
// Credits to BobboHobbo for below procedure
procedure PrintOnSmart(TP: TStringArray; Placement: TPoint; Colour, Shadow: integer);
var
mx, my, Pic, I, B, H, TPH, Numb: Integer;
TTP: TPointArray;
Canvas: TCanvas;
begin
SmartSetDebug(True);
GetClientDimensions(mx, my);
Pic := BitmapFromString(mx, my, '');
TPH := High(TP);
for I := 0 to TPH do
begin
TTP := LoadTextTPA(TP[i], SmallChars, H);
for B := 0 to High(TTP) do
begin
Numb := ((I + 1) * 13);
FastSetPixel(Pic, TTP[b].x + 1, TTP[b].y + Numb + 1, Shadow);
FastSetPixel(Pic, TTP[b].x, TTP[b].y + Numb, Colour);
end;
end;
Canvas := TCANVAS.Create;
Canvas.Handle := SmartGetDebugDC;
DrawBitmap(Pic, Canvas, Placement.x, Placement.y);
FreeBitmap(Pic);
end;
// Credits to BobboHobbo for below procedure
procedure DoSmartPrint;
var
NowXP, Wet, Wst, Cst, Srt, Tih, Tim, Tis, Awt, Sec: Integer;
begin
Cst := GetSystemTime;
Srt := (cst - sst) / 1000;
Tih := srt / 3600;
tim := (srt / 60) - tih * 60;
Tis := srt - tim * 60 - tih * 3600;
Awt := wet - wst
Sec := GetTimeRunning div 1000 + 1;
NowXP := R_GetSkillExperience(Skill_Range) - TempXp;
PrintOnSmart([' Home'#39's Guild Ranger ' + Ver], Point(15, 30), 62207, 131072);
PrintOnSmart([
'Name : ' + Capitalize(Players[CurrentPlayer].Name),
'',
'Money : ' + IntToStr(GetCoins),
'',
'Xp / Hour : ' + IntToStr(Round(3600 * NowXP / Sec)),
'',
'Xp Gained : ' + IntToStr(NowXP),
'',
'Worked : ' + inttostr(tih) + ' Hours, ' + inttostr(tim) + ' Mins, ' + inttostr(tis) + ' Secs',
'',
''], Point(20, 60), 1959605, 131072)
end;
function H_InFight: boolean;
var
Me: TMe;
begin
Me := GetMe;
result := Me.InFight;
end;
function FindTarget(var b, a: Integer): Boolean;
var
TP: TPoint;
begin
Result := False;
if not R_LoggedIn then Exit;
if not TileOnMS(Point(2679, 3426), 0) then begin
SetAngle(False);
MakeCompass(45);
R_FindRandoms;
end;
TP := TileToMS(Point(2679, 3426), 0);
MMouse(TP.x - 2, TP.y - 25, 5, 5);
MouseSpeed := RandomRange(3, 4);
if R_WaitUpTextMulti(['Fire', 'Target'], RandomRange(250, 350))
then
begin
Result := True;
GetMousePos(b, a);
end;
end;
procedure FireTarget;
var MouseTemp, CounterX, Counter, C, x, y: Integer;
begin
if not R_LoggedIn then Exit;
MouseTemp := MouseSpeed;
while not FindNPCText('Compet') do begin
if not R_LoggedIn then Exit;
if UpdatePos then Break;
if H_InFight then
HandleFight;
R_FindRandoms;
if FindTarget(x, y) then SpamMouse(x, y, 0, 0, RandomRange(Players[CurrentPlayer].Integers[1], Players[CurrentPlayer].Integers[2]));
CounterX := 0;
Counter := 0;
Wait(10);
if not DidClick(True, 50) then Inc(C)
else
C := 0;
if (C >= RandomRange(2, 3)) then begin
MouseSpeed := MouseTemp;
CloseWindow;
CloseWindow; // FailSafe
end;
end;
MouseSpeed := MouseTemp;
end;
begin
SetScriptProp(SP_OnTerminate, ['ProgressReport']);
Smart_Server := 39;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupReflectionEX(True);
DeclarePlayers;
if not LoggedIn then LoginPlayer;
SetAngle(False);
MakeCompass(45);
TempXP := R_GetSkillExperience(Skill_Range);
Sst := GetSystemTime;
repeat
ClearDebug;
MouseSpeed := Players[CurrentPlayer].Integers[3] + Random(2);
if EnoughCoins then HandleJudge else LogOut;
R_ClickWield(B_ARROWS_ID);
FireTarget;
DoSmartPrint;
until (not R_LoggedIn);
end.Big thanks!
~Home