PDA

View Full Version : DTM dependent findWorlds function



HT BaaFly
12-16-2014, 11:35 AM
Before I start, let me just say that this is not my best work. This code was whipped up 4 months ago as a response to the tesseract not working for me; actually more like me not knowing how to use it :p. A lot of the code is redundant and most of it, if not all, can be summarised in fewer lines. I haven't gone back to this draft for mainly 2 reasons: firstly because it works perfectly and secondly it scares me to have to go through rewriting and debugging such long code, haha!

Without further ado, let me present my findWorld include (attachement). The include has been split into 2 files, findWorlds 1 and 2, due to size issues. Please merge both files and rename include to findWorld.

And as a freebie :p, here's the code that I use in my scripts to interact with this include just to give you guys an idea on how it works (This contains functions found only in my include, so it redundent without them)

function SwitchWorld: boolean;
var
T, i, WorldNumber, x, y: integer;
P, PP: TPoint;
D: boolean;
label StartLabel, LobbyLabel, OpenWorldScreenLabel, PlayLabel, ScrollLabel, SelectWorldLabel, notLoadingLabel;
begin
i := -1;
while (i = -1) or (lobbyWorlds.isOpen() and (findCurrentWorld = WorldNumber)) do
begin
i := randomrange(0, high(Worlds));
WorldNumber := Worlds[i];
end;
PP := Point(757 + randomrange(-3, 3), 375 + randomrange(-125, 125));
Stat := 'Switching to world ' + IntToStr(WorldNumber);
Stats;
StartLabel:
antiBan;
CurrentWorld := findCurrentWorld
if isServerOfflineLobby then
begin
while isServerOfflineLobby2 do
begin
wait(500 + round(reflexFactor/2) + random(0, 100));
typeB(27);
wait(100 + round(reflexFactor/2) + random(0, 100));
end;
while (CurrentWorld = Worlds[i]) do
begin
i := randomrange(0, high(Worlds));
WorldNumber := Worlds[i];
end;
end;
if isLobbySixHour then
sixHourFix();
if not lobby.isOpen and (not isLobbySixHour) then goto LobbyLabel;
if not lobbyWorlds.isOpen() and (not isLobbySixHour) then goto OpenWorldScreenLabel;
if lobbyWorlds.isOpen() and (not FindColorTolerance(x, y, 1610968, IntToBox(751, 237, 762, 252), 40)) and (not isLobbySixHour) then goto notLoadingLabel;
if lobbyWorlds.isOpen() and (CurrentWorld = WorldNumber) and (not isLobbySixHour) then goto PlayLabel;
if not findWorlds(P, IntToStr(WorldNumber), D) and (not isLobbySixHour) then goto ScrollLabel;
goto SelectWorldLabel;

LobbyLabel:
if (CurrentWorld = WorldNumber) then exit;
if isLoggedIn then
begin
Stat := 'Player is logged in, logging out to lobby';
Stats;
LogoutLobby;
end else
begin
Stat := 'Logging in to lobby';
Stats;
LogToLobby;
end;
goto StartLabel;

OpenWorldScreenLabel:
Stat := 'Opening world screen';
Stats;
CustomMouse(0, Point(200 + randomrange(-MouseRandomness, MouseRandomness), 125 + randomrange(-MouseRandomness, MouseRandomness)), Mouse_Left);
wait(300 + round(reflexFactor/2) + random(0, 100));
T := 0;
goto StartLabel;

notLoadingLabel:
Stat := 'Waiting for world list to pop up';
Stats;
if lobbyWorlds.isOpen() and not (FindColorTolerance(x, y, 1610968, IntToBox(751, 237, 762, 252), 40)) then
repeat
inc(T);
wait(1000 + round(reflexFactor/2) + random(0, 100));
if FindColorTolerance(x, y, 1610968, IntToBox(751, 237, 762, 252), 40) then
break;
if isLoggedIn then exit;
until(T > 100);
if (T > 100) and not (FindColorTolerance(x, y, 1610968, IntToBox(751, 237, 762, 252), 40)) then
SixHourFix;
goto StartLabel;

ScrollLabel:
Stat := 'Scrollin to world ' + IntToStr(WorldNumber);
Stats;
if not D then mouseScroll(PP, 5)
else mouseScroll(PP, 5, false);
wait(round(reflexFactor/2) + random(0, 100));
goto StartLabel;

PlayLabel:
Stat := 'Clicking on play - ' + IntToStr(WorldNumber);
Stats;
CurrentWorld := findCurrentWorld;
CustomMouse(0, Point(400 + randomrange(-MouseRandomness*10, MouseRandomness*10), 550 + randomrange(-MouseRandomness*2, MouseRandomness*2)), Mouse_Left);
wait(600 + round(reflexFactor/2) + random(0, 100));
T := 0;
Stat := 'Waiting for player to be ingame';
Stats;
while isLoading do
wait(round(reflexFactor/2) + random(0, 100));
if isLoggedIn then
begin
wait(2000 + round(reflexFactor/2) + random(0, 100));
DealWithOptions;
DealWithMap;
DealWithPoll;
minimap.clickCompass();
TRSMainscreen.setAngle(MS_ANGLE_HIGH);
CustomMouse(0, Point(688 + randomrange(-MouseRandomness, MouseRandomness), 106 + randomrange(-50, 50)), Mouse_Move);
if (not isBank) and (not isBackPack) then
tabBackpack.open();
exit;
end
goto StartLabel;

