SRL Archive - OSR Help

Aero - Scripting Help


icode

2014-11-09 19:28:05

Information:
Hello all I am trying to write an Aero script that superheats steel bars. (Please refrain from hate/flame)

I am using Fitta's Alcher as a base script due to this being the first time I am scripting with Aero.

Code credits to @Fitta

Here is the current code:
program icodeheater;
{$i AeroLib/AeroLib.Simba}


const
LIMIT = 10;
LOGOUT_WHEN_DONE = TRUE;
Version = '0.9';
INPUT_YES = 6;
INPUT_NO = 7;
INPUT_CANCEL = 2;

var
GLOBAL_DONE, GLOBAL_ItemAmount: Integer;
GLOBAL_HEATBOX: TBox;

procedure SetupScript;
var
Info_s: string;
action: integer;
begin
if FileExists(ScriptPath + 'playersetup.ini') then
begin
Me.Name := ReadINI('playersetup', 'username', ScriptPath + 'playersetup.ini');
Me.Pass := ReadINI('playersetup', 'password', ScriptPath + 'playersetup.ini');
action := MessageBox('Do you wish to use player ' + Me.Name, 'Player setup', 3);
end
else
action := INPUT_NO;
case action of
INPUT_YES: warn('Using player ' + Me.Name, WT_CORE);
INPUT_NO:
begin
InputQuery('Player setup', 'Username', Me.Name);
InputQuery('Player setup', 'Password', Me.Pass);
WriteINI('playersetup', 'username', Me.Name, ScriptPath + 'playersetup.ini');
WriteINI('playersetup', 'password', Me.Pass, ScriptPath + 'playersetup.ini');
end;
INPUT_CANCEL:
begin
warn('You choose to cancel, terminating script.', WT_SCRIPT);
TerminateScript;
end;
end;
if (Me.Name = '') then
begin
warn('No player info detected, terminating script..', WT_SCRIPT);
TerminateScript;
end;
Me.Active := True;
end;

procedure DB(S: string);
begin
warn(S + ' [TimeStamp]: ' + timeRunning, WT_SCRIPT);
end;

procedure Fail(FailedAT: string);
begin
DB('Failed: ' + FailedAT);
logoutPlayer;
end;

function MouseOnScreen: boolean;
var
x, y: integer;
begin
GetMousePos(x, y);
Result := PointInBox(Point(x, y), IntToBox(0, 0, 760, 500));
end;

procedure Handle_MouseOffScreen;
begin
if MouseOnScreen then
MMouseOffClient('rand');
end;

procedure Handle_MightOffScreen;
begin
if Random(2000) = 0 then
begin
Handle_MouseOffScreen;
Wait(1000 + Random(20000));
end;
end;

procedure RandomizeActions;
begin
if not isLoggedIn() then
Exit;
case Random(4000) of
0: GameTab(TAB_MAGIC);
1: GameTab(TAB_STATS);
2: compassMovement(0, 360, False);
end;
Handle_MightOffScreen;
end;

procedure Progress;
begin
Writeln(' [ Steel Bar Superheater]');
Writeln(' By iCode v' + Version);
Writeln('');
Writeln(' Time running: ' + msToTime(GetTimeRunning, TIME_SHORT));
Writeln(' Alches done: ' + ToStr(GLOBAL_DONE));
Writeln(' XP gained: ' + ToStr(GLOBAL_DONE * 65));
Writeln(' Casts left in inventory: ' + ToStr(GLOBAL_ItemAmount - GLOBAL_DONE));
Writeln('');
end;

