SRL Archive - Reflection Tutorials

Reflection randoms: How does it work?


Naike

2010-10-16 19:26:19

Functions we will be working with
  • r_SetupRandoms
  • r_GetMusic
  • R_SolveNonTalkingRandoms

Const
r_RandomCount = 18;

R_RANDOM_ABYSS = 0;
R_RANDOM_BEEKEEPER = 1;
R_RANDOM_CAPNARRAV = 2;
R_RANDOM_CERTER = 3;
R_RANDOM_DRILLDEMON = 4;
R_RANDOM_EVILBOB = 5;
R_RANDOM_EXAM = 6;
R_RANDOM_FREAKYFORESTER = 7;
R_RANDOM_FROG = 8;
R_RANDOM_GRAVEDIGGER = 9;
R_RANDOM_MAZE = 10;
R_RANDOM_MIME = 11;
R_RANDOM_MOLLY = 12;
R_RANDOM_PILLORY = 13;
R_RANDOM_PINBALL = 14;
R_RANDOM_PRISON = 15;
R_RANDOM_QUIZ = 16;
R_RANDOM_SANDWICHLADY = 17;

type
r_Random = Record
RandName, Music: String;
r_InRandom, r_SolveRandom: function: Boolean;
end;

var
r_RandomArr: Array [0..17] of r_Random;
r_RandomVarSet: Boolean;

Procedure r_SetupRandoms;
begin
With r_RandomArr[R_RANDOM_ABYSS] do
begin
RandName := 'Abyss';
Music := 'into the abyss';
r_InRandom := nil;
r_SolveRandom := nil;
end;

With r_RandomArr[R_RANDOM_BEEKEEPER] do
begin
RandName := 'Beekeeper';
Music := '';
r_InRandom := @r_InBeekeeper;
r_SolveRandom := @R_SolveBeekeeper;
end;

With r_RandomArr[R_RANDOM_CAPNARRAV] do
begin
RandName := 'Cap n'' Arrav';
Music := 'sea shanty';
r_InRandom := nil;
r_SolveRandom := nil;
end;

With r_RandomArr[R_RANDOM_CERTER] do
begin
RandName := 'Certer';
Music := '';
r_InRandom := nil;
r_SolveRandom := nil;
end;

With r_RandomArr[R_RANDOM_DRILLDEMON] do
begin
RandName := 'Drill Demon';
Music := 'corporal punishment';
r_InRandom := @R_InDemon;
r_SolveRandom := nil;
end;

With r_RandomArr[R_RANDOM_EVILBOB] do
begin
RandName := 'Evilbob';
Music := 'evil bob''s island';
r_InRandom := nil;
r_SolveRandom := nil;
end;

With r_RandomArr[R_RANDOM_EXAM] do
begin
RandName := 'Exam';
Music := 'school''s out';
r_InRandom := nil;
r_SolveRandom := nil;
end;

With r_RandomArr[R_RANDOM_FREAKYFORESTER] do
begin
RandName := 'Freaky forester';
Music := 'pheasant peasant';
r_InRandom := nil;
r_SolveRandom := nil;
end;

With r_RandomArr[R_RANDOM_FROG] do
begin
RandName := 'Frog';
Music := 'frogland';
r_InRandom := @R_InFrogCave;
r_SolveRandom := @R_SolveFrogCave;
end;

With r_RandomArr[R_RANDOM_GRAVEDIGGER] do
begin
RandName := 'Gravedigger';
Music := 'spooky';
r_InRandom := nil;
r_SolveRandom := nil;
end;

With r_RandomArr[R_RANDOM_MAZE] do
begin
RandName := 'Maze';
Music := 'time out';
r_InRandom := nil;
r_SolveRandom := nil;
end;

With r_RandomArr[R_RANDOM_MIME] do
begin
RandName := 'Mime';
Music := 'artistry';
r_InRandom := @R_InMime;
r_SolveRandom := @R_SolveMime;
end;

With r_RandomArr[R_RANDOM_MOLLY] do
begin
RandName := 'Molly';
Music := 'head to head';
r_InRandom := @R_InMolly;
r_SolveRandom := @R_SolveMolly;
end;

With r_RandomArr[R_RANDOM_PILLORY] do
begin
RandName := 'Pillory';
Music := '';
r_InRandom := nil;
r_SolveRandom := nil;
end;

With r_RandomArr[R_RANDOM_PINBALL] do
begin
RandName := 'Pinball';
Music := '';
r_InRandom := nil;
r_SolveRandom := nil;
end;

With r_RandomArr[R_RANDOM_PRISON] do
begin
RandName := 'Prison';
Music := 'in the clink';
r_InRandom := nil;
r_SolveRandom := nil;
end;

With r_RandomArr[R_RANDOM_QUIZ] do
begin
RandName := 'Quiz';
Music := '';
r_InRandom := nil;
r_SolveRandom := nil;
end;

With r_RandomArr[R_RANDOM_SANDWICHLADY] do
begin
RandName := 'Sandwhich lady';
Music := 'snack attack';
r_InRandom := @r_InSandwichLadyRandom;
r_SolveRandom := @r_SolveSandwichRandom;
end;

r_RandomVarSet := True;
end;

