PDA

View Full Version : Ultimate Alcher



BazzBarrett
07-19-2011, 08:16 PM
Bazzbarretts Ultimate Alcher

This script will alch (almost flawlessly) using high alch or low alch, works with members and non members and on any item you want.

to run just start the script with fire staff equiped and nature runes + alch item(s) in your inventory

Features:
can work on more than one items in a session.
high alch and low alch
fancy on screen proggy with time till next level
alot of failsafes
alchs like a human (sets up items for minimal clicking)
breaks
antiban (i feel like i need to credit some one for this...)

post any bugs/proggys below :)

program new;
{$DEFINE SMART}
{$i SRL\SRL.scar}
{$i SRL\SRL\misc\arrayloader.scar}
{$i Reflection\reflection.simba}
{$i SRL/SRL/Misc/paintsmart.scar}

type
{Contains informations pertaining to Interface Components [aka child]
From new reflcetion needed for MMouseSpell}
TInterfaceComponent = record
Actions: TStringArray;
ID, ParentID, Stack: Integer;
TextureID, ModelID, ModelZoom: Integer;
RelativeX, RelativeY, Width, Height: Integer;
X, Y: Integer;
Bounds: TBox;
Text, Name: String;
IsHidden: Boolean;
end;

Var
BlueB : Integer;
AlchSpell, AlchSlot, AlchsDone, T, StartNats, NatSlot, TTotal, TimeTillBreak :Integer;
Items: Array of string;
LOW_ALCH, HIGH_ALCH, MEMBER: Boolean;

{************************************************* ***********************************
Edit this bit

************************************************** ***********************************}
procedure DeclarePlayers;
begin
LOW_ALCH := False; // Low alch?
HIGH_ALCH := True; // High alch?
Items := ['Iron platebody', 'Gold bracelet']; // Item(s) your are alching
MEMBER := True; //is the acount members?

HowManyPlayers := 1; // How many players are we using?
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := ''; // Username
Players[0].Pass := ''; // Password
Players[0].Pin := '';
Players[0].Active := True; // Use player?
end;

{************************************************* ***********************************
Dont Edit Below here!

************************************************** ***********************************}

Procedure Fail(reason: String);
begin
FreeBitmap(BlueB);
closebank;
logout;
writeln(' ');
Writeln('Script terminated:');
writeln(reason);
terminatescript;
end;

{************************************************* ******************************
Function R_GetInterface(Index, ChildIndex: Integer): Integer;
By: Bobarkinator
Description: Returns the interface of InterfaceCache[Index][ChildIndex].
************************************************** *****************************}
function R_GetInterface(Index, ChildIndex: Integer): Integer;
begin
Result := SmartGetFieldArray2DObject(0, hook_static_GetInterfaces, Index, ChildIndex);
end;

{************************************************* ******************************
function R_GetAbsolutePos(Parent, Child, Component: Integer): TPoint;
By: Drags111
Description: Returns the absolute x and y of the interface or interface
component. If it is NOT a component, set Component to be -1.
Example: to get the bank's close button absolute pos:
R_GetAbsolutePosition(762, INTERFACE_BANK_BUTTON_CLOSE, -1);
Example 2: To get an item's position in the bank:
R_GetAbsolutePosition(762, INTERFACE_BANK_SLOTS, 7);
************************************************** *****************************}
function R_GetAbsolutePos(Parent, Child, Component: Integer): TPoint;
var
inter, PID, rx, ry, comp: Integer;
BoundsIndex, BoundsObject: Integer;
begin
try
if(Component > -1)then
begin
comp := R_GetInterface(Parent, Child);
inter := SmartGetFieldArrayObject(comp, hook_interface_GetChildren, Component);
end else
inter := R_GetInterface(Parent, Child);
PID := SmartGetFieldInt(inter, hook_interface_GetParentID);

if(PID > 0)then
begin
Result := R_GetAbsolutePos(PID shr 16, PID and $FFFF, -1);
end else
begin
BoundsIndex := SmartGetFieldInt(inter, hook_interface_GetBoundsArrayIndex);
BoundsObject := SmartGetFieldArrayObject(0, hook_static_GetInterfaceBoundsArray, BoundsIndex);
if(BoundsObject > 0)then
begin
Result.x := SmartGetFieldInt(BoundsObject, 'x');
Result.y := SmartGetFieldInt(BoundsObject, 'y');
end;
end;

