Hey everyone! I have finished a few new lobby functions that are very useful for logging in!
I started with what @Ross; wrote (surprise!) from here (https://villavu.com/forum/showthread.php?t=113330)! Big thanks to him
First of all, I have integrated this into my program by using a lobby record, so first of all make sure you have this:
Simba Code:
type tLobby = record
__: boolean;
isSortByType: boolean;
isSortByPing: boolean;
typeBox: TBox;
pingBox: TBox;
end;
var
lobby : tLobby;
Remember that these will be using some of the code written by Ross: hasLobby, getTab, setTab, clickPlay, and getWorld, and clickWorld! I modified setTab and clickWorld, so I am going to start with them:
setTab will set the tab you wish to go to. Remember the first tab starts at 0! I modified Ross' code to allow sorting.
Simba Code:
function tlobby.setTab(tab: integer): boolean;
begin
if (self.hasLobby()) then
begin
mouse.click(ogl.getTextures(235527)[tab].toPoint().adjustPosition(random(-4, 25), random(-5, 5)));
result:=true;
end;
wait(random(500, 1500));
if (tab = 1) then
self.updateSorts();
exit(result);
end;
clickWorld will click any you give it, scrolling down until it locates the correct one. Pass it the world you wish to click as an Integer.
Simba Code:
function tlobby.clickWorld(worldToClick: integer): boolean;
var
index, world, scrollCount : integer;
stars: glTextureArray;
worldBox:TBox;
begin
if (self.hasLobby()) then
begin
if (not self.getTab() = 1) then
begin
self.setTab(1);
wait(100);
end;
movemouse(randomrange(200, 800), randomrange(350, 500));
scrollCount := 0;
repeat
stars:= ogl.getTextures(13504);
for index:=0 to high(stars) do
begin
worldBox:=intToBox(stars[index].bounds.x1, stars[index].bounds.y1, stars[index].bounds.x2+70, stars[index].bounds.y2);
world:=ogl.getChars(worldBox).toString().parseInt();
if (world = worldToClick) then
begin
mouse.click(middleBox(worldBox).adjustPosition(random(-10, 20), random(-2, 2)));
exit(true);
end;
end;
self.scrollDown();
until (scrollCount > 12);
end;
exit(false);
end;
clickRandomWorld will simply choose a random world shown in the list (without scrolling).
Simba Code:
function tlobby.clickRandomWorld() : Boolean;
var
stars : GlTextureArray;
worldIndex : Integer;
worldBox : TBox;
begin
if self.hasLobby() then
begin
if (self.getTab() <> 1) then
repeat
self.setTab(1);
wait(500);
until (self.getTab() = 1);
stars := ogl.getTextures(13504);
if (not stars.isEmpty()) then
begin
worldIndex := randomrange(0, high(stars));
worldBox := intToBox(stars[worldIndex].bounds.x1, stars[worldIndex].bounds.y1,
stars[worldIndex].bounds.x2+70, stars[worldIndex].bounds.y2);
writeLn('Logging into world: ', ogl.getChars(worldBox).toString());
mouse.click(middleBox(worldBox).adjustPosition(random(-10, 20), random(-2, 2)));
result := true;
end;
end;
exit(result);
end;
Now I have two sorting methods for the world list that I find useful: Sort by Type (p2p/f2p) and Sort by Ping. These functions will need updateSorts and compareBoxes to function.
Note: If you sort by ping and then sort by type, then world list will be in descending order of ping with all p2p worlds on top!
sortByType sorts the world list with member worlds on the top.
Simba Code:
procedure tlobby.sortByType();
var
tArr : GlTextureArray;
begin
mouse.click(self.typeBox);
wait(randomrange(800, 1600));
mouse.click(self.typeBox);
tArr := ogl.getTextures(10, self.typeBox);
while ((not tArr.isEmpty()) and self.hasLobby()) do
begin
mouse.click(self.typeBox);
movemouse(self.typeBox.X1 + randomrange(-20, 20), self.typeBox.Y1 + randomrange(-20, -80));
wait(randomrange(1000, 2000));
self.updateSorts();
tArr := ogl.getTextures(10, self.typeBox);
end;
end;
sortByPing sorts the world list with the lowest ping worlds on top.
Simba Code:
procedure tlobby.sortByPing();
var
tArr : GlTextureArray;
begin
mouse.click(self.pingBox);
wait(randomrange(800, 1600));
mouse.click(self.pingBox);
tArr := ogl.getTextures(10, self.pingBox);
while (tArr.isEmpty() and self.hasLobby()) do
begin
mouse.click(self.pingBox);
movemouse(self.pingBox.X1 + randomrange(-20, 20), self.pingBox.Y1 + randomrange(-20, -80));
wait(randomrange(1000, 2000));
self.updateSorts();
tArr := ogl.getTextures(10, self.pingBox);
end;
end;
updateSorts is a helper for the sorting to figure out which sort boxes are where. No need to actually use this in your code as it is already implemented.
Simba Code:
function tlobby.updateSorts(): boolean;
var
boxTextures : GlTextureArray;
boxLength, i : Integer;
boxArray : TBoxArray;
temp : TBox;
begin
boxTextures := ogl.getTextures(11475);
boxLength := length(boxTextures);
if (boxLength < 1) then
begin
writeln('boxLength < 1, exiting.');
exit(false);
end;
setLength(boxArray, boxLength);
for i := 0 to boxLength - 1 do
boxArray[i] := boxTextures[i].bounds;
self.pingBox := boxArray[boxLength-1];
if self.compareBoxes(boxArray[boxLength-1], boxArray[boxLength-2]) then
self.typeBox := boxArray[boxLength-4]
else if self.compareBoxes(boxArray[boxLength-2], boxArray[boxLength-3]) then
self.typeBox := boxArray[boxLength-4]
else
self.typeBox := boxArray[boxLength-3];
self.isSortByType := (ogl.getTextures(10, self.typeBox).indexes() = 0);
self.isSortByPing := (ogl.getTextures(10, self.pingBox).indexes() = 0);
cleardebug();
writeln(isSortByType, ' ', isSortByPing);
exit(true);
end;
compareBoxes is used by updateSorts to compare the location of the sort boxes. Again, no need to use.
Simba Code:
function tlobby.compareBoxes(box1, box2 : TBox): boolean;
begin
if (box1.x1 = box2.x1) and (box1.x2 = box2.x2) and
(box1.y1 = box2.y1) and (box1.y2 = box2.y2) then
result := true
else
result := false;
end;
And finally, we have my little helper function to scroll down the list!
scrollDown scrolls down about one page. This is used in the clickWorld function.
Simba Code:
Just kidding, as someone pointed out there is already a tmouse.scroll(x, y, direction)!!!
I hope that everyone has fun using these! As usual, let me know how it goes, and if there are any problems.