SRL Archive - OSR Help

Dervish - help needed


Dervish

2011-12-28 15:43:14

program JailFighter;
{$DEFINE SMART}
{$DEFINE PAINT}
{$i SRL\SRL.scar}
{$i SRL\SRL\MISC\Paintsmart.scar}
{$i ObjectDTM\ObjDTMInclude.simba}
{$i SRL/SRL/skill/fighting.scar}
const
{SETUP IS HERE}{SETUP IS HERE}{SETUP IS HERE}{SETUP IS HERE}{SETUP IS HERE}{SETUP IS HERE}
{SETUP IS HERE}{SETUP IS HERE}{SETUP IS HERE}{SETUP IS HERE}{SETUP IS HERE}{SETUP IS HERE}
{SETUP IS HERE}{SETUP IS HERE}{SETUP IS HERE}{SETUP IS HERE}{SETUP IS HERE}{SETUP IS HERE}

FoodTab = 4; // Number of the bank tab in which your food is located.
FoodType = 'trout'; // only trout or lobster supported so far
Username = ''; // Player Name
Password = ''; // Player password
NickName = ''; // 3-4 lowercase letters from username (Dervish -> erv / ervi / rvis)
Training = 'strength'; // Skill trained : attack , strength , or defence.

{SETUP END}{SETUP END}{SETUP END}{SETUP END}{SETUP END}{SETUP END}{SETUP END}{SETUP END}
{SETUP END}{SETUP END}{SETUP END}{SETUP END}{SETUP END}{SETUP END}{SETUP END}{SETUP END}
{SETUP END}{SETUP END}{SETUP END}{SETUP END}{SETUP END}{SETUP END}{SETUP END}{SETUP END}
var
WalkTreeDTM, FoodDTM, WalkTree2DTM, FinalWalk1DTM, FinalWalk2DTM,
BankWalk1DTM,BankWalk2DTM,BankDTM,
Trips,Food,FinalXP,InitialXP,
x,y,Tries: integer;

UEinfo : string;

LowFood : boolean;


procedure DeclarePlayers;
begin
HowManyPlayers := 1; // This is set to the total amount of players (more on multiplayer later ;)), for now, just keep it set as 1
NumberOfPlayers(HowManyPlayers); // This is a procedure in SRL which sets up player arrays (also, more on that later), this will always be the same
CurrentPlayer := 0; // This is the player to start with; the first player will always be 0 (you'll find out when you learn all about arrays)

Players[0].Name := Username; // Username
Players[0].Pass := Password; // Password
Players[0].Nick := NickName; // 3-4 lowercase letters from username; used for random event detection
Players[0].Active := True; // Set to true if you want to use Player 0
Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin
Players[0].Skill := Training; // Fighting style : attack , strength , defence
Players[0].Loc := 'bank'; //
end;

procedure FreeDTMs(DTMs : array of Integer);
begin
for x := 0 to high(DTMs) do
FreeDTM(x)

end;

procedure ScriptDeath;
begin

Writeln('Thanks for using Jail Fighter by Dervish.');
Writeln('Ran for : '+TimeRunning);
Writeln('Did : '+inttostr(trips)+' trips.');
Writeln('Ate : '+inttostr(food)+' food.');
Writeln('Gained : '+inttostr(FinalXP-InitialXP) + Players[0].skill +' exp.');
Writeln('Undesired Event Info : '+ UEInfo);
FreeDTMs([WalkTreeDTM, FoodDTM, WalkTree2DTM, FinalWalk1DTM, FinalWalk2DTM,
BankWalk1DTM,BankWalk2DTM,BankDTM]);
end;

procedure WMouse(x,y,rx,ry: integer; left: boolean);
begin
Mouse(x,y,rx,ry,left);
Wait(100+random(50));
end;

function UE(s: string): boolean;
begin

case s of

'start' : begin
if (LoggedIn) then
if FindSymbol(x,y,'bank') then
exit;

UEInfo:='Problem at start.';
end;

'bank' : begin
if (LoggedIn) then
if FindSymbol(x,y,'bank') then
if (FindNormalRandoms) then
exit;

UEInfo:='Problem at bank.';
end;

