Simba Code:
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' +
'xh5wrJmqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq' +
'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq' +
'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.