Naike
2010-10-15 11:02:45
Since so many people are developing on the randoms I figured it'll be the best to update the core. Hardly any(if any?) random solvers work in reflection, so it's a perfect timing!
I started thinking, and figured the best way to do this is clearly the same way SRL does it.
This might break a script or two, not sure if it does(can't really see how it would).
Changes that's made
r_SetupRandoms
New r_SolveNonTalkingRandoms
So.. how does it work?
Discuss?
For the maintaining part, I'll help out.
I will end up doing a random or two(possibly)!
Note: This is not commit yet. It won't be until tomorrow, or later today.
Reason for that is fairly simple, I want to be able to write a tutorial on how the separate random functions should work and be structured.
I started thinking, and figured the best way to do this is clearly the same way SRL does it.
This might break a script or two, not sure if it does(can't really see how it would).
Changes that's made
- Now it's not including all of the "Randomname.simba" files, as none worked. (They'll stay there as an example for the re-built/modifications to work again).
- Took Anti-Randoms consts from Constants.simba to Antirandoms.simba (duh, should've been there in the first place).
- New r_SetupRandoms added.
- Added r_GetMusic (needed for R_SolveNonTalkingRandoms).
- Added a new R_SolveNonTalkingRandoms.
r_SetupRandoms
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..14] 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 := 'horizon';
r_InRandom := nil;
r_SolveRandom := nil;
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 := nil;
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 := nil;
r_SolveRandom := nil;
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 := nil;
r_SolveRandom := nil;
end;
With r_RandomArr[R_RANDOM_MOLLY] do
begin
RandName := 'Molly';
Music := 'head to head';
r_InRandom := nil;
r_SolveRandom := nil;
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 := nil;
r_SolveRandom := nil;
end;
r_RandomVarSet := True;
end;
New r_SolveNonTalkingRandoms
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;
So.. how does it work?
- Check music. If music = "" @ Skips the search for music.
- Runs the specific r_InRandom function
- If it's in the random it'll output a text saying that's desovered and that the solving is starting.
- r_SolveRandom is executed
Discuss?
For the maintaining part, I'll help out.
I will end up doing a random or two(possibly)!
Note: This is not commit yet. It won't be until tomorrow, or later today.
Reason for that is fairly simple, I want to be able to write a tutorial on how the separate random functions should work and be structured.