SRL Archive - Reflection Development

Solve all talking randoms w/o nicks! (And all my other reflection functions)


almost

2009-01-10 16:32:03

I'm rapidly coming up with reflection functions, so instead of spamming this area I will just use this page for what ever things I come up with that could possibly be added to the next version of reflection.

R_FindTalkingNPC and R_SolveFrog have been removed because they were added into reflection.

ClickInvID-
Nothing too original, but need for attaching the pick head.

FindPick-
Added in a check for if you can wield your pick or not (My army all has 40+ attack so I didn't consider this at first)
It sets a boolean based on if your Attack level is 40 or higher (Doesn't have to open your stats tab either)

This will work for any type of pickaxe, without setting anything before calling this function.
I've tested it loads of times at weird angles, things covering up the pick head, all types of picks, pick head being far off screen, and nothing stumps it.

There are two places you might have to edit to fit your script.
What to do if your pick is broken and the ID of the ore you are mining.


function ClickInvID(ID: integer; Left: boolean): boolean;
var
ItemSlots: TIntegerArray;
begin
if not InventoryContains(ID, ItemSlots) then
begin
Result:= false;
Exit;
end;
MouseItem(ItemSlots[0], Left);
Result:= true;
end;





function FindPick: boolean;
var
Items: array of TGroundItem;
PickHeadTile: TPoint;
c, c2, x, y: integer;
WieldPick: boolean;
CharStats: TMe;
begin
for c:= 1 to 5 do
begin
if not FindGroundItems(Items, [480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491], 50) then
begin
{your pick is broken}
{Put whatever your script needs to do for broken picks here}
end;
WieldPick:= (CharStats.Levels[0] >= 40);
if WieldPick then
for c:= 1 to 10 do
begin
if (InvCount > 26) then
begin
ClickInvID(454 {this id is for coal, change if you are mining another ore}, false);
Wait(800 + Random(500));
ChooseOption('rop');
Wait(800 + Random(500));
end;
end else
for c:= 1 to 10 do
begin
if (InvCount > 27) then
begin
ClickInvID(454 {this id is for coal, change if you are mining another ore}, false);
Wait(800 + Random(500));
ChooseOption('rop');
Wait(800 + Random(500));
end;
end;
if not (TileOnMS(Items[0].Tile, 0)) then
TileWalk(Items[0].Tile, 5, 0, 1, 1);
PickHeadTile:= TileToMS(Items[0].Tile, 0);
for c2:= 1 to 20 do
begin
MMouse(PickHeadTile.x - 5, PickHeadTile.y - 5, 10, 10);
Wait(500 + Random(500));
if (Pos('ick', RS_GetUpText) > 0) then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
AlmFlag(0);
Result:= true;
Break;
end;
end;
if Result then
Break;
end;
Result:= false;
if WieldPick then
begin
GameTab(5);
Mouse(579, 303, 5, 5, true);
Wait(100 + Random(500));
end;
GameTab(4);
Wait(500 + Random(500));
if ClickInvID(489, true) then
begin
Wait(500 + Random(500));
if ClickInvID(467, true) then
begin
Wait(2000 + Random(500));
for c2:= 1265 to 1276 do
if ClickInvID(c2, true) then
begin
WriteLn('Attached pick head!');
Result:= true;
{if your script keeps track of picks fixed
Inc(PicksFixed); }
Exit;
end;
end;
end;
end;


R_SolvePinball2-
Solves the pinball random
function R_SolvePinball2: boolean;
var
i, PinballMark: integer;
Posts: array [0..5] of TPoint;
PostMS: TPoint;
PostObj: UID;
begin
if not (R_InPinBall) then
Exit;
Result:= false;
WriteLn('Found pinball random!');
SetRun(true);
if not FindObject(Posts[2], 15004) then
if not FindObject(Posts[2], 15005) then
begin
WriteLn('The reference post could not be found.');
Exit;
end;
Posts[0]:= Point(Posts[2].x - 5, Posts[2].y - 4);
Posts[1]:= Point(Posts[2].x - 3, Posts[2].y - 1);
Posts[3]:= Point(Posts[2].x + 3, Posts[2].y - 1);
Posts[4]:= Point(Posts[2].x + 5, Posts[2].y - 4);
MarkTime(PinballMark);
while ((GetScore < 10) and (TimeFromMark(PinballMark) < 60000)) do
begin
for i:= 0 to 4 do
begin
PostObj:= GetObjectAt(Posts[i].x, Posts[i].y);
if (PostObj.ObjType mod 2 = 0) then
begin
repeat
Wait(500);
until(TileOnMS(Posts[i], 0) or (TimeFromMark(PinballMark) > 30000));
PostMS:= TileToMS(Posts[i], 0);
Mouse(PostMS.x - 2, PostMS.y - Random(25), 4, 0, false);
Wait(800 + Random(500));
if (ChooseOption('ag')) then
begin
R_Flag;
Wait(5000 + Random(3000));
MarkTime(PinballMark);
Break;
end;
end;
end;
end;
R_Flag;
Wait(5000 + Random(3000));
if (GetScore = 10) then
for i:= 1 to 5 do
begin
Wait(1000 + Random(500));
R_Flag;
KeyDown(Vk_Down);
Wait(2000 + Random(1000));
KeyUp(Vk_Down);
Wait(800 + Random(400));
MakeCompass('s');
MakeCompass('s');
Wait(200 + Random(400));
PostMS:= TileToMS(Point(Posts[2].x, Posts[2].y - 12), 0);
Mouse(PostMS.x - 2, PostMS.y - Random(15), 4, 0, false);
Wait(800 + Random(400));
if (ChooseOption('xit')) then
begin
Result:= True;
R_Flag;
Wait(10000 + Random(5000));
Inc(RSolved[RPinball]);
WriteLn('Solved Pinball random!');
Exit;
end;
end;
Inc(RFailed[RPinball]);
end;

randy marsh

2009-01-10 20:33:17

Nice good work i am learning to use reflection good work on the randoms!

Method

2009-01-10 20:38:31

The problem is that trying to talk to randoms without knowing that they are targeting you will probably lead to more suspicion, not an easier time solving them.

senrath

2009-01-10 20:45:29

What happens if someone else's random appears within 6 tiles of you?

mormonman

2009-01-10 20:57:05

From: Method
The problem is that trying to talk to randoms without knowing that they are targeting you will probably lead to more suspicion, not an easier time solving them.


Can't you just check to see if the NPC is talking to you(can't remember what the technical word is for it).

Method

2009-01-10 21:03:04

From: mormonman
Can't you just check to see if the NPC is talking to you(can't remember what the technical word is for it).