rx := SmartGetFieldInt(inter, hook_interface_GetX) + Result.x;
ry := SmartGetFieldInt(inter, hook_interface_GetY) + Result.y;

if(SmartGetFieldInt(inter, hook_interface_GetHorizontalScrollBarSize) <> 0)then
rx := rx - SmartGetFieldInt(inter, hook_interface_GetHorizontalScrollBarPosition);
if(SmartGetFieldInt(inter, hook_interface_GetVerticalScrollBarSize) <> 0)then
ry := ry - SmartGetFieldInt(inter, hook_interface_GetVerticalScrollBarPosition);

Result := Point(rx, ry);

finally
SmartFreeObject(inter);
SmartFreeObject(BoundsObject);
end;
end;

Function R_GetSpellCoords(SpellID:Integer):Tpoint;
begin
Result := R_GetAbsolutePos(192, SpellID, -1);
end;

{ Custom spell uses reflection to MMouse a spell
NORMAL = normal book
false = lunar }
Procedure R_MMouseSpellEX( SpellID: Integer; Normal:Boolean);
var
info: TPoint;
Book, tmod: Integer;
begin
if member then tmod := 15;
if Normal then Book := 192 else book := 430;
if GameTab(TAB_MAGIC) then
begin
info := R_GetAbsolutePos(book, SpellID, -1);
if IntInBox(Info.X, Info.Y, IntToBox(547, 205, 737, 430)) then //spell vissible?
MouseBox(info.X + tmod, info.Y + tmod, info.X+24, info.Y+24, 3) //move mouse
else begin
mouse(727, 385, 3, 5, true); //scroll down
if IntInBox(Info.X, Info.Y, IntToBox(547, 205, 737, 434)) then //spell vissible now?
MouseBox(info.X + tmod, info.Y + tmod, info.X+24, info.Y+24, 3) //move mouse
else
writeln('MMouseSpell Failed');
end;
end;
end;

Procedure R_MMouseSpell( SpellID: Integer);
begin
R_MMouseSpellEX(SpellID, true);
end;

procedure R_MouseSpellEX( SpellID: Integer; Normal:Boolean);
begin
R_MMouseSpellEX(SpellID, Normal);
ClickMouse2(true);
end;

procedure R_MouseSpell( SpellID:Integer);
begin
R_MMouseSpell(SpellID);
ClickMouse2(true);
end;

function RC_WaitUpText(s :String; t : Integer):Boolean;
begin
Result := true;
if not R_waitUpText(s, t) then
result := WaitUpText(s, t);
end;

Procedure SetupPlayer;
var
I, ML: Integer;
begin
FindNormalRandoms;
MouseSpeed:=10+random(5);
if LOW_ALCH = HIGH_ALCH then fail('please select high alch or low alch, not both');
LoginPlayer;
wait(1500);
NatSlot := -1;
ML := R_GetSkillLevel('magic');
if ML < 21 then Fail('Magic lvl is too low');
if (ML < 55) and HIGH_ALCH then Fail('Magic lvl is too low');
for I := 0 to 27 do
begin
if GetItemNameAt(I) = 'Nature rune' then
begin
startnats := GetItemStackSizeAt(I);
natslot := I;
end;
if (I = 27) and (NatSlot = -1) then Fail('No Nature runes found');
end;
//MakeCompass('e');
end;

Function AntiBanEx:Boolean;
begin
Result := true;
Case random(2000) of
0..2,20..30: HoverSkill('magic',false);
3..6: RandomRClick;
7..14: PickUpMouse;
15..16: RandomMovement;
17: BoredHuman;
18: ExamineInv;
19: RandomAngle(random(1));
31..2000: Result := false;
end;
if result then GameTab(TAB_MAGIC);
end;

procedure takeabreak;
begin
if (getsystemtime-T) > TimeTillBreak then
begin
logout;
writeln('taking a break :)');
wait(randomrange(600000,1500000));
writeln('ok lets go again');
loginplayer;
T := Getsystemtime;
TimeTillBreak := Randomrange(2700000, 5400000);
end;
end;

procedure fixbook;
begin
GameTab(TAB_MAGIC);
if SimilarColors(getcolor(727, 238), 4807781, 10) and HIGH_ALCH then mouse(727, 385, 3, 5, true);
if SimilarColors(getcolor(725, 227), 4807781, 10) and LOW_ALCH then
dragmouse(727, 303, 0, 4, 727, 317, 0, 4);
end;

