SRL Archive - Research & Development Lounge

Reflection AntiRandoms


Seroko

2008-09-26 00:49:19

I am starting a long list of all the randoms done in reflection. Don't flame if you hate reflection, I am not asking your opinion. I am just simply asking you to test these functions and give me your feedback, first off a very very simple script to open scar and run a test on a function for me, just past the function you are testing onto the script and change the function name at the bottom.

Please note I currently am completely unable to play at all and when I say UNTESTED I mean they have never been run, I know thats not good but >_> having bad issues right now in rl.

R_SolveBox [UNTESTED] this one should be VERY basic, would like to change the bitmap to a dtm, suggestions? a screenshot to make the dtm off of anyone?
{*******************************************************************************
function R_SolveBox: Boolean;
by: Seroko
Description: Checks for and solves the mysterious box random.
*******************************************************************************}
function R_SolveBox: Boolean;
var
i, x, y : Integer;
begin

i := BitmapFromString(25, 25, 'beNpjYMAF/mMABtIBLo0km' + // From SRL
'UyS7bhMJtsLyCbASQoBJUFKSeCMGjVq1KhRw94ouCFUKfFwcck2h4' +
'wqgCQHEDSZEo8QdjYABzDsFA==');

Result := False;
GameTab(4);
Wait(100 + Random(50));
if FindBitmapMaskTolerance(i, x, y, 547, 202, 737, 466, 5, 5) then
begin
repeat
Mouse(x + 8, y + 8, 10, 10, True);
Wait(3000+Random(2500)); // We want to make sure we look human-like
Mouse((120+(120*GetBoxAnswer)), 290, 30, 10, True);
Wait(1000+Random(1500));
if not(FindBitmapMaskTolerance(i, x, y, 547, 202, 737, 466, 5, 5)) then
Result := True;
until(Result);
end;
FreeBitmap(i);
end;

R_SolveMime [UNTESTED] I know Drags111 has one out but I feel his is rather long and a bit rough, reviews please!
{*******************************************************************************
function R_SolveMime: Boolean;
by: Seroko
Description: Checks for and solves the mime random.
*******************************************************************************}
function R_SolveMime: Boolean;
var
Mime : TNPC;
i, mx, my : Integer;
Animation : String;
Emotes : TIntegerArray;
begin
Result := False;
if not FindNPC('Mime', Mime) then
Exit;
Emotes := [857, 860, 861, 866, 1128, 1128, 1130, 1131];
repeat
i := Mime.Animation;
if InIntArray(Emotes, i) then
begin
case i of // Set our Animation text
857: Animation := 'Think';
860: Animation := 'Cry';
861: Animation := 'Laugh';
866: Animation := 'Dance';
1128: Animation := 'Glass Wall';
1128: Animation := 'Lean on air';
1130: Animation := 'Climb Rope';
1131: Animation := 'Glass Box';
end;
while not(FindColorTolerance(mx, my, 1122502, MCX1, MCY1, MCX2, MCY2, 40)) do // Drags111
Wait(100 + Random(100));
Wait(1000 + Random(1000));
FindTextTpaEx(11503238, 10, MCX1, MCY1, MCX2, MCY2, mx, my, Animation, npcchars, ClickLeft)
end;
until(not(FindNPC('Mime', Mime)));
Result := True;
end;

Next will by Molly Random~ [Its done if someone has a character in molly willing to test this function send me a PM because its a little rough]

Script you can paste the function onto, setup declare players, paste the function, and change the area at the bottom to match the function name. Let it play and hit F2. (Make sure SMART is ENABLED >_>)

Program Tests;
{.include srl/srl/misc/smart.scar}
{.include srl/srl.scar}
{.include srl/srl/reflection/reflection.scar}

const
Members = 'yes'; // YES for members worlds NO for free worlds!!

procedure DeclarePlayers;
begin
NumberOfPlayers(1);
CurrentPlayer := 0;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
end;

// PASTE THE FUNCTION HERE!!

function RandomWorld: String;
var
Worlds: TIntegerArray;
begin
if (Lowercase(Members) = 'no') then
begin
Worlds := [25, 81, 102, 11, 105, 16, 106, 80, 135, 152, 72, 113, 37, 75,
169, 34, 40, 128, 87, 41, 101, 43, 35, 93, 33, 73, 120, 95, 90,
86, 96, 85, 38, 55, 57, 94, 127, 20, 126, 74, 125, 50, 118,
119, 30, 13, 123, 62, 7, 149, 165, 49, 8, 63, 21, 136, 19, 109,
153, 161, 14, 150, 163, 167, 154, 108, 61, 29, 47, 134, 107,
155, 32];
result := 'world'+IntToStr(Worlds[Random(high(Worlds))]);
end;
if (Lowercase(Members) = 'yes') then
begin
Worlds := [84, 92, 71, 129, 83, 82, 23, 143, 54, 130, 100, 45, 60, 44, 46,
97, 59, 78, 99, 36, 103, 98, 104, 77, 58, 88, 39, 91, 116, 115,
79, 114, 164, 89, 76, 132, 22, 69, 27, 168, 121, 67, 28, 166,
124, 70, 66, 48, 64, 12, 56, 133, 156, 162, 111, 117, 145, 137,
65, 138, 42, 110, 151, 148, 26, 159, 51, 112, 160, 15, 131, 52,
158, 157];
result := 'world'+IntToStr(Worlds[Random(high(Worlds))]);
end;
end;