Yep, you can easily do that by grabbing its message (using a hook).

senrath

2009-01-10 21:13:59

From: Method
Yep, you can easily do that by grabbing its message (using a hook).


Wouldn't that need a nick, though?

Method

2009-01-10 21:19:20

From: senrath
Wouldn't that need a nick, though?


You'd need some sort of username or nickname information, which can either be gathered from the Players array or through a username hook in the client.

almost

2009-01-10 21:36:43

Ok a few things here…
Talking to someone else's random won't mess up anything, but I suppose it could be suspicious.
But ever since I have been autoing I haven't used SRL's FindTalk.
I have used my own system that will do what this one does, talk to any random that is close to you.
And it has worked.

So let's say that is a problem though, and people won't want to do that (I can see that happening)
You can use that function that returns your user name and check if the NPC is talking to you using a new hook.
It would be totally worth it, finding talks will be flawless.

Even if you don't do that, IMO talking to someone else's random once every 50 hours of autoing is worth having really solid random protection. (I add a variable for counting if the random was actually talking to you or not, and it's very rare)

NiCbaZ

2009-01-11 04:19:09

{*******************************************************************************
Function IsInteractingWithMe(Index : Integer) : Boolean;
By: n3ss3s
Description: Returns true if Index is interacting with logged in player.
*******************************************************************************}
function IsInteractingWithMe(Index : Integer) : Boolean;

var
TheNPC : Integer;

begin
TheNPC := SmartGetFieldArrayObject(0, NPCArray, Index);
Result := SmartGetFieldInt(TheNPC, CharInteracting) - 32768 = SmartGetFieldInt(0, SelfInteracting);
SmartFreeObject(TheNPC);
end;


This?

almost

2009-01-11 11:56:39

Nicbaz, have I ever told you I love you?
I didn't think that existed.
I'll put up a new version implementing this soon.

Edit:
Ok the new version is up and I even got to test it out and it works great.
I was worried it wouldn't return true unless you were actually talking to the NPC, but nope it worked fine.
PS- Where did you find that function?

Nava2

2009-01-16 23:40:40

Now, why wouldn't you post this in the randoms thread?

Fix up some things, and I will consider committing these. Standards are off, look for more efficient means of completing things.

mormonman

2009-01-17 01:13:07

From: Nava2
Now, why wouldn't you post this in the randoms thread?

Fix up some things, and I will consider committing these. Standards are off, look for more efficient means of completing things.


i say, once the standards are good, that we get reflection solving for everything so that color and reflection don't try to mix… plus i think reflection solving is more reliable…

Nava2

2009-01-17 12:41:45

Committed:
{*******************************************************************************
function FindTalkingNPC(var NPC : TNPC): Boolean;
By: almost
Description: Looks for Talking NPCs and if they are interacting with you.
*******************************************************************************}
function FindTalkingNPC(var NPC : TNPC): Boolean;

var
NPCs: array of TNPC;
NPCNames: array of string;
I, II, H, HH: integer;

begin
NPCs:= GetNPCs;
if High(NPCs) < 0 then
begin
Result:= false;
Exit;
end;
Result := True;
//In order the names are-
//Miles, Captain Hands, Jekyll, Drunken dwarf, certer, frog, genie, mysterious man, security guard, sandwich lady
NPCNames:= ['iles', 'Hand', 'kyll', 'warf', 'erter', 'rog', 'enie', 'eriou', 'urity', 'andwi'];
H := High(NPCs);
HH := High(NPCNames);
for I := 0 to H do
for II := 0 to HH do
if (Pos(NPCNames[II], NPCs[I].Name) <> 0) and (IsInteractingWithMe(NPCs[I].Index)) then
begin
NPC := NPCs[I];
Exit;
end;
Result := False;
end;


{*******************************************************************************
function R_FindTalk: Boolean;
By: answer & Nava2
Description: Finds talking randoms, and solves them using SRL means. Will be
replaced.
*******************************************************************************}

Function R_FindTalk: Boolean;
var
NPC : TNPC;
P : TPoint;
RawMenuText : String;

begin;
if not FindTalkingNPC(NPC) then
Exit;
P := TileToMS(NPC.Tile, NPC.Height / 2);
MMouse(P.x, P.y, 4, 4);
Wait(RandomRange(100, 200));
if IsUpTextMultiCustom(['Talk','lk-to','uard']) then
begin
GetMousePos(P.x, P.y);
Mouse(P.x, P.y, 0, 0, False);
Wait(RandomRange(400, 500));
R_Flag;
if ChooseOptiongetMenuText(RawMenuText, P.x, P.y, 'Talk') then
begin
R_Flag;
Wait(RandomRange(200, 400));
Result := SolveTalkingRandom(RawMenuText);
end;
end;
if Result then
Inc(RSolved[RTalks])
else
Inc(RFailed[RTalks]);
end;

As well as:
{*******************************************************************************
function R_SolveFrogInCave : Boolean;
by: Nava2 & answer
Description: Attempts to solve frog random, if in cave.
*******************************************************************************}
function R_SolveFrogInCave : Boolean;

var
NPC : TNPC;
P : TPoint;
I, FrogMark : Integer;

begin
Result := False;
FrogMark := GetTimeRunning + RandomRange(40000, 70000);
repeat
if not R_InSwampCave then
Exit;
WalkToTile(Point(2464, 4781), 0, 3);
R_Flag;
if FindNPCByID(2470, NPC) then
begin
if DistanceFrom(NPC.Tile) > 5 then
begin
WalkToTile(NPC.Tile, 0, 2);
FindNPCByID(2470, NPC);
end;
MMouse(NPC.MS.x, NPC.MS.y, 4, 4);
Wait(RandomRange(200, 300));
if IsUpText('rog') then
begin
GetMousePos(P.x, P.y);
Mouse(P.x, P.y, 0, 0, True);
R_Flag;
Wait(RandomRange(500, 1000));
for I := 0 to 2 do
ClickContinue(True, True);
Wait(RandomRange(1000, 2000));
Result := not R_InSwampCave;
end;
end;
until(FrogMark < GetTimeRunning) or (not R_LoggedIn);
if Result then
Inc(RSolved[RFrogs])
else
Inc(RFailed[RFrogs]);
end;

I would like to see a frog solver which doesn't use the cave, btw. :)

And from now on, could you please use the randoms thread?

E: Just so you know, I was annoyed with your standards through out, thats why I credited myself. If you want it removed, just say. Try and work on those xD

E2: Skill related functions wont be added. At least for awhile.

almost

2009-01-17 21:47:00

And from now on, could you please use the randoms thread?

If you look at the title, this thread was for anything I come up with and find useful.
But if it's better for things regarding randoms to be placed there, I'll put it there next time.

E: Just so you know, I was annoyed with your standards through out, thats why I credited myself. If you want it removed, just say. Try and work on those xD

If you look into the official thread on standards (where I learned my standards), they are correct.
I think you are referring to how I don't indent with if then statements, for loops, etc.
I just don't like that way that looks :p

I wouldn't need any credit for the frog solver because you made it, I just put in a repeat until a certain time, so it's cool.

Good job on making the FindTalk more efficient though, looks good.
Cleaned up a little bit too.
I wasn't worried about it at the time.

Nava2

2009-01-17 22:04:27

From: almost
If you look at the title, this thread was for anything I come up with and find useful.
But if it's better for things regarding randoms to be placed there, I'll put it there next time.


If you look into the official thread on standards (where I learned my standards), they are correct.
I think you are referring to how I don't indent with if then statements, for loops, etc.
I just don't like that way that looks :p

I wouldn't need any credit for the frog solver because you made it, I just put in a repeat until a certain time, so it's cool.

Good job on making the FindTalk more efficient though, looks good.
Cleaned up a little bit too.
I wasn't worried about it at the time.


Cheers ;)

Have you tested the FindTalk btw?

Just wondering. :)

almost

2009-01-17 22:18:09

Have you tested the FindTalk btw?

Mine- yes.
The new one- not yet.
I put it in my script and autoed for about 3 hours today, but no randoms at all…

But tonight should be an all nighter with my guildminer, so I will be able to test it out.
I just finished my mordaut solving technique and it's working 100% :)

Edit:
I would like to see a frog solver which doesn't use the cave, btw.

I just remembered something.
The new R_FindTalk has 'rog' in the names array, so it will search for the frog random.
If it finds it, it will try solving it using SRL instead of the reflection version.
So it should probably be taken out.
I remembered that because the SRL version will try to solve it by talking to the frog before you are in the cave, and if you end up in the cave it will solve it from there.

Nava2

2009-01-18 10:37:05

From: almost
Mine- yes.
The new one- not yet.
I put it in my script and autoed for about 3 hours today, but no randoms at all…

But tonight should be an all nighter with my guildminer, so I will be able to test it out.
I just finished my mordaut solving technique and it's working 100% :)

Edit:

I just remembered something.
The new R_FindTalk has 'rog' in the names array, so it will search for the frog random.
If it finds it, it will try solving it using SRL instead of the reflection version.
So it should probably be taken out.
I remembered that because the SRL version will try to solve it by talking to the frog before you are in the cave, and if you end up in the cave it will solve it from there.