Procedure SetupItems;
var I, x, y:Integer;
begin
if high(items) > -1 then
begin
for I := 0 to high(items) do
Items[I] := Lowercase(Items[I]);
end;
If Not LoggedIn then terminatescript;
If(R_BankScreen) Then CloseBank;
for I := 0 to 28 do
begin
if(StrInArr(lowercase(GetItemNameAt(I)),items)) then
begin
if I = AlchSlot then exit;
MMouseItem(I);
getmousepos(x, y);
DragMouse(x, y, 0, 0,Itemcoords(AlchSlot).x, Itemcoords(AlchSlot).y, 5, 5);
wait(randomrange(600,1200));
exit;
end;
end;
Fail('no Items found :(');
end;

Procedure SetupAlch;
var
SpellCoord: Tpoint;
begin
blueB := BitmapFromString(280, 100, 'meJztwkERAAAMAqD+EYxmBVOs' +
'xh5wrJmqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq qqqq' +
'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq qqqq' +
'qqqqqqqqr/HiMPHZ8=');
if High(Items) < 0 then Fail('No items to alch selected');
GameTab(TAB_MAGIC)
fixbook;
wait(100);
SpellCoord := R_GetSpellCoords(alchspell);
AlchSlot := CoordsToItem(SpellCoord.x, spellcoord.y);
if alchslot = 0 then AlchSlot := CoordsToItem(SpellCoord.x+25, spellcoord.y+10);
end;

procedure Report(witch : String);
var
MSToNxtLvl, AlchsPerHour, Time, AD, xp : extended;
begin
case witch of
'alch':
begin
Alchsdone := StartNats - GetItemStackSizeAt(NatSlot);
if LOW_ALCH then xp := alchsdone * 31
else xp := alchsdone * 65;
time := (getsystemtime - TTotal);
AD := Alchsdone;
AlchsPerHour := (AD div time)*3600000;
MsToNxtLvl := R_ExpToNextLevel('magic');
MsToNxtLvl := MsToNxtLvl / (AlchsPerhour * 65);
MsToNxtLvl := MsToNxtLvl * 3600000;
ClearRSCanvas(SMART_Canvas.canvas);
DrawBitmap(BlueB, SMART_Canvas.canvas, 5, 237);
SMART_DrawTextEx(false, 15, 242, loginchars, 'Mage lvl: ' + inttostr(R_GetSkillLevel('magic')), 65535);
SMART_DrawTextEx(False, 15, 257, loginchars, 'Alchs done: '+Inttostr(alchsdone), 65535);
SMART_DrawTextEx(False, 15, 272, loginchars, 'Alchs Per Hour: ' + inttostr(floor(AlchsPerHour)), 65535);
SMART_DrawTextEx(False, 15, 287, loginchars, 'Xp gained: ' + inttostr(floor(xp)), 65535);
SMART_DrawTextEx(False, 15, 302, loginchars, 'Time Run: ' + MsToTime(GetTimeRunning, Time_Short), 65535);
SMART_DrawTextEx(False, 15, 317, loginchars, 'Time Till next Lvl: ' + MsToTime(floor(mstonxtlvl), Time_Short), 65535);
end;
end;
end;

procedure WaitBetweenClicks;
begin
if not LOW_ALCH then wait(900+random(300)-random(300)); //models a real persons clicking behaviour
end;

procedure Alch;
var
Fails :integer;
begin
if Not Loggedin then terminatescript;
FindNormalRandoms;
Gametab(Tab_Magic);
fixbook;
R_MouseSpell(alchspell);
repeat
if AntibanEx then
begin
Gametab(Tab_Magic);
fixbook;
R_MouseSpell(alchspell);
end;
if RC_WaitUpText('options', 2000) then
begin
Fails := 0;
FindNormalRandoms;
if Not R_ItemSlotExists(NatSlot) then
begin
fail('Out of nature runes');
end;
clickmouse2(true);
Waitbetweenclicks;
levelup;
if RC_WaitUpText('lch', 2000) then
begin
wait(200);
clickmouse2(true);
end else exit;
Waitbetweenclicks;
Report('alch');
TakeABreak;
end else
begin
if IsUpText('options') then
begin
writeln('its ok reflection is retarded');
Fails := 0;
FindNormalRandoms;
clickmouse2(true);
Waitbetweenclicks;
levelup;
clickmouse2(true);
Waitbetweenclicks;
Report('alch');
TakeABreak;
end else
begin
FindNormalRandoms;
if Not R_ItemSlotExists(AlchSlot) then
begin
setupitems;
exit;
end;
Gametab(Tab_Magic);
fixbook;
R_MouseSpell(alchspell);
inc(Fails);
if Fails > 3 then
Fail('were stuck in a loop. terminateing script');
end;
end;
until(false);
end;


