SRL Archive - RS has been updated.

Help Please!


Rs Baws

2012-01-16 15:24:40

How can I make this script no check the xp bar? It just keeps spam clicking it. I know this is effected by the update but I just want to take the option out as a temp fix. Thanks

program NathanPlankMake;
{$DEFINE SMART}
{.include srl/srl.simba}

//Start in soul wars bank
//Start with earth staff equipped and runes in inventory
//Start with Mahogony logs visible in bank
//Mahogony logs should be in the upper-right corner of the bank

//Version 1.01
//Automatically sets up your magic tab now
//Increased humanness with the AntiBanSleep method
//Other random fixes

//Version 1.02
//More failsafes added
//Missclicking inventory added to increase humanness
//Cleaned up coding standards

//Version 1.1
//Checks to make sure runes are in inventory
//Checks to make sure logs are left in slot before withdrawing
//Chest finding is now done via TPAs, more reliable
//Inventory count done via DTMs to more accuratley know when to bank
//Re-did failsafe around opening chest to not call reset procedure if it might not need to
//Tweaks to random methods to increase efficiency
//Updated debug output for optimal information to tweek settings
//Updated missclicks to make sure we are missclicking on logs and not missclicking on planks using a 2D-TPA
//Removed paint and updated progress report in debug window, looks better
//Fixed up player handling
//Other random changes

//Version 1.11
//Updated GetXP to not possibly through an error if it cannot find the text

//Version 1.2
//Updated to SRL - 5
//Fixed issue with exp, should work perfectly and not crash the script!
//Correctly am freeing DTMs now
//Updated timings on some waits, should be more efficient now

//TODO
//Breaking system
//Redo item clicking, TPA of items with a smaller than current click box, current click box is clicking outside of item, slightly too large
//Add 'status' to progress report

var resets,x,y,inventories,inventories2,startingExp,cnt,p,missclicks,rsleep,antibans:integer;
var invFinished:boolean;
var logs:LongInt;
var missclickLocs: TPointArrayArray;

const
//*****************Edit*********************//
SERVER = 114; //Set a server here.
INVENTORIES_TODO = 115; // How many loads should we go through?
GAIN_PER_CAST =-97; // How much do we make or lose per cast?

//How often do you want antiban waiting to occur?
//182 will aprox be one random sleep per inventory
//364 will be one random sleep per two inventories
//A number between 100 and 550 is reccommended
//The lower the number the more humanlike (to an extent)
//The higher the number the fast the script will go
FREQUENCY = 275; //Explained ^^^^^^^^^^^^^^^^^^^

MISSCLICK = True; //Humanlike inventory missclicks? I reccomend true.
MISSCLICK_PERCENT = 3; //How many percent of the time should we missclick? 4 works well, 2-7 is reccomended
HUMAN_MOUSESPEED = 12; // 10-17 are good, the higher the faster, use what seems humanlike to you
//**************Done editing****************//
LOG_COLOR = 1916256; //Color of a log in the inventory
CHEST = 11842748; //Colors of bank chest, don't edit
CHEST2 = 5921374; // Colors of bank chest, don't edit
DebugOn = False; //Debug output? False recommended

//*****************Edit*********************//
//******************************************//
//******************************************//
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := ''; // Fill in
Players[0].Pass := ''; //Fill in
Players[0].Nick := 'ace'; //3 letters of your username (not the first letter)
Players[0].Active := True;
end;
//******************************************//
//******************************************//
//******************************************//

//Only gives annoying debug if debug mode is on
procedure DebugOutput(text:String);
begin
if(DebugOn) then
Writeln(text);
end;

//Frees all DTMs the script uses. Only 1 currently...
procedure FreeOurDTMs;
begin
FreeDTM(logs);
end;

