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:
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.