Now, the issue is, will the frog actually be talking to you? As, I'm almost positive they don't.

almost

2009-01-18 11:05:58

Oooh I think you are right.
Unless we can find some sort of hook for it, it might have to be done in the cave.

I sort of got a chance to test out the new R_FindTalk last night.
A genie popped up so I logged out really fast and brought up scar.
I made something like this really quick-

repeat
R_FindTalk;
Wait(1000);
until(false);
But it just sat there.
Could be a problem with something I did somehow, not really sure.

But then while I was sleeping last night I got a sandwich lady and my own version didn't pick up on it at all.
This is the very first time I've seen this happen.
My script takes screen shots and my guy just kept walking around.
(But luckily my mordaut solving method activates when you fail any talking random)

Could they have somehow randomly updated the NPC hooks?

Edit:
Something is wrong…
Neither version of the R_FindTalk detects the randoms now.
I don't see how this is possible since hooks are up to date and it was flawless 2 days ago.

Widget

2009-01-18 20:08:08

You don't need to use nicks, just use the full player name, since that's what the NPCs say.

Also, capital letters work in reflection (since we don't have to deal with some of the problems SCAR's OCR has). Lowercase() both the name and what the NPC is saying, and check that way. Do we have hooks to get messages above NPCs heads?

Method

2009-01-18 20:09:28

