SRL Archive - Reflection Development

Leo grave solver


Cstrike

2010-10-26 21:37:31

This is NOT complete, but almost there.

If anyone has suggestions or additions, please do so and show where you edited. There are probably lots of random things that could be improved.

Updated to newest:

program ReflectionBasic;
{$DEFINE SMART}
{$i srl\srl.scar}
{$i reflection\reflection.simba}

const
{---SMART Setup Constants---}
WORLD = 121;
MEMBERS = false;
SIGNED = true;
{---------------------------}

Procedure DeclarePlayers;
Begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

With Players[0] Do
Begin
Name := '';
Pass := '';
Nick := '';
Active := True;
Pin := '';
End;
End;

{*******************************************************************************
Leo Solver [gravedigger]
By: Cstrike
Solves leo pretty flawlessly. Have not tested it as you are teleporting in, so
it can only solve it guaranteed flawless upon logging in. Does not have despoit
yet. In addition, the last few interfaces might not work to exit the random, but
they should. Needs more testing.
Special thanks to bolshak25.
*******************************************************************************}

// I needed this, someone please commit a different version to the interface core
function R_LeoComponentID (ParentI, ChildI : Integer) : Integer;
var
Child: Integer;
begin
Child := GetInterface(ParentI, ChildI);
Result := SmartGetFieldInt(Child, hook_interface_GetID);
SmartFreeObject(Child);
end;

// Waits to timeout for the inventory to decrease by amount (waits for grave to be put in the, grave... XD)
procedure R_LeoInvDecrease (amount, timeout : Integer);
var t, invicount : Integer;
begin
if not loggedin then exit;
invicount := R_InvCount;
MarkTime (t);
repeat
wait (50);
until (TimeFromMark(t) > amount) or (invicount < R_InvCount)
wait (4000+random(2500)); // More human?
end;

// If in Leo, true
function R_InLeoRandom : Boolean;
begin
if not LoggedIn then exit;
result := false;
if ValidNPC('Leo') then result := true;
end;

// Walks to center
procedure R_LeoWalkToCenter;
var GraveStone : TRSObject;
TP : TPoint;
begin
GraveStone := GetObjectByID (12718, OBJECT_TYPE_INTERACTABLE, 52);
TP := TileToMM(Tile(GraveStone.Tile.x,GraveStone.Tile.y+1));
Mouse (TP.x, TP.y, 1, 1, true);
wait (3000+random(1200));
end;

// This function talks to leo at the start
function R_TalkToLeoStart : Boolean;
var t, x, y : Integer;
NPCs : TNPCArray;
TP : TPoint;
begin
if not LoggedIn then Exit;
result := false;
if (not ValidInterface(242)) and (not ValidInterface(241)) and (not ValidInterface(243)) and (not ValidInterface(64)) then
begin
NPCs := SortNPCs(GetNPCs);
TP := TileToMS (NPCs[0].Tile, 0);
Mouse (TP.x, TP.y, 3, 3, false);
wait (500+random(500));
if ChooseOptionMulti(['Ta','-to']) then writeln ('Talked to leo');
wait (2500+random(1500));
end else writeln ('Leo is already chatting with us');
wait (3000+random(2000)); // Stops lag at start up from screwing us over
MarkTime(t);
repeat
if (GetInterfaceText(242, 6) = 'Click here to continue') then Mouse (303, 452, 72, 7, true);
if (GetInterfaceText(241, 5) = 'Click here to continue') or (GetInterfaceText(243, 7) = 'Click here to continue')
or (GetInterfaceText(64, 5) = 'Click here to continue') then
begin
GetMousePos (x, y);
Mouse (x, y, 0, 0, true);
end;
if (ValidInterface(220)) then Mouse (456,44, 6, 6, true);
wait (670+random(600));
if (not ValidInterface(242)) and (not ValidInterface(241)) and (not ValidInterface(243)) and (not ValidInterface(64)) and (not ValidInterface(220)) then
begin
writeln ('successfully done talking to leo');
result := true;
Exit;
end;
until (TimeFromMark(t) > 30000)
writeln ('Timeout talking to Leo, result = false');
end;

// Deposits the last items in your invi (slots 23-28) if invi too full
function R_LeoDepositFiveInv : Boolean;
begin
if not LoggedIn then exit;
result := false;
if R_InvCount > 23 then
begin
writeln ('Replace this line with deposit code here (if you see this, youre fucked)');
end else writeln ('We have 5+ inventory spaces for the Leo random, not depositing');
end;

// Returns the dug out grave tiles relative to leo
function R_LeoGraveTiles (i : Integer) : TTile;
var NPCs : TNPCArray;
var LeoTile : TTile;
begin
if not LoggedIn then Exit;
result := Tile(0,0);
NPCs := SortNPCs(GetNPCs);
LeoTile := NPCs[0].Tile;
case i of // TL, TR, BL, BM, Bottom Right [BR]
0: result := Tile(LeoTile.x-2,LeoTile.y-4);
1: result := Tile(LeoTile.x+2,LeoTile.y-4);
2: result := Tile(LeoTile.x-4,LeoTile.y-7);
3: result := Tile(LeoTile.x-0,LeoTile.y-7);
4: result := Tile(LeoTile.x+4,LeoTile.y-7);
end;
end;

// Returns the tile of the gravestone relative to Leo since the tiles can change
function R_LeoGravestoneTiles (i : Integer) : TTile;
var NPCs : TNPCArray;
var LeoTile : TTile;
begin
if not LoggedIn then Exit;
result := Tile(0,0);
NPCs := SortNPCs(GetNPCs);
LeoTile := NPCs[0].Tile;
case i of // TL, TR, BL, BM, Bottom Right [BR]
0: result := Tile(LeoTile.x-2,LeoTile.y-2);
1: result := Tile(LeoTile.x+2,LeoTile.y-2);
2: result := Tile(LeoTile.x-4,LeoTile.y-5);
3: result := Tile(LeoTile.x-0,LeoTile.y-5);
4: result := Tile(LeoTile.x+4,LeoTile.y-5);
end;
end;