'jail' : begin
if (LoggedIn) then
if (FindSymbol(x,y,'dungeon')) then
if (FindNormalRandoms) then
exit;
UEInfo:='Problem at Jail.';
end;

'BS' : begin
if (BankScreen) then
if (FindSymbol(x,y,'bank')) then
exit;
UEInfo:='Problem at Bank Screen';
end;
end;
FindNormalRandoms;

result := false
end;

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////STARTUP/////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
procedure StartUp;
begin

Writeln('Welcome to Jail Fighter by Dervish');
Smart_Server := 10;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
Writeln('SRL set up.');
DeclarePlayers;
Writeln('Players set up.');
//DTMs n shit
WalkTreeDTM := DTMFromString('mbQAAAHicY2VgYLBmYWBQAmJVIFYEYgsgTmBkYEgE4hwgdgfiYCC2MpRhMIwWYnCMloDT/4H6udAwIxYMBgDLqQcY');
WalkTree2DTM := DTMFromString('mbQAAAHicY2VgYLBlYWBQAWI9ILYEYgcgTmNkYEgH4hAgzgHiCCB2dpJiME4QZnBOkATTIGwE1M+FhhmxYDAAAMlcBrg=');
FinalWalk1DTM := DTMFromString('mWAAAAHicY2FgYJjFxMCwAIgXAnE3ELsAxQKBOA6I44FYP0aQ4SOQhmERNMyIhkEAALXJB4g=');
FinalWalk2DTM := DTMFromString('mWAAAAHicY2FgYJjFxMCwAIgXAnE3ELsAxQKBOA6I44FYP0aQ4SOQhmERNMyIhkEAALXJB4g=');
BankWalk1DTM := DTMFromString('mWAAAAHicY2FgYPBmYmBwBOIwIA4G4nygWB4QRwFxNRB7OcoxGEWLMDhFS4ExP1AMGTOiYRAAAEypBew=');
BankWalk2DTM := DTMFromString('mWAAAAHicY2FgYHBnYmBwBmJHIA4GsYFilkAcBMSGQOxjr89gFC3CoBQowPDu5VcGfqAYMmZEwyAAAGZDBxQ=');
BankDTM := DTMFromString('mbQAAAHicY2VgYPBmYmDIBOJsIE4G4kggLgKKpzFA6C4gngLE+uqyDEbRIgxO0VIMS/rLwPg/UFwEDTNiwWAAALsLCsQ=');
ObjDTM_Setup;
Writeln('DTMS set up.');
case FoodType of
'trout' : FoodDTM := DTMFromString('mrAAAAHic42BgYMhmYmDIA+IqIC4E4jQgjgPiRCibk5GBgRmIGYGYC4iFoZgbiNmAOMrfF2gKI04sAiTxYdw6IRgGAMGHBWM=');
'lobster': FoodDTM := DTMFromString('mrAAAAHic42BgYMhmYmDIA+IqIC4E4jQgjgPiRCibk5GBgRmIGYGYC4iFoZgbiNmAOMrfF2gKI04sAiTxYdw6IRgGAMGHBWM=');
end;
Writeln('Food type set up.');
ActivateClient;
Writeln('Client activated.');
LoginPlayer;
Writeln('Logging in..');
Wait(5000);

if (UE('start')) then
ScriptDeath;

SetCombatType(Players[0].Skill);
InitialXP:=GetXP(Players[0].Skill);
end;
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////BANKING///////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
procedure Banking;
begin

//Opening the bank
Tries := 0;

while (not(BankScreen)) or
(Tries <> 5) do
begin
case random(3) of
0: OpenBankNPC;
1: OpenBankQuiet('db');
2: OpenBankFast('db');
end;
Inc(Tries);
end;

UE('BS');

//Withdrawing Stuff
BankTab(FoodTab);

if FindDTM(FoodDTM,x,y,MSX1,MSY1,MSX2,MSY2) then
begin
WMouse(x,y,3,3,false);
ChooseOption('ll');
end;

//Finishing
CloseBank;
end;

procedure Bank;
begin

Writeln('Banking');

If not (UE('bank')) then
Banking;

Inc(Trips);
Writeln('Banking done.');
end;