//Antiban
procedure AntiBan;
begin
//We want antiban to occur every second inventory
//26 clicks per inventory so we need a 1/52 chance of antiban occuring
//6 possibilites so 6*52 = 1/321 chance will give up 1 antiban per 2 inventories
case random(312) of
1:begin HoverSkill(SKILL_MAGIC,false); antibans:=antibans+1; end;
2:begin PickUpMouse; antibans:=antibans+1; end;
3:begin PickUpMouse; antibans:=antibans+1; end;
4:begin MouseBox(MSX1,MSY1,MSX2,MSY2,3); sleep(500+random(1500)); antibans:=antibans+1; end;
5:begin SleepAndMoveMouse(4000+random(3000)); antibans:=antibans+1; end;
6:begin HoverSkill(SKILL_MAGIC,false); antibans:=antibans+1; end;
end;
end;

//Random sleeps to increase "humanness" called during spell casting
//The user can change how often this will occur by modifiying the const FREQUENCY
procedure AntiBanSleep(freq:integer);
var rand:integer;
begin
rand:=random(freq);

case rand of
1:begin sleep(100+random(100)); DebugOutput('rand sleep'); rsleep:=rsleep+1; end;
2:begin sleep(500+random(500)); DebugOutput('rand sleep'); rsleep:=rsleep+1; end;
3:begin sleep(300+random(300)); DebugOutput('rand sleep'); rsleep:=rsleep+1; end;
4:begin sleep(1000+random(1000)); DebugOutput('rand sleep'); rsleep:=rsleep+1; end;
5:begin sleep(500+random(1000)); DebugOutput('rand sleep'); rsleep:=rsleep+1; end;
6:begin sleep(2000+random(2000)); DebugOutput('rand sleep'); rsleep:=rsleep+1; end;
7:begin sleep(2000+random(4000)); DebugOutput('rand sleep'); rsleep:=rsleep+1; end;
end;
end;

procedure AntiBanMissClick(spot:integer);
var rand:integer;
begin
if(MISSCLICK) then
begin
rand:=random(4);
DebugOutput('Misslicking on purpose!');
missclicks:=missclicks+1;
Mouse(missclickLocs[spot-1][rand].x,missclickLocs[spot-1][rand].y,2,2,true);
end;
end;
//If something messes up this is called to fix it
//Prevents the script from having to terminate if the problem can be solved
procedure Reset;
begin
resets:=resets+1;
DebugOutput('We have had: ' + inttostr(resets) + ' resets.');
FindNormalRandoms;
if(BankScreen) then //Close bank
begin
CloseBank;
sleep(300+random(300));
end;
MouseBox(644,168,669,202,1);//Clicks inventory tab
sleep(300+random(300));
if((rs_GetCompassAngleDegrees() < 15) or (rs_GetCompassAngleDegrees() > 65)) then
MakeCompass(RandomRange(20,60));
end;

//Custom object finding with TPAs
function ClickObj(x, y: Integer; HMod, SMod: Extended; color,tol:Integer; UpText:TStringArray):Boolean;
var
init, I: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
init:=GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(HMod, SMod);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, color, MSX1, MSY1, MSX2, MSY2, tol);
ColorToleranceSpeed(init);
ATPA:=TPAToATPAEx(TPA, 25, 25);
for i:=0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 2, 2);
sleep(100+random(100));
If(IsUpTextMultiCustom(UpText)) then
begin
Result := True;
GetMousePos(x, y);
Mouse(x,y,0,0,true);
sleep(150+random(150));
Break;
end;
end;
end;

//Opens the bank - Fairly simple code, but for the soulwars bank it works flawlessly
//The player isn't moving and the bank isn't moving, no need for complexity here
Function OpenChest:boolean;
begin
if not(BankScreen) then
begin
if(IsUpText('hest')) then
begin
DebugOutput('Already on chest');
GetMousePos(x,y);
Mouse(x,y,0,0,true);
end else
begin
// if(FindObj(x,y,'ank',CHEST,5)) then
// begin
// DebugOutput('color 1');
// Mouse(x,y,3,3,true);
// end else
// if(FindObj(x,y,'ank',CHEST2,5)) then
// begin
// DebugOutput('color 2');
// Mouse(x,y,3,3,true);
if(ClickObj(x,y,0.057,0.0959,8750735,36,['ank','chest'])) then
begin
DebugOutput('Found bank');
result:=true;
end;
end;
sleep(700+random(300));
end;
end;

