SRL Archive - RS3 Help

Making a function to determine if death accured or not?


trips

2015-05-20 19:05:45

Hello,

Could someone help me out on my script?

I have the code:

procedure climbLadders();
var
x, y, i: integer;
begin
if not isLoggedIn() then
exit;
minimap.setAngle(Random(360));
wait(randomRange(2000, 3000));
if mainscreen.findObject(x, y, 4411735, 4, colorSetting(2, 0.16, 0.28), mainscreen.playerPoint, 50, 30, 50, ['adder'], MOUSE_LEFT) then //sara ladder
exit()
else mainscreen.findObject(x, y, 3033169, 6, colorSetting(2, 0.11, 0.97), mainscreen.playerPoint, 50, 50, 10, ['imb', 'adder'], MOUSE_LEFT); //zammy ladder
end;

What it does is climb the ladders in the sara/zammy side of the respawn base at castle wars. What I want to do is add a function to my script where it determines if I have died so it can go back up the ladder and repeat. ATM I just have it as a procedure in my script that loops.

I need to make a function like function inRespawn(): or something and outRespawn(): but I don't really know how. I could provide my script if needed.

Clarity

2015-05-20 19:09:15

Isn't there some text that pops up like "You will be kicked if you don't leave the respawn room in 2 minutes" or something?
You should check for whether that text is on your screen.

trips

2015-05-20 19:14:28

From: Clarity
Isn't there some text that pops up like "You will be kicked if you don't leave the respawn room in 2 minutes" or something?
You should check for whether that text is on your screen.


Yes, it doesn't pop up untill 2 minutes of sitting in the respawn room. Hopefully by two minutes I would already be up the ladder. However, I have a working procedure in my script now that will climb the ladders but I don't think it's efficient. I think I should have a function that determines if I have respawned in the respawn room.

When the game starts it goes up the ladder with the provided snippet above, however, during the game it's possible death could accure. I want it to detect if it has died and then proceed back up the ladder.

In the waiting room it says:

"You have two minutes to leave the respawn room.." accross the interface.

After two minutes it says, in red:

"WARNING: YOU HAVE LESS THAN A MINUTE TO LEAVE THE RESPAWN ROOM!"

Clarity

2015-05-20 19:15:57

From: trips
Yes, it doesn't pop up untill 2 minutes of sitting in the respawn room. Hopefully by two minutes I would already be up the ladder. However, I have a working procedure in my script now that will climb the ladders but I don't think it's efficient. I think I should have a function that determines if I have respawned in the respawn room.

When the game starts it goes up the ladder with the provided snippet above, however, during the game it's possible death could accure. I want it to detect if it has died and then proceed back up the ladder.

In the waiting room it says:

"You have two minutes to leave the respawn room.." accross the interface.

After two minutes it says, in red:

"WARNING: YOU HAVE LESS THAN A MINUTE TO LEAVE THE RESPAWN ROOM!"


Right, so I meant you should be constantly checking for the "You have two minutes to leave the respawn room…" since it appears instantly when you have died and ended up in that room again. There's no need to detect the red text since you presumably would have already reacted to the initial warning, although you can if you like.

trips

2015-05-20 19:20:05

From: Clarity
Right, so I meant you should be constantly checking for the "You have two minutes to leave the respawn room…" since it appears instantly when you have died and ended up in that room again. There's no need to detect the red text since you presumably would have already reacted to the initial warning, although you can if you like.


So should i put it in my procedure to constantly check for the text or make a function that does it? I'm very confused and lost, I'm not sure what to do at this point. :p

EDIT: it could also detect "Oh dear, you are dead!" maybe and then proceed up the ladder then. I'm not sure how to actually make it though.

Clarity

2015-05-20 19:28:44

From: trips
So should i put it in my procedure to constantly check for the text or make a function that does it? I'm very confused and lost, I'm not sure what to do at this point. :p

EDIT: it could also detect "Oh dear, you are dead!" maybe and then proceed up the ladder then. I'm not sure how to actually make it though.


Your script could have a main loop format like so:

procedure climbLadders();
begin
{...your ladder climbing code...}
end;

procedure goAFK();
begin
wait(random(2500, 7500));
someAntibanHere();
end;

function inRespawn(): boolean;
var
searchBox: TBox;
begin
searchBox := IntToBox(x1, y1, x2, y2);
result := (countColor(warningTextColorHere, searchBox) > someThresholdAmount);
end;

procedure mainLoop();
begin
if (not isLoggedIn()) then
exit();
if inRespawn() then
climbLadders()
else
goAFK();
end;

Notice that inRespawn uses the countColor() method. Count color will return the amount of pixels that match the given color within a certain search box. In the inRespawn function, you would check to see if the correct amount of pixels match the text color, which I am assuming will be a constant amount. I doubt they are varying their text spacing/format to trick bots in this case.

trips

2015-05-20 19:41:26

From: Clarity
Your script could have a main loop format like so:

procedure climbLadders();
begin
{...your ladder climbing code...}
end;

procedure goAFK();
begin
wait(random(2500, 7500));
someAntibanHere();
end;

function inRespawn(): boolean;
var
searchBox: TBox;
begin
searchBox := IntToBox(x1, y1, x2, y2);
result := (countColor(warningTextColorHere, searchBox) > someThresholdAmount);
end;

procedure mainLoop();
begin
if (not isLoggedIn()) then
exit();
if inRespawn() then
climbLadders()
else
goAFK();
end;

Notice that inRespawn uses the countColor() method. Count color will return the amount of pixels that match the given color within a certain search box. In the inRespawn function, you would check to see if the correct amount of pixels match the text color, which I am assuming will be a constant amount. I doubt they are varying their text spacing/format to trick bots in this case.


Thank you Clarity, I'm going to mess with this and see if I can get this going. Thanks for breaking it down for me.

EDIT: Also, here is my mainloop/setup.

//main loop
procedure mainLoop();
begin
repeat
if not isLoggedIn() then
exit;
if reportVisible() then
closeReport();
if inLobby() and (not reportVisible()) then
startGame();
if inWaitRoom() then
waitGameRoom();
if inRespawn() then
clickLadders();
if outRespawn() then
antiban();
until (not isLoggedIn());
end;

procedure setup();
begin
if isLoggedIn() then
begin
exitTreasure();
closePopUp();
//minimap.clickCompass(true);
mainScreen.setZoom(false);
mainScreen.setAngle(MS_ANGLE_HIGH);
end;
end;

Just so you can see what I have going on

Also,

function inRespawn(): Boolean;
begin
result := false;
end;


^ is this correct?

Clarity

2015-05-20 19:43:14

From: trips
Thank you Clarity, I'm going to mess with this and see if I can get this going. Thanks for breaking it down for me.


No problem, don't hesitate to ask any further questions, or let me know if you want something explained better. Also it's good that you've been making public posts rather than PMs, as everybody can learn with a publicly posted thread :)