////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////Walking///////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

{function AutoColor: Integer;//ACA v2 by Nielse95 and Sumillion
var //^ Full credits ^
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
R, G, B: Integer;
X, Y, Z: Extended;

begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.00, 0.00);

FindColorsSpiralTolerance(MMCX, MMCY, arP, 3031374, MMX1, MMY1, MMX2, MMY2, 0);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToRGB(arC[i], R, G, B);

if (R >= 77) and (R <= 79) and (G >= 64) and (G <= 66) and (B >= 45) and (B <= 47) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 5.51) and (X <= 5.55) and (Y >= 5.58) and (Y <= 5.62) and (Z >= 3.35) and (Z <= 3.39) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;}

function Walking(Path: integer): boolean;
begin

case Path of

1: begin
Writeln('Walking : 1.');
If FindObjDTM('680:72:2:1:7:663:76:1:7:663:65',x,y,true) then
begin
Writeln('Found ObjDTM : 1.');
WMouse(x,y,0,0,true);
result := true;
Exit;
end;
Writeln('Did not find ObjDTM.');
ScriptDeath;
end;

2: begin
Writeln('Walking : 2.');
if FindObjDTM('680:66:2:1:7:670:68:1:7:675:52',x,y,true) then
begin
Writeln('Found ObjDTM : 2.');
WMouse(x,y,0,0,true);
result := true;
Exit;
end;
Writeln('Did not find ObjDTM.');
ScriptDeath;
end;

3: begin
Writeln('Walking : 3.');
if FindObjDTM('658:92:3:2:7:676:83:1:7:658:85:1:7:641:77',x,y,true) then
begin
Writeln('Found ObjDTM : 3.');
WMouse(x,y,0,0,true);
result := true;
exit;
end;
Writeln('Did not find ObjDTM.');
ScriptDeath;
end;

end;
end;




procedure Walk(tojail:boolean);
begin

if (tojail) then
if Walking(1) then
begin
FFLag(3);
if (FindSymbol(x,y,'dungeon')) then
if Walking(2) then
begin
FFLag(3);
if Walking(3) then
begin
Writeln('Walked to Jail');
Players[0].Loc := 'Jail';
end;
end;
end;

if (not(tojail)) then
if Walking(3) then
begin
FFLag(3);
if Walking(2) then
begin
FFLag(3);
if Walking(1) then
begin
Writeln('Walked to Bank');
Players[0].Loc := 'Bank';
end;
end;
end;
end;

////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////Eating/////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
procedure FindNEat;
var
I: integer;
begin

for I:=0 to 28 do
if (ExistsItem(I)) then
begin
MMouseItem(I);
If (IsUpText('at')) then
begin
GetMousePos(x,y);
case random(6) of
0: begin
WMouse(x,y,0,0,false);
ChooseOption('at');
end;
1,2,3,4,5: Mouse(x,y,0,0,true);
end;
Inc(Food);
end;
end;

end;

procedure Eat;
begin
UE('jail');
if (InvCount < 2+random(4)) then
begin
FindNEat;
LowFood := true;
end;

if (HPPercent<50) then
begin
FindNEat;
end;
end;

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////Fighting////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
function FindTarget: boolean;
begin

If (not(Players[0].loc = 'Jail')) then
begin
Writeln('Something is wrong.. Not at Jail ?');
ScriptDeath;
end;

Tries := 0

while (Tries <> 20) or
(not(InFight)) do
begin

if (FindObjCustom(x,y,['ttack','ail','uard','evel'],[5860980,4146244,
4544090,7436155,4478041],10)) then
begin
case random(2) of
1: WMouse(x,y,0,0,true);
2: begin
WMouse(x,y,0,0,false);
ChooseOption('ttack');
end;
end;
Wait(1000);
result := true;
exit;
end;

Inc(Tries);
end;

if (inFight) then
begin
Writeln('You seem to have been attacked by something, fighting back.');
exit;
end;

if (Tries = 20) then
begin
Writeln('Tried to find target 20 times without success, terminating.');
ScriptDeath;
end;


end;

procedure Fight;
begin

while (not(LowFood)) or
(not(UE('jail'))) do
begin
FindTarget;
Eat;
end;