This is the setup for all the randoms that can appear while you're botting.
It'll declare:
  • The random name (in a string var, RandName)
  • Music(the music played in the random)
  • r_InRandom(the function to check that you're in the random)
  • r_SolveRandom(the solving function for the random)

What this will do, is prepare us from whatever random that will appear.
With the correct info, such as the above, all we need to do is run R_SolveNonTalkingRandoms and it'll detect and solve the random!


So how does R_SolveNonTalkingRandoms work?
function R_SolveNonTalkingRandoms: Boolean;
var
I, iTime: Integer;
Music: String;
InRand: Boolean;
begin
If Not LoggedIn then
Exit;

If Not r_RandomVarSet then
r_SetupRandoms;

Music := LowerCase(r_GetMusic);
for I := 0 to r_RandomCount-1 do
begin

If (r_RandomArr[I].Music = Music)or(r_RandomArr[I].Music = '')then
if (r_RandomArr[I].r_InRandom <> nil) then
InRand := r_RandomArr[I].r_InRandom()
else
begin
If (Not(r_RandomArr[I].r_InRandom <> nil)and(r_RandomArr[I].Music = ''))then
Continue;
Writeln('[Reflection] Might be in a random(missing r_InRandom function), terminating.');
Players[CurrentPlayer].Rand := r_RandomArr[I].RandName;
Logout;
Exit;
end;

If InRand then
begin
//Players[CurrentPlayer].Rand := r_RandomArr[I].RandName;
Writeln('[Reflection] Trying to solve: ' + r_RandomArr[I].RandName);
if (r_RandomArr[I].r_SolveRandom <> nil) then
Result := r_RandomArr[I].r_SolveRandom()
else
begin
Writeln('[Reflection] No random solver for this random yet!, terminating');
Logout;
Exit;
end;

If not Result then
begin
Writeln('[Reflection] Random solving for ' + r_RandomArr[I].RandName + ' failed, terminating.');
Logout;
Exit;
end else
Writeln('[Reflection] Random solved');

iTime := GetSystemTime;
While (Not IsIdle) do
begin
Wait(100+Random(100));
if (GetSystemTime-iTime > 60*1000)then
begin
Writeln('[Reflection] Took more than a minute to get out of the random, terminating.');
LogOut;
Exit;
end;
end;

UseRewardBox;
Exit;
end;

end;
end;

  1. Check if music played is the same as the ones played when you're located in a random event.
  2. If music is correct, it'll run the specific r_InRandom function which matches the random with that music being played
  3. If r_InRandom is true, r_SolveRandom will start and solve the random.

Simple as that really.
It's very similar to SRLs random finding.

Any other questions?, feel free to ask.

mormonman

2010-10-16 21:27:36

You should add in there a template for the r_InRandom functions…

ZephyrsFury

2010-10-17 01:21:16

You could also edit SRL to allow "custom" random detection and solver functions. That way you can incorporate Reflection random solvers directly into the SRL randoms detection and solving system.

Naike

2010-10-17 04:34:34

From: mormonman
You should add in there a template for the r_InRandom functions…

It's a simple Function r_InRandom: Boolean; ?
No template needed as long as it does it's job..
Templates for stuff like that could limit the way we think, and our creativity.


From: ZephyrsFury
You could also edit SRL to allow "custom" random detection and solver functions. That way you can incorporate Reflection random solvers directly into the SRL randoms detection and solving system.


Good idea! :redface:

Cstrike

2010-10-17 10:20:34

I was wondering if its possible that there's some really bad fail with the random for it to decide if we want to set NextPlayer to false?

If we can choose whether to have the script set it or not that would help massive projects. For example, with MSI or other scripts like MSI… they hope to rely a lot on running for a long time with many accounts. Since they have an artificial AI of the sorts, having it log out in a random if a bad error occurs means a ton of new prevention code would have to come into play.


Of course reflection randoms should never fail >:-D BUT runescape is runescape.
BTW this is a minor request, but would be setting ourselves up for being integratable into massive projects.

If the function gets utterly lost, maybe R_FindRandoms can return false? Then good safety code would be like this in these massive scripts (since were heading that way):

procedure FindThoseRandoms;
begin
if not R_FindRandoms then // If it returns false for whatever reason, and IMPORTANTLY: assuming we don't have NextPlayer(false) inbedded in there if we screw up...
begin
writeln ('Warning, random failed... invoking memory dump and player change');
DoMemoryDump;
DoPlayerChange;
TerminateActiveScriptsForAI;
end;
end;

Naike

2010-10-17 15:11:42

From: cstrike
I was wondering if its possible that there's some really bad fail with the random for it to decide if we want to set NextPlayer to false?

If we can choose whether to have the script set it or not that would help massive projects. For example, with MSI or other scripts like MSI… they hope to rely a lot on running for a long time with many accounts. Since they have an artificial AI of the sorts, having it log out in a random if a bad error occurs means a ton of new prevention code would have to come into play.


Of course reflection randoms should never fail >:-D BUT runescape is runescape.
BTW this is a minor request, but would be setting ourselves up for being integratable into massive projects.

If the function gets utterly lost, maybe R_FindRandoms can return false? Then good safety code would be like this in these massive scripts (since were heading that way):

procedure FindThoseRandoms;
begin
if not R_FindRandoms then // If it returns false for whatever reason, and IMPORTANTLY: assuming we don't have NextPlayer(false) inbedded in there if we screw up...
begin
writeln ('Warning, random failed... invoking memory dump and player change');
DoMemoryDump;
DoPlayerChange;
TerminateActiveScriptsForAI;
end;
end;


They could easily solve that with a function?
10-20 lines tops?

Cstrike

2010-10-17 15:29:41

From: Naike
They could easily solve that with a function?
10-20 lines tops?


Sorry I wasnt clear (i need to working on condensing my stuff :p):

Will there be NextPlayer(false) if the random fails at all? Or will R_FindRandomsFunction return false if failed?

Naike

2010-10-17 15:44:31

If the random fails, it'll simply log out your account.

FindRandoms function will return true if a random is found and successfully solved!