SRL Archive - Reflection Development

Certer solver


Cstrike

2010-11-10 13:03:51

I feel awesome, this worked in my first try without any errors :)!!

Now it needs more testing, and I have wasted code by making a function that just returns true. The certer talks to you all the time so I might remove it, but this code fully works.

Needs to be tested upon entering random

Also: CERTER_MUSIC = 'Dream';

And of course: 1 MORE TO GO!!

// Special thanks to RSBot for making this possible
// Special thanks to Bad Boy JH for helping us create this

const
CERTER_PORTALID = 11368;
CERTER_MUSIC = 'Dream';
CERTER_GILES_NPC_ID = 8635;
CERTER_NPCNAME1 = 'Niles';
CERTER_NPCNAME2 = 'Miles';
CERTER_NPCNAME3 = 'Giles';
CERTER_START_TALK = 'to identify something for me.';
CERTER_MODELINTERFACE = 184;
CERTER_MODELCHILD = 8;
CERTER_MODELCOMP = 3; // Get model ID
CERTER_CHOICE_A_TEXT = 0; // From 184 8 [x]
CERTER_CHOICE_B_TEXT = 1; // "
CERTER_CHOICE_C_TEXT = 2; // "

{*******************************************************************************
function R_InCerter : Boolean;
By: Cstrike
Description: Checks if in this random.
*******************************************************************************}
function R_InCerter : Boolean;
begin
Result := (ValidNPC (CERTER_NPCNAME1)) or (ValidNPC (CERTER_NPCNAME2)) or (ValidNPC (CERTER_NPCNAME3));
end;

// Thanks to some help from ZephyrsFury
function R_CerterGetChildCompID (ParentI, ChildI, CompI: Integer): Integer;
var
Child, Comp: Integer;
begin
Child := GetInterface(ParentI, ChildI);
Comp := SmartGetFieldArrayObject(Child, hook_interface_GetChildren, compI);
Result := SmartGetFieldInt(Comp, hook_interface_GetModelID);
SmartFreeObject(Comp);
SmartFreeObject(Child);
end;

// This was pretty much made to my knowledge by ZephyrsFury
function R_CerterGetComponentText(ParentI, ChildI, CompI: Integer): String;
var
Text, Child, Comp: Integer;
begin
Child := GetInterface(ParentI, ChildI);
Comp := SmartGetFieldArrayObject(Child, hook_interface_GetChildren, compI);
Text := SmartGetFieldObject(Comp, hook_interface_GetText);
Result := GetJavaString(Text, 255);
SmartFreeObject(Text);
SmartFreeObject(Comp);
SmartFreeObject(Child);
end;

{*******************************************************************************
function R_CerterClickContinueIfTalking : Boolean;
By: Cstrike
Description: Handles certer talking to us.
*******************************************************************************}
function R_CerterClickContinueIfTalking : Boolean;
var
i, j, t : Integer;
ChatActive : Boolean;
begin
if not LoggedIn then Exit;
Result := False;
ChatActive := False; // Boolean for if were talking

// Check if were being talked to
for j := 241 to 245 do
begin
if ValidInterface(j) then
begin
ChatActive := True;
Break;
end;
end;

// If we find no chat boxes then...
if not ChatActive then
begin
Writeln ('[Reflection] Certer is not talking to us, returning result true');
Result := True;
Exit;
end;

// Since we have chat, enter a 15-20 second loop that keeps looking for chat and clicking continue
MarkTime(t);
repeat
for i := 241 to 245 do
begin
if ValidInterface(i) then
begin
Mouse(303, 452, 72, 7, True);
MMouse (203, 352, 80, 50);
wait (1000+random(2000));
end;
end;

// Check if were being talked to again
for j := 241 to 245 do
begin
if ValidInterface(j) then
begin
ChatActive := True;
Break;
end;
end;
wait (500+random(350));

if not ChatActive then Break;
ChatActive := False; // If we come around again it will be set true if were still talking

until (TimeFromMark(t) > 20000)

if not (TimeFromMark(t) > 20000) then Result := True
else Writeln ('[Reflection] Had an error (or lag) while talking to certer!');
end;

