PDA

View Full Version : Fight sequence ends too early



o0Matthius0o
08-31-2014, 04:27 AM
Alright. So i have everything working ok now. The fighter will run continuously and get great xp. The only bug that i find very annoying is that sometimes it will end the fight sequence a bit early and start doing the doabilities procedure.

which is fine, but...

I am trying to add in my pickUpCharms procedure. When i did that it will be looking for the charms somewhere in the middle/end of the fight. And then it will skip doing the healing procedure because there is no adrenaline.

I know my colors are off for the bones. So i will fix that.

Right now my question is: How do i get it to wait until the fight is done?

Secondary question: How should i implement the pickUpCharms procedure?

Brief overview of how the script works::

-fights fire giants in the chaos tunnels
-uses atpa to find the giants
-detects that it is in a fight using a dtm to find the lock in the top left corner of the fire giants head. I used points on the axe like this. 23940
-will then continuously cycle through your abilities on the ability bar from 9 down to 1. Highest cooldowns should be on the right. food should be in the z slot and regenerate should be in the 0 slot.
-will stay in the fight til 2 dtms show up. 1 for the completely empty hp bar, and another to find the 0 in the middle
-when the end of fight is detected it will check hp to see if it is below 75% and if the Adrenaline bar is above 20%. If those 2 conditions are met then it will use regenerate.
-If you are below 50% health then it will eat.
-will then run antiban
-Whenever the break timer is up it will start a break for a short period.

23941

program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/LIB/SPS-RS3.simba}


const
//-------Login Settings-------//
PLAYER_FILE = 'Godlist';
NICKNAME = 'Main';
LOGIN_WORLD = 0;
//----------------------------//
//-------Break settings-------//
ENABLE_BREAKS = True;

MIN_PLAY_TIME = 45; //45
MAX_PLAY_TIME = 180; //180

MIN_BREAK_TIME = 5;
MAX_BREAK_TIME = 45;
//----------------------------//

var
//-------Global Variables-------//
TotalBreakTime, StatsTime, misClick : 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;
setupSRL();

players.Setup([NICKNAME], PLAYER_FILE);
currentPlayer := 0;
players[currentPlayer].world := LOGIN_WORLD;

exitTreasure();

resetBreakTimer();
TotalBreakTime.start();
TotalBreakTime.pause();
end;
//-------------------------------------------------------------------------------------------------------------------------------//

//-------------------------------------------------------------------------------------------------------------------------------//
function heal(): boolean;
var
heartBar, x, y : integer;
begin
heartBar := DTMFromString('mlwAAAHicY2dgYJjACMHTgbgTyu4G4qlAfA 2ILwDxJSh9B4hvAPF1IJ6hJMvw6/YFhqOexgyvl9Qx1OsaMbSJCDOUWogz4AOMeDAUAABpNxL5');
if findDTM(heartBar, x, y, actionBar.getBounds()) = True then
begin
writeLn('In the HEAL procedure: Found the Heart');
sendKeys('0', 250, 40);
wait(randomRange(6000, 6500));
result := True;
exit;
end;

end;

//-------------------------------------------------------------------------------------------------------------------------------//


//-------------------------------------------------------------------------------------------------------------------------------//
procedure healthEat();
var
heartBar, x, y : integer;
fhb : boolean;
begin
heartBar := DTMFromString('mlwAAAHicY2dgYJjACMHTgbgTyu4G4qlAfA 2ILwDxJSh9B4hvAPF1IJ6hJMvw6/YFhqOexgyvl9Qx1OsaMbSJCDOUWogz4AOMeDAUAABpNxL5');
fhb := False;
if actionBar.getHPPercent() < 75 then
begin
if actionBar.getAdrenalinePercent() > 20 then
begin
writeLn('Using Heal');
repeat
heal();
until heal() = True;
writeLn('Healing is done. Hp: ', actionBar.getHPPercent());

exit;
End else
begin
exit;
end;
end;
if actionBar.getHPPercent() <= 50 then
begin
repeat
sendKeys('z', 250, 40);
until actionBar.getHPPercent() > 50;
end;

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
begin
repeat
players[currentPlayer].logout();
until not isLoggedIn();
end
else
begin
repeat
players[currentPlayer].exitToLobby();
until lobby.isOpen();
end;


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;
//-------------------------------------------------------------------------------------------------------------------------------//