//Depreciated - Using DepositAllExceptIgnoreColor
//Will deposit all items except those having the toptext of items
Procedure DepositAllExcept(items: Array of String);
var i,ii:integer;
begin
if(BankScreen) then
begin
for i := 1 to 28 do
begin
if(ExistsItem(i)) then
begin
MMouseItem(i);
sleep(100+random(100));
for ii := 0 to (Length(items)-1) do
begin
if not(IsUpText(items[ii])) then
begin
GetMousePos(x,y);
Mouse(x,y,0,0,false);
WaitOptionMulti(['Deposit-All', 'All', 'Deposit'], 200);
sleep(200+random(100));
end;
end;
sleep(200+random(200));
end;
end;
end;
end;

//Same as DepositAllExcept, however it ignores the colors of the nature rune
//and the astral rune to be more human like (a human wouldn't mouse over the runes
//in order to decide whether or not to deposit them)
Procedure DepositAllExceptIgnoreColor(items: Array of String);
var i,ii:integer;
var cur:TBox;
var spot:boolean;
begin
if(BankScreen) then
begin
for i := 1 to 28 do
begin
spot:=true;
if(ExistsItem(i)) then
begin
cur:= InvBox(i)
if(FindColorTolerance(x,y,1276176,cur.X1,cur.Y1,cur.X2,cur.Y2,20)) then
spot:= false;
if(FindColorTolerance(x,y,13349068,cur.X1,cur.Y1,cur.X2,cur.Y2,20)) then
spot:= false;
if(spot) then
begin
MMouseItem(i);
sleep(100+random(100));
for ii := 0 to (Length(items)-1) do
begin
if not(IsUpText(items[ii])) then
begin
GetMousePos(x,y);
Mouse(x,y,0,0,false);
WaitOptionMulti(['Deposit-All', 'All', 'Deposit'], 200);
sleep(350+random(100));
end;
end;
sleep(200+random(200));
end;
end;
end;
end else
Reset;
end;

//Wrapper
procedure DepositAllButRunes;
begin
DepositAllExceptIgnoreColor(['une']);
end;

//Withraws all mahogany logs from the most upper-right corner of the bank
//Hardcoded spot works just fine, a DTM would be "Better" but for this simple
//non-dynamic aspect, its un-needed.
procedure WithdrawLogs;
begin
if(BankScreen) then
begin
FixBank;
MMouse(447,108,8,8); //Moves mouse to bank position
sleep(250+random(250));
if(IsUpTextMultiCustom(['any','logs'])) then
begin
GetMousePos(x,y);
Mouse(x,y,0,0,false);
WaitOptionMulti(['Withdraw-All', 'All'], 200);
sleep(200+random(100));
end else
begin
writeln('Out of logs, shutting down!');
if(BankScreen) then
CloseBank;
Logout;
FreeOurDTMs
TerminateScript;
end;
invFinished:= false;
end else
Reset;
end;

//Depreciated - DTMs now
//Will return an array of integers with all of the inventory spots that contain the given color
Function FindInvItemByColor(color:integer):Array of Integer;
var i,count,ccount:integer;
var a:Array [1..28] of Boolean;
var b:Array of Integer;
var cur:TBox;

begin
if(GetCurrentTab=tab_Inv) then
begin
count:= 0;
for i:=1 to 28 do
begin
cur:= InvBox(i)
if(FindColorTolerance(x,y,color,cur.X1,cur.Y1,cur.X2,cur.Y2,5)) then
begin
a[i]:= true;
count:=count+1;
end else
a[i]:= false;
end;
SetArrayLength(b, count);
ccount:=0;
for i:=1 to 28 do
begin
if(a[i] = true) then
begin
b[ccount]:= i;
ccount:=ccount+1;
end;
end;
result:= b;
end else
result:= [-1];
end;

//Returns an array of integers of the inventory spots that have the given DTM in them
Function FindInvItemByDTM(DTM:LongInt):Array of Integer;
var i,count,ccount:integer;
var a:Array [1..28] of Boolean;
var b:Array of Integer;
var cur:TBox;

