Feroc1ty
2010-11-16 17:38:02
although my scripting ability is far from newbie I haven't released a single script to the public (have some private ones but they're outdated), and i think it's mostly due to the fact that I have no dedication towards finishing the scripts, most of the time I finish the project to 80% and quit it, start another project
it gets really annoying, but i figured if i posted on the forums about the script in the making (al-kharid smelter) i'm gonna have for force myself to finish it… so here is my W.I.P
edit: this wip is almost done so if u can test it, it would be cool, all it requires you to do is set up the player setup and have the character waiting at al-kharid bank
it gets really annoying, but i figured if i posted on the forums about the script in the making (al-kharid smelter) i'm gonna have for force myself to finish it… so here is my W.I.P
edit: this wip is almost done so if u can test it, it would be cool, all it requires you to do is set up the player setup and have the character waiting at al-kharid bank
program Smelter;
{$i SRL/SRL/Misc/SMART.scar}
{$i SRL/SRL.scar}
{$i reflection/reflection.simba}
// My main concept of the script before I even attempt to create it
{ The program flow :
i = initialization functions, will only run when the script starts
# = scripts main loop, starts at 1 and ends at highest number
x i check if there are any ores in inventory
x i check to see the location of the character
i if the character is at bank
n if the inventory isn't full of ores
fill them up
x i make your way to the smelter
x i smelt the bars
x i walk to the bank
x 1 open bank and deposit items, check to see if character has a forging ring equiped
2 if usage of rings is turned on take one out and wear it, than take out ores
x 3 make your way to the smelter
x 4 smelt the bars
x 5 make your way back
1:
x open the bank
x deposit all items
x click equipment menu on bank and check the ring slot
2:
x revert back to bank menu
if no ring found and its turned on take one and wear it
fill inventory with ores
3:
x use reflection to move to the smelter
i was thinking of creating two boxes of possible clickpoints
and randomly clicking inside them for randomness
x have anti-random inbetween each click
4:
x click smelter and click the iron bars
there will be a long wait so have anti-random every 5 seconds
or something to that extent, also check if the last inventory slot
is not an ore, and when this happens move on to the next step
5:
x move back to the bank and repeat the loop
probably will need another one or two boxes of points, one for
the bank for sure
Updated: Nov 18, 2010 12:28AM
}
function WithdrawOres(Col, Row: Integer): Boolean;
var
BBox: TBox;
X, Y: Integer;
begin
Result := False;
BBox := BankIndexToMSBox(BankPointToBankIndex(Point(Col, Row)));
GetMousePos(X, Y);
if (not PointInBox(Point(X, Y), BBox)) then
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, 3);
ClickMouse2(false);
Result := WaitOptionMulti(['Withdraw-All', 'w-A'], 300);
end;
const IronOreColor = 1515316;
function FindOres(): Boolean;
var
x, y: integer;
BPoint: TPoint;
BankBox: TBox;
Found: Boolean;
t: TPointArray;
label
Start;
begin
Result := False;
if not BankScreen then Exit;
if (Players[CurrentPlayer].Integers[1] = 0) then
begin
Start:
for Players[CurrentPlayer].Integers[1] := 1 to 50 do
begin
if FindItemEx(x, y, 'color', IronOreColor, BankIndexToMSBox(Players[CurrentPlayer].Integers[1]), [5,20]) then
begin
MMouse(x, y, 4, 4);
if WaitUpTextMulti(['ron, ore','ron ore','ron, '], 300) then
begin
Writeln('Found Item at Bank Slot ' + IntToStr(Players[CurrentPlayer].Integers[1]) + '.');
Found := True;
Break;
end else
Writeln('Found Incorrect Item, Moving to new Bank Spot.');
writeln(getuptext());
end;
end;
end else
begin
BankBox := BankIndexToMSBox(Players[CurrentPlayer].Integers[1]);
FindColors(t, srl_outline_black, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2);
BankBox := GetTPABounds(t);
MouseBox(BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, 3);
if WaitUpTextMulti(['ron, ore','ron ore','ron, '], 300) then
Found := true
else
begin
Writeln('Item Moved from Bank Slot ' + IntToStr(Players[CurrentPlayer].Integers[1]) + ', checking bank again.');
GoTo Start;
end;
end;
Wait(RandomRange(200, 350));
if Found then
begin
BPoint := BankIndexToBankPoint(Players[CurrentPlayer].Integers[1]);
WithdrawOres(BPoint.x, BPoint.y);
Result := True;
end else
begin
Players[CurrentPlayer].Integers[1] := 0;
end;
end;
function GetOres():boolean;
var i:integer;
begin
result := false;
FixBank;
if Players[CurrentPlayer].Integers[2] = -1 then
begin
FixBankTab;
for i := 0 to 9 do
begin
if not (CurrentBankTab = i) then
begin
if not(i = 0) and not ExistsBankTab(i) then
begin
writeln('Could not find iron ores, went through ' + inttostr(i) + ' bank tabs.');
exit;
end;
if not (i = 0) then
BankTab(i);
Sleep(200+random(200));
end;
if FindOres then
begin
Players[CurrentPlayer].Integers[2] := i;
result := true;
writeln('Found the ore!');
exit;
end;
end;
end else
begin
BankTab(Players[CurrentPlayer].Integers[2]);
if not FindOres then
begin
writeln('Could not find iron ores in the appropriate bank tab!');
Players[CurrentPlayer].Integers[2] := -1;
exit;
end;
result := true;
end;
sleep(200+random(200));
if R_CountItemName('Iron ore') = 0 then
result := false;
end;
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 := '*'; // Characters full RS username.
Pass := '*'; // Characters RS password.
Nick := '*'; // 3 non-caps letters of char's RS username.
Member := true; // Is character a member?
Pin := ''; // Characters bank pin if one exists
BoxRewards := ['mote', 'ostume', 'XP', 'Gem',
'ithril', 'oal', 'une', 'oins']; // Which reward to get from box
Integers[0] := 2000; // How many ores to smelt
Active := True;
// ~!~ Don't touch
Integers[1] := 0; // Ores bank index
Integers[2] := -1; // Ores bank tab
end;
end;
// tested and working!
function IsWearingRing():boolean;
begin
result := IsEquippedName('Ring of forging');
end;
// variable for boundaries of smelt all iron bars button
var smeltbars:TBox;
// 235,397:283,452
// function to click a TBox, higher chance to click middle of box
// than outer edges
procedure ClickBox(box:TBox);
var x,y:integer;
begin
x := (box.x2 - box.x1)/2;
y := (box.y2 - box.y1)/2;
Mouse(box.x1 + x + Random(RandomRange(-x,x)), box.y1 + y + Random(RandomRange(-y,y)), 0, 0, true);
end;
var osmelter:TTile;
procedure ClickSmelter();
var p:TPoint;
begin
p := TileToMS(osmelter, 30);
Mouse(p.x,p.y,5,5,true);
Sleep(2500+random(random(500)));
end;
procedure ClickSmeltAll();
begin
ClickBox(smeltbars);
end;
// procedure to take care of smelting all the ores
procedure SmeltAll();
var ores,s:integer;
begin
ClickSmelter;
ClickSmeltAll;
s := R_CountItemName('Iron ore');
Sleep(3000+random(random(500)));
// main procedure loop, will run until out of iron ore
repeat
// counts iron ores, if 0 then exits the procedure
ores := R_CountItemName('Iron ore');
if ores = 0 then
begin
Players[CurrentPlayer].Integers[0] := Players[CurrentPlayer].Integers[0] - s;
exit;
end;
// if not done smelting will check for randoms and wait a bit
FindNormalRandoms;
Sleep(2500 + random(random(500)));
// checks to see if the ore count is going down, if not
// will recurse the function, after the recursed function is done
// will come back to this one and exit immediatly
if ores = R_CountItemName('Iron ore') then
begin
SmeltAll();
Exit;
end;
until false
end;
procedure DepositBars();
begin
R_DepositAll(true);
end;
procedure Bank();
begin
repeat
Sleep(1500 + Random(random(500)));
until R_OpenBankBooth(Bank_AK)
Wait(1000+Random(500));
if R_PinScreen then
begin
InPin(Players[CurrentPlayer].Pin);
end;
end;
// Box variables, will be used to click a random point on minimap
// within their bounds, makes everything more simple
var tbank,tmid,tsmelt:TBox;
// still need to get values for them, can't do them since I can't
// get a hold of the path maker since simba doesn't download the
// .exe file, simply the .scar/.simba files
// selects a random point in box, clicks to move to the random tile
// and waits for the movement to be finished, doesn't have a timeout
// but the function really shouldn't fail since its so straight forward
procedure MoveToBox(box:TBox);
var tpt:TPoint;
ttl:TTile;
attempts:integer;
begin
// select random point in box and convert the point to a tile
repeat
tpt.x := RandomRange(box.x1, box.x2);
tpt.y := RandomRange(box.y1, box.y2);
ttl := PointToTile(tpt);
sleep(300+random(200));
until TileOnMM(ttl);
// convert the tile to a location on minimap and click it, than wait
// for the movement to finish
tpt := TileToMM(ttl);
Mouse(tpt.x, tpt.y, 2, 2, true);
Sleep(400+random(200));
FindNormalRandoms;
R_Flag;
end;
procedure MoveToBank();
begin
MoveToBox(tmid);
MoveToBox(tbank);
end;
procedure MoveToSmelter();
begin
MoveToBox(tmid);
MoveToBox(tsmelt);
end;
// tbank tl = (3269,3169) br = (3272,3165)
// tmid tl = (3274,3178) br = (3280,3171)
// tsmelt tl = (3276,3188) br = (3281,3184)
// osmelter = (3273,3186)
// not completely sure about these values made a crappy debug
// tool that didnt work for shit lol
procedure InitLocations();
begin
tbank.x1 := 3269; tbank.y1 := 3169;
tbank.x2 := 3272; tbank.y2 := 3165;
tmid.x1 := 3274; tmid.y1 := 3178;
tmid.x2 := 3280; tmid.y2 := 3171;
tsmelt.x1 := 3276; tsmelt.y1 := 3188;
tsmelt.x2 := 3281; tsmelt.y2 := 3184;
smeltbars.x1 := 235; smeltbars.y1 := 397;
smeltbars.x2 := 283; smeltbars.y2 := 452;
osmelter := Tile(3273,3186);
end;
var p:TTile;
terminate:boolean;
tries:integer;
begin
Smart_Members := true;
Smart_Server := 60;
Smart_Signed := true;
Smart_SuperDetail := false;
SetupSRL;
SetupReflection;
ActivateClient;
DeclarePlayers;
terminate := false;
tries := 0;
InitLocations;
if not LoggedIn then
LoginPlayer;
SetAngle(true);
repeat
Bank;
DepositBars;
repeat
tries := tries + 1;
if tries > 5 then
begin
writeln('The script could not find the ores, terminating');
terminate := true;
end;
until GetOres or terminate
if terminate then
exit;
tries := 0;
MoveToSmelter;
SmeltAll;
MoveToBank;
until (Players[CurrentPlayer].Integers[0] <= 0)
writeln('The script has finished doing all your dirty work, congradulations!');
Logout;
end.