SelectWorldLabel:
Stat := 'Selecting world ' + IntToStr(WorldNumber);
Stats;
CustomMouse(0, Point(P.x + randomrange(-MouseRandomness, MouseRandomness*2), P.y + randomRange(round(-MouseRandomness/2), round(MouseRandomness/2))), Mouse_Left);
goto StartLabel;
end;

Explanation of variables and functions in SwitchWorld:
* Stats is my debugging and progress function, it prints script status at each significent script activity. Preceded by Stat variable which is a string declaring current activity
* Worlds is an array of integer for worlds to select. Declared at start of script
* PP is point located in scroll bar in the world screen for scrolling purposes, avoids highlighting worlds which can offset result.
* MouseRandomness is a random variable generated at start of script and uniqu teo each user, part of human antiban, provides different randomness when clicking.
* CustomMouse is my modified mouse function with added antiban capabilities, such as multiclicking and target missing. Kudos to Clarity on this one. :)
* reflexFactor is a random variable generated at start of script and unique to each user, part of human antiban, provides different waiting times for users. Idea by Clarity as well
* isLoading checks client for loading scr
* DealWithOptions closes options menu ingame
* DealWithMap closes map
* DealWithPoll closes polls
all the others are self-explanatory, I hope.

Explanation of variables and functions in findWorld include:
I'm not going to go through all variables because that would take an eternity, I'll just outline the paramters and general function.
* var outPoint returns a point in the world list which is the selected worlds' position on screen.
* World is the world to find and return the outPoint of.
* Direction is a boolean that determines which direction in the world list to scroll to. True could be to scroll up and false to scroll down or vice versa, can't remember exact designation, so sorry :duh:. The world list must be arranged according to number, asecending, world 1 comes first and world 141 last.

The findWorld function starts by finding all Stars - on the left end - in the world screen. Each Star represents a possible world. Each Star is used to generate the data for variables B1 to B13. These variables are WorldPos records which store information about single lines in world screen with a fully visible Star. The record includes BB which is the TBox for the world line; TPoints, named N0 and N00 up to N9 and N99, each is for storing the position of numbers found in the BB; and finally, there is World which is a string that is calculated by arranging all N variables in the correct order, it is also used in the end of the function to determine if it is the script parameter, World.

The N variables in WorldPos are all calculated using carefully made DTMS. N variables with single digit, i.e. N5, stores the TPoint for number 5 if it is found in BB. It also determines that the first character is going to be 5. N variables with double digit, i.e. N44, stores the TPoint for number 4 if it is found in BB. It determines the second character of the world, if there is one.
Examples:
* we have N6 not equaling null and also N88 not equaling null, so the result for this specific N variable (single line) would be world 68
* N1 is not null and all N double values are null results in finding world 1
and so on and so forth

Sometimes, a third digit is found and this is determined by calculating X value of N variables. (Don't remeber exact mechanism)

Since all of my scripts run exclusively on members' worlds, this function is viable only for rs members. The script reads most lines perfectly but it sometimes fails to read worlds 21 to 24 for an unknown reason. In addition, DTMs have been updated for safe mode (originally opengl) so it might not work as well on all modes.

What do you guys think about this? Post your thoughts please! Curious to know if this has been attempted before...

HT BaaFly
12-16-2014, 11:50 AM
Side note: I have several fully functional scripts like nature rune graahk crafter, and air runner and a bunch of other small time scripts like herb cleaners that I'm hoping to release some of. What do you I should release? The nature crafter has the potential to run for 48 hours straight on (tested by myself) but I need to work on it for a while to add a personalised playing style. :spot:

John
12-17-2014, 12:27 PM
Side note: I have several fully functional scripts like nature rune graahk crafter, and air runner and a bunch of other small time scripts like herb cleaners that I'm hoping to release some of. What do you I should release? The nature crafter has the potential to run for 48 hours straight on (tested by myself) but I need to work on it for a while to add a personalised playing style. :spot:

I have a nature graahk crafter too :) I know other people that have one too. It would be interesting to see how we all went about certain things(pouch fixing etc, etc).

HT BaaFly
12-18-2014, 07:49 AM
I have a nature graahk crafter too :) I know other people that have one too. It would be interesting to see how we all went about certain things(pouch fixing etc, etc).

that's sweet bro! add my skype if you wanna talk about our scripts ;)

The Mayor
12-18-2014, 08:46 AM
but can't you just go:


players[currentPlayer].switchToWorld(10);

HT BaaFly
12-18-2014, 11:08 AM
but can't you just go:


players[currentPlayer].switchToWorld(10);


I could have, but tesseract was not working for me at the time so I had to find an alternative