begin
if(GetCurrentTab=tab_Inv) then
begin
count:= 0;
for i:=1 to 28 do
begin
cur:= InvBox(i)
if(FindDTM(DTM,x,y,cur.X1,cur.Y1,cur.X2,cur.Y2)) then
begin
a[i]:= true;
count:=count+1;
end else
a[i]:= false;
end;
SetArrayLength(b, count);
ccount:=0;
for i:=1 to 28 do
begin
if(a[i] = true) then
begin
b[ccount]:= i;
ccount:=ccount+1;
end;
end;
result:= b;
end else
result:= [-1];
end;

//Counts the number of DTMs found in an inventory that match the input "DTM"
Function CountInvDTM(DTM:longint):integer;
var items:TPointArray;
begin
if(GetCurrentTab=tab_Inv) then
begin
FindDTMs(DTM,items,556,210,733,465);
result:=(Length(items)/9);
end else
result:=-1;
end;

//Casts the spell on the logs
//Uses the array of which spots contain logs and randomly choose on to use
//Humans (or at least I) never go in order, so to keep the script human like
//it will randomly select which log to click on in no particular order
procedure CastSpell;
var click,spots,rand7:integer;
var invArray:Array of Integer;

begin
if not(GetCurrentTab = tab_Magic) then
MouseBox(735,171,758,200,1);//Clicks magic tab
sleep(150+random(150));
MouseBox(621,277,635,294,1);//Clicks spell
sleep(200+random(150));
if not(GetCurrentTab = tab_Inv) then
sleep(100+random(100));
invArray:= FindInvItemByDTM(logs);
spots:= Length(invArray);
if(CountInvDTM(logs) < 2) then
invFinished:=true;
rand7:=random(100);
click:=random(spots);
if(rand7 < (100-MISSCLICK_PERCENT)) then
begin
if(GetCurrentTab=tab_Inv) then
MouseItem(invArray[click],1);
sleep(850+random(300));
if(IsChatBoxTextAnyLine('this spell',clBlack)) then
begin
writeln('Out of runes, shutting down!');
Logout;
FreeOurDTMs
TerminateScript;
end;
end else
begin
AntiBanMissClick(invArray[click]);
sleep(200+random(300));
end;
AntiBan;
AntiBanSleep(FREQUENCY);
if(Length(FindInvItemByDTM(logs)) < 1) then
begin
DebugOutput('inv finished');
invFinished:=true;
end;
end;

procedure Setup;
var i:integer;
begin
writeln('Setup beginning');
//Load missclick TPA with info
SetArrayLength(missclickLocs, 28);
for I := 0 to 27 do
SetLength(missclickLocs[i], 4);

