SRL Archive - Help and Support

help with running this script


Bonfield

2010-08-24 22:00:18

i started working on a script about a month ago, but a few weeks ago my computer decided to stop working and now i have finally gotten access to the internet and a computer again,i was wondering if someone could help me, because now i cant get the script i was working on to run properly.

i have the lastest simba and srl, but when i try to run my script it gets stuck on procedures like GetAllLevels, FindNormalRandoms… i cant even get the script to cast either curse or high alchemy, it tries to toggle defensive casting on then sort it, i cant see why it would be doing this

here is the script, you will need the XPchars Narcle made from here

could someone please figure out whats going wrong please

program AlchAndCurser;
{$i SRL/SRL.scar}
{$i SRL/SRL/Misc/Stats.scar}
{$i SRL/SRL/Misc/Users.scar}
{$i SRL/SRL/Misc/Reports.scar}
{$i SRL/SRL/Skill/Magic.scar}
{$i SRL/SRL/Misc/Debug.scar}
{=========================================================================]
[ ]
[ NAME : Alcher and Curser ]
[ WRITER : Bonfield ]
[ CATEGORY : Magic ]
[ DESCRIPTION : Casts High Level Alchemy and Curse on a NPC ]
{ for pretty quick xp ]
[ CONTACT ]
[ [url]http://villavu.com/forum/private.php?do=newpm&u=2357[/url] ]
[ ]
[=========================================================================]
[ Instructions ]
[=========================================================================]
[ 1. Have your display settings set to 32 bit TRUE color. ]
[ 2. Fill out DeclarePlayers. ]
[ (For further instructions on how to fill it out, visit this thread: ]
[ [url]http://www.villavu.com/forum/showthread.php?t=5410[/url]) ]
[ 3. If you want to use S.M.A.R.T., uncomment line 34, otherwise ]
[ drag the crosshair over the RS client window. ]
[ 4. Start script! ]
[=========================================================================}

const
ScriptVersion = '1.00';

YourStatsUserID = '46'; // User UID from scriptmanager.freehostia.com
YourStatsPass = 'jacob'; // Your pass from scriptmanager.freehostia.com

World = 32; // Smart World
Members = False; // Use Members World
Signed = True; // Use Signed applet

Take_Screenshot = True; // Take Screenshot on level up.
Debug_Script = True; // Do you want the script to debug.

Use_Breaks = True; // Do you want to break?
Random_Breaktime = 5; // Adds random time to each breaktime eg. + or - 5 minutes.

type
NPC = record
Name: String;
Uptext: TStringArray;
Color: Integer;
Hue_Mod: Extended;
Sat_Mod: Extended;
Tolerance: Integer;
end;

var
Curses_Failed, TOT_Curses, TOT_High_Alches: Integer;
MOB : NPC;
Script_Total: array[0..4] of LongInt;

procedure DeclarePlayers;
begin
HowManyPlayers := 1; // How many players declared?
CurrentPlayer := 0; // Number of player to start with.
NumberOfPlayers(HowManyPlayers);

with Players[0] do
begin
Name := 'name'; // Characters full RS username.
Pass := 'pass'; // Characters RS password.
Nick := 'hi'; // 3 non-caps letters of char's RS username
Strings[0] := 'zamorak monk'; // Supports 'Zamorak Monk', 'Lesser Demon'
// 'Curse' and 'High Level Alchemy' if you only want to cast one of them
Integers[5] := 20; // How long before breaking or switching in minutes
Integers[6] := 6; // How long to break for in minutes + or - Random_Breaktime const
Active := True;
end;
end;

procedure Debug(x :string);
begin
if not Debug_Script then exit;
writeln(x);
end;
{*******************************************************************************
procedure DeactivatePlayer(PlayerNum: Byte; Reason: string);
By: SRL Template
*******************************************************************************}
procedure DeactivatePlayer(PlayerNum: Byte; Reason: string);
begin
LogOut;
Players[PlayerNum].Loc := Reason;
Players[PlayerNum].Active := False;
srl_Warn('Player ' + IntToStr(PlayerNum) + ' (' +Players[PlayerNum].Nick + ')', 'deactivated -- ' + Reason, warn_Debug);
end;

procedure Antiban;
var
x, y: Integer;
begin
if (GetTimeRunning mod (10 * 60000)) = 0 then
Debug('Performing AntiBan');
case Random(15) of
0: MMouse(Random(500), Random(500), Random(MIX2), Random(MIX2));
1: SleepAndMoveMouse(Random(500));
2: IdleTime(Random(500), 2, 5.2);
3: begin
MMouse(Random(500), Random(500), Random(MIX2), Random(MIX2));
Wait(200 + Random(100));
if IsUpText('xamine') then
begin
GetMousePos(x, Y);
Mouse(x, y, 0, 0, False);
Wait(200 + Random(100));
ChooseOption('xamine');
end;
end;
4: PickUpMouse;
5: RandomRClick;
6: if MouseSpeed < 15 then
IncEx(MouseSpeed, Random(5))
else
DecEx(MouseSpeed, Random(5));
7: BoredHuman;
end;
end;

{*******************************************************************************
function SetXPTotal(Open: boolean): Boolean;
By: Narcle
Description: Opens the XP counter on the mainscreen.
*******************************************************************************}
function SetXPTotal(Open: boolean): Boolean;
begin
if (GetColor(512, 63) = 4160941) xor Open then
Mouse(519, 48, 29, 29, true);
end;

{*******************************************************************************
function GetXPTotal: boolean;
By: Narcle
Description: Returns the value of the XP in the counter.
*******************************************************************************}
function GetXPTotal: Integer;
begin
Result := StrToInt(ExtractFromStr(GetTextAtExWrap(452, 55, 512, 69, 0, 5, 4, clWhite, 0, 'XPChars'), numbers));
Debug('GetXPTotal: XP is '+IntToStr(Result)+'.');
end;

{*******************************************************************************
function Convert_To_Time(BreakTime: integer): string;
By: Bonfield
Description: Gets the current time and adds BreakTime in ms and dispays that time.
eg. Taking a break at 06:21:43 PM
Breaking for 10 minutes (10 * 60000)
Returning at 06:31:43 PM
*******************************************************************************}
function Convert_To_Time(BreakTime: integer): string;
var
Time, PA: string;
Hours, hh, Minutes, mm, Seconds, ss, Total_Ms : integer;
begin
Time := TheTime;

hh:= StrToInt(Time[1]) * 10 + StrToInt(Time[2]);
mm:= StrToInt(Time[4]) * 10 + StrToInt(Time[5]);
ss:= StrToInt(Time[7]) * 10 + StrToInt(Time[8]);
PA:= time[10]+time[11];

Hours:= (Hh * 3600000);
Minutes:= (Mm * 60000);
Seconds:= (Ss * 1000);
Total_Ms:= Hours + Minutes + Seconds + BreakTime

Result:= MsToTime(Total_Ms,3)+' '+PA;
end;

{*******************************************************************************
function function Take_Break: Integer;
By: Bonfield
Description: Break or switches players.
*******************************************************************************}
function Take_Break: Integer;
var
Break_Time: Integer;
begin
if Use_Breaks then
begin
if (GetTimeRunning mod (Players[CurrentPlayer].Integers[5] * 60000)) = 0 then
begin
Players[CurrentPlayer].Loc := 'Breaking.';
Result := Players[CurrentPlayer].Integers[6];
Logout;
writeln(thetime);
if (HowManyPlayers > 1) then
begin
NextPlayer(True);
end else
begin
writeln('Taking a break at '+TheTime);
Break_Time := (Result * 60000) + (RandomRange( - Random_Breaktime, Random_Breaktime) * 60000);
writeln('Breaking for ' + IntToStr(Break_Time / 60000) + ' minutes');
writeln('Returning at '+Convert_To_Time(Break_Time));
wait(Break_Time);
LoginPlayer;
end;
end;
end;
end;

{*******************************************************************************
function Check_Staff_Equiped: boolean;
By: Bonfield
Description: Checks Equipment tab for an Earth Staff.
*******************************************************************************}
function Check_Staff_Equiped: Boolean;
var
Earth_Staff, x, y: Integer;
begin
Earth_Staff := BitmapFromString(6, 3, 'beNpjYGJgYFKSFA4P' +
'Di7Jz6+OdGuM9XJ2dgAKVkcJVRQXAUVqo9yB3FhXPqBIWWEhkM0AA' +
'GD2DRs=');

GameTab(tab_Equip);
if FindBitmapToleranceIn(Earth_Staff, x, y, MIX1, MIY1, MIX2, MIY2, 15) then
begin
Result := True;
Debug('Check_Staff_Equiped: Found Earth Staff Bitmap.');
Writeln('Earth Staff Equiped.');
end else
begin
Writeln('Please Equip an Earth Staff!');
Players[CurrentPlayer].Loc := 'No earth staff.';
end;
FreeBitmap(Earth_Staff);
end;

{*******************************************************************************
function Check_Equipment: boolean;
By: Bonfield
Description: Checks for Earth Staff and that High Level Alchemy and Curse
can be casted also checks if there is anything in inventory slot 15
*******************************************************************************}
function Check_Equipment: Boolean;
var
Spell_Box: TBox;
begin
if not loggedin then Exit;
if ExistsItem(15) then
begin
Players[CurrentPlayer].Loc := 'Check Equipment';
Check_Staff_Equiped;
Gametab(tab_Magic);
if SpellAvailable(Spell_Box, 'High Level Alchemy') and SpellAvailable(Spell_Box, 'Curse') then
begin
Result := True;
Writeln('Have runes for High Level Alchemy and Curse.');
end else
begin
Writeln('Not enough runes to cast High Level Alchemy and Curse.');
Players[CurrentPlayer].Loc := 'Not enough Runes.';
end;
end else
begin
Writeln('Nothing exists in Inventory slot 15.');
Players[CurrentPlayer].Loc := 'Nothing in inv slot.';
end;
end;

{*******************************************************************************
function Load_NPC_Record: NPC;
By: Bonfield
Description: Loads the information for each NPC.
*******************************************************************************}
function Load_NPC_Record: NPC;
begin
if (Lowercase(Players[CurrentPlayer].Strings[0]) = 'high level alchemy') then Exit;
case Lowercase(Players[CurrentPlayer].Strings[0]) of

'zamorak monk', 'monk':
with MOB do
begin
Name := 'Zamorak Monk';
UpText := ['onk'];
Color := 2369905;
Hue_Mod := 0.02;
Sat_Mod := 0.09;
Tolerance := 11;
end;

'lesser demon', 'demon':
with MOB do
begin
Name := 'Lesser Demon';
UpText := ['demon', 'emo', 'mon'];
Color := 1318490;
Hue_Mod := 0.11;
Sat_Mod := 1.18;
Tolerance := 10;
end;
end;
end;

{*******************************************************************************
function Cast_NPC(Which_Spell: String) : Boolean;
By: Bonfield
Description: Finds the NPC and casts a spell.
*******************************************************************************}
function Cast_NPC(Which_Spell: String) : Boolean;
var
CTS, H, i, x, y, S_Mousespeed: integer;
NPC: TPointArray;
ATPA: T2DPointArray;
begin
if not loggedin then Exit;

CTS := GetColorToleranceSpeed;
S_Mousespeed := MouseSpeed

ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(MOB.Hue_Mod, MOB.Sat_Mod);

FindColorsSpiralTolerance(MSCX, MSCY, NPC, MOB.Color, MSX1, MSY1, MSX2, MSY2, MOB.Tolerance);
ATPA := TPAToATPAEx(NPC, 70, 65);

if Debug_Script then DebugATPA(ATPA,'');
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));

H := High(ATPA);
for i := 0 to H do
if MiddleTPAEx(ATPA[I], x, y) then
begin
MMouse(x, y, 0, 0);
if WaitUpTextMulti(MOB.UpText, 400) then
begin
Result := True;
Cast(Which_Spell, False);
MouseSpeed := (25 + Random(5));
Mouse(x, y, 5, 5, True);
Exit;
end;
end;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
MouseSpeed:= S_MouseSpeed;
end;

{*******************************************************************************
procedure Cast_Curse;
By: Bonfield
Description: Casts curse on the NPC loaded.
*******************************************************************************}
procedure Cast_Curse;
var
Start_Curse_XP, Finish_Curse_XP, t: Integer;
begin
if not loggedin then Exit;
if (Lowercase(Players[CurrentPlayer].Strings[0]) = 'high level alchemy') then Exit;

Players[CurrentPlayer].Loc := 'Cast_Curse';
t := GetTimeRunning;

Start_Curse_XP := GetXPTotal;
Gametab(tab_Magic);
Cast_Npc('Curse');
Wait(800);

Finish_Curse_XP := (GetXPTotal - Start_Curse_XP);
if (Finish_Curse_XP >= 29) then
begin
Writeln('Successfully casted Curse.');
FindNonInventoryRandoms;

Inc(Players[CurrentPlayer].Integers[1]);
Inc(TOT_Curses);

Inc(Script_Total[2]);
WriteINI('Script_Total', '2', IntToStr(Script_Total[2]), ScriptPath + 'ScriptStats.INI');
IncEx(Script_Total[3], 29);
WriteINI('Script_Total', '3', IntToStr(Script_Total[3]), ScriptPath + 'ScriptStats.INI') Inc(Stats_CustomVars[2]);

IncEx(Stats_CustomVars[3], 29);

if (FindNPCChatText('ongrat', Nothing) or FindNPCChatText('dvanced', Nothing) or FindNPCChatText('agic', Nothing)) then
begin
if Take_Screenshot then TakeScreenshotEx(AppPath+'\Scripts\Screenshots\', MSX1, MSY1, MSX2, MSY2);
Writeln('Magic level gained!');
Inc(Players[CurrentPlayer].Integers[3]);
Writeln('Congratulations ' + (Players[CurrentPlayer].Nick) + ' increased a Magic level.');
Players[CurrentPlayer].Loc := 'Increased magic level.';
end
end else
Writeln('Did not cast Curse.');
Inc(Curses_Failed);
end;

{*******************************************************************************
procedure Cast_High_Alchemy(x: Integer);
By: Bonfield
Description: Casts High Level Alchemy on a Inventory Spot.
*******************************************************************************}
procedure Cast_High_Alchemy(x: Integer);
var
Start_Alch_XP, Finish_Alch_XP, t: Integer;
TB: TBox;
begin
if not loggedin then Exit;
if (Lowercase(Players[CurrentPlayer].Strings[0]) = 'curse') then Exit;

Players[CurrentPlayer].Loc := 'Cast_High_Alchemy';
t := GetTimeRunning;

Start_Alch_XP := GetXPTotal;
GameTab(tab_Magic);
Cast('high level alchemy', false);

GetInvItemBounds(x, TB);
MouseBox(TB.X1, TB.Y1, TB.X2, TB.Y2, 1);
Wait(800);

Finish_Alch_XP := (GetXPTotal - Start_Alch_XP);
if (Finish_Alch_XP >= 65) then
begin
Debug('Cast_High_Alchemy -' + MOB.Name + ' took ' + IntToStr(GetTimeRunning - t) + ' msec.');
Writeln('Successfully casted High Alchemy.');
FindNonInventoryRandoms;

Inc(TOT_High_Alches);
Inc(Players[CurrentPlayer].Integers[0]);

Inc(Script_Total[1]);
WriteINI('Script_Total', '1', IntToStr(Script_Total[1]), ScriptPath + 'ScriptStats.INI');
IncEx(Script_Total[3], 65);
WriteINI('Script_Total', '3', IntToStr(Script_Total[3]), ScriptPath + 'ScriptStats.INI') Inc(Stats_CustomVars[1]);

IncEx(Stats_CustomVars[3], 65);

Players[CurrentPlayer].Integers[2] := ((Players[CurrentPlayer].Integers[0] * 65) + (Players[CurrentPlayer].Integers[1] * 29));

if (FindNPCChatText('ongrat', Nothing) or FindNPCChatText('dvanced', Nothing) or FindNPCChatText('agic', Nothing)) then
begin
if Take_Screenshot then TakeScreenshotEx(AppPath+'\Scripts\Screenshots\', MSX1, MSY1, MSX2, MSY2);
Writeln('Magic level gained!');
Inc(Players[CurrentPlayer].Integers[3]);
Writeln('Congratulations ' + (Players[CurrentPlayer].Nick) + ' increased a Magic level.');
Players[CurrentPlayer].Loc := 'Increased magic level.';
end
end else
Writeln('Did not cast High Alchemy.');
end;

{*******************************************************************************
function Out_Of_Runes : Boolean;
By: Bonfield
Description: Looks for chat message to show there are not enough runes to
cast a spell
*******************************************************************************}
function Out_Of_Runes: Boolean;
begin
Result := Pos('enough', GetChatBoxText(8, clBlack)) > 0;
Players[CurrentPlayer].Loc := 'Out of Runes.';
end;

{*******************************************************************************
function Count_Item(i: Integer): Integer;
By: Bonfield
Description: Returns the number of stacked items in the inventory slot.
*******************************************************************************}
function Count_Item(i: Integer): Integer;
var
TB: TBox;
begin
TB := InvBox(i);
Result := StrToInt(ExtractFromStr(GetTextAtExWrap(TB.X1, TB.Y1, TB.X2, TB.Y2, 0, 15, 10, clYellow, 50, 'StatChars'), numbers));
Debug('Count_Item: '+IntToStr(Result)+'.');
end;

{*******************************************************************************
procedure Curse_And_Alch;
By: Bonfield
Description: Casts Curse and High Level Alchemy.
*******************************************************************************}
procedure Curse_And_Alch;
begin
if not loggedin then Exit;
repeat
Cast_Curse;
Cast_High_Alchemy(15);
until Out_Of_Runes or (Players[CurrentPlayer].Integers[0]>= Players[CurrentPlayer].Integers[4]);
end;

{*******************************************************************************
function SRLProgressReport(
ResultType:integer; ScriptName, ScriptAuthor, ScriptVersion: String;
VarNames: TStringArray;
VarValues: TVariantArray
): Variant;
By: Rasta Magician
Description: Prints a Standardized Progress Report, with the variables of your choice
*******************************************************************************}
procedure Progress_Report;
var
XP_per_Hour, XP_Gained : Integer;
begin
if (GetTimeRunning mod (10 * 60000)) = 0 then

XP_Gained := (TOT_High_Alches * 65) + (TOT_Curses * 29);
XP_per_Hour := Round(XP_Gained / (GetTimeRunning / 3600000.0));

IncEx(Script_Total[0], GetTimeRunning);
WriteINI('Script_Total', '0', IntToStr(Script_Total[0]), ScriptPath + 'ScriptStats.INI')

SRLProgressReport(
ResultDebugBox, 'Alch and Curse', 'Bonfield', ScriptVersion,
['Time Running','High Alch Casted', 'Curses Casted','XP Gained', 'XP per hour'],
[TimeRunning, TOT_High_Alches, TOT_Curses, XP_Gained, XP_per_Hour ]
);

SRLPlayerReport(
ResultDebugBox, 6, False,
[True, False, True, True, False, False],
['High Alchs', 'Curses', 'XP Gained', 'Levels Gained'],
[], [0,1,2,3], [], []
);

end;

{*******************************************************************************
procedure Script_Totals;
By: Bonfield
Description: Displays the totals for each script user.
*******************************************************************************}
procedure Script_Totals;
var
i : Integer;
begin
for i := 0 to 4 do
Script_Total[i] := StrToIntDef(ReadINI('Script_Total', IntToStr(i), ScriptPath + 'ScriptStats.INI'), 0);

Writeln(' Total Time Ran : ' + MsToTime(Script_Total[0], Time_Formal));
Writeln(' Total High Alches : ' + IntToStr(Script_Total[1]));
Writeln(' Total Curses : ' + IntToStr(Script_Total[2]));
Writeln(' Total XP Gained : ' + IntToStr(Script_Total[3]));
Writeln(' Script Runs : ' + IntToStr(Script_Total[4]));
end;

{*******************************************************************************
procedure Setup_Script;
By: Bonfield
Description: Sets the script up
*******************************************************************************}
procedure Setup_Script;
begin
if not DirectoryExists(AppPath+'\Scripts\Screenshots') then CreateDirectory(AppPath+'\Scripts\Screenshots');

SetUpSRL;
SRLRandomsReport;

Stats_ScriptID := '66';
Stats_UserID := YourStatsUserID;
Stats_Password := YourStatsPass;


Stats_SendReport;
Stats_ManageAccounts;

DeclarePlayers;
Load_NPC_Record;
Inc(Script_Total[4]);
WriteINI('Script_Total', '4', IntToStr(Script_Total[4]), ScriptPath + 'ScriptStats.INI');
Script_Totals;
ActivateClient;
end;

{*******************************************************************************
procedure Setup_Player;
By: Bonfield
Description: Sets up each player
*******************************************************************************}
procedure Setup_Player;
begin
LogInPlayer;
if (SRL_Logs < 1) then SRL_Logs := 1;
//FindNormalRandoms; gets stuck here for me
if (not LoggedIn) then exit;

// GetAllLevels; gets stuck here for me

SetAllChats('on', 'off', 'on', 'off', 'off', 'off');
SetXPTotal(True);

//Check_Equipment; gets stuck here for me

SetAngle(True);
case Lowercase(Players[CurrentPlayer].Strings[0]) of
'zamorak monk', 'monk', 'lesser demon', 'demon': MakeCompass('W');
end

Players[CurrentPlayer].Integers[4]:= Count_Item(15);
end;

procedure Main_Loop;
begin
Setup_Script;
repeat
Setup_Player;
repeat
Cast_Curse;
Progress_Report;
Antiban;
Take_Break;
until (AllPlayersInactive);
until(false);
end;

var i :integer;

begin
SetupSRL;
DeclarePlayers;
Load_NPC_Record;
repeat
inc(i);
//Cast_Curse;
Cast_High_Alchemy(15);
until i>= 10;
end.

{ Integers[0] := High Alches Casted Script_Total[0] := Total time ran Stats_CustomVars[1] := High Alchs
Integers[1] := Curses casted Script_Total[1] := Total High Alches Stats_CustomVars[2] := Curses
Integers[2] := XP gained Script_Total[2] := Total Curses Stats_CustomVars[3] := XP Gained
Integers[3] := Levels gained Script_Total[3] := Total XP Gained
Integers[4] := Inv Amount Script_Total[4] := Total Starts
Integers[5] := Time till break
Integers[6] := Time to break for

}

Thanks in advance
Bonfield

nielsie95

2010-08-26 04:42:08

Maybe SRL's cast() is not working properly?

Bonfield

2010-08-26 05:37:06

I'm not sure, nothing I try works but I asked Ian about it and he tried the script and he said it did cast curse but had trouble finding the zamorack Mage when he moved

Did anyone want to borrow an account to test this script?