pyroryan
2010-02-11 19:31:30
Alright guys, here's my first script. It's an alcher, and does more than 1k alchs an hour. This script is derived from Coh3n's woodcutting script, so all, and I do mean all, credit should go to him. There is no stats, so all feedback will have to be from you guys. It checks for randoms, and takes a break every hour or so.
If the script can't solve a random after 5 tries it logs out. Not being able to solve the randoms is an SRL issue, not a scripting issue. The best I can do is to increase the opportunities that it has to search for the randoms. As of this writing, the script will find the randoms, but fails to solve any teleport randoms. Once again, this seems to be an SRL issue.
Instructions, please follow correctly:
1. Equip fire staff.
2. Place item to alch in noted form in the 3rd inventory slot.
3. Hide combat, teleport and skill spells. (VERY IMPORTANT)
4. Turn off all chat but game.
5. Make sure you have enough nature runes in your inventory.
6. Set the number of items to alch. Do not put a number higher than the number of items you have.
7. Post any progress reports and/or bugs!
If the script can't solve a random after 5 tries it logs out. Not being able to solve the randoms is an SRL issue, not a scripting issue. The best I can do is to increase the opportunities that it has to search for the randoms. As of this writing, the script will find the randoms, but fails to solve any teleport randoms. Once again, this seems to be an SRL issue.
Instructions, please follow correctly:
1. Equip fire staff.
2. Place item to alch in noted form in the 3rd inventory slot.
3. Hide combat, teleport and skill spells. (VERY IMPORTANT)
4. Turn off all chat but game.
5. Make sure you have enough nature runes in your inventory.
6. Set the number of items to alch. Do not put a number higher than the number of items you have.
7. Post any progress reports and/or bugs!
{==============================================================================]
[ Instructions ]
[==============================================================================]
[ ]
[ 1. Equip fire staff. ]
[ 2. Place item to alch in noted form in the 3rd inventory slot. ]
[ 3. Hide combat, teleport and skill spells. (VERY IMPORTANT) ]
[ 4. Turn off all chat but game. ]
[ 5. Make sure you have enough nature runes in your inventory. ]
[ 6. Post any progress reports and/or bugs! ]
[ 7. Determine whether or not you're using SMART (line 16). ]
[ Created by pyroryan. Major credit to Coh3n for letting me use his script ]
[ as a base. ]
[ ]
[==============================================================================}
program AutoAlch;
{.Include srl\srl\Misc\Smart.scar}
{.Include srl\srl.scar}
{.Include srl\srl\Misc\Debug.scar}
const
// Integers.
TAlchs = 0;
Alchs = 1;
LEVELS = 2;
EXP = 3;
BREAKS = 4;
// Booleans.
TAKE_BREAKS = 0;
// Strings.
LAMP_SKILL = 0;
{ const Mouse Constants;
Description: Constants representing different types mouse clicks. }
const
MOUSE_OPTIONS = 3;
CLICK_LEFT = 1;
CLICK_RIGHT = 2;
HOVER = 3;
{ var Global;
Description: Global variables used throughout the script. }
var
srl_MMTPA: TPointArray;
startLevel: Integer;
{==============================================================================]
[ Setup the script from here to line 77! ]
[==============================================================================}
const
SMART_WORLD = 152; // World to load.
SMART_MEMBERS_WORLD = False; // True = Members world.
SMART_HIGH_DETAIL = False; // True = High detail.
SMART_SIGNED_CLIENT = True; // True = Signed client.
const
RANDOM_SOUND = False; // True = a sound when a random is found.
BREAK_TIME = 10; // How long to break for (in minutes).
// Script will +/- a random 5 minutes.
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := 'Username';
Pass := 'Password';
Nick := ''; // 3-4 LOWERCASE letters from your username.
Active := True; // True = use this player.
Integers[TAlchs] := 450; // Total times to alch.
Booleans[TAKE_BREAKS] := True; // True = the script will take breaks.
Strings[LAMP_SKILL] := 'Magic';
BoxRewards := ['amp', 'mote', 'ostume', 'oins', 'unes', 're', 'ems'];
Integers[LEVELS] := 0; //Do not edit this.
end;
end;
{==============================================================================]
[ Don't edit below this ]
[==============================================================================}
{*******************************************************************************
function AC_CircleTPA(cX, cY, r: Integer): TPointArray;
By: Nava2
Description: Creates a TPA of a circle with radius 'r' and center point cX, cY.
*******************************************************************************}
function AC_CircleTPA(cX, cY, r: Integer): TPointArray;
var
i, j, l, tX, tY: Integer;
begin
setLength(Result, 4 * r * r);
l := 2 * r - 1;
tX := cX - r;
tY := cY - r;
for i := 0 to l do
for j := 0 to l do
Result[j + l * i] := Point(tX + i, tY + j);
Result := RemoveDistTPointArray(cX, cY, r, Result, True);
end;
{*******************************************************************************
function AC_ReturnMMTPA: TPointArray;
By: Nava2
Description: Performs AC_CircleTPA for the RS minimap.
*******************************************************************************}
function AC_ReturnMMTPA: TPointArray;
begin
if High(srl_MMTPA) < 0 then
begin
Result := AC_CircleTPA(MMCX, MMCY, (MMX2 - MMX1) div 2);
srl_MMTPA := Result;
end else
Result := srl_MMTPA;
end;
procedure Load_Antiban;
var
i, x, y: Integer;
begin
case Random(40) of
0: begin // Boredhuman without camera movement.
Writeln('Performing Antiban - Boredhuman.');
if not LoggedIn then Exit;
for i := 1 to (1 + Random(5)) do
begin
MMouse(Random(MSX2), Random(MSY2), 0, 0);
if IsUpText('opti') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
ChooseOption('Examine');
end;
end;
end;
10: begin
Writeln('Performing Antiban - HoverSkill[Random].');
HoverSkill('random', False);
end;
20: begin
Writeln('Performing Antiban - RandomRClick.');
RandomRClick;
end;
30: begin
Writeln('Performing Antiban - HoverSkill[Magic].');
HoverSkill('magic', False);
end;
40: begin
Writeln('Performing Antiban - PickUpMouse.');
PickUpMouse;
end;
end;
end;
procedure Next_Break;
begin
if (not LoggedIn) then
Exit;
begin
Writeln('Taking a ' + IntToStr(BREAK_TIME) + ' minute break.');
Logout;
Wait((BREAK_TIME * 60000) + RandomRange(-300000, 300000));
Writeln('Break over, logging back in.');
LoginPlayer;
end;
with Players[CurrentPlayer] do
Integers[BREAKS] := Integers[BREAKS] + 1;
end;
procedure Find_Randoms;
var
soundStr: String;
begin
if (not LoggedIn) then
Exit;
LampSkill := Lowercase(Players[CurrentPlayer].Strings[LAMP_SKILL]);
Writeln('Scanning for random events...');
if (FindNormalRandoms) then
begin
if (RANDOM_SOUND) then
begin
PlaySound(ScriptPath + 'RandomSound.wav');
soundStr := 'Playing Random Sound.';
end;
Writeln('Found Random! ' + soundStr);
end;
UseRewardBox;
FindLamp(LampSkill);
end;
procedure Setup_Report;
begin
Writeln('[=================================================================]');
Writeln(PadR('[ Auto Alch ', 66) + ']');
Writeln('[=================================================================]');
Writeln('[ ]');
with Players[CurrentPlayer] do
begin
Writeln(PadR('[ Ran For: ' + TimeRunning, 66) + ']');
Writeln(PadR('[ Items Alched: ' + IntToStr(Integers[Alchs]), 66) + ']');
Writeln(PadR('[ Levels Gained: ' + IntToStr(Integers[LEVELS]), 66) + ']');
Writeln(PadR('[ Breaks: ' + IntToStr(Integers[BREAKS]), 66) + ']');
end;
Writeln('[ ]');
Writeln('[=================================================================]');
Writeln('[=================================================================]');
end;
procedure Setup_Player;
begin
LoginPlayer;
SetAngle(True);
startLevel := GetSkillLevel('magic');
Writeln('Current Magic Level: ' + IntToStr(startLevel) + '.');
end;
procedure Setup_Script;
begin
Smart_Server := SMART_WORLD;
Smart_Signed := SMART_SIGNED_CLIENT;
Smart_SuperDetail := SMART_HIGH_DETAIL;
Writeln('Loading, please wait...');
SetupSRL;
ActivateClient;
DeclarePlayers;
Disguise('Items alched: 0');
end;
procedure Alch_items;
var
a,b,r: Integer;
begin
if (not LoggedIn) then
Exit;
begin
a:=0;
r:=0;
b:=RandomRange(40, 50);
repeat
if(GameTab(tab_Magic)) then
begin
Mouse(643+RandomRange(-5,5), 230+RandomRange(-5,5), 3, 3, True);
Wait(RandomRange(100, 200));
Mouse(660+RandomRange(-5,5), 228+RandomRange(-5,5), 3, 3, True);
Wait(RandomRange(1000, 1200));
a:=a+1;
r:=0;
with Players[CurrentPlayer] do
begin
Integers[Alchs] := Integers[Alchs] + 1;
Disguise('Items Alched: ' + IntToStr(Players[CurrentPlayer].Integers[Alchs]));
if (FindNPCChatText('ongrat', Nothing) or FindNPCChatText('dvanced', Nothing) or FindNPCChatText('ulatio', Nothing) or FindNPCChatText('agic', Nothing)) then
begin
Writeln('Magic level gained!');
with Players[CurrentPlayer] do
begin
Integers[Levels] := Integers[Levels] + 1;
end;
end;
if(Integers[Alchs]=Integers[TAlchs]) then
begin
Writeln('Alched desired number of items, exiting.');
Setup_Report;
Logout;
TerminateScript;
end;
end;
end else
begin
Writeln('Can''t find magic tab, possibly in a random!');
Find_Randoms;
r:=r+1;
if (r=5) then
begin
Writeln('Can''t find magic tab or solve random after 5 tries, exiting.');
Setup_Report;
Logout;
TerminateScript;
end;
end;
until(a>b);
Wait(RandomRange(100, 1000));
Find_Randoms;
Load_Antiban;
end;
end;
procedure Setup_MainLoop;
var
sinceLogin: Integer;
begin
Setup_Script;
sinceLogin := 0;
MarkTime(sinceLogin);
Setup_Player;
repeat
Alch_items;
if (Players[CurrentPlayer].Booleans[TAKE_BREAKS]) then
if (TimeFromMark(sinceLogin) >= (60*60000+RandomRange(-300000, 300000))) then
begin
Setup_Report;
Next_Break;
MarkTime(sinceLogin);
end;
until(AllPlayersInactive);
end;
begin
Setup_MainLoop;
end.