// Failsafe if we miss any graves
// 12718 = middle gravestone
function R_GraveObjectCoffinCollect : Boolean;
var ObjCasket, ObjCasketUpdated : TRSObjectArray;
t, InviCount : Integer;
TP : TPoint;
begin
if not LoggedIn then Exit;
result := false;
ObjCasket := GetObjectsByID ([12721, 12722, 12723, 12724, 12725], OBJECT_TYPE_INTERACTABLE, 52); // SO FAR USELESS, REMOVE ME LATER
if high(ObjCasket) < 0 then
begin
result := true;
Exit;
end;
SetAngle(true);
repeat
ObjCasketUpdated := GetObjectsByID ([12721, 12722, 12723, 12724, 12725], OBJECT_TYPE_INTERACTABLE, 52); // Allows for dynamic stuff
if high(ObjCasketUpdated) < 0 then Break;
if not TileOnMS(ObjCasketUpdated[0].Tile, 0) then R_LeoWalkToCenter;
TP := TileToMS (ObjCasketUpdated[0].Tile, 0);
Mouse (TP.x, TP.y, 2, 3, true);
InviCount := R_InvCount;
MarkTime(t);
repeat
wait(50);
until (R_InvCount > InviCount) or (TimeFromMark(t) > 10000)
until (high(ObjCasketUpdated) < 0)
if (R_CountItemID(7587) = 1) and (R_CountItemID(7588) = 1) and (R_CountItemID(7589) = 1) and (R_CountItemID(7590) = 1) and (R_CountItemID(7591) = 1) then result := true;
end;

// Based on the name you put (flowerpot, pickaxe...etc), it will return what coffin ID matches the grave
function R_LeoFindCasket (name : String) : Integer;
var i, j, IDToFind : Integer;
begin
if not LoggedIn then exit;
result := 0;
case name of
'flowerpot': IDToFind := 7608;
'pickaxe': IDToFind := 7607;
'chef hat': IDToFind := 7601;
'hatchet': IDToFind := 7603;
'shears': IDToFind := 7610;
end;
for i:=7587 to 7591 do
begin
R_ClickItemID(i, true, 'open');
wait (500+random(500));
for j:=3 to 11 do // Search interfaces for ID to find
begin
wait (50+random(50)); // More human like waiting
if (R_LeoComponentID (141, j) = IDToFind) then // 141 is the ID
begin
writeln ('Found IDToFind, this casket is the right one');
result := i;
writeln ('Closing interface');
Mouse (493, 27, 3, 3, true);
wait (700+random(500));
Exit;
end;
end;
end;
end;

// Goes to each grave starting from BR (bottom right) to TR and solves them
function R_LeoSolveGraves : Boolean;
var i, j, t, texID, CasketID : Integer;
GStoneTile : TTile;
TP : TPoint;
begin
if not LoggedIn then exit;
result := false;
for i:=4 downto 0 do // START AT BOTTOM RIGHT since thats where you got your last casket
begin
GStoneTile := R_LeoGravestoneTiles(i);
if not TileOnMS (GStoneTile, 0) then R_LeoWalkToCenter;
TP := TileToMS (GStoneTile, 0);
Mouse (TP.x, TP.y, 3, 3, true);
MarkTime(t);
repeat
wait (50);
until (ValidInterface(143)) or (TimeFromMark(t) > 10000)
if ValidInterface(143) then
begin
writeln ('Interface is up...');
for j:=0 to 3 do // Search the 3x3 item square
begin
texID := R_LeoComponentID(143, j);
case texID of
7614: begin
writeln (texID);
writeln ('Found hatchet model');
wait (800+random(2200)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('hatchet');
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
7615: begin
writeln (texID);
writeln ('Found chef hat model');
wait (800+random(2200)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('chef hat');
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
7616: begin
writeln (texID);
writeln ('Found pickaxe model');
wait (640+random(1800)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('pickaxe');
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
7617: begin
writeln (texID);
writeln ('Found watertank model');
wait (11100+random(1100)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('shears');
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
7618: begin
writeln (texID);
writeln ('Found flowerpot model');
wait (1100+random(2000)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('flowerpot');
writeln ('casketID = '+inttostr(casketID));
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
end;
end;
end;
wait (1000+random(1000)); // More wait here, must replace thsi later on
end;
result := true; // Fix me failsafe :(
end;

function R_TalkToLeoEnd : Boolean;
var t : Integer;
NPCs : TNPCArray;
TP : TPoint;
begin
if not LoggedIn then Exit;
result := false;
if (not ValidInterface(241)) and (not ValidInterface(64)) then
begin
NPCs := SortNPCs(GetNPCs);
if not TileOnMS(NPCs[0].Tile, 0) then R_LeoWalkToCenter;
TP := TileToMS (NPCs[0].Tile, 0);
Mouse (TP.x, TP.y, 3, 3, false);
wait (500+random(500));
if ChooseOptionMulti(['Ta','-to']) then writeln ('Talked to leo');
wait (2500+random(1500));
end else writeln ('Leo is already chatting with us');
wait (3000+random(2000)); // Stops lag at start up from screwing us over
MarkTime(t);
repeat
if (GetInterfaceText(241, 5) = 'Click here to continue') or (GetInterfaceText(64, 5) = 'Click here to continue') then Mouse (303, 452, 72, 7, true);
wait (670+random(600));
if (not ValidInterface(241)) and (not ValidInterface(64)) then
begin
writeln ('Apparently done talking @ end');
result := true;
Exit;
end;
until (TimeFromMark(t) > 30000)
writeln ('Timeout talking to Leo, result = false');
end;

function R_SolveLeoRandom : Boolean;
var failsafe : Integer;
begin
result := false;
if R_InLeoRandom then
begin
failsafe := 0;
repeat
writeln ('TALKING TO LEO');
if R_TalkToLeoStart then
begin
writeln ('COLLECTING GRAVES');
if R_GraveObjectCoffinCollect then
begin
writeln ('SOLVING GRAVES');
if R_LeoSolveGraves then
begin
writeln ('GRAVES SOLVED, TALK TO LEO @ END');
if R_TalkToLeoEnd then
begin
writeln ('We are assuming we didnt mess up the graves at all, mission accomplished.');
result := true;
exit;
end;
end else
begin
writeln ('Failed solving graves');
Inc(failsafe);
end;
end else
begin
writeln ('Had trouble grabbing all the ground coffins');
Inc(failsafe);
end;
end else
begin
writeln ('Had trouble talking to leo @ start');
Inc(failsafe);
end;
until (failsafe > 2)
if failsafe > 2 then
begin
writeln ('We have failed leo too many times, aborting...');
//NextPlayer(false);
end;
end else writeln ('Not in Leo random');
end;

begin
Smart_Members := MEMBERS;
Smart_Server := WORLD;
Smart_Signed := SIGNED;
SetupSRL;
SetUpReflectionEx(true);
DeclarePlayers;
LoginPlayer;
//Cleardebug;
SetAngle (true);
MakeCompass ('n');
R_SolveLeoRandom;
end.

pyroryan

2010-10-26 22:05:53

A 30 second look says it looks good. I did notice that it was in script form instead of anti-random.

Edit:
Forgot to update Item class in hooks I guess…thats why grounditems weren't working. Fixed and Thanks TomTuff for reporting :)

Cstrike

2010-10-26 22:40:26

From: pyroryan
A 30 second look says it looks good. I did notice that it was in script form instead of anti-random.

Edit:
Forgot to update Item class in hooks I guess…thats why grounditems weren't working. Fixed and Thanks TomTuff for reporting :)


Ah… I thought the random coffins were just not working ;)
Actually if they're fixed, then I'll have to update the script XD

i luffs yeww

2010-10-27 02:40:03

As I just slept for about nine hours for the first time this week, can you point out exactly isn't working and what is? :) I'd love to help with randoms.

Cstrike

2010-10-27 11:07:00

Sleep = fun :)

So far my plan for today is:
1) R_LeoFindCasket, I need it to click each casket, and search all the interfaces inside to see what ID matches up with the name, then repeat this for all of them
Then it must return the integer of the casket that matches the name (ex: if we search 'hatchet' and it finds the one with the hatchet, it will return the casket ID it found it in)

2) Then in R_LeoSolveGraves I need to have it (once found the ID) to place it in the grave

3) I need to then have it repeat for all of them (it should for the most part)