procedure startsetup;
begin
Smart_Server := 36;
Smart_Members:= false;
Smart_Signed := True;
Smart_SuperDetail := False;
Cleardebug;
SetupSRL;
SetupReflection;
SMART_SetupDebug;
T := getsystemtime;
TTotal := T;
TimeTillBreak := Randomrange(2700000, 5400000);
end;

procedure AlchMain;
begin
SetupAlch;
setupItems;
repeat
Alch;
until(false);
end;

begin
StartSetup;
DeclarePlayers;
setupplayer;
If LOW_ALCH then alchspell := 38 else alchspell := 59;
AlchMain;
end.

footballjds
07-19-2011, 08:22 PM
pretty large script for just alching (:
but looks nice. grats on the release

Shuttleu
07-19-2011, 08:25 PM
what would happen if i set high and low alch both to true or false?

also maybe make it a single option for each player

~shut

EDIT: change this line

if LOW_ALCH and HIGH_ALCH then

to

if LOW_ALCH = HIGH_ALCH then

EDIT: or like i said, have it as one bool and have it in the Players[x]

BazzBarrett
07-19-2011, 08:28 PM
what would happen if i set high and low alch both to true or false?

also maybe make it a single option for each player

~shut

both to true it will come up with a warning and end. not sure about both to false. oh yer and it does not support multiplayer i forgot about that. ill add that in later.

Shuttleu
07-19-2011, 08:29 PM
both to true it will come up with a warning and end. not sure about both to false. oh yer and it does not support multiplayer i forgot about that. ill add that in later.

change this line

if LOW_ALCH and HIGH_ALCH then

to

if LOW_ALCH = HIGH_ALCH then

or like i said, have it as one bool and have it in the Players[x]

~shut

footballjds
07-19-2011, 08:31 PM
why not just have HIGH_ALCH.
OBVIOUSLY if your not high alching your low alching :p

BazzBarrett
07-19-2011, 08:37 PM
why not just have HIGH_ALCH.
OBVIOUSLY if your not high alching your low alching :p

originaly it was gonna be a huge script that did alching plank making and auto heating, with a GUI how ever i never made the auto heater bit and alot of the script was built around the idea of all 4 (hence high alch and low alch option(and support for the lunar spellbook)) the script is not very idiot proof as well because the alching part was origionaly a personal script. :p

Shuttleu
07-19-2011, 08:54 PM
i always like to keep my script dynamic, make all of the changable bits a global var and set them at the start of the user, so things like the spell and the item, it makes adding things and extending the script much easier

for a example take a look at my catherby fisher (red bar in siggy)

~shut

fanboy
08-01-2011, 02:14 AM
this works great! did a test run with a thousand magic longs and there wasn't a single problem that i saw, the on screen proggy is pretty cool to :D i don't have a way to put it on here though :/ but it finished the longs in record time since i always get bored of clicking lol. great script.

blother
08-01-2011, 02:46 AM
both to true it will come up with a warning and end. not sure about both to false. oh yer and it does not support multiplayer i forgot about that. ill add that in later.

I don't think there is really need for multiplayer for an alching script. I rarely see anyone adding multiplayer lately. Most of the scripts now are more focused on leveling mains and what not, which is definitely a good thing :D

fanboy
08-04-2011, 04:42 AM
i'm loving this script iv'e done 10k magic longs and my magic level is going up so much easier :D it seems flawless!

onilika
08-05-2011, 09:04 AM
Great Script! Really great script, Bazz!
I've used it to high alch all items I've done at crafting! It saved me a lot of time!
Keep making these kind of scripts...good and efficient! *thumbs up*

Mike408
08-23-2011, 03:39 AM
This script always crashes for me. Idk why :S

anthurium
08-23-2011, 12:57 PM
it keeps saying "magic level too low" and terminates the script.
My magic level is 72?

otavioafm
09-01-2011, 09:00 PM
outdated =/, can you fix?

FEAR
09-03-2011, 07:46 AM
outdated =/, can you fix?

Use Smurg's JackofAllTrades http://villavu.com/forum/showthread.php?t=62146

Mr. Bottomtooth
09-05-2011, 06:58 PM
outdated =/, can you fix?

MSI Alcher works nicely as well. http://villavu.com/forum/showthread.php?t=57723