SRL Archive - OSR Help

Banking withdrawing problem!


Wreck

2012-05-17 18:35:00

Refering to this script:
http://villavu.com/forum/showthread.php?t=82591

The only thing failing me right now is sometimes when trying to find iron ore to withdraw it goes mental and begins hovering over it in different spots a million times a second and never ends up withdrawing anything and I cant figure out why, this doesnt happen every time mind you I got it to run for over a thousand casts earlier no problem and then it messed up. I suspect its the IsUpText that is failing.

So what im wondering is if someone could either have a look and see if theres something ive done wrong or tell me a better way to do this?

Thanks!

Edit: Forgot to mention that the same DTM works 100% of the time when clicking the item in inventory it just screws up while trying to withdraw from bank!

John

2012-05-17 19:34:33

Here's the script if your to lazy to go to the link :p
program Superheater;
//{$DEFINE SMART}
{$i SRL/SRL.simba}
{$i SRL/SRL/SKILL/Magic.simba}

//{$IFDEF SMART}
// {$i srl/srl/mis/paintsmart.simba}
//{$ENDIF}

//MIX1, MIY1, MIX2, MIY2 - main inventory coords
//MSX1, MSY1, MSX2, MSY2 - main screen coords
//MSCX, MSCY - main screen center coords

var
XPPerHour, LevelsGained, SuperheatsPerHour, SuperheatsDone, AntiBansDone, InvOre, InvBars :Integer;

//~~~~~~~~~~~~~~~~~~~~~~~~~~
//~ ---=< Setup >=---
//~~~~~~~~~~~~~~~~~~~~~~~~~~

const
VERSION = '0.3';
SUPERHEATSTODO = 500;

SRLStats_User = '';
SRLStats_Password = '';

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

Players[0].Name := ''; //Account Name
Players[0].Pass := ''; //Account Password
Players[0].Nick := ''; //Account Nickname
Players[0].Active:= True;
Players[0].Pin := ''; //Blank if no pin
end;

//~~~~~~~~~~~~~~~~~~~~~~~~~~
//~ ---=< Setup End >=---
//~~~~~~~~~~~~~~~~~~~~~~~~~~

procedure OnStart;
begin
ClearDebug;
Writeln('~~~~~~~~~~~~~~~~~');
Writeln(' Superheater');
Writeln(' Version: '+ version);
Writeln(' Author: Wreck');
Writeln('~~~~~~~~~~~~~~~~~');
Writeln('');
MakeCompass('W');
SetAngle(SRL_ANGLE_HIGH);
end;