end;

begin
StartUp;

repeat
Bank;
Walk(true);
Fight;
Walk(false);
until(false);
end.

I had some free time lately so I decided I'd take up scripting.

I decided I'd do a fighting script since they are quite few and Jail seems like a good spot.

But I've ran into quite a few problems. Now I know that this script is nowhere close to finished but I tried to do a test run (a few actually)..

1:
Welcome to Jail Fighter by Dervish
SRL Compiled in 15 msec
SMART Initialized.
Loaded: Server 10, Members: False, Signed: True, Super Detail: False.
SRL set up.
Players set up.
DTMS set up.
Food type set up.
Client activated.
Logging in..
Banking
Banking done.
Walking : 1.
Found ObjDTM : 1.
Something is wrong.. Not at Jail ?

Why does it say the Jail part already ? I do not understand.

2:
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.

Simple warning so no problem I guess but I would like to know what that means :p.

3:
Error: Exception: The given DTM Index[0] doesn't exist at line 412

In Antirandoms.scar ?

Lines 410 to 415 are :

  if not SRLBitmapsLoaded then
LoadSRLBitMaps;
if (FindDTM(Lamp, x, y, MIX1, MIY1, MIX2, MIY2) or
FindDTM(BookOfKnowledge, x, y, MIX1, MIY1, MIX2, MIY2)) then
begin
Result := True;

Thanks in advance.

Love, Dervish :).

Brandon

2011-12-28 16:04:57

In your walk(tojail: Boolean) either your findsymbol('dungeon') is not found OR your object dtm 2 is not found.. Then it calls the fight procedure..

That then checks to see if low on food.. lets say we are not low on food.. then it will run those instructions instantly. Then we check UE('Jail').. if it returns false it will not do the instructions..

The problem is the OR statement as far as I see it.. it does if (NOT low on food) OR (UE('Jail') = False) then do instructions..

UE jail will always result false if randoms are not found.. AND low on food will always return true if we are not low on food..

Or statement will be true if either one is true.. Not low on food = TRUE at the time of execution AND UE jail = False at the time of execution.. Thus we fight/find a target..

The next problem is that in the fight procedure if not players.loc[0] = 'Jail'.. will always result to true because that dungeon symbol is not found in the walk procedure so the loc = 'bank' still.. that's why it executes that jail problem.

Edit:
Shit Iunno if I made that confusing.. K I'll try again.. if we have lots of food, we fight OR if jail = true we fight.. You seem to have food so your script fights since you are "NOT low on food"


As for that anti-random stuff.. looks like the script terminated before its time and the DTM was already freed with that AddOnTerminate.. So since it tried to free a dtm that's already free then u get that crap lol.

Dervish

2011-12-28 16:26:32

From: ggzz
In your walk(tojail: Boolean) either your findsymbol('dungeon') is not found OR your object dtm 2 is not found.. Then it calls the fight procedure..

That then checks to see if low on food.. lets say we are not low on food.. then it will run those instructions instantly. Then we check UE('Jail').. if it returns false it will not do the instructions..

The problem is the OR statement as far as I see it.. it does if (NOT low on food) OR (UE('Jail') = False) then do instructions..

UE jail will always result false if randoms are not found.. AND low on food will always return true if we are not low on food..

Or statement will be true if either one is true.. Not low on food = TRUE at the time of execution AND UE jail = False at the time of execution.. Thus we fight/find a target..

The next problem is that in the fight procedure if not players.loc[0] = 'Jail'.. will always result to true because that dungeon symbol is not found in the walk procedure so the loc = 'bank' still.. that's why it executes that jail problem.

Edit:
Shit Iunno if I made that confusing.. K I'll try again.. if we have lots of food, we fight OR if jail = true we fight.. You seem to have food so your script fights since you are "NOT low on food"


As for that anti-random stuff.. looks like the script terminated before its time and the DTM was already freed with that AddOnTerminate.. So since it tried to free a dtm that's already free then u get that crap lol.


Oh god what ? :s

Brandon

2011-12-28 16:42:33

This is what I'm trying to say.. I'm seriously bad at explaining stuff.. I could never be a good teacher. But I really really hope you understand this: