mormonman
2010-12-28 14:24:51
This is a temporary fix to see if the ids of the pheasants stay constant or if they change now like they do in the prison random.
I will probably remodel this random because I don't like the idea of a linear solver…it should be dynamic.
I will probably remodel this random because I don't like the idea of a linear solver…it should be dynamic.
const
R_FORESTERID = 2458;
R_ONETAIL_1 = 4277;
R_ONETAIL_2 = 7445;
R_TWOTAIL_1 = 13246;
R_TWOTAIL_2 = 7446;
R_THREETAIL_1 = 13248;
R_THREETAIL_2 = 13247;
R_FOURTAIL_1 = 13249;
R_FOURTAIL_2 = 13250;
R_MEATID = 6178;
R_FORESTERPORTALID = 8972;
Function r_InForester: Boolean;
begin
Result := ValidNPCNull(R_FORESTERID);
end;
Function r_ForesterWants: TIntegerArray;
var
S: String;
begin
Result := [-1];
while ClickContinue(False, False) do
begin
S := GetInterfaceText(242, 4);
if Pos('kill', S) > 0 then
Break;
ClickContinue(True, True);
end;
Delete(S, 1, Pos('kill a', S)+6);
Delete(S, Pos('-', S), Length(S));
Case S of
'one': Result := [R_ONETAIL_1, R_ONETAIL_2];
'two': Result := [R_TWOTAIL_1, R_TWOTAIL_2];
'three': Result := [R_THREETAIL_1, R_THREETAIL_2];
'four': Result := [R_FOURTAIL_1, R_FOURTAIL_2];
end;
r_Debug('Going to look for ' + S + ' tailed pheasant!', 'Forester');
ClickToContinue;
end;
Function r_FindForester: Boolean;
var
NPC: TNPC;
C: TPoint;
iTime: Integer;
begin
r_Debug('Finding Freaky forester..', 'Forester');
iTime := GetSystemTime;
Repeat
NPC := GetNPCNull(R_FORESTERID);
If Not TileOnMS(NPC.Tile, 0)then
begin
r_Debug('Tile not on MS' + ToStr(NPC.Tile) + ', walking there.', 'Forester');
WalkToTile(NPC.Tile, 0, 0);
end;
C := TileToMS(NPC.Tile, 0);
Mouse(C.X, C.Y, 5, 5, False);
Result := WaitOption('alk-', 200+Random(100));
If Result then
begin
r_Debug('Found Freaky forester!', 'Forester');
Wait(2000+Random(1000));
Flag;
Exit;
end;
until(GetSystemTime-iTime > 30000);
r_Debug('Took > 30 secs finding forester, result = false', 'Forester');
end;
function r_ForesterFight: boolean;
var
T: Integer;
begin
T := GetSystemTime + 4000;
repeat
wait(66)
if (GetAnimation > -1) then
Result := true;
until Result or (GetSystemTime > T);
end;
function r_GetNPC(IDs: TIntegerArray):TNPC;
var
NPCs: TNPCArray;
i, Hi: Integer;
B: Boolean;
begin
Result := NULL_NPC;
NPCs := SortNPCS(GetNPCs);
Hi := High(NPCs);
for i := Hi downto 0 do
begin
if InIntArray(IDs, NPCs[i].ID) then
begin
Result := NPCs[i];
Exit;
end;
end;
end;
Function r_ForesterKill(SeekFor: TIntegerArray): Boolean;
var
NPC: TNPC;
C: TPoint;
iTime, iTimeEx: Integer;
begin
r_Debug('Finding pheasant..', 'Forester');
iTime := GetSystemTime;
Repeat
NPC := r_GetNPC(SeekFor);
If (NPC = NULL_NPC) then
Exit;
If Not TileOnMS(NPC.Tile, 0)then
begin
r_Debug('Tile not on MS' + ToStr(NPC.Tile) + ', walking there.', 'Forester');
WalkToTile(NPC.Tile, 0, 0);
Exit;
end;
C := TileToMS(NPC.Tile, 0);
Mouse(C.X, C.Y, 5, 5, False);
Result := WaitOption('tack', 200+Random(100));
If Result then
begin
r_Debug('Attacked pheasant!', 'Forester');
Wait(2000+Random(500));
Flag;
iTimeEx := GetSystemTime;
While (Not Pos('ollect', GetInterfaceText(241, 4)) > 0) do
begin
Wait(100+Random(100));
If (GetSystemTime - iTimeEx > 6000)then
Exit;
end;
r_Debug('Time to collect the raw pheasant!', 'Forester');
Wait(3000+Random(500));
end;
until(Result)or(GetSystemTime-iTime > 60000)
end;
Function r_ForesterLastTalk: Boolean;
begin
Result := False;
end;
Function r_ForesterPortal: Boolean;
var
Obj: TRSObject;
C: TPoint;
begin
Obj := GetObjectByIDEx([R_FORESTERPORTALID], OBJECT_TYPE_INTERACTABLE, 40);
If Not (Obj.ID = R_FORESTERPORTALID)then
begin
r_Debug('Problem finding leaving portal, result = false', 'Forester');
Exit;
end;
If Not TileOnMS(Obj.Tile, 0)then
WalkToTile(Obj.Tile, 0, 0);
C := TileToMS(Obj.Tile, 0);
MMouse(C.X, C.Y, 5, 5);
Result := WaitUpText('ortal', 200+Random(100));
GetMousePos(C.X, C.Y);
Mouse(C.X, C.Y, 0, 0, Result);
If Not Result then
Result := WaitOption('nter', 200+Random(100));
If Result then
begin
Wait(2000+Random(1000));
Flag;
end;
end;
Function r_SolveForester: Boolean;
var
iTime: Integer;
FWants: TIntegerArray;
begin
Result := r_InForester;
If Not Result then
Exit;
iTime := GetSystemTime;
Repeat
If Not r_FindForester then
Exit
else
FWants := r_ForesterWants;
Until(Length(FWants) > 0)or(GetSystemTime - iTime > 60000);
If (FWants[0] < 1) then
Exit;
iTime := GetSystemTime;
Repeat
r_ForesterKill(FWants);
If (GetSystemTime - iTime > 60000)then
begin
r_Debug('Took more than one minute to recive food!', 'Forester');
Exit;
end;
Until(R_CountItemID(R_MEATID) > 0);
If Not r_FindForester then
Exit;
iTime := GetSystemTime;
Repeat
If (GetSystemTime - iTime > 30000)then
begin
r_Debug('Took more than 30 secs to leave!', 'Forester');
Exit;
end;
Until(r_ForesterPortal);
Wait(1000+Random(2000));
Result := (Not r_InForester)and(LoggedIn);
end;