procedure OnFinish;
var
MagicXP :Integer;
begin
MagicXP := SuperheatsDone * 53;
XPPerHour := Round((MagicXP * 3600) / (GetTimeRunning / 1000));
SuperheatsPerHour := Round((SuperheatsDone * 3600) / (GetTimeRunning / 1000));
Writeln('');
Writeln('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
Writeln(' Thank you for using Superheater');
Writeln(' Version '+ version);
Writeln(' Author: Wreck');
Writeln('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
Writeln('Time Running: ' + TimeRunning);
Writeln('AntiBans Done: ' + IntToStr(Antibansdone));
Writeln('');
Writeln('Levels Gained: ' + IntToStr(LevelsGained));
Writeln('Superheats Done: ' + IntToStr(SuperheatsDone));
Writeln('Superheats/Hour: ' + IntToStr(SuperheatsPerHour));
Writeln('Magic XP Gained: ' + IntToStr(MagicXP));
Writeln('Magic XP/Hour: ' + IntToStr(XPPerHour));
Writeln('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
Logout;
end;

procedure AntiBan;
begin
case random(400) of
1: Begin HoverSkill('magic', False); AntiBansDone := AntiBansDone + 1; End;
2: Begin HoverSkill('random', False); AntiBansDone := AntiBansDone + 1; End;
3: Begin Boredhuman; AntiBansDone := AntiBansDone + 1; End;
4: Begin Wait(2500 + random(4500)); AntiBansDone := AntiBansDone + 1; End;
5: Begin HoverSkill('smithing', False); AntiBansDone := AntiBansDone + 1; End;
6: Begin PickUpMouse; AntiBansDone := AntiBansDone + 1; End;
7: Begin RandomMovement; AntiBansDone := AntiBansDone + 1; End;
8: Begin RandomRClick; AntiBansDone := AntiBansDone + 1; End;
end;

end;

//~~~~~~~~~~~~~~~~~~~~~~~~~~
//~ ---=< Nitty Gritty >=---
//~~~~~~~~~~~~~~~~~~~~~~~~~~

procedure Count;
var
IronOreDTM, IronBarDTM:Integer;
begin
IronOreDTM := DTMFromString('mKgEAAHicncxJCoAwEETRjkoIiEZdOOB4CO9/Nn+wNi5Nwds0Vd2aWURACYdatw4LVsyy4cKuTdTOY8KIAT0a/QpS2Zv7TM3it8Py4jJ98wAHJwJd');
IronBarDTM := DTMFromString('m1gAAAHic42JgYOADYnYgZmSAAEkgFgBiLiAWAWJZIJYCYlYgZoKq54RiISAWhIqxQPU72dtDVeLHcgzEAUYiMQIAACAQAfU=');
InvOre := CountItems('dtm', IronOreDTM, []);
InvBars := CountItems('dtm', IronBarDTM, []);
//writeln('There are ' + IntToStr(InvOre) + ' ores left to smelt!');
//writeln('There are ' + IntToStr(InvBars) + ' bars in your inventory!');
FreeDTM(IronOreDTM);
FreeDTM(IronBarDTM);
end;

function HasNatures: Boolean;
var
x, y, NatureRuneDTM :Integer;
begin
writeln('hasnatures');
NatureRuneDTM := DTMFromString('mrAAAAHic42BgYOBlQAA2IBYEYkkglgFiaSBmBmJGIOYEYiEgFgFifiBmh+oRqgKJMOHEcgz4ASMBDAMAui4Bmg==');
if (not (GameTab(tab_inv))) then
GameTab(tab_inv);
if FindDTM(NatureRuneDtm, x, y, MIX1, MIY1,MIX2,MIY2) then
begin
writeln('Nature Runes Found!');
Result := True;
end
else
Result := False;
FreeDTM(NatureRuneDtm);
end;

procedure BankDeposit;
var
x, y, IronBarDTM :Integer;
begin
IronBarDTM := DTMFromString('m1gAAAHic42JgYOADYnYgZmSAAEkgFgBiLiAWAWJZIJYCYlYgZoKq54RiISAWhIqxQPU72dtDVeLHcgzEAUYiMQIAACAQAfU=');
if FindDTM(IronBarDtm, x, y, MIX1, MIY1,MIX2,MIY2) then
begin
Mouse(x, y, 10, 10, mouse_Right);
WaitOption('All', 500);
wait(750+RandomRange(50,250));
writeln('deposit count');
Count;
end;
FreeDTM(IronBarDTM);
end;

procedure BankWithdraw;
var
x, y, IronOreDTM :Integer;
begin
IronOreDTM := DTMFromString('mKgEAAHicncxJCoAwEETRjkoIiEZdOOB4CO9/Nn+wNi5Nwds0Vd2aWURACYdatw4LVsyy4cKuTdTOY8KIAT0a/QpS2Zv7TM3it8Py4jJ98wAHJwJd');
if FindDTM(IronOreDTM, x, y, MSX1, MSY1, MSX2, MSY2) then
begin
MMouse(x, y, 5, 5);
if IsUpText('ron or') then
begin
Mouse(x, y, 0, 0, False);
WaitOption('All', 500);
wait(750+RandomRange(50,250));
Count;
end else
writeln('Withdrawing Failed');
end else
writeln('FindDTM unable to find IronOreDtm');
FreeDTM(IronOreDTM);
end;

procedure Bank;
begin
if (not (BankScreen)) then
begin
OpenBankChest(SRL_BANK_SW);
wait(500+RandomRange(50,250));
end else
if (PinScreen) then
InPin(Players[0].Pin) else
if (InvBars >= 1) then
BankDeposit else
if (InvOre = 0) then
BankWithdraw;
end;

procedure Superheat;
var
x, y, SuperheatItemDTM, IronOreDTM :Integer;
begin
SuperheatItemDTM := DTMFromString('mlwAAAHicY2dgYOAAYnYgZgZiQSAWYIAARiDmg7LZgJgTKscPxDxA/O71BgY9RmasWI4BN2DEg6EAAISYBF4=');
IronOreDTM := DTMFromString('mKgEAAHicncxJCoAwEETRjkoIiEZdOOB4CO9/Nn+wNi5Nwds0Vd2aWURACYdatw4LVsyy4cKuTdTOY8KIAT0a/QpS2Zv7TM3it8Py4jJ98wAHJwJd');
if FindDTM(SuperheatItemDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 7, 7, mouse_Left);
FindNormalRandoms;
if FindDTM(IronOreDtm, x, y, MIX1, MIY1,MIX2,MIY2) then
begin
MMouse(x, y, 10, 10);
if IsUpText('ast Sup') then
begin
Count;
GetMousePos(x, y);
Mouse(x, y, 0, 0, mouse_Left);
SuperheatsDone := SuperheatsDone + 1;
InvOre := InvOre - 1;
InvBars := InvBars + 1;
WaitFindDTM(x, y, SuperHeatItemDTM, 1000+RandomRange(150,200));
end;
end
else
writeln('FindDTM unable to find IronOreDtm');
end else
begin
writeln('Unable to find spell - Selecting Spellbook');
if (not (GameTab(tab_magic))) then
GameTab(tab_magic);
end;
FreeDTM(SuperheatItemDTM);
FreeDTM(IronOreDTM);
end;

//~~~~~~~~~~~~~~~~~~~~~~~~~~
//~ ---=< Main Loop >=---
//~~~~~~~~~~~~~~~~~~~~~~~~~~

begin
{$IFDEF SMART}
Smart_Server := 0;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ENDIF}
SetUpSRL;
ActivateClient;
DeclarePlayers;
if not(LoggedIn) then
LoginPlayer;
OnStart;
FindNormalRandoms;
if HasNatures then
begin
Count;
SetSpellMode(False, False, False, True);
SortBook(BOOKSORT_COMBAT);
repeat
if LevelUp then
LevelsGained := LevelsGained + 1;
if (InvOre = 0) then
Bank else
if ((InvOre >= 1) and BankScreen) then
CloseBank else
Superheat;
Antiban;
until (SuperheatsDone = SUPERHEATSTODO)
end
else
writeln('Unable to find nature runes - Ending Script');
OnFinish;
end.


Here at aprox. ~ Line 158
if IsUpText('ron or') then
begin
Mouse(x, y, 0, 0, False);
WaitOption('All', 500);
wait(750+RandomRange(50,250));
Count;
end else
Maybe change it to this and try it? I was thinking it might be a "Mouse" problem
  if IsUpText('ron or') then
begin
ClickMouse2(False);
WaitOption('All', 500);
wait(750+RandomRange(50,250));
Count;
end else
If it's not then maybe it's an Uptext problem? Try different variants.
Like:
if IsUpText('ron') then

Brandon

2012-05-17 19:42:23

Script needs more failsafes. If it cannot find the DTM, try again.

Use WaitFindDTMEx(DTM, X, Y, MBX1, MBY1, MBX2, MBY2, 1500); //I think those are the parameters.

Use WaitUptextMulti(['All', 'w-A', 'raw-Al'], 600);

Reason why:

Wait(1000);
FindDTM... //Waits 1 second.. Finds DTM only once.


WaitFindDTM(...., 1000); //during a 1 second interval, every 50 milliseconds, it will attempt to find your DTM. Does not always have to wait the 1 second. If it's found before 1 second is up, the function returns true.

tehq

2012-05-17 19:48:41

Procedure BankWithdraw;
var
x, y, IronOreDTM :Integer;
begin
IronOreDTM := DTMFromString('mKgEAAHicncxJCoAwEETRjkoIiEZdOOB4CO9/Nn+wNi5Nwds0Vd2aWURACYdatw4LVsyy4cKuTdTOY8KIAT0a/QpS2Zv7TM3it8Py4jJ98wAHJwJd');
if FindDTM(IronOreDTM, x, y, MSX1, MSY1, MSX2, MSY2) then//seems like a long dtm. FindDTM isn't needed if you loop WithdrawItem
begin
WithdrawItem(IronOreDTM, 'dtm', 5{=#}, {small uptext} 'r', [3]);
Count;
end else
writeln('Withdrawing Failed');
end;
FreeDTM(IronOreDTM);
end;

and try to use:

WaitFindDTMEx(DTM: integer; var x, y: integer; xs, ys, xe, ye, WaitPerLoop, MaxTime: integer)

instead of FindDTM :)

Wreck

2012-05-18 02:05:16

From: tehq

and try to use:

WaitFindDTMEx(DTM: integer; var x, y: integer; xs, ys, xe, ye, WaitPerLoop, MaxTime: integer)

instead of FindDTM :)


From the look of it, does this do something like say WaitPerLoop 2.5sec loops until MaxTime = 10 so it would have done 4 loops trying to find DTM? How I've never noticed this before I will never know.

Thanks for the help guys! :)

punkd

2012-05-18 02:14:37

Well, guys from what wreck said, it finds the iron ore, but I'm guessing there isn't enough wait time to check up text. Use waituptext instead. I'm on my phone so I can't get the parameters for that but that should be the problem.

Recursive

2012-05-18 02:32:26

Instead of doing this,

if FindDTM(IronOreDTM, x, y, MSX1, MSY1, MSX2, MSY2) then
begin
MMouse(x, y, 5, 5);
if IsUpText('ron or') then
begin
Mouse(x, y, 0, 0, False);
WaitOption('-All', 500);
wait(750+RandomRange(50,250));
Count;
end else
writeln('Withdrawing Failed');
end else
writeln('FindDTM unable to find IronOreDtm');
FreeDTM(IronOreDTM);
end;


you can try this

if FindDTM(IronOreDTM, x, y, MBX1, MBY1, MBX2, MBY2) then
begin
Mouse(x, y, 5, 5, False);
WaitOption('All', 500);
Count;
end else
writeln('Withdrawing Failed, FindDTM unable to find IronOreDtm');
FreeDTM(IronOreDTM);
CloseBank;
end;

Simple and straight to the point

Wreck

2012-05-18 05:56:18

Hmm im still having problem ill have another go later but while I have you guy's attention tell me what you think about this :)

Ive implemented some of your suggestions to my superheat procedure after a quick rewrite and tried to add some failsafes and antirandoms that after a couple tests seem to work :D


procedure FindRandoms;
begin
FindNonInventoryRandoms;
FindNormalRandoms;
end;
function Failsafes: Boolean;
begin
if (a >= 5) then //Stop script if unable to find superheat >= 5 times
Result := false else
if (b >= 5) then //Stop script if unable to find iron ore >= 5 times
Result := false else
Result := true;
end;
procedure Superheat;
var
x, y, SuperheatDTM, IronOreDTM :Integer;
begin
SuperheatDTM := DTMFromString('mlwAAAHicY2dgYOAAYnYgZgZiQSAWYIAARiDmg7LZgJgTK' +
'scPxDxA/O71BgY9RmasWI4BN2DEg6EAAISYBF4=');
IronOreDTM := DTMFromString('mKgEAAHicncxJCoAwEETRjkoIiEZdOOB4CO9/Nn+wNi5Nwds' +
'0Vd2aWURACYdatw4LVsyy4cKuTdTOY8KIAT0a/QpS2Zv7TM3' +
'it8Py4jJ98wAHJwJd');
if (not (GameTab(tab_magic))) then
begin
FindRandoms;
writeln('Unable to find spell - Selecting Spellbook');
GameTab(tab_magic);
end else
if WaitFindDTMEx(SuperheatDTM, x, y, MIX1, MIY1, MIX2, MIY2, 100, 500) then
begin
a := 0;
Mouse(x, y, 7, 7, mouse_Left);
FindRandoms;
if WaitFindDTMEx(IronOreDtm, x, y, MIX1, MIY1,MIX2,MIY2, 100, 500) then
begin
b := 0;
MMouse(x, y, 10, 10);
//if IsUpText('ast Sup') then
if WaitUpTextMulti(['ast Sup', 'ron ore'], 500) then
begin
Count;
GetMousePos(x, y);
Mouse(x, y, 0, 0, mouse_Left);
Superheatsdone := Superheatsdone + 1;
InvOre := InvOre - 1;
InvBars := InvBars + 1;
WaitFindDTM(x, y, SuperheatDTM, 1000+RandomRange(150,250));
end;
end else
b := b + 1;
end else
a := a + 1;
FreeDTM(SuperheatDTM);
FreeDTM(IronOreDTM);
end
In main loop:
repeat
until (Superheats = SUPERHEATSTODO) or (Failsafes = False)