{*******************************************************************************
function R_CerterSelectAnswer : Boolean;
By: Cstrike
Description: Selects right answer.
*******************************************************************************}
function R_CerterSelectAnswer : Boolean;
var
CerterIDArr : TIntegerArray;
CerterNameArr : TStringArray;
ModelIDNumber, i, j, t, AnswerLetter : Integer;
ModelIDName : String;
begin
if not LoggedIn then Exit;
Result := False;
ModelIDName := '';
ModelIDNumber := -2;
AnswerLetter := -1;

// Interface failsafe
if not ValidInterface(CERTER_MODELINTERFACE) then
begin
Writeln ('[Reflection] Not at certer interface!');
Exit;
end;

// These line up with one another for what to look for
CerterIDArr := [2807, 8828, 8829, 8832, 8833, 8834, 8835, 8836, 8837];
CerterNameArr := ['bowl', 'battleaxe', 'fish', 'shield', 'helmet', 'ring', 'shears', 'sword', 'spade'];
ModelIDNumber := R_CerterGetChildCompID (CERTER_MODELINTERFACE, CERTER_MODELCHILD, CERTER_MODELCOMP);

// Search for index
for i := 0 to high (CerterIDArr) do
begin
if CerterIDArr[i] = ModelIDNumber then Break;
end;

// If we max out the array and dont find it, then we failed...
if (i = high (CerterIDArr)) and (ModelIDNumber <> CerterIDArr[high (CerterIDArr)]) then
begin
Writeln ('[Reflection] Warning, ID number not known (Random gave us model ID #'+ToStr(ModelIDNumber)+')');
Exit;
end;

// Now, since we found it...
ModelIDName := CerterNameArr[i];

// Failsafe
if ModelIDName = '' then
begin
Writeln ('[Reflection] Model name not valid (its blank)');
Exit;
end;

// Tell our user and debug at the same time
Writeln ('[Reflection] Found ID #'+ToStr(ModelIDNumber)+', therefore looking for '+ModelIDName+' in answers');

// Search interface for proper name
for j := CERTER_CHOICE_A_TEXT to CERTER_CHOICE_C_TEXT do
begin
if (pos(lowercase(ModelIDName),lowercase(R_CerterGetComponentText(CERTER_MODELINTERFACE, CERTER_MODELCHILD, j))) > 0) then
begin
AnswerLetter := j;
Writeln ('[Reflection] Found answer at position: '+ToStr(AnswerLetter)+' of 2');
end;
end;

// Failsafe
if AnswerLetter < 0 then
begin
Writeln ('[Reflection] Had trouble finding the answer text: '+ModelIDName);
Exit;
end;

// Seem human while making decision
wait (1000+random(2500));

// Move mouse to answer [based off of answerletter
Mouse (120, (55 + (AnswerLetter*35)), 40, 3, true);

// Wait for response to see if we succeeded
MarkTime(t);
repeat
wait (50);
until (not ValidInterface(CERTER_MODELINTERFACE)) or (TimeFromMark(t) > 15000)
if not ValidInterface(CERTER_MODELINTERFACE) then
begin
Writeln ('[Reflection] Chose answer, hopefully correct');
Result := True;
end;
end;

{*******************************************************************************
function R_CerterTalkToNPC : Boolean;
By: Cstrike
Description: Talks to certer. NOT USED, BUT USED IN SCRIPT. FIX LATER :)
*******************************************************************************}
function R_CerterTalkToNPC : Boolean;
begin
if not LoggedIn then Exit;
{
Result := False;
if ValidInterface(CERTER_MODELINTERFACE) then
begin
Result := True;
Exit;
end;
}
Result := True;
end;

{*******************************************************************************
function R_CerterExitCerter : Boolean;
By: Cstrike
Description: Exits through portal.
*******************************************************************************}
function R_CerterExitCerter : Boolean;
var
PortalObj : TRSObject;
TP : TPoint;
begin
if not LoggedIn then Exit;
Result := False;
PortalObj := GetObjectByID(CERTER_PORTALID, OBJECT_TYPE_INTERACTABLE, 30);
if PortalObj = NULL_RSOBJECT then Exit;
if TileOnMS (PortalObj.Tile, 0) then
begin
TP := TileToMS (PortalObj.Tile, 0);
Mouse (TP.x, TP.y, 3, 3, false);
if R_ChooseOptionMulti (['nte', 'orta']) then
begin
Result := True;
wait (1000+random(2000));
end;
wait (500+random(500));
end;

end;

{*******************************************************************************
function R_SolveCerter : Boolean;
By: Cstrike
Description: Solves certer.
*******************************************************************************}
function R_SolveCerter : Boolean;
var
i : Integer;
begin
if not LoggedIn then Exit;
Result := False;