//-------------------------------------------------------------------------------------------------------------------------------//
function clickEnemy(): boolean;
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
hpDTM, hBarDTM, fightDTM: integer;
isMobDead : boolean;
misClick : TTimeMarker;
begin
if isLoggedIn() then
begin
fightDTM := DTMFromString('mbQAAAHicY2VgYLgCxLqMDAxGQKwGxNpAfB godgiITwPxJSA+A8SXJ0ky3Ll+ieHh3RsM0WYKDBUFsQzYACMW DAYAtIEOEA==');
hBarDTM := DTMFromString('mKgEAAHic42NgYFBhZGDwB+IgIP4J5P8GYk kgW5sRQmsBsQUQOwIxGxC/Bcp7AelzDBB8EYgvAPEZJHwJis8g0YeB+CgQ2wgLM2hzcsJpRT Y2MI0L84lIMvCJSjFIgtxFBmYkE6MCAFnIFUE=');
hpDTM := DTMFromString('mbQAAAHicY2VgYFBhZWBQBmI1IFYFYiUg3g wUXw/EG4B4GxTbCAsz/D/NynB3AwuYDtMRZJAEiqNjRiwYDADI8wr3');
isMobDead := false;
repeat

if findDTM(fightDTM, x, y, mainscreen.getBounds()) = True then
begin
writeLn('Top of Procedure: You are in a fight'); //fix this statement. it just exits sometimes and the script gets stuck in a loop. doing nothing.
result := True;
exit;
end;
findColorsSpiralTolerance(x, y, TPA, 2571108, mainScreen.getBounds(), 14, colorSetting(2, 0.20, 0.82));
if length (TPA) < 1 then //If there are no monsters found it will terminate and rerun.
begin
exit;
end;
ATPA := TPA.toATPA(50, 50);
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
fastClick(MOUSE_RIGHT);
if chooseOption.optionsExist(['ttack']) then // attacks mob
begin
chooseOption.select(['ttack Fire giant']);
wait(randomRange(4000, 4500));
break;

end;
end;
end;
until findDTM(fightDTM, x, y, mainscreen.getBounds()) = True;
clearDebug();
writeLn('You are in a Fight');
smartImage.clear();
result := True;
exit;
End else
if not isLoggedIn() then
begin
writeLn('You are not logged in');
exit;
end;

end;
//-------------------------------------------------------------------------------------------------------------------------------//


//-------------------------------------------------------------------------------------------------------------------------------//
function isMonsterDead(): boolean;
var
hpDTM, hBarDTM, x, y : integer;
isMobDead : boolean;
begin
hBarDTM := DTMFromString('mKgEAAHic42NgYFBhZGDwB+IgIP4J5P8GYk kgW5sRQmsBsQUQOwIxGxC/Bcp7AelzDBB8EYgvAPEZJHwJis8g0YeB+CgQ2wgLM2hzcsJpRT Y2MI0L84lIMvCJSjFIgtxFBmYkE6MCAFnIFUE=');
hpDTM := DTMFromString('mbQAAAHicY2VgYFBhZWBQBmI1IFYFYiUg3g wUXw/EG4B4GxTbCAsz/D/NynB3AwuYDtMRZJAEiqNjRiwYDADI8wr3');
isMobDead := false;
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');
clearDebug();
if findDTM(hBarDTM, x, y, mainScreen.getBounds()) then
begin
writeLn('DTM 2 found, Monster Healthbar empty');
isMobDead := True;
result := True;
end;
end;
end;

//-------------------------------------------------------------------------------------------------------------------------------//


//-------------------------------------------------------------------------------------------------------------------------------//
function pickUpCharms(): boolean;
var
x, y, i : integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
if IsLoggedIn() then
begin
wait(randomRange(3500, 4000));
writeLn('Searching for Charms');
findColorsSpiralTolerance(x, y, TPA, 10666722, mainScreen.getBounds(), 23, colorSetting(2, 0.22, 2.07));
if length (TPA) < 1 then //If there are no bones found it will terminate and rerun.
begin
exit;
end;
ATPA := TPA.toATPA(40, 40);
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.
if chooseOption.optionsExist(['ake Gold charm']) then
begin
chooseOption.select(['ake Gold charm']);
tabBackPack.waitForShift(10000);
smartImage.clear();
result := True;
exit;
end
else if chooseOption.optionsExist(['ake Green charm']) then
begin
chooseOption.select(['ake Green charm']);
tabBackPack.waitForShift(10000);
smartImage.clear();
result := True;
exit;
end
else if chooseOption.optionsExist(['ake Crimson charm']) then
begin
chooseOption.select(['ake Crimson charm']);
tabBackPack.waitForShift(10000);
smartImage.clear();
result := True;
exit;
end
else
begin
smartImage.clear();
result := False;
exit;
end;

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;
isMobDead : boolean;
begin
hpDTM := DTMFromString('mbQAAAHicY2VgYFBhZWBQBmI1IFYFYiUg3g wUXw/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

until clickEnemy() = True;
repeat
misClick.reset();
misClick.start();
isMonsterDead();
doAbilities();
until isMonsterDead() = True or misClick.getTime() > 90000;
healthEat();
antiBan();
takeBreak();
wait(randomRange(3000, 3500));
until(false);
end.

sipfer3
08-31-2014, 01:01 PM
to look if your fight ended just use your isMonsterDead function.
like

repeat
wait(500)
until(isMonsterDead = true);

or smth like that. and dont forget to set a timemark as antifail maybe it would work out