From: Widget
You don't need to use nicks, just use the full player name, since that's what the NPCs say.

Also, capital letters work in reflection (since we don't have to deal with some of the problems SCAR's OCR has). Lowercase() both the name and what the NPC is saying, and check that way. Do we have hooks to get messages above NPCs heads?


Yeah, I've got that field hooked. This build it's 'p'.

almost

2009-01-18 20:32:08

Edit: Nevermind.

NiCbaZ

2009-01-18 20:36:18

Nicbaz, have I ever told you I love you?
I didn't think that existed.
I'll put up a new version implementing this soon.


No but, you did now.

Dracody

2009-01-19 00:36:18

From: Method
You'd need some sort of username or nickname information, which can either be gathered from the Players array or through a username hook in the client.


Yeah this is a great idea , can be done , like when finding the blacktext but just looking at the Nickname display, that could be the hook.

Would just save time to people and they wouldnt need to write a nick, hmm , could be that it looks for the name and then stores it in some kind of constant, or variable to keep on using it with all randoms and autoresponders.

I think this should work:
{*******************************************************************************
function GetNickname;
By: Dracody
Description: Returns your nickname.
*******************************************************************************}

function GetNickname: string;
var
P: TPoint;
cArr: TPointArray;
B: TBox;
begin
P := TextCoords(9);
if (FindColorsTolerance(cArr, ClBlack, MCX1, P.y, MCX2, P.y + 13, 0)) then
begin
B := GetTPABounds(cArr);
Result := TrimOthers(GetTextAtEx(B.x1 - 1, B.y1 - 2, 0, SmallChars, False, False,
0, 1, ClBlack, 80, False, tr_AllChars));
end;
end;

lordsaturn

2009-01-19 00:43:02

From: Dracody
Yeah this is a great idea , can be done , like when finding the blacktext but just looking at the Nickname display, that could be the hook.

Would just save time to people and they wouldnt need to write a nick, hmm , could be that it looks for the name and then stores it in some kind of constant, or variable to keep on using it with all randoms and autoresponders.

I think this should work:
…