4) It needs to then talk to leo at the end properly

5) I need to add mausoleum depositing

and then complete and onto a new one! woo

Naike

2010-10-27 15:28:10

Really nice work!

Hardest one, no?

Really good work there mate.

Cstrike

2010-10-27 17:01:58

UPDATE: COMPLETE

program ReflectionBasic;
{$DEFINE SMART}
{$i srl\srl.scar}
{$i reflection\reflection.simba}

const
{---SMART Setup Constants---}
WORLD = 121;
MEMBERS = false;
SIGNED = true;
{---------------------------}

Procedure DeclarePlayers;
Begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

With Players[0] Do
Begin
Name := '';
Pass := '';
Nick := '';
Active := True;
Pin := '';
End;
End;

{*******************************************************************************
Leo Solver [gravedigger]
By: Cstrike
Solves leo pretty flawlessly. Have not tested it as you are teleporting in, so
it can only solve it guaranteed flawless upon logging in. Does not have despoit
yet. In addition, the last few interfaces might not work to exit the random, but
they should. Needs more testing.
Special thanks to bolshak25.
*******************************************************************************}

// I needed this, someone please commit a different version to the interface core
function R_LeoComponentID (ParentI, ChildI : Integer) : Integer;
var
Child: Integer;
begin
Child := GetInterface(ParentI, ChildI);
Result := SmartGetFieldInt(Child, hook_interface_GetID);
SmartFreeObject(Child);
end;

// Waits to timeout for the inventory to decrease by amount (waits for grave to be put in the, grave... XD)
procedure R_LeoInvDecrease (amount, timeout : Integer);
var t, invicount : Integer;
begin
if not loggedin then exit;
invicount := R_InvCount;
MarkTime (t);
repeat
wait (50);
until (TimeFromMark(t) > amount) or (invicount < R_InvCount)
wait (4000+random(2500)); // More human?
end;

// If in Leo, true
function R_InLeoRandom : Boolean;
begin
if not LoggedIn then exit;
result := false;
if ValidNPC('Leo') then result := true;
end;

// Walks to center
procedure R_LeoWalkToCenter;
var GraveStone : TRSObject;
TP : TPoint;
begin
GraveStone := GetObjectByID (12718, OBJECT_TYPE_INTERACTABLE, 52);
TP := TileToMM(Tile(GraveStone.Tile.x,GraveStone.Tile.y+1));
Mouse (TP.x, TP.y, 1, 1, true);
wait (3000+random(1200));
end;

// This function talks to leo at the start
function R_TalkToLeoStart : Boolean;
var t, x, y : Integer;
NPCs : TNPCArray;
TP : TPoint;
begin
if not LoggedIn then Exit;
result := false;
if (not ValidInterface(242)) and (not ValidInterface(241)) and (not ValidInterface(243)) and (not ValidInterface(64)) then
begin
NPCs := SortNPCs(GetNPCs);
TP := TileToMS (NPCs[0].Tile, 0);
Mouse (TP.x, TP.y, 3, 3, false);
wait (500+random(500));
if ChooseOptionMulti(['Ta','-to']) then writeln ('Talked to leo');
wait (2500+random(1500));
end else writeln ('Leo is already chatting with us');
wait (3000+random(2000)); // Stops lag at start up from screwing us over
MarkTime(t);
repeat
if (GetInterfaceText(242, 6) = 'Click here to continue') then Mouse (303, 452, 72, 7, true);
if (GetInterfaceText(241, 5) = 'Click here to continue') or (GetInterfaceText(243, 7) = 'Click here to continue')
or (GetInterfaceText(64, 5) = 'Click here to continue') then
begin
GetMousePos (x, y);
Mouse (x, y, 0, 0, true);
end;
if (ValidInterface(220)) then Mouse (456,44, 6, 6, true);
wait (670+random(600));
if (not ValidInterface(242)) and (not ValidInterface(241)) and (not ValidInterface(243)) and (not ValidInterface(64)) and (not ValidInterface(220)) then
begin
writeln ('successfully done talking to leo');
result := true;
Exit;
end;
until (TimeFromMark(t) > 30000)
writeln ('Timeout talking to Leo, result = false');
end;

// Deposits the last items in your invi (slots 23-28) if invi too full
function R_LeoDepositFiveInv : Boolean;
begin
if not LoggedIn then exit;
result := false;
if R_InvCount > 23 then
begin
writeln ('Replace this line with deposit code here (if you see this, youre fucked)');
end else writeln ('We have 5+ inventory spaces for the Leo random, not depositing');
end;

// Returns the dug out grave tiles relative to leo
function R_LeoGraveTiles (i : Integer) : TTile;
var NPCs : TNPCArray;
var LeoTile : TTile;
begin
if not LoggedIn then Exit;
result := Tile(0,0);
NPCs := SortNPCs(GetNPCs);
LeoTile := NPCs[0].Tile;
case i of // TL, TR, BL, BM, Bottom Right [BR]
0: result := Tile(LeoTile.x-2,LeoTile.y-4);
1: result := Tile(LeoTile.x+2,LeoTile.y-4);
2: result := Tile(LeoTile.x-4,LeoTile.y-7);
3: result := Tile(LeoTile.x-0,LeoTile.y-7);
4: result := Tile(LeoTile.x+4,LeoTile.y-7);
end;
end;