procedure handle_Heat;
var
T: Timer;
WaitT: Integer;
begin
if not isLoggedIn() then
Exit;
WaitT := RandomRange(3000, 4350);
T.START;
repeat
Wait(250 + Random(200));
RandomizeActions;
until (getCurrentTab = TAB_MAGIC) or (WaitT < T.timeElapsed());
GameTab(TAB_MAGIC);
if not mouseInBox(GLOBAL_HEATBOX) then
MouseBox(GLOBAL_HEATBOX.X1, GLOBAL_HEATBOX.Y1, GLOBAL_HEATBOX.X2, GLOBAL_HEATBOX.Y2, 5, MOUSE_MOVE);
if CountColor(255, 557, 418, 731, 452) > 0 then
begin
Fail('Out of runes - handle_Heat');
Exit;
end;
fastClick(MOUSE_Left);
WaitT := RandomRange(1000, 1350);
T.START;
while T.timeElapsed() < WaitT do
begin
wait(50 + Random(100));
end;
if not getCurrentTab = TAB_MAGIC then
begin
DB('getCurrentTab = TAB_MAGIC after click, solving');
Exit;
end;
if not mouseInBox(GLOBAL_HEATBOX) then
MouseBox(GLOBAL_HEATBOX.X1, GLOBAL_HEATBOX.Y1, GLOBAL_HEATBOX.X2, GLOBAL_HEATBOX.Y2, 5, MOUSE_MOVE);
fastClick(MOUSE_Left);
Inc(GLOBAL_DONE);
WaitT := RandomRange(2000, 2300) - WaitT;
T.START;
while T.timeElapsed() < WaitT do
begin
wait(50 + Random(100));
RandomizeActions;
end;
end;

procedure SetupPlayer;
begin
if not isLoggedIn() then
Exit;
DB('Setting up player..');
setAngle(ANGLE_HIGH);
randomMovement;
GameTab(TAB_MAGIC);
if itemInSlot(9) then
begin
if GLOBAL_ItemAmount = 0 then
begin
GLOBAL_ItemAmount := getItemAmount(MiddleBox(invBox(9)));
DB('Starting off with ' + ToStr(GLOBAL_ItemAmount) + ' items');
end
else
DB('Started with ' + ToStr(GLOBAL_ItemAmount) + ' and you now have ' + ToStr(GLOBAL_ItemAmount - GLOBAL_DONE) + ' left');
end
else
begin
Fail('SetupPlayer, no item in slot 9');
Exit;
end;
gameTab(TAB_MAGIC);
end;

begin
initAL();
SetupScript;
GLOBAL_HEATBOX := IntToBox(652, 301, 657, 308);
ClearDebug;
if not isLoggedIn then
loginPlayer(True);
SetupPlayer;
repeat
handle_Heat;
ClearDebug;
Progress;
if not isLoggedIn() then
Me.Active := False;
until (Me.Active = False) or (GLOBAL_DONE >= LIMIT);
if isLoggedIn then
begin
Progress;
DB('We are done with the task. :)');
if LOGOUT_WHEN_DONE then
logoutPlayer;
end;
end.

Things that I need help with adding:

*KEY*
Not Started - Red
In Progress - Orange
Finished - Green

1. Banking (this is a biggy)
2. Withdrawing the way I want it to

3. The actual Superheating method (I need to modify the current alching protocol to fit superheating, I changed it to the right coords and it clicks the superheat icon correctly)

How I want the script to…
Withdraw:
1. Withdraw 1 coal
2. Withdraw 9 iron
3. Withdraw all coal
4. Close Bank



Superheat:
1. I need to make it so that it double checks it's on mage tab before clicking the superheat coords (it also checks # of casts in inv now before switching to mage tab)
2. Then should loop clicking superheat->item w/ randomized time (coords should be randomized already)


icode

2014-11-09 19:49:34

Been looking through this to find out how to implement banking…

https://github.com/J-Flight/AeroLib/blob/master/core/Bank.simba

icode

2014-11-09 22:34:57

Anyone want to offer some suggestions?

Hoodz

2014-11-10 03:55:47

From: icode
Anyone want to offer some suggestions?


do you want me to release my steel bar superheater (aerolib) just got 99 magic with it.

icode

2014-11-10 14:57:54

From: hoodz
do you want me to release my steel bar superheater (aerolib) just got 99 magic with it.


You don't have to release publicly yet if you don't want to, I sent you a pm :)