SRL Archive - SRL Archives

[FIXED] With FindDead....


ZephyrsFury

2008-04-21 10:35:13

Well just looking at the new FindDead here… it now uses GetBlackChatMessage which could pose a problem. I don't know if the new one works or not because I haven't died while using a script in a while but in theory there could be one problem.

GetBlackChatMessage only returns the last line of the chat box. So if someone were to talk in Lummy after the character dies but before FindDead was called it wouldn't detect the 'Oh dear you are dead' message and would therefore return false. So wouldn't it be better to check the last actual black chat message not just the last line in the chatbox?

Its not much of a big deal but…

Just a quick edit I made:

function FindDead: Boolean;
var
TC: TPoint;
Text: string;
begin
Result := False;

for i := 8 downto 1 do
begin
TC := TextCoords(i);
if (FindColor(x, y, 16711680, TC.x, TC.y, TC.x + 50, TC.y + 14)) //If the line has blue chat text
or (not(FindColor(x, y, 0, TC.x, TC.y, TC.x + 50, TC.y + 14))) then //or doesn't have any black text
Continue; //then continue
Text := Trim(GetTextAtEx(TC.X - 2, TC.Y - 2, 0, SmallChars, False, False, 0,
1, 0, 80, False, tr_AllChars));
Result := (Pos('dead', Text) <> 0) and (Pos('dear', Text) <> 0);
Break; //Break makes sure it only checks the last black message line
end; //so it doesn't return true if you've just died recently but were reincarnated

if (Result) then
begin
Deaths := Deaths + 1;
Result := True;
SaveToChatLog;
if Reincarnate then Exit
else
begin
if ScreenShots then
TakeScreen('Found Dead');
{ repeat
Wait(1000 + Random(1000));
until (not (LoggedIn)); }
LogOut;
Players[CurrentPlayer].Rand := 'Oh Dear You Are in Lumby';
Players[CurrentPlayer].Active := False;
end;
end;
end;

EvilChicken!

2008-04-21 10:38:44

IsChatBlackTextAnyLine?

ZephyrsFury

2008-04-21 10:42:13

From: EvilChicken!
IsChatBlackTextAnyLine?


I was thinking of that but thats slower…

Actually I don't know why I didn't use that. I guess its too late here. Anyway the idea is still valid.

EvilChicken!

2008-04-21 10:53:56

Add or take 10 MS, doesn't matter. Still, this is important and good this you posted the fix, you still should use IsChatBlackTextAnyLine. I've experienced a lot of times when players say something and the last chat message that really was important to register, didn't register.

Harry

2008-04-21 16:43:15

Those 10 ms add up EvilChicken.

Run a script for 100 hours, you wasted over 1 hour of time just with that section of randoms finding =D

EvilChicken!

2008-04-22 09:33:03

I knew someone were gonna say that.

Your formula is SO untrue. It actually depends on how often the random checks are. And how did you manage to turn milliseconds to HOURS?!

And if this function is so fast, why don't the devs replace IsChatBlackTextAnyLine wit this?

SKy Scripter

2008-04-22 13:16:48

Im pretty Sure Finding The text is going to be alot faster then getting the text…
-.-

Wizzup?

2008-04-22 13:55:03

Only a bit, SKy.
The FindDead isn't really new, it has been like this for a long time. :p
I suppose you could add all lines, for now it seems too slow to me… Maybe with the new OCR. ;)

Markus

2008-04-22 13:56:04

How about FindTextTPA on the chatbox?

SKy Scripter

2008-04-22 15:18:39

I agree with markus :)

Harry

2008-04-22 15:37:50

From: EvilChicken!
I knew someone were gonna say that.

Your formula is SO untrue. It actually depends on how often the random checks are. And how did you manage to turn milliseconds to HOURS?!

…


=]

It does add up. And that function can cause a bit of lag for the script. It makes it so FindNormalRandoms goes even slower.

@Markus+SKy: I agree :)

Santa_Clause

2008-04-22 19:36:26

Not to hijack or anything, but if we're going to use FindTextTPA for FindDead, can we also use it for ChooseOption and ClickToContinue?

Cazax

2008-04-25 18:14:44

Here yo go:
FindTextTPA(0, 0, MCX1, MCY1, MCX2, MCY2, 'dear', SmallChars, Nothing)
with FindDead:
function FindDead: Boolean;

begin
Result := False;
if FindTextTPA(0, 0, MCX1, MCY1, MCX2, MCY2, 'dear', SmallChars, Nothing) then
begin
Deaths := Deaths + 1;
Result := True;
SaveToChatLog;
if Reincarnate then Exit
else
begin
if ScreenShots then
TakeScreen('Found Dead');
{ repeat
Wait(1000 + Random(1000));
until (not (LoggedIn)); }
LogOut;
Players[CurrentPlayer].Rand := 'Oh Dear You Are in Lumby';
Players[CurrentPlayer].Active := False;
end;
end;
end;

mastaraymond

2008-04-25 18:54:36

From: Santa_Clause
Not to hijack or anything, but if we're going to use FindTextTPA for FindDead, can we also use it for ChooseOption and ClickToContinue?

Not for ChooseOption because that uses multiply colors.. But since the text of the chat is black… ;).

Wizzup?

2008-04-25 19:27:49

From: mastaraymond
But since the text of the chat is black… ;).


Just to clarify: The RuneScape message text in the chat box is black… Which automatically makes sure you don't get triggered when a person types 'oh dear you are dead'.