// Returns the tile of the gravestone relative to Leo since the tiles can change
function R_LeoGravestoneTiles (i : Integer) : TTile;
var NPCs : TNPCArray;
var LeoTile : TTile;
begin
if not LoggedIn then Exit;
result := Tile(0,0);
NPCs := SortNPCs(GetNPCs);
LeoTile := NPCs[0].Tile;
case i of // TL, TR, BL, BM, Bottom Right [BR]
0: result := Tile(LeoTile.x-2,LeoTile.y-2);
1: result := Tile(LeoTile.x+2,LeoTile.y-2);
2: result := Tile(LeoTile.x-4,LeoTile.y-5);
3: result := Tile(LeoTile.x-0,LeoTile.y-5);
4: result := Tile(LeoTile.x+4,LeoTile.y-5);
end;
end;

// Failsafe if we miss any graves
// 12718 = middle gravestone
function R_GraveObjectCoffinCollect : Boolean;
var ObjCasket, ObjCasketUpdated : TRSObjectArray;
t, InviCount : Integer;
TP : TPoint;
begin
if not LoggedIn then Exit;
result := false;
ObjCasket := GetObjectsByID ([12721, 12722, 12723, 12724, 12725], OBJECT_TYPE_INTERACTABLE, 52); // SO FAR USELESS, REMOVE ME LATER
if high(ObjCasket) < 0 then
begin
result := true;
Exit;
end;
SetAngle(true);
repeat
ObjCasketUpdated := GetObjectsByID ([12721, 12722, 12723, 12724, 12725], OBJECT_TYPE_INTERACTABLE, 52); // Allows for dynamic stuff
if high(ObjCasketUpdated) < 0 then Break;
if not TileOnMS(ObjCasketUpdated[0].Tile, 0) then R_LeoWalkToCenter;
TP := TileToMS (ObjCasketUpdated[0].Tile, 0);
Mouse (TP.x, TP.y, 2, 3, true);
InviCount := R_InvCount;
MarkTime(t);
repeat
wait(50);
until (R_InvCount > InviCount) or (TimeFromMark(t) > 10000)
until (high(ObjCasketUpdated) < 0)
if (R_CountItemID(7587) = 1) and (R_CountItemID(7588) = 1) and (R_CountItemID(7589) = 1) and (R_CountItemID(7590) = 1) and (R_CountItemID(7591) = 1) then result := true;
end;

// Based on the name you put (flowerpot, pickaxe...etc), it will return what coffin ID matches the grave
function R_LeoFindCasket (name : String) : Integer;
var i, j, IDToFind : Integer;
begin
if not LoggedIn then exit;
result := 0;
case name of
'flowerpot': IDToFind := 7608;
'pickaxe': IDToFind := 7607;
'chef hat': IDToFind := 7601;
'hatchet': IDToFind := 7603;
'shears': IDToFind := 7610;
end;
for i:=7587 to 7591 do
begin
R_ClickItemID(i, true, 'open');
wait (500+random(500));
for j:=3 to 11 do // Search interfaces for ID to find
begin
wait (50+random(50)); // More human like waiting
if (R_LeoComponentID (141, j) = IDToFind) then // 141 is the ID
begin
writeln ('Found IDToFind, this casket is the right one');
result := i;
writeln ('Closing interface');
Mouse (493, 27, 3, 3, true);
wait (700+random(500));
Exit;
end;
end;
end;
end;