missclickLocs[0]:=[IntToPoint(557,211),IntToPoint(597,211),IntToPoint(557,248),IntToPoint(597,248)];
missclickLocs[1]:=[IntToPoint(599,211),IntToPoint(639,211),IntToPoint(599,248),IntToPoint(639,248)];
missclickLocs[2]:=[IntToPoint(641,211),IntToPoint(684,211),IntToPoint(641,248),IntToPoint(684,248)];
missclickLocs[3]:=[IntToPoint(684,211),IntToPoint(729,211),IntToPoint(684,248),IntToPoint(729,248)];
missclickLocs[4]:=[IntToPoint(557,247),IntToPoint(597,247),IntToPoint(557,282),IntToPoint(597,282)];
missclickLocs[5]:=[IntToPoint(599,247),IntToPoint(639,247),IntToPoint(599,282),IntToPoint(639,282)];
missclickLocs[6]:=[IntToPoint(641,247),IntToPoint(684,247),IntToPoint(641,282),IntToPoint(684,282)];
missclickLocs[7]:=[IntToPoint(684,247),IntToPoint(729,247),IntToPoint(684,282),IntToPoint(729,282)];
missclickLocs[8]:=[IntToPoint(557,282),IntToPoint(597,282),IntToPoint(557,318),IntToPoint(597,318)];
missclickLocs[9]:=[IntToPoint(599,282),IntToPoint(639,282),IntToPoint(599,318),IntToPoint(639,318)];
missclickLocs[10]:=[IntToPoint(641,282),IntToPoint(684,282),IntToPoint(641,318),IntToPoint(684,318)];
missclickLocs[11]:=[IntToPoint(684,282),IntToPoint(729,282),IntToPoint(684,318),IntToPoint(729,318)];
missclickLocs[12]:=[IntToPoint(557,318),IntToPoint(597,318),IntToPoint(557,355),IntToPoint(597,355)];
missclickLocs[13]:=[IntToPoint(599,318),IntToPoint(639,318),IntToPoint(599,355),IntToPoint(639,355)];
missclickLocs[14]:=[IntToPoint(641,318),IntToPoint(684,318),IntToPoint(641,355),IntToPoint(684,355)];
missclickLocs[15]:=[IntToPoint(684,318),IntToPoint(729,318),IntToPoint(684,355),IntToPoint(729,355)];
missclickLocs[16]:=[IntToPoint(557,355),IntToPoint(597,355),IntToPoint(557,391),IntToPoint(597,391)];
missclickLocs[17]:=[IntToPoint(599,355),IntToPoint(639,355),IntToPoint(599,391),IntToPoint(639,391)];
missclickLocs[18]:=[IntToPoint(641,355),IntToPoint(684,355),IntToPoint(641,391),IntToPoint(684,391)];
missclickLocs[19]:=[IntToPoint(684,355),IntToPoint(729,355),IntToPoint(684,391),IntToPoint(729,391)];
missclickLocs[20]:=[IntToPoint(557,391),IntToPoint(597,391),IntToPoint(557,431),IntToPoint(597,431)];
missclickLocs[21]:=[IntToPoint(599,391),IntToPoint(639,391),IntToPoint(599,431),IntToPoint(639,431)];
missclickLocs[22]:=[IntToPoint(641,391),IntToPoint(684,391),IntToPoint(641,431),IntToPoint(684,431)];
missclickLocs[23]:=[IntToPoint(684,391),IntToPoint(729,391),IntToPoint(684,431),IntToPoint(729,431)];
missclickLocs[24]:=[IntToPoint(557,431),IntToPoint(597,431),IntToPoint(557,463),IntToPoint(597,463)];
missclickLocs[25]:=[IntToPoint(599,431),IntToPoint(639,431),IntToPoint(599,463),IntToPoint(639,463)];
missclickLocs[26]:=[IntToPoint(641,431),IntToPoint(684,431),IntToPoint(641,463),IntToPoint(684,463)];
missclickLocs[27]:=[IntToPoint(684,431),IntToPoint(729,431),IntToPoint(684,463),IntToPoint(729,463)];

while not(LoggedIn) do
sleep(2000);

if(BankScreen) then
CloseBank;
DebugOutput('Checking magic tab');
if not(GetCurrentTab = tab_Magic) then
MouseBox(735,171,758,200,1);//Clicks magic tab
sleep(500+random(500));
if(FindColorTolerance(x,y,16711422,596,441,596,441,12)) then
begin
writeln('Checking first box');
MouseBox(594,443,607,460,1);
sleep(700+random(500));
end;
sleep(500);
if(FindColorTolerance(x,y,16711422,628,441,628,441,12)) then
begin
writeln('Checking second box');
MouseBox(616,443,632,458,1);
sleep(700+random(500));
end;
sleep(500);
if not(FindColorTolerance(x,y,16711422,645,441,652,441,12)) then
begin
writeln('Checking third box');
MouseBox(643,443,658,459,1);
sleep(700+random(500));
end;
sleep(500);
if not(FindColorTolerance(x,y,16711422,678,441,682,441,12)) then
begin
writeln('Checking fourth box');
MouseBox(677,442,690,457,1);
sleep(700+random(500));
end;
MakeCompass(RandomRange(20,60));
end;

Function OutputDecimals(a,b:integer):String;
var c,d:double;
begin
c:=a;
d:=b;
result:=FloatToStr(c/d);
end;

