From: bonsai
getAbilityCooldown tells you if the ability is ready. I think the documentation says it returns 100 but it returns 1 when the ability is ready to use.
The cycling is not random. It loops backwards from 9 to 1 and checks that slot to see if it is ready. That way when people put their threshold skills to the right of the actionbar it will choose them before the basic skills (on the left).
So the for loop and the if test will choose the right-most skill that is ready.
The case statement decides which key to be press to activate the chosen ability. It has entries for 10/11/12 but they are not needed any more since I'm only looping from 9.
Then it calls sendkeys to actually push the key.
This was incredibly helpful! Now thanks to using that and a few of the functions from The Mayor i now have a functional script with breaks. Still want to clean up the debug window and add a proggy.
I have now moved the start location. Instead of goblins it now fights the minotaurs right next door. Or anywhere in that floor of the dungeon. I commented out the looting of the bones for now as it was pretty useless at this stage.
Ok so the biggest change i made was in the script finding the end of the fight. I used a DTM to find the monsters hp. When it sees the "0" it will stop the fight and move on to the next one. I did this because he kept aggroing all the minotaurs.
Please let me know your thoughts on this!
program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/LIB/SPS-RS3.simba}
const
//-------Login Settings-------//
PLAYER_FILE = 'Godlist';
NICKNAME = 'Miner2';
LOGIN_WORLD = 0;
//ENABLE_DEBUG = False;
//----------------------------//
//-------Break settings-------//
ENABLE_BREAKS = True;
MIN_PLAY_TIME = 45;
MAX_PLAY_TIME = 180;
MIN_BREAK_TIME = 5;
MAX_BREAK_TIME = 45;
//----------------------------//
var
//-------Global Variables-------//
TotalBreakTime, StatsTime : TTimeMarker; //Timers Here
BreakTimeTotal, BreakTime, Breaked, XpGained : integer; //Stats Here
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure resetBreakTimer();
begin
BreakTime := getSystemTime() + gaussRangeInt(MIN_PLAY_TIME * 60000, MAX_PLAY_TIME * 60000);
end;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure setup();
begin
smartEnableDrawing := true;
//disableSRLDebug := not ENABLE_DEBUG;
setupSRL();
players.Setup([NICKNAME], PLAYER_FILE);
currentPlayer := 0;
players[currentPlayer].world := LOGIN_WORLD;
exitTreasure();
resetBreakTimer();
TotalBreakTime.start();
TotalBreakTime.pause();
end;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function antiBan(): boolean;
var
antiBanNum : integer;
begin
antiBanNum := random(1500);
if antiBanNum <= 100 then
begin
writeLn('Antiban Time!');
case antiBanNum of
1..10: boredHuman(false);
11..25: hoverRandomSkill();
26..31: hoverOnlineFriend();
32..52: mouseMovingObject();
53..69: mouseOffClient(4);
70..80: randomCameraAngle(MS_ANGLE_HIGH);
81..90: randomCompass(10, 40, True);
91..100: wait(randomRange(3000, 5000));
end;
end;
end;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function timeUntilBreak() : string;
var
breakFromNow, H, M, S : integer;
begin
if ENABLE_BREAKS then
begin
breakFromNow := BreakTime - getSystemTime();
convertTime(breakFromNow, H, M, S);
result := (toStr(H) + 'h ' + toStr(M) + 'm ' + toStr(S) + 's');
end else
result := ('Breaking disabled');
end;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure takeBreak();
var
H, M, S, HH, MM, SS, breakFor, timeLeft : integer;
breakStartTimer : TTimeMarker;
begin
if not ENABLE_BREAKS then
exit;
if (getSystemTime() >= BreakTime) then
begin
TotalBreakTime.start();
writeLn('Taking a break');
if random(2) = 0 then
players[currentPlayer].logout()
else
players[currentPlayer].exitToLobby();
breakFor := gaussRangeInt(MIN_BREAK_TIME * 60000, MAX_BREAK_TIME * 60000);
convertTime(breakFor, H, M, S);
writeLn('You are taking a break for: ' + toStr(H) + 'h ' + toStr(M) + 'm ' + toStr(S) + 's');
breakStartTimer.start();
repeat
timeLeft := breakFor - breakStartTimer.getTime();
convertTime(timeLeft, HH, MM, SS);
writeLn('Ending break in: ' + toStr(HH) + 'h ' + toStr(MM) + 'm ' + toStr(SS) + 's');
wait(25000 + random(4000));
until breakFor < breakStartTimer.getTime();
inc(Breaked);
resetBreakTimer();
TotalBreakTime.pause();
players[currentPlayer].login();
wait(gaussRangeInt(1500, 3500));
exitTreasure();
minimap.clickCompass();
end;
end;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure doAbilities();
var
i : integer;
keyStr : string;
begin
for i := 9 downto 1 do
begin
if (actionBar.getAbilityCooldown(i) = 1) then
begin
case i of
0..9: keyStr := intToStr(i);
10: keyStr := '0';
11: keyStr := '-';
12: keyStr := '=';
end;
SendKeys(keyStr[1], 60 + Random(60), 60 + Random(60));
exit;
end;
end;
end;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure clickEnemy();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
hpDTM: integer;
isMobDead : boolean;
begin
if isLoggedIn() then
begin
hpDTM := DTMFromString('mbQAAAHicY2VgYFBhZWBQBmI1IFYFYiUg3gwUXw/EG4B4GxTbCAsz/D/NynB3AwuYDtMRZJAEiqNjRiwYDADI8wr3');
isMobDead := false;
findColorsSpiralTolerance(x, y, TPA, 2709450, mainScreen.getBounds(), 24, colorSetting(2, 0.09, 1.42));
if length (TPA) < 1 then //If there are no monsters found it will terminate and rerun.
begin
exit;
end;
ATPA := TPA.toATPA(40, 40);
ATPA.sortFromMidPoint(mainscreen.playerPoint); //Chooses the closest monster to you.
smartImage.debugATPA(ATPA);
for i := 0 to high(ATPA) do //Finds and draws all the monsters a debug box.
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['ttack'], 500) then
begin
if findDTM(hpDTM, x, y, mainScreen.getBounds()) then
begin
writeLn('DTM found, Moster hp 0');
isMobDead := True;
break;
end;
fastClick(MOUSE_LEFT); // attacks mob
repeat
if findDTM(hpDTM, x, y, mainScreen.getBounds()) then //Will keep fighting the monster til their health reaches 0
begin
writeLn('DTM found, Moster hp 0');
isMobDead := True;
break;
end;
doAbilities();
until isMobDead = True;
smartImage.clear();
antiBan();
wait(randomRange(5000, 8000));
break;
end;
if isMouseOverText(['pen Gate of War']) then // keeps you from stepping through the door
begin
writeLn('Gate of War found');
break;
end;
end;
End else
if not isLoggedIn() then
begin
writeLn('You are not logged in');
exit;
end;
end;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure pickUpBones();
var
x, y, i : integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if IsLoggedIn() then
begin
findColorsSpiralTolerance(x, y, TPA, 9015205, mainScreen.getBounds(), 21, colorSetting(2, 0.08, 0.43));
if length (TPA) < 1 then //If there are no bones found it will terminate and rerun.
begin
exit;
end;
ATPA := TPA.toATPA(20, 20);
ATPA.sortFromMidPoint(mainscreen.playerPoint); //Chooses the closest drop to you.
smartImage.debugATPA(ATPA);
for i := 0 to high(ATPA) do
begin
wait(1000);
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['ake'], 500) then
begin
mouse(middleTPA(ATPA[i]), MOUSE_RIGHT); // picks up the bones at the closest point to you.
chooseOption.select(['ake Bones']);
tabBackPack.waitForShift(10000);
smartImage.clear();
break;
end;
end;
end;
end;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure buryBones();
var
slotNum, i : integer;
begin
if isLoggedIn() then
begin
slotNum := 28;
for i := 1 to slotNum do //for every time "i" is not equal to slotNum
begin //keep clicking the bones in the next box over.
tabBackPack.mouseSlot(i, MOUSE_LEFT);
wait(randomRange(1500, 2300)); //wait until the bones are out of the inventory
i + 1;
end;
end;
end;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure checkAngle();
var
angle : extended;
begin
angle := minimap.getAngleRadians();
if angle <> MM_DIRECTION_NORTH and MS_ANGLE_HIGH then // checks to see if the camera is in the correct position. If its not it will put it there.
begin
mainScreen.setAngle(MS_ANGLE_HIGH);
minimap.setAngle(MM_DIRECTION_NORTH);
end;
end;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure monsterHealthDTM();
var
hpDTM: integer;
begin
hpDTM := DTMFromString('mbQAAAHicY2VgYFBhZWBQBmI1IFYFYiUg3gwUXw/EG4B4GxTbCAsz/D/NynB3AwuYDtMRZJAEiqNjRiwYDADI8wr3');
end;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
begin
setup();
repeat
if not isLoggedIn() then
begin
players[currentPlayer].login();
end;
until isLoggedIn();
mainScreen.setAngle(MS_ANGLE_HIGH);
minimap.setAngle(MM_DIRECTION_NORTH);
repeat
//repeat
clickEnemy();
wait(randomRange(3000, 3500));
//pickUpBones();
//until tabBackPack.isFull();
//buryBones();
until(false);
end.