// Goes to each grave starting from BR (bottom right) to TR and solves them
function R_LeoSolveGraves : Boolean;
var i, j, t, texID, CasketID : Integer;
GStoneTile : TTile;
TP : TPoint;
begin
if not LoggedIn then exit;
result := false;
for i:=4 downto 0 do // START AT BOTTOM RIGHT since thats where you got your last casket
begin
GStoneTile := R_LeoGravestoneTiles(i);
if not TileOnMS (GStoneTile, 0) then R_LeoWalkToCenter;
TP := TileToMS (GStoneTile, 0);
Mouse (TP.x, TP.y, 3, 3, true);
MarkTime(t);
repeat
wait (50);
until (ValidInterface(143)) or (TimeFromMark(t) > 10000)
if ValidInterface(143) then
begin
writeln ('Interface is up...');
for j:=0 to 3 do // Search the 3x3 item square
begin
texID := R_LeoComponentID(143, j);
case texID of
7614: begin
writeln (texID);
writeln ('Found hatchet model');
wait (800+random(2200)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('hatchet');
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
7615: begin
writeln (texID);
writeln ('Found chef hat model');
wait (800+random(2200)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('chef hat');
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
7616: begin
writeln (texID);
writeln ('Found pickaxe model');
wait (640+random(1800)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('pickaxe');
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
7617: begin
writeln (texID);
writeln ('Found watertank model');
wait (11100+random(1100)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('shears');
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
7618: begin
writeln (texID);
writeln ('Found flowerpot model');
wait (1100+random(2000)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('flowerpot');
writeln ('casketID = '+inttostr(casketID));
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
end;
end;
end;
wait (1000+random(1000)); // More wait here, must replace thsi later on
end;
result := true; // Fix me failsafe :(
end;

function R_TalkToLeoEnd : Boolean;
var t : Integer;
NPCs : TNPCArray;
TP : TPoint;
begin
if not LoggedIn then Exit;
result := false;
if (not ValidInterface(241)) and (not ValidInterface(64)) then
begin
NPCs := SortNPCs(GetNPCs);
if not TileOnMS(NPCs[0].Tile, 0) then R_LeoWalkToCenter;
TP := TileToMS (NPCs[0].Tile, 0);
Mouse (TP.x, TP.y, 3, 3, false);
wait (500+random(500));
if ChooseOptionMulti(['Ta','-to']) then writeln ('Talked to leo');
wait (2500+random(1500));
end else writeln ('Leo is already chatting with us');
wait (3000+random(2000)); // Stops lag at start up from screwing us over
MarkTime(t);
repeat
if (GetInterfaceText(241, 5) = 'Click here to continue') or (GetInterfaceText(64, 5) = 'Click here to continue') then Mouse (303, 452, 72, 7, true);
wait (670+random(600));
if (not ValidInterface(241)) and (not ValidInterface(64)) then
begin
writeln ('Apparently done talking @ end');
result := true;
Exit;
end;
until (TimeFromMark(t) > 30000)
writeln ('Timeout talking to Leo, result = false');
end;

function R_SolveLeoRandom : Boolean;
var failsafe : Integer;
begin
result := false;
if R_InLeoRandom then
begin
failsafe := 0;
repeat
writeln ('TALKING TO LEO');
if R_TalkToLeoStart then
begin
writeln ('COLLECTING GRAVES');
if R_GraveObjectCoffinCollect then
begin
writeln ('SOLVING GRAVES');
if R_LeoSolveGraves then
begin
writeln ('GRAVES SOLVED, TALK TO LEO @ END');
if R_TalkToLeoEnd then
begin
writeln ('We are assuming we didnt mess up the graves at all, mission accomplished.');
result := true;
exit;
end;
end else
begin
writeln ('Failed solving graves');
Inc(failsafe);
end;
end else
begin
writeln ('Had trouble grabbing all the ground coffins');
Inc(failsafe);
end;
end else
begin
writeln ('Had trouble talking to leo @ start');
Inc(failsafe);
end;
until (failsafe > 2)
if failsafe > 2 then
begin
writeln ('We have failed leo too many times, aborting...');
//NextPlayer(false);
end;
end else writeln ('Not in Leo random');
end;

begin
Smart_Members := MEMBERS;
Smart_Server := WORLD;
Smart_Signed := SIGNED;
SetupSRL;
SetUpReflectionEx(true);
DeclarePlayers;
LoginPlayer;
//Cleardebug;
SetAngle (true);
MakeCompass ('n');
R_SolveLeoRandom;
end.


Note as such I need more experimentation, but this pretty much solves it and has some good failsafes. Not everything is perfect though, but it's pretty much 95% done even with failsafes for that 95%. Some are missing though like @ start, but it'll do for now until I can get another account in there.

Things I need to update:
- Make deposit work (I have the numbers and interfaces but I need an acct again to test it)
- Make more failsafes for talking to leo @ start
- Make a failsafe incase we somehow manage to screw up the coffin order or forget one [we ONLY forget one if there is some extreme lag]



Damnit, ~450 lines of code. This is longer than most member applicants :(

Naike

2010-10-27 17:08:01

You really need to get msn or get on the irc more often..

Do any within the next 20 minutes and I fetch you accounts :)

Cstrike

2010-10-27 17:22:17

From: Naike
You really need to get msn or get on the irc more often..

Do any within the next 20 minutes and I fetch you accounts :)


I'm going to try and get on IRC more often :p
Stupid real life keeps throwing things at me and I forget to log on :(
I'm going to auto setup a login tonight for IRC

DeSnob

2010-10-27 17:56:42

From: cstrike
UPDATE: COMPLETE

Damnit, ~450 lines of code. This is longer than most member applicants :(

[offtopic]Wow. Last year I was about to apply with a 1054 line script (1-60+ wc trainer for fally) until they updated all the minimap colors. [/offtopic]

This is pretty sweet. Wish my account could try it but it cannot. Nevertheless, great job on this complicated solver! :)

Cstrike

2010-10-28 18:08:24

Should be fully working now:
There is a part I want to code shrink though, as it chews up excess space.
//Special thanks to bolshak25.
const
LEO_GRAVESTONE_MIDDLE = 12718;
LEO_CASKET1 = 12721;
LEO_CASKET2 = 12722;
LEO_CASKET3 = 12723;
LEO_CASKET4 = 12724;
LEO_CASKET5 = 12725;
LEO_INVENTORY_CASKET1 = 7587;
LEO_INVENTORY_CASKET2 = 7588;
LEO_INVENTORY_CASKET3 = 7589;
LEO_INVENTORY_CASKET4 = 7590;
LEO_INVENTORY_CASKET5 = 7591;
LEO_FLOWERPOTID = 7608;
LEO_PICKAXEID = 7607;
LEO_CHEFHATID = 7601;
LEO_HATCHETID = 7603;
LEO_SHEARSID = 7610;

{*******************************************************************************
function R_LeoComponentID (ParentI, ChildI : Integer) : Integer;
By: Cstrike
Description: This function wasn't in the core, so I made my own.
*******************************************************************************}
function R_LeoComponentID (ParentI, ChildI : Integer) : Integer;
var
Child: Integer;
begin
Child := GetInterface(ParentI, ChildI);
Result := SmartGetFieldInt(Child, hook_interface_GetID);
SmartFreeObject(Child);
end;

{*******************************************************************************
procedure R_LeoInvDecrease (amount, timeout : Integer);
By: Cstrike
Description: Function used mainly for seeing when we have put the casket in the
grave.
*******************************************************************************}
procedure R_LeoInvDecrease (amount, timeout : Integer);
var t, invicount : Integer;
begin
if not loggedin then exit;
invicount := R_InvCount;
MarkTime (t);
repeat
wait (50);
until (TimeFromMark(t) > amount) or (invicount < R_InvCount)
wait (4000+random(2500)); // More human?
end;

{*******************************************************************************
function R_InLeo : Boolean;
By: Cstrike
Description: Returns true if in Gravedigger.
*******************************************************************************}
function R_InLeo : Boolean;
begin
result := ValidNPC('Leo');
end;

{*******************************************************************************
procedure R_LeoWalkToCenter;
By: Cstrike
Description: Moves us above middle grave so everything is in sight.
*******************************************************************************}
procedure R_LeoWalkToCenter;
var GraveStone : TRSObject;
TP : TPoint;
begin
GraveStone := GetObjectByID (LEO_GRAVESTONE_MIDDLE, OBJECT_TYPE_INTERACTABLE, 52);
TP := TileToMM(Tile(GraveStone.Tile.x,GraveStone.Tile.y+1));
Mouse (TP.x, TP.y, 1, 1, true);
wait (3000+random(1200));
end;

{*******************************************************************************
function R_TalkToLeoStart : Boolean;
By: Cstrike
Description: Talks to Leo at start (if we are already, proceeds normally).
*******************************************************************************}
function R_TalkToLeoStart : Boolean;
var t, x, y : Integer;
NPCs : TNPCArray;
TP : TPoint;
begin
if not LoggedIn then Exit;
result := false;
if (not ValidInterface(242)) and (not ValidInterface(241)) and (not ValidInterface(243)) and (not ValidInterface(64)) then
begin
NPCs := SortNPCs(GetNPCs);
if not TileOnMS(NPCs[0].Tile, 0) then R_LeoWalkToCenter;
TP := TileToMS (NPCs[0].Tile, 0);
Mouse (TP.x, TP.y, 3, 3, false);
wait (500+random(500));
if ChooseOptionMulti(['Ta','-to']) then writeln ('[Reflection] Talked to leo');
wait (2500+random(1500));
end else writeln ('[Reflection] Leo is already chatting with us');
wait (3000+random(2000)); // Stops lag at start up from screwing us over
MarkTime(t);
repeat
if (GetInterfaceText(242, 6) = 'Click here to continue') then Mouse (303, 452, 72, 7, true);
if (GetInterfaceText(241, 5) = 'Click here to continue') or (GetInterfaceText(243, 7) = 'Click here to continue') or (GetInterfaceText(64, 5) = 'Click here to continue') then
begin
GetMousePos (x, y);
Mouse (x, y, 0, 0, true);
end;
if (ValidInterface(220)) then Mouse (456, 44, 6, 6, true);
wait (670+random(600));
if (not ValidInterface(242)) and (not ValidInterface(241)) and (not ValidInterface(243)) and (not ValidInterface(64)) and (not ValidInterface(220)) then
begin
writeln ('[Reflection] Successfully done talking to leo');
result := true;
Exit;
end;
until (TimeFromMark(t) > 30000)
writeln ('[Reflection] Timeout talking to Leo at start');
end;

{*******************************************************************************
function R_LeoDropInv : TIntegerArray;
By: Cstrike
Description: Makes space by dropping items farthest down in your inventory.
result := [tile x dropped, tile y dropped (, item1 (, item2 (, item 3...];
*******************************************************************************}
function R_LeoDropInv : TIntegerArray;
var i, arrPos: Integer;
myTile : TTile;
begin
if not LoggedIn then exit;
result := [];
if R_InvCount > 23 then
begin
writeln ('[Reflection] Making space for random');
arrPos := 2; // 0 is Tile.x, 1 is Tile.y, 2 is item1, 3 is item2...etc, we want to start filling at index w/ arrPos
SetArrayLength (result, (R_InvCount-23)+2); // If count is 25, then we have the first 2 as tile, last two as ID's
myTile := GetMyPos;
result[0] := myTile.x;
result[1] := myTile.y;
for i:=28 downto 0 do // If there is that 'destroy crap' for whatever, then this will probably skip it... thus downto 0
begin
if R_InvCount < 24 then Exit;
if R_ItemExists(i) then
begin
result[arrPos] := GetItemIDAt(i);
R_DropItem(i);
wait (900+random(350));
Inc(arrPos);
end;
end;
end else writeln ('[Reflection] We have 5+ inventory spaces for the Leo random, proceeding...');
end;

{*******************************************************************************
procedure R_LeoRetrieveInv (TIA : TIntegerArray);
By: Cstrike
Description: If you dropped anything, picks it up.
*******************************************************************************}
procedure R_LeoRetrieveInv (TIA : TIntegerArray);
var GIA : TGroundItemArray;
t : Integer;
TP : TPoint;
begin
if not LoggedIn then Exit;
if (high(TIA) < 0) then Exit;
GIA := []; // Failsafe
MarkTime(t);
writeln ('[Reflection] Picking up items dropped');
if (high(TIA) < 2) then Exit else // No items to retrieve
begin
if not TileOnMS (Tile(TIA[0],TIA[1]), 0) then WalkToTile (Tile(TIA[0],TIA[1]), 1, 0);
repeat
GIA := GetItemsAt(Tile(TIA[0],TIA[1]));
if high(GIA) > -1 then
begin
TP := TileToMS (Tile(TIA[0],TIA[1]), 0);
Mouse (TP.x, TP.y, 2, 2, true);
wait (500+random(250));
end;
until (high(GIA) < 0) or (TimeFromMark(t) > 15000)
end;
GIA := []; // Need to blank this for a memory reason
TIA := []; // Blank TIA in case we fail and need to start fresh
end;

{*******************************************************************************
function R_LeoGraveTiles (i : Integer) : TTile;
By: Cstrike
Description: Returns grave tile positions relative to Leo. This can be revamped
in the future with objects.
*******************************************************************************}
function R_LeoGraveTiles (i : Integer) : TTile;
var NPCs : TNPCArray;
var LeoTile : TTile;
begin
if not LoggedIn then Exit;
result := Tile(0,0); // Failsafe
NPCs := SortNPCs(GetNPCs);
LeoTile := NPCs[0].Tile;
case i of // TL, TR, BL, BM, Bottom Right [BR]
0: result := Tile(LeoTile.x-2,LeoTile.y-4);
1: result := Tile(LeoTile.x+2,LeoTile.y-4);
2: result := Tile(LeoTile.x-4,LeoTile.y-7);
3: result := Tile(LeoTile.x-0,LeoTile.y-7);
4: result := Tile(LeoTile.x+4,LeoTile.y-7);
end;
end;

{*******************************************************************************
function R_LeoGravestoneTiles (i : Integer) : TTile;
By: Cstrike
Description: Returns graveSTONE tile positions relative to Leo. This can be
revamped in the future with objects.
*******************************************************************************}
function R_LeoGravestoneTiles (i : Integer) : TTile;
var NPCs : TNPCArray;
var LeoTile : TTile;
begin
if not LoggedIn then Exit;
result := Tile(0,0);
NPCs := SortNPCs(GetNPCs);
LeoTile := NPCs[0].Tile;
case i of // TL, TR, BL, BM, Bottom Right [BR]
0: result := Tile(LeoTile.x-2,LeoTile.y-2);
1: result := Tile(LeoTile.x+2,LeoTile.y-2);
2: result := Tile(LeoTile.x-4,LeoTile.y-5);
3: result := Tile(LeoTile.x-0,LeoTile.y-5);
4: result := Tile(LeoTile.x+4,LeoTile.y-5);
end;
end;

{*******************************************************************************
function R_GraveObjectCoffinCollect : Boolean;
By: Cstrike
Description: Collects all the coffins. Returns true if successful.
*******************************************************************************}
// 12718 = middle gravestone
function R_GraveObjectCoffinCollect : Boolean;
var ObjCasket, ObjCasketUpdated : TRSObjectArray;
t, InviCount : Integer;
TP : TPoint;
begin
if not LoggedIn then Exit;
result := false;
// Failsafe below
ObjCasket := GetObjectsByID ([LEO_CASKET1, LEO_CASKET2, LEO_CASKET3, LEO_CASKET4, LEO_CASKET5], OBJECT_TYPE_INTERACTABLE, 52);
if high(ObjCasket) < 0 then
begin
writeln ('[Reflection] We have all the coffins');
result := true;
Exit;
end;
// Main part of script
SetAngle(true);
writeln ('[Reflection] Grabbing coffins');
repeat
ObjCasketUpdated := GetObjectsByID ([LEO_CASKET1, LEO_CASKET2, LEO_CASKET3, LEO_CASKET4, LEO_CASKET5], OBJECT_TYPE_INTERACTABLE, 52); // Allows for dynamic stuff
if high(ObjCasketUpdated) < 0 then Break;
if not TileOnMS(ObjCasketUpdated[0].Tile, 0) then R_LeoWalkToCenter;
TP := TileToMS (ObjCasketUpdated[0].Tile, 0);
Mouse (TP.x, TP.y, 2, 3, true);
InviCount := R_InvCount;
MarkTime(t);
repeat
wait(50);
until (R_InvCount > InviCount) or (TimeFromMark(t) > 10000)
until (high(ObjCasketUpdated) < 0)
if (R_CountItemID(LEO_INVENTORY_CASKET1) = 1) and (R_CountItemID(LEO_INVENTORY_CASKET2) = 1) and (R_CountItemID(LEO_INVENTORY_CASKET3) = 1) and (R_CountItemID(LEO_INVENTORY_CASKET4) = 1) and (R_CountItemID(LEO_INVENTORY_CASKET5) = 1) then result := true;
end;

{*******************************************************************************
function R_LeoFindCasket (name : String) : Integer;
By: Cstrike
Description: Searches for the name of what casketID matches the name you give it
*******************************************************************************}
function R_LeoFindCasket (name : String) : Integer;
var i, j, IDToFind : Integer;
begin
if not LoggedIn then exit;
result := 0;
case name of
'flowerpot': IDToFind := LEO_FLOWERPOTID;
'pickaxe': IDToFind := LEO_PICKAXEID;
'chef hat': IDToFind := LEO_CHEFHATID;
'hatchet': IDToFind := LEO_HATCHETID;
'shears': IDToFind := LEO_SHEARSID;
end;
for i:=7587 to 7591 do
begin
R_ClickItemID(i, true, 'open');
wait (500+random(500));
for j:=3 to 11 do // Search interfaces for ID to find
begin
wait (50+random(50)); // More human like waiting
if (R_LeoComponentID (141, j) = IDToFind) then // 141 is the ID
begin
writeln ('[Reflection] Found proper casket for grave');
result := i;
Mouse (493, 27, 3, 3, true);
wait (700+random(500));
Exit;
end;
end;
end;
end;

{*******************************************************************************
function R_LeoSolveGraves : Boolean;
By: Cstrike
Description: This is the big procedure that solves the graves. False = failed.
*******************************************************************************}
function R_LeoSolveGraves : Boolean;
var i, j, t, texID, CasketID : Integer;
GStoneTile : TTile;
TP : TPoint;
begin
if not LoggedIn then exit;
result := false;
for i:=4 downto 0 do // START AT BOTTOM RIGHT since thats where you got your last casket
begin
GStoneTile := R_LeoGravestoneTiles(i);
if not TileOnMS (GStoneTile, 0) then R_LeoWalkToCenter;
TP := TileToMS (GStoneTile, 0);
Mouse (TP.x, TP.y, 3, 3, true);
MarkTime(t);
repeat
wait (50);
until (ValidInterface(143)) or (TimeFromMark(t) > 10000)
if ValidInterface(143) then
begin
for j:=0 to 3 do // Search the 3x3 item square
begin
texID := R_LeoComponentID(143, j);
case texID of
7614: begin
writeln ('[Reflection] Found hatchet model (ID Found: '+inttostr(texID)+')');
wait (800+random(2200)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('hatchet');
writeln ('[Reflection] Casket ID found = '+inttostr(casketID));
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
7615: begin
writeln ('[Reflection] Found chef hat model (ID Found: '+inttostr(texID)+')');
wait (800+random(2200)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('chef hat');
writeln ('[Reflection] Casket ID found = '+inttostr(casketID));
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
7616: begin
writeln ('[Reflection] Found pickaxe model (ID Found: '+inttostr(texID)+')');
wait (640+random(1800)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('pickaxe');
writeln ('[Reflection] Casket ID found = '+inttostr(casketID));
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
7617: begin
writeln ('[Reflection] Found watertank model (ID Found: '+inttostr(texID)+')');
wait (11100+random(1100)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('shears');
writeln ('[Reflection] Casket ID found = '+inttostr(casketID));
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
7618: begin
writeln ('[Reflection] Found flowerpot model (ID Found: '+inttostr(texID)+')');
wait (1100+random(2000)); // Seem human I guess?
Mouse (491, 29, 3, 3, true);
wait (100+random(500)); // Exits the model view
CasketID := R_LeoFindCasket('flowerpot');
writeln ('[Reflection] Casket ID found = '+inttostr(casketID));
if R_ClickItemID(CasketID, false, 'use') then
begin
TP := TileToMS(Tile(GStoneTile.x, GStoneTile.y-1), 0);
Mouse (TP.x, TP.y, 3, 3, true);
R_LeoInvDecrease(1, 12000);
end;
end;
end;
end;
end;
wait (1000+random(1000)); // More wait here, must replace thsi later on
end;
result := true; // Fix me failsafe :(
end;

{*******************************************************************************
function R_TalkToLeoEnd : Boolean;
By: Cstrike
Description: Talks to Leo to solve the random. If we mess up, returns false.
*******************************************************************************}
function R_TalkToLeoEnd : Boolean;
var t : Integer;
NPCs : TNPCArray;
TP : TPoint;
begin
if not LoggedIn then Exit;
result := false;
if (not ValidInterface(241)) and (not ValidInterface(64)) then
begin
NPCs := SortNPCs(GetNPCs);
if not TileOnMS(NPCs[0].Tile, 0) then R_LeoWalkToCenter;
TP := TileToMS (NPCs[0].Tile, 0);
Mouse (TP.x, TP.y, 3, 3, false);
wait (500+random(500));
if ChooseOptionMulti(['Ta','-to']) then writeln ('[Reflection] Talked to leo at end');
wait (2500+random(1500));
end else writeln ('[Reflection] Leo is already chatting with us');
wait (3000+random(2000)); // Stops lag at start up from screwing us over
MarkTime(t);
repeat
if (GetInterfaceText(241, 5) = 'Click here to continue') or (GetInterfaceText(64, 5) = 'Click here to continue') then Mouse (303, 452, 72, 7, true);
wait (670+random(600));
if (not ValidInterface(241)) and (not ValidInterface(64)) then
begin
writeln ('[Reflection] Done chatting with Leo at end');
result := true;
Exit;
end;
until (TimeFromMark(t) > 20000)
writeln ('[Reflection] Timeout talking to Leo at end, result = false');
end;

{*******************************************************************************
function R_SolveLeo : Boolean;
By: Cstrike
Description: Attempts to solve the random.
*******************************************************************************}
function R_SolveLeo : Boolean;
var failsafe : Integer;
ItemDropData : TIntegerArray;
begin
result := false;
ItemDropData := []; // Failsafe
if R_InLeo then
begin
failsafe := 0;
repeat
writeln ('[Reflection] Leo Phase 1: Talk to Leo at start');
if R_TalkToLeoStart then
begin
if R_InvCount > 23 then ItemDropData := R_LeoDropInv; // Declared it here so it can pick it up later
writeln ('[Reflection] Leo Phase 2: Collect graves');
if R_GraveObjectCoffinCollect then
begin
writeln ('[Reflection] Leo Phase 3: Solve the graves');
if R_LeoSolveGraves then
begin
if (high(ItemDropData) < 0) then R_LeoRetrieveInv (ItemDropData); // If we dropped something, now is the time to pick it up
writeln ('[Reflection] Leo Phase 4: Talk to Leo at end');
if R_TalkToLeoEnd then
begin
writeln ('[Reflection] Leo solved!');
result := true;
Exit;
end;
end else
begin
writeln ('[Reflection] Failed solving graves');
if (high(ItemDropData) < 0) then R_LeoRetrieveInv (ItemDropData); // If we dropped something, now is the time to pick it up
Inc(failsafe);
end;
end else
begin
writeln ('[Reflection] Had trouble grabbing all the ground coffins');
Inc(failsafe);
end;
end else
begin
writeln ('[Reflection] Had trouble talking to leo @ start');
Inc(failsafe);
end;
if failsafe < 3 then writeln ('[Reflection] Re-attempting Leo');
until (failsafe > 2)
if failsafe > 2 then
begin
writeln ('[Reflection] We have failed leo too many times, aborting Leo solving procedure');
//NextPlayer(false);
end;
end; //else writeln ('[Reflection] Not in Leo random');
end;

mormonman

2010-10-28 18:12:59

Looks nice, but there are still some ids and numbers that should be constants in there.

Cstrike

2010-10-28 18:27:34

From: mormonman
Looks nice, but there are still some ids and numbers that should be constants in there.


What things should be constants (example)? Interfaces?

NCDS

2010-10-28 18:32:29

Doesn't Leo have a DepositBox?

If so, why drop items instead of just deposit them?

Cstrike

2010-10-28 18:39:53

From: NCDS
Doesn't Leo have a DepositBox?

If so, why drop items instead of just deposit them?


That will be included once I update Bank.simba to deal with those deposit boxes, then it can be integrated :)
And of course this would be the ideal way too

mormonman

2010-10-28 19:22:46

From: cstrike
What things should be constants (example)? Interfaces?


Yes

From: NCDS
Doesn't Leo have a DepositBox?

If so, why drop items instead of just deposit them?


Because certain scripts don't want items deposited. Picking them up is easier for the compatibility of all scripts.

Cstrike

2010-10-28 19:30:30

From: mormonman
Yes


As some good news, it was committed and I was taught all the little standard holes I was missing :)

NCDS

2010-10-28 19:33:14

From: mormonman

Because certain scripts don't want items deposited. Picking them up is easier for the compatibility of all scripts.

SRL's current Leo solver deposits, just figured Reflection might as well follow the same general method.

If you just drop the items there is always a possibility of not picking it up again whereas if you deposit it, there is no chance of losing the item.

mormonman

2010-10-28 19:48:50

From: NCDS
SRL's current Leo solver deposits, just figured Reflection might as well follow the same general method.

If you just drop the items there is always a possibility of not picking it up again whereas if you deposit it, there is no chance of losing the item.


Then we should at least create the option of adding items that should not be deposited. For example a woodcutting script would declare the safeitems := [bronzehatchetid, ironhatchetid, etc];

In the depositing function just have a if (High(safeitems) > 0) then donotdepositthem. Or just make it a choice between depositing and dropping.

Cstrike

2010-10-28 19:59:23

From: mormonman
Then we should at least create the option of adding items that should not be deposited. For example a woodcutting script would declare the safeitems := [bronzehatchetid, ironhatchetid, etc];

In the depositing function just have a if (High(safeitems) > 0) then donotdepositthem. Or just make it a choice between depositing and dropping.


That would be an interesting thing to add, it could end up being like this:

R_FindRandoms (ItemsToDeposit : TIntegerArray);

NCDS

2010-10-28 21:56:26

I'm pretty sure right now it jjst deposits the last 5 inventory items, but that is a nice suggestion.

mormonman

2010-10-28 22:37:53

From: cstrike
That would be an interesting thing to add, it could end up being like this:

R_FindRandoms (ItemsToDeposit : TIntegerArray);


We actually started working on this system on the old googlecode page, but then runetek5 screwed all of our work up.

Naike

2010-10-29 03:18:41

Wait with the deposit item id's.
Waste of energy to do that when we don't have a stable system.

Cstrike

2010-11-14 13:27:18

Just curious, was the "Leo Walk to center" function thing removed or not working? Without it, the random won't work (and can't find some graves).
I'll check into it.


I FOUND THE GLITCH :D

{*******************************************************************************
procedure R_LeoWalkToCenter;
By: Cstrike
Description: Moves us above middle grave so everything is in sight.
*******************************************************************************}
procedure R_LeoWalkToCenter;
var
GraveStone: TRSObject;
TP: TPoint;
begin
GraveStone := GetObjectByID (LEO_GRAVESTONE_MIDDLE, OBJECT_TYPE_INTERACTABLE, 52);
TP := TileToMM(Tile(GraveStone.Tile.X, GraveStone.Tile.Y+1));
Mouse (TP.X, TP.X, 1, 1, True); // <---- THIS LINE, TWO TP.X's
Wait (3000+Random(1200));
end;

pyroryan

2010-11-15 21:16:09

From: cstrike
Just curious, was the "Leo Walk to center" function thing removed or not working? Without it, the random won't work (and can't find some graves).
I'll check into it.


I FOUND THE GLITCH :D

{*******************************************************************************
procedure R_LeoWalkToCenter;
By: Cstrike
Description: Moves us above middle grave so everything is in sight.
*******************************************************************************}
procedure R_LeoWalkToCenter;
var
GraveStone: TRSObject;
TP: TPoint;
begin
GraveStone := GetObjectByID (LEO_GRAVESTONE_MIDDLE, OBJECT_TYPE_INTERACTABLE, 52);
TP := TileToMM(Tile(GraveStone.Tile.X, GraveStone.Tile.Y+1));
Mouse (TP.X, TP.X, 1, 1, True); // <---- THIS LINE, TWO TP.X's
Wait (3000+Random(1200));
end;


Committed.

{*******************************************************************************
procedure R_LeoWalkToCenter;
By: Cstrike
Description: Moves us above middle grave so everything is in sight.
*******************************************************************************}
procedure R_LeoWalkToCenter;
var
GraveStone: TRSObject;
TP: TPoint;
begin
GraveStone := GetObjectByID (LEO_GRAVESTONE_MIDDLE, OBJECT_TYPE_INTERACTABLE, 52);
TP := TileToMM(Tile(GraveStone.Tile.X, GraveStone.Tile.Y+1));
Mouse (TP.X, TP.Y, 1, 1, True);
Wait (3000+Random(1200));
end;