PDA

View Full Version : OGL simple break system



Lucidity
07-03-2015, 08:34 PM
Simple little break system I'll be using on my divination script for OGL. Use if you want


const
ONE_MINUTE:=60000;
MIN_BREAK:=5; //edit this to your preference
MAX_BREAK:=10; //edit this to your preference



var
breakTaken: boolean;



var
timeForBreakCd: tCountDown;



function isExitOpen: boolean;
var
exitScreenTexture: glTextureArray;
begin //eoc, legacy
exitScreenTexture:=ogl.getTextures([163024, 163200], [5912096, 6181698]);
if not exitScreenTexture.isEmpty() then
exit(true);
end;

function logToLobby(): boolean;
begin
if not isExitOpen() then
repeat
typeByte(VK_ESCAPE);
wait(random(300, 750));
until isExitOpen();

if isExitOpen() then
begin
mouse.click('Exit');
wait(random(1500, 3000));
exit(true);
end;
end;

function loginFromLobby(): boolean;
var
lobbyIndicator, ingameIndicator, loginButton: glTextureArray;
begin
lobbyIndicator:=ogl.getTextures(51329);
loginButton:=ogl.getTextures([1331318], [8806430]);
ingameIndicator:=ogl.getTextures([237147], [66823]);
if not lobbyIndicator.isEmpty() then
begin
mouse.click(loginButton[0].randomizePointEllipse(7), 1);
wait(random(15000, 20000));
if not ingameIndicator.isEmpty() then
begin
writeln('Successfully logged in.');
breakTaken:=false;
mouse.scroll(point(ogl.getClientMidPoint.x+random( 20, 100), ogl.getClientMidPoint.y+random(20, 100)), 'down');
end;
end else
writeln('Failure to login');
terminateScript;
end;

function takeBreak(): boolean;
var
breakTimer: integer;
begin
if not timeForBreakCd.isFinished() then
begin
exit(false);
end;
if timeForBreakCd.isFinished() then
begin
breakTimer:=random(ONE_MINUTE, ONE_MINUTE+25000)*random(MIN_BREAK, MAX_BREAK);
case random(50) of
0..25: wait(random(ONE_MINUTE*5, ONE_MINUTE*6));
26..50: logToLobby;
end;
breakTaken:=true;
writeln('Taking break for '+toStr(round(breakTimer/ONE_MINUTE)));
wait(breakTimer);
loginFromLobby;
timeForBreakCd.setTime(ONE_MINUTE*random(123, 190) + random(20*ONE_MINUTE, 30*ONE_MINUTE));
writeln('Time til next break : '+toStr(round(timeForBreakCd.timeRemaining()/ONE_MINUTE)));
end;
end;

Edit :

Forgot, in your start up (before repeat mainloop until false;) put
timeForBreakCd.setTime(ONE_MINUTE*random(123, 190) + random(20*ONE_MINUTE, 30*ONE_MINUTE));
and to call the breaks, in your mainloop add
takeBreak;

Obscurity
07-03-2015, 09:09 PM
If your script requires going to lobby or any loading while logging in or teleporting etc, sometimes minimap functions will fail due to an invalid floatpoint operation. I've fixed this and updated the Git. :).

Awesome job on the OGL snippets, mate!

Lucidity
07-03-2015, 09:11 PM
If your script requires going to lobby or any loading while logging in or teleporting etc, sometimes minimap functions will fail due to an invalid floatpoint operation. I've fixed this and updated the Git. :).

Awesome job on the OGL snippets, mate!

The break system will wait until it sees the minimap after logging in. When it logs to lobby it'll look for the star as an indicator. The issue shouldn't affect this at all unless I'm misunderstanding what you're implying

Edit : Just updated my include to the latest version, thanks. My Div script does use minimap for majority of it :p

Lucidity
07-04-2015, 04:33 PM
Updated the break system, added a fail safe in case it fails to login.