if R_InCerter then
begin
for i := 1 to 3 do // 3 chances
begin
if R_CerterClickContinueIfTalking then
begin
wait (200+random(200));
if R_CerterTalkToNPC then
begin
wait (300+random(300));
if R_CerterClickContinueIfTalking then
begin
wait (250+random(270));
if R_CerterSelectAnswer then
begin
wait (400+random(210));
if R_CerterClickContinueIfTalking then
begin
wait (600+random(250));
if R_CerterExitCerter then
begin
wait (400+random(700));
Writeln ('[Reflection] Certer portal exiting completed.');
Result := True;
Break;
end else Writeln ('[Reflection] Error: Had trouble exiting random');
end else Writeln ('[Reflection] Error: Had trouble while talking to certer');
end else Writeln ('[Reflection] Error: Had trouble selecting right answer');
end else Writeln ('[Reflection] Error: Had trouble while talking to certer');
end else Writeln ('[Reflection] Error: Had trouble with certer interaction');
end else Writeln ('[Reflection] Error: Had trouble while talking to certer');
wait (1000+random(2000));
end; // End 3 chances
end else Writeln ('[Reflection] Warning: Not in certer random');

Result := R_LoggedIn;
if not Result then Writeln ('[Reflection] Failed solving certer.')
else Writeln ('[Reflection] Certer solved!');
end;

mormonman

2010-11-10 13:24:44

Prison left?

Cstrike

2010-11-10 13:53:55

From: mormonman
Prison left?


Prison is the last one to do :)

I'm pretty sure I can script right now the code to make it work even without testing it. I might do that later, then I just need an account in one.

Then after that all randoms are solved.

Then after touching them up and adding failsafes, we are unstoppable.

Overtime

2010-11-15 23:41:18

This should be committed..

Naike

2010-11-16 09:01:28

From: Squancy
This should be committed..


Please.. posts like this annoy me more than anything on these forums.
I need to test it properly before I can commit anything, and before I see you doing any work, testing or coding don't complain about me not doing work.
We rather have stable randoms than some russian roulette.

Instead you could try getting the certer random, I would be more than happy to get it tested and later on added to the include.

Overtime

2010-11-16 10:10:39

I didn't specify you do add it.

I did add to my reflections folder and have since it was first released.

Out of 72 MSI accounts, not one had this random.

Does it work i dont know.

But the fact that none of my accounts got this one and other randoms they did, then maybe.

No need to rage at me.

Naike

2010-11-16 15:42:07

From: Squancy
I didn't specify you do add it.

I did add to my reflections folder and have since it was first released.

Out of 72 MSI accounts, not one had this random.

Does it work i dont know.

But the fact that none of my accounts got this one and other randoms they did, then maybe.

No need to rage at me.


I never raged. To be honest, I'm not even going to try explaining myself.

Overtime

2010-11-16 16:12:17

You made it seem like I told you that u weren't doing anything right….

You made it seem like i just posted that for shi*s and giggles and made it seem like as well hadn't tried adding it to my reflection folder.

I was just bumping it up here, in case it has been forgotten as it was fairly in the middle, or if anyone wanted to add to it, or post thier results.

Next time ill just use "Bump" instead or post "Anyone else tried this?"
You don't have anything to say anything, your above post says it all.

Naike

2010-11-16 18:52:25

Squancy don't try to out-smart me, don't even go there.

You wanted to be a smart little boy going "add thiz I need eet" post count++.
It was 2nd to the list, so scratch that.

I was strictly explaining what was taking time, don't take everything so offensive. World war II is over, chill pill.

Overtime

2010-11-16 18:58:54

Lol if your going to quote someone, quote it right.

You continue to add sh't that i did not say.

I was strictly explaining what was taking time, don't take everything so offensive


Likewise.

Shuttleu

2010-11-16 19:36:17

maybe we need to calm down here and not bite each others heads off

squancy, i respect you, but i do think that if you had posted something else then the outcome may have been different, although i do see your point as it was 6 days ago and no posts

but anyway, lets stop the arguments and not get into any trouble :D

~shut

Naike

2010-11-17 04:06:08

Never argue with an idiot. They drag you down to their level and then beat you with experience!
Squancy, Lovely.


Certer is being tested now! Expect some major changes and new functions in the coming week :)