SRL Archive - SRL Snippets

hoverXPPopup(); and browseSkillMenu();


Clarity

2014-11-07 12:49:43

Two new functions for antiban, to add a bit of human variety to scripts!

If your script allows usage of XP Popups without disrupting any mainscreen color searches, then you can call this occasionally to have the player check his or her progress.


hoverXPPopup(moveAway: boolean = true): boolean;


(*
hoverXPPopup
~~~~~~~~~~~~

.. code-block:: pascal

function hoverXPPopup(moveAway: boolean = true);

If the circular XP tracker is present, this procedure will hover over to check
your player's skill progress.

.. note::

- by Clarity
- Last Updated: 7th November 2014 by Clarity

Example:

.. code-block:: pascal

hoverXPPopup();
*)
function hoverXPPopup(moveAway: boolean = true): boolean;
var
popupDTM, x, y: integer;
finalBox: TBox;
begin
print('hoverXPPopup()', TDebug.HEADER);
result := false;
popupDTM := DTMFromString('mWAAAAHicY2FgYJgHxAuBeDaUHcHIwBDJCKGjgTjDESjIwMiQEcHAcGg+AwMXAypmRMMgAACX2Qbc');

if findDTM(popupDTM, x, y, mainscreen.getBounds()) then
begin
mouseCircle(x, y - 20, 15, MOUSE_MOVE);

wait(150 + random(4500));

if moveAway then
begin
finalBox := IntToBox(mainscreen.x1 + 20, mainscreen.y1 + 80, mainscreen.x2 - 20, mainscreen.y2 + 20);
mouseBox(finalBox, MOUSE_MOVE, MOUSE_HUMAN);
wait(50 + random(500));
end;

result := true;
end else
print('hoverXPPopup(): XP Popup was not found.', TDebug.SUB);

freeDTM(popupDTM);
print('hoverXPPopup(): result = ' + toStr(result), TDebug.FOOTER);
end;

Sometimes players like to look at their new skill unlocks after leveling up, or just in general. Call this function to browse a skill menu of your choice.


browseSkillmenu(skill: integer; maxScrollAmount: integer = 10): boolean;


(*
browseSkillMenu
~~~~~~~~~~~~~~~

.. code-block:: pascal

function browseSkillMenu(skill: integer; maxScrollAmount: integer = 10);

Clicks on the skill 'skill' and scrolls through its skill information menu.
Specify the maximum scroll amount via maxScrollAmount.

.. note::

- by Clarity
- Last Updated: 7th November 2014 by Clarity

Example:

.. code-block:: pascal

browseSkillMenu(SKILL_ATTACK, 5);
*)
function browseSkillMenu(skill: integer; maxScrollAmount: integer = 10): boolean;
var
t, x, y, w, h, k, menuBMP: integer;
begin
print('browseSkillMenu()', TDebug.HEADER);
result := false;
t := gameTabs.getActiveTab();
menuBMP := BitmapFromString(53, 4, 'meJyrqaosLC6Fo9SkhOysnKjo2Oy' +
'YQPngem4fEOJMny9ZuVR/4h69+q1AttGkC9XH761aPn/NunWnls/s' +
'WrGff8ppoCxQjXr2Al6ffBFNJzFxW3EpBwlpZwXlECCSlvVBRnJKX' +
'nA2UA0aA1lZDarzgG6DuBDoPKAjWYInwp0HdBuQBCKg8xI3PIc4D+' +
'JCoALump1At/FnT5D1SBaWsxYRMwM6D9M9QDegOUNM0hpZCq4SwkB' +
'zGxyBHBkTCAk9oKUQh0EQMKyAzgMG2oxpU4EI6DxgOAPFgY4EMtiM' +
'wvkE1EXEzJGdB7Ea03ZcshAF8NADugfNeZAAtPeLAAYg0HnILgQGF' +
'NB5kcuvQQIQSAIVA+MUFHQW8cLaDqLi5lKyDuJSjhDrIPbCbUeLTW' +
'DUw6XgzoOkByAXACKyxKI=');
getClientDimensions(w, h);

if (t <> TAB_STATS) then
gameTabs.openTab(TAB_STATS);

mouseBox(tabStats.getSkillBox(skill), MOUSE_LEFT, MOUSE_HUMAN);

k := (getSystemTime() + 10000);

repeat
wait(random(100, 300));
until findBitmapIn(menuBMP, x, y, 1, 1, w-1, h-1) or (getSystemTime() > k);

if not findBitmapIn(menuBMP, x, y, 1, 1, w-1, h-1) then
begin
print('browseSkillMenu(): Skill menu never opened.', TDebug.SUB);
end else
begin
wait(150 + random(500));
mouseScroll(point(492 + random(-90, 90), 364 + random(-90, 90)), random(0, maxScrollAmount));
wait(150 + random(3500));
repeat
typeByte(VK_ESCAPE);
wait(500 + random(500));
until (not findBitmapIn(menuBMP, x, y, mainscreen.getBounds()));
result := true;
end;

if (t <> TAB_STATS) then
gameTabs.openTab(t);

freeBitmap(menuBMP);
print('browseSkillMenu(): result = ' + toStr(result), TDebug.FOOTER);
end;

Hope these are helpful! :)

Lipcot

2014-11-07 13:27:54

nice! i like specially the skill menu procedure! i haad thought of making something similar but with the Vote screen

Clarity

2014-11-07 13:58:21

From: undorak7
nice! i like specially the skill menu procedure! i haad thought of making something similar but with the Vote screen


If you aren't going to, I'd be happy to make something that votes for a random choice :)

Also, regarding hoverXPPopup(); I have discovered that the colors for the DTM change a lot after levelling up, causing it to fail until you get some experience back in the next level. I can't get a good image of this happening so if someone could post a picture for me to recreate the DTM that would be great! (picture of an XP Popup just after levelling)

Lipcot

2014-11-07 15:39:34

From: Clarity
If you aren't going to, I'd be happy to make something that votes for a random choice :)


Go ahead ! :)

Justin

2014-11-07 16:17:45

Nice work Clarity, I'd like to see a failsafe here:

   repeat
typeByte(VK_ESCAPE);
wait(500 + random(500));
until (not findBitmapIn(menuBMP, x, y, mainscreen.getBounds()));

As in the past, I've seen the VK_ESCAPE key fail

Clarity

2014-11-07 16:48:59

From: Justin
Nice work Clarity, I'd like to see a failsafe here:

   repeat
typeByte(VK_ESCAPE);
wait(500 + random(500));
until (not findBitmapIn(menuBMP, x, y, mainscreen.getBounds()));

As in the past, I've seen the VK_ESCAPE key fail

Ah really? Fail as in repeating the command multiple times would do nothing?

Justin

2014-11-07 16:53:34

From: Clarity
Ah really? Fail as in repeating the command multiple times would do nothing?


Correct, I've seen 'players[currentPlayer].logout();' fail several times, IIRC the logout function will push the ESC key 5 times before returning false

KeepBotting

2014-11-07 16:57:12

Very nice, 10/10 will use.

Clarity

2014-11-07 17:01:37

From: KeepBotting
Very nice, 10/10 will use.

My pleasure :)

From: Justin
Correct, I've seen 'players[currentPlayer].logout();' fail several times, IIRC the logout function will push the ESC key 5 times before returning false


Didn't know that, I'll add a manual mouse click on the X then.
Also will edit the DTM.

The Mayor

2014-11-07 18:12:05

Very nice! If I actually played legit, this would be the type of antiban stuff I would do (as opposed to boredHuman, haha).