begin
SetupSRL;
SmartSetup(RandomWorld, True, True, False);
Wait(5000);
SetTargetDC(SmartGetDC);
DeclarePlayers;
LoginPlayer;
Repeat
If (IsFKeyDown(2)) Then
Begin
if {FUNCTION NAME THING HERE} then
Writeln('Random ~SHOULD~ be solved');
end;
While IsFKeyDown(2) Do
Wait(1);
until IsFKeyDown(3);
end.

Naike

2008-09-26 01:06:58

R_SolveBox dosnt got anything with Reflection to do ? Or am i missing something.

SolveMime wont work eaither becuase it only get the array once outside the repeat loop then it breaks..

So if your lucky and hit it right, it will click the first emote right.

Narcle

2008-09-26 01:08:42

I haven't seen the other Mime solver, but I know the way you currently have yours won't work. I'll tell you why. Animation isn't a long lasting action, it happens over a brief few MS. So to detect it, you need to do a repeating loop until animation is recorded for the next step.

I know yours is repeating, but that While to do loop stops it.

Seroko

2008-09-26 01:19:29

From: N1ke!
R_SolveBox dosnt got anything with Reflection to do ? Or am i missing something.

SolveMime wont work eaither becuase it only get the array once outside the repeat loop then it breaks..

So if your lucky and hit it right, it will click the first emote right.


It uses reflection to get the box answer out of the settings array, and it updates the mime every time it goes through the until.

From: Narcle
I haven't seen the other Mime solver, but I know the way you currently have yours won't work. I'll tell you why. Animation isn't a long lasting action, it happens over a brief few MS. So to detect it, you need to do a repeating loop until animation is recorded for the next step.

I know yours is repeating, but that While to do loop stops it.


You sure? Its all in an if statement and it doesn't kick in unless the animation is caught so if theres no animation it should repeat until it catches one then work through it.

Narcle

2008-09-26 03:06:22

From: Seroko
It uses reflection to get the box answer out of the settings array, and it updates the mime every time it goes through the until.



You sure? Its all in an if statement and it doesn't kick in unless the animation is caught so if theres no animation it should repeat until it catches one then work through it.


Ok I see the if statement, but what if the Animation you record isn't the correct one? If I recall there's a few animations that are done so much that they are used in other animation loops as well. So the animation you record might not be the right one (or any in your case statement).

Seroko

2008-09-26 06:14:37

From: Narcle
Ok I see the if statement, but what if the Animation you record isn't the correct one? If I recall there's a few animations that are done so much that they are used in other animation loops as well. So the animation you record might not be the right one (or any in your case statement).


Ah thanks I didn't know this, well. I set the if from if i>0 to check against a TIntegerArray so that should solve that problem, I got my molly solver done but it looks a bit rough would like someone to contact me in pms / msn to test it before i post it here.

n3ss3s

2008-09-26 07:32:47

The box solver doesn't user reflection. Here's mine that does,


Function ClientSolveBox: Boolean;

Var
TPA: TPointArray;
TPAA: T2DPointArray;
I: Integer;
Begin
FindColorsTolerance(TPA, 4803916, 107, 277, 431, 322, 10);
If GetArrayLength(TPA) < 1 Then Exit;
TPAA := TPAToATPAEx(TPA, 70, 30);
SetArrayLength(TPA, 0);
TPA := TPAA[GetBoxAnswer];
I := GetArrayLength(TPA);
Mouse(TPA[Random(i)].x, TPA[Random(i)].y, 0, 0, True);
Result := True;
End;


Function FindNormRandoms: Boolean;

Var
I: Integer;
Begin
For i := 1 To 8 Do
Begin
Case I of
1: SolveNonTalkingRandoms;
2: Respond;
3: Result := FindTalk;
4: Result := FindDead;
5: Result := FindLamp(LampSkill);
6:
If FindBox Then
Begin
Result := OpenBox;
If Result Then
Result := ClientSolveBox;
End;
7: Result := RC;
8: Result := FindMod;
End;
If Result Then
Break;
//Wait(1);
End;
End;


Lee Lok Hin

2008-09-26 07:36:28

Yes it does.

Mouse((120+(120*GetBoxAnswer)), 290, 30, 10, True);