Function XPPerHour(runtime,gained:integer):String;
begin
result:=inttostr(Round((gained * 3600) / (runtime / 1000)));
end;

Function GainedXP:integer;
begin
result:= GetXPBarTotal - startingExp;
end;

begin
logs:= DTMFromString('mlwAAAHicY2dgYDjLxMBwDIjPAPFVIL4DxDeA+BIQn2RkYDgAxJeB+CIQnwLig0C8F4ibcj2AupmwYkkG3IARD4YCANO2DK8=');
Smart_Members := True;
Smart_Server := SERVER;
SetupSRL;
MouseSpeed:=HUMAN_MOUSESPEED;
DeclarePlayers;
AddOnTerminate('FreeAll');
if not(LoggedIn) then
LogInPlayer;
while not(LoggedIn) do //Wait for login
sleep(2500);
if not(IsXPBarOpen) then //Need XP bar for progress reports
ToggleXPBar(True);
startingExp:= GetXPBarTotal;
DebugOutput(inttostr(startingExp));
Setup;
while(true) do //Main loop
begin
if(inventories2 < INVENTORIES_TODO) then //Switches players after loads complete
begin

for p:=0 to 3 do
begin
if(OpenChest()) then
Break;
if(p=3) then
Reset;
end;
sleep(300+random(500));
DepositAllButRunes;
WithdrawLogs;
CloseBank;
cnt:=0;
while not(invFinished) do
begin
CastSpell;
if(inventories > 0) then
begin
ClearDebug;
Writeln('***************Nathan''s Magic Planker***************');
Writeln('********** Inventories: ' + inttostr(inventories) + ' Planks: ' + inttostr((GainedXP/90)) + ' **********' );
Writeln('****************************************************');
Writeln('Running for: ' + TimeRunning);
Writeln('Missclicks (on purpose): ' + inttostr(missclicks) + ' || ' + OutputDecimals(missclicks,inventories) + ' avg/inventory' );
Writeln('Random waits: ' + inttostr(rsleep) + ' || ' + OutputDecimals(rsleep,inventories) + ' avg/inventory');
Writeln('Antiban actions: ' + inttostr(antibans) + ' || ' + OutputDecimals(antibans,inventories) + ' avg/inventory');
Writeln('Exp Gained: ' + inttostr(GainedXP) + ' || ' + XPPerHour(GetTimeRunning,GainedXP) + ' exp/hour');
Writeln('We have made/lost: ' + inttostr(Round(((GainedXP*GAIN_PER_CAST)/90))) + ' gp || ' + XPPerHour(GetTimeRunning,(Round(((GainedXP*GAIN_PER_CAST)/90)))) + ' gp/hour');

end;
cnt:=cnt+1;
if(cnt>50) then
Exit;
end;
inventories:=inventories+1;
inventories2:=inventories2+1;

end else
begin
inventories2:=0;
writeln(inttostr(INVENTORIES_TODO) + ' loads complete. Switching to next player!');
NextPlayer(False);
if(PlayersActive < 1) then
TerminateScript;
while not(LoggedIn) do
begin
writeln('Sleeping while not logged in');
sleep(1000);
end;
end;
end;
FreeOurDTMs
end.

Chris

2012-01-16 15:33:26

You should ask for a fix in the script's thread instead of asking us to fix it.

PatDuffy

2012-01-16 15:35:16

From: Chris
You should ask for a fix in the script's thread instead of asking us to fix it.


that

Rs Baws

2012-01-16 15:40:56

From: Chris
You should ask for a fix in the script's thread instead of asking us to fix it.


I thought it was just a matter of deleting some code.

PatDuffy

2012-01-16 15:50:41

From: Rs Baws
I thought it was just a matter of deleting some code.


It is. Either do it yourself, or post in that script's thread.

Chris

2012-01-16 15:50:59

From: Rs Baws
I thought it was just a matter of deleting some code.


The script has a reason to check the xp bar so if we just delete the function the script might stop working as it should work. We could test it and make the script functional again but this is what the scripter should do.