That's not what he meant by 'hook'. By 'hook' he means a method in the runescape client that SMART uses to grab a value.

Method

2009-01-19 00:44:21

From: Dracody
Yeah this is a great idea , can be done , like when finding the blacktext but just looking at the Nickname display, that could be the hook.

Would just save time to people and they wouldnt need to write a nick, hmm , could be that it looks for the name and then stores it in some kind of constant, or variable to keep on using it with all randoms and autoresponders.

I think this should work:
{*******************************************************************************
function GetNickname;
By: Dracody
Description: Returns your nickname.
*******************************************************************************}

function GetNickname: string;
var
P: TPoint;
cArr: TPointArray;
B: TBox;
begin
P := TextCoords(9);
if (FindColorsTolerance(cArr, ClBlack, MCX1, P.y, MCX2, P.y + 13, 0)) then
begin
B := GetTPABounds(cArr);
Result := TrimOthers(GetTextAtEx(B.x1 - 1, B.y1 - 2, 0, SmallChars, False, False,
0, 1, ClBlack, 80, False, tr_AllChars));
end;
end;


There's no need for color finding when reflection can be used. That's what this topic and forum are for discussing.

noidea

2009-01-19 00:46:17

From: Dracody
Yeah this is a great idea , can be done , like when finding the blacktext but just looking at the Nickname display, that could be the hook.

Would just save time to people and they wouldnt need to write a nick, hmm , could be that it looks for the name and then stores it in some kind of constant, or variable to keep on using it with all randoms and autoresponders.

I think this should work:
{*******************************************************************************
function GetNickname;
By: Dracody
Description: Returns your nickname.
*******************************************************************************}

function GetNickname: string;
var
P: TPoint;
cArr: TPointArray;
B: TBox;
begin
P := TextCoords(9);
if (FindColorsTolerance(cArr, ClBlack, MCX1, P.y, MCX2, P.y + 13, 0)) then
begin
B := GetTPABounds(cArr);
Result := TrimOthers(GetTextAtEx(B.x1 - 1, B.y1 - 2, 0, SmallChars, False, False,
0, 1, ClBlack, 80, False, tr_AllChars));
end;
end;

Thats better than what you posted for your application yesterday… Darn, you should put more stuff like that :)

JonM1892

2009-01-19 12:04:16

I dont know why but i put this in one of my friends scripts. And it didnt work. I got sent someone cuz of a random. Granted i wasnt on the screen so i couldnt tell you which one it was.

almost

2009-01-19 12:06:32

I debugged the R_FindTalk on every line I could and figured out the problem.
It finds the NPCs matching the random event names just fine, but IsInteractingWithMe always comes back false.
So for right now I guess I'm going back to checking by distance from the NPC.
Until that can somehow get fixed.

JonM1892

2009-01-19 15:14:40

Hi I figured out what random it was. It was a evil twin one….Cuz it did it again like 10 minutes ago. Is there any way i can fix this from happening? If so reply back thanks

almost

2009-01-19 15:46:22

If you read some of my previous posts, part of that function isn't working anymore, causing it to not find the randoms.

I can put my old version back up for a temp fix.
Edit:
To fix it temporarily change the line in R_FindTalk that says
if (Pos(NPCNames[II], NPCs[I].Name) <> 0) and (IsInteractingWithMe(NPCs[I].Index)) then
to
if (Pos(NPCNames[II], NPCs[I].Name) <> 0) and (DistanceFrom(NPCs[i].Tile) < 4) then
This will try to talk to other people's randoms though if they are within 3 tiles of you.
If you don't see that as a problem (I don't) then use it.

Edit:
The highwayman, Rick Turpentine, isn't on the list of names.
I just remembered I left him off because I didn't know if his actual name was rick or highwayman.
I got him last night and died :(
So I'm still not sure what his name is.
I added 'rpent' and 'ighwa' to the list on mine so next time I get one it will debug it and tell me which name matched.