Cstrike
2010-10-14 21:41:46
function R_InBeekeeper: boolean;
begin
Result := ValidNPC('Bee keeper');
end;
function BuildInterfaceUp: boolean;
begin
Result := ValidInterface(420);
end;
{*******************************************************************************
function LoggingInToBeeKeeperClickContinue : Boolean;
By: Cstrike
Description: Handles bee keeper if you log into this random, does not handle bee
keeper at the start though.
*******************************************************************************}
function LoggingInToBeeKeeperClickContinue : Boolean;
var timeOut : Integer;
begin
result := false;
if (GetInterfaceText(241,3) = 'Bee keeper') and (GetInterfaceText(241,5) = 'Click here to continue') and (GetInterfaceText(241,4) = '<p=1>Ready to try again?') then
begin
writeln ('Found bee keeper Click To Continue after logging back in');
Mouse (287, 455, 50, 2, true);
MarkTime (timeOut);
repeat
wait (300+random(150));
until (GetInterfaceText(236,2) = 'Yeah, let me get on with it.') or (TimeFromMark(timeOut) > 10000)
if (GetInterfaceText (236,2) = 'Yeah, let me get on with it.') then
begin
writeln ('Found second part where we respond says "Yeah lets get on with it"');
Mouse (258, 440, 50, 3, true);
MarkTime (timeOut);
repeat
wait (300+random(150));
until (not GetInterfaceText(236,2) = 'Yeah, let me get on with it.') or (TimeFromMark(timeOut) > 10000)
if not GetInterfaceText(236,2) = 'Yeah, let me get on with it.' then
begin
writeln ('"Yeah lets get on with it" is now gone, function complete.');
result := true;
end;
end;
end;
end;
function TalkToKeeper: boolean;
var
NPC: TNPC;
P: TPoint;
t: integer;
begin
if not FindNPC('Bee keeper', NPC)then Exit;
if not TileOnMS(NPC.Tile, NPC.Height * 2 / 3)then
begin
SetAngle(true);
if not TileOnMS(NPC.Tile, NPC.Height * 2 / 3)then
if not WalkToTile(NPC.Tile, 0, 0)then
Exit;
end;
P := TileToMS(NPC.Tile, NPC.Height * 2 / 3);
Mouse(P.x, P.y, 3, 3, false);
Result := R_ChooseOption('Talk-to');
if Result then
begin
MarkTime(t);
While ((not FindNPCText('click here to')) and (TimeFromMArk(t) < 5000))do
begin
if charactermoving then
MarkTime(t);
wait(100+Random(100));
end;
end;
end;
function HandleKeeper: boolean;
var
Keeper: TNPC;
begin
if not R_LoggedIn then Exit;
Result := BuildInterfaceUp;
if Result then Exit;
While not BuildInterfaceUp do
begin
if not FindNPC('Bee keeper', Keeper)then Exit;
if not(InteractingWithMe(keeper))then
TalkToKeeper;
R_ClickToContinue;
if(FindNPCText('yeah, let me'))then
begin
Mouse(260, 444, 15, 3, true);
wait(800+Random(2000));
end;
end;
end;
function GetSlotChild(slot: integer): Integer;
begin
case Slot of
1: Result := 25;
2: Result := 22;
3: Result := 23;
4: Result := 21;
else
begin
Writeln('Invalid slot number.');
Result := -1;
end;
end;
end;
function GetPieceIDAt(Slot: Integer): Integer;
begin
if not ValidInterface(420)then Exit;
Result := GetModelID(420, GetSlotChild(Slot));
end;
procedure MovePiece(From, toSlot: Integer);
var
IFace, Child, EndChild, x, y: Integer;
TL, BR, P: TPoint; //Top left, Bottom right
begin
if not ValidInterface(420) then Exit;
case From of
1: Child := 12;
2: Child := 13;
3: Child := 14;
4: Child := 15;
end;
case toSlot of
1: EndChild := 16;
2: EndChild := 17;
3: EndChild := 18;
4: EndChild := 19;
end;
//Clicking component slot.
IFace := GetInterface(420, Child);
TL.x := SmartGetFieldInt(IFace, hook_interface_GetX);
TL.y := SmartGetFieldInt(IFace, hook_interface_GetY);
BR.x := SmartGetFieldInt(IFace, hook_interface_GetWidth) + TL.x;
BR.y := SmartGetFieldInt(IFace, hook_interface_GetHeight) + TL.y;
P := MiddleTPA([TL, BR]);
MMouse(p.x, p.y, 10, 5);
GetMousePos(x, y);
HoldMouse(x, y, 1);
SmartFreeObject(IFace);
//Moving mouse to destination slot.
IFace := GetInterface(420, EndChild);
TL.x := SmartGetFieldInt(IFace, hook_interface_GetX);
TL.y := SmartGetFieldInt(IFace, hook_interface_GetY);
BR.x := SmartGetFieldInt(IFace, hook_interface_GetWidth) + TL.x;
BR.y := SmartGetFieldInt(IFace, hook_interface_GetHeight) + TL.y;
P := MiddleTPA([TL, BR]);
MMouse(p.x, p.y, 10, 5);
GetMousePos(x, y);
ReleaseMouse(x, y, 1);
SmartFreeObject(IFace);
end;
{*******************************************************************************
procedure BeeKeeperBlindlyClickContinueAndWaitRandom (waitInMS, randomWaitInMS : Integer);
By: Cstrike
Description: This should be removed in the future, it's a blind click on the
Click To Continue crap with a wait in there.
*******************************************************************************}
procedure BeeKeeperBlindlyClickContinueAndWaitRandom (waitInMS, randomWaitInMS : Integer);
begin
Mouse (287, 455, 50, 2, true);
wait (waitInMS+random(randomWaitInMS));
end;
function R_SolveBeekeeper: boolean;
var
i, ID, t: integer;
begin
if not R_InBeekeeper then Exit;
while(R_InBeekeeper)do
begin
LoggingInToBeeKeeperClickContinue;
if not BuildInterfaceUp then
begin
HandleKeeper;
end else
begin
for i := 1 to 4 do
begin
ID := GetPieceIDAt(i);
case ID of
16036: MovePiece(i, 1);
16025: MovePiece(i, 2);
16022: MovePiece(i, 3);
16034: MovePiece(i, 4);
end;
wait(300+Random(1000));
end;
Mouse(216, 277, 8, 8, true);
MarkTime(t);
while(R_InBeekeeper and (TimeFromMark(t) < 10000))do
begin
R_ClickToContinue;
Wait(300+Random(300));
end;
end;
end;
//R_ClickToContinue;
BeeKeeperBlindlyClickContinueAndWaitRandom (3000, 1000); // I replaced this since apparently it doesnt click at the end...
Result := not R_InBeekeeper;
if Result then
Inc(RSolved[RBees])
else
Inc(RFailed[RBees]);
end;I went through and fixed the code. It now solves the bee keeper but only upon logging into it. I do not know how it handles being taken straight to it.
Also, there has to be a way to fix the R_ClickToContinue function, and I know a way… but the interface loop that crashes simba has to be found and fixed. I think Drags had a way around it.
So yes, this DOES work, but needs to be tweaked before thinking about committing it.
EDIT: I don't know much about the other procedures, since I didn't make this. I did try making my own, but found that there already was a file that somewhat worked. Now it should work minus the intro which I have no idea how to get at besides someone who can debug reflection good.