Cstrike
2010-10-29 01:42:45
Mordaut is turning out to be easier than I thought. I just REALLY need help with strings.
Thus far, the code works flawlessly. In fact, it works too flawlessly, needed to add a mega wait in there to act human.
QUESTION 1 OF 3 DONE SO FAR, ATTEMPTING REST TOMORROW:
Here is code minus credits:
This pretty much will be solved tomrorow
BUT I NEED HELP WITH STRINGS BADLY
My weakness keeps kicking me in the balls. Does anyone know how to find string 'ABC' in 'AD IADJ NE XXABCH EIORJA'?
Thus far, the code works flawlessly. In fact, it works too flawlessly, needed to add a mega wait in there to act human.
QUESTION 1 OF 3 DONE SO FAR, ATTEMPTING REST TOMORROW:
Here is code minus credits:
const
EXAM_QUESTIONEONEINTERFACE = 103;
// Gets Component ID
function R_ExamGrabComponentID (ParentI, ChildI : Integer) : Integer;
var
Child: Integer;
begin
Child := GetInterface(ParentI, ChildI);
Result := SmartGetFieldInt(Child, hook_interface_GetID);
SmartFreeObject(Child);
end;
// Shut his interfaces up, or if important they will be processed first and result in something
procedure R_ExamShutMordautUp;
var
t : Integer;
begin
if not LoggedIn then Exit;
MarkTime(t);
repeat
if (GetInterfaceText(243, 6) = 'object to come next in a pattern.')
or (GetInterfaceText(243, 6) = 'select them and confirm.')
or (GetInterfaceText(241, 4) = '<p=68>Pick the object that should come next in the pattern.') then Mouse(303, 452, 72, 7, True);
wait (2000+random(2000));
if (TimeFromMark(t) > 20000) then Exit;
until (not ValidInterface(243)) and (not ValidInterface(241))
end;
// Returns name
function R_ExamReturnModelName (ID : Integer) : String;
begin
if not LoggedIn then Exit;
Result := 'none';
case ID of
11539, 11540, 11541, 11614, 11615, 11633: Result := 'range';
11526, 11529, 11545, 11549, 11550, 11555, 11560, 11563, 11564, 11607,
11608, 11616, 11620, 11621, 11622, 11623, 11628, 11629, 11634, 11639,
11641, 11649, 11624: Result := 'cooking';
11527, 11574, 11578, 11580, 11599, 11600, 11601, 11602, 11603, 11604,
11605, 11606, 11625: Result := 'fishing';
11528, 11531, 11536, 11537, 11579, 11591, 11592, 11593, 11597, 11627,
11631, 11635, 11636, 11638, 11642, 11648, 11617: Result := 'combat';
11530, 11532, 11547, 11548, 11554, 11556, 11571, 11581, 11586, 11610,
11645: Result := 'farming';
11533, 11534, 11538, 11562, 11567, 11582: Result := 'magic';
11535, 11551, 11552, 11559, 11646: Result := 'firemaking';
11540, 11557, 11558, 11560, 11570, 11619, 11626, 11630, 11632, 11637,
11654: Result := 'hats';
11570, 11626, 11558: Result := 'pirate';
11572, 11576, 11652: Result := 'jewellery';
11542, 11543, 11544, 11644, 11647: Result := 'drinks';
11573, 11595: Result := 'woodcutting';
11561, 11618, 11650, 11651: Result := 'boots';
11546, 11553, 11565, 11566, 11568, 11569, 11572, 11575, 11576, 11577,
11581, 11583, 11584, 11585, 11643, 11652, 11653: Result := 'crafting';
11587, 11588, 11594, 11596, 11598, 11609, 11610: Result := 'mining';
11611, 11612, 11613: Result := 'fishing';
end;
end;
// Searches for slot that is answer and clicks it
function R_ExamCompleteQ1 (IntNum, CompNumLow, CompNumHigh : Integer; Name : String) : Boolean;
var
i, ItemID, xpos : Integer;
ItemName : String;
begin
if not LoggedIn then Exit;
result := false;
if not (ValidInterface (EXAM_QUESTIONEONEINTERFACE)) then Exit;
for i:=CompNumLow to CompNumHigh do
begin
ItemID := R_ExamGrabComponentID(EXAM_QUESTIONEONEINTERFACE, i);
ItemName := R_ExamReturnModelName(ItemID);
if ItemName = Name then
begin
Writeln ('[Reflection] Found match at position '+inttostr(i)+' in range '+inttostr(CompNumLow)+'/'+inttostr(CompNumHigh));
wait (3500+random(6200)); // High wait times since this solves it literally instantly
xpos := 109+((i-CompNumLow)*96);
Mouse (xpos, 220, 16, 14, true);
Exit;
end;
end;
Writeln ('[Reflection] Found no match in question 1 at the bottom four objects');
end;
// Using TIA, returns most common name
function R_ExamCheckModeOfNames (ItemIDs : TIntegerArray) : String;
var
ItemNameArr : TStringArray;
i : Integer;
begin
SetArrayLength (ItemNameArr, high(ItemIDs)+1);
Result := 'none'
for i:=0 to high(ItemIDs) do
begin
ItemNameArr[i] := R_ExamReturnModelName(ItemIDs[i]);
end;
if (ItemNameArr[0] = ItemNameArr[1]) or (ItemNameArr[0] = ItemNameArr[2]) or (ItemNameArr[1] = ItemNameArr[2]) then
begin
Writeln ('[Reflection] Perfect match found for name: '+ItemNameArr[0]);
Result := ItemNameArr[0];
end else
if (ItemNameArr[0] = ItemNameArr[1]) or (ItemNameArr[0] = ItemNameArr[2]) then
begin
Writeln ('[Reflection] Partial match found for name: '+ItemNameArr[0]);
Result := ItemNameArr[0];
end else
if (ItemNameArr[1] = ItemNameArr[2]) then
begin
Writeln ('[Reflection] Partial match found for name: '+ItemNameArr[0]);
Result := ItemNameArr[1];
end else Writeln ('[Reflection] Warning: No match found for any of the items!');
end;
// Handles Q1
function R_ExamQuestionOne : Boolean;
var
ThreeItemIDs : TIntegerArray;
i : Integer;
CommonType : String;
begin
if not LoggedIn then Exit;
Result := False;
R_ExamShutMordautUp; // Place me elsewhere later
if not (ValidInterface (EXAM_QUESTIONEONEINTERFACE)) then Exit;
SetArrayLength (ThreeItemIDs, 3);
for i:=6 to 8 do
begin
ThreeItemIDs[i-6] := R_ExamGrabComponentID (EXAM_QUESTIONEONEINTERFACE, i); // Minus 6 to start at index zero
end;
Writeln ('[Reflection] IDs obtained for three items in Question one: '+inttostr(ThreeItemIDs[0])+', '+inttostr(ThreeItemIDs[1])+', '+inttostr(ThreeItemIDs[2]));
CommonType := R_ExamCheckModeOfNames (ThreeItemIDs);
Writeln ('[Reflection] Common name obtained: '+CommonType+', searching for IDs in the bottom row that match this name');
if R_ExamCompleteQ1(EXAM_QUESTIONEONEINTERFACE, 10, 13, CommonType) then Result := True;
end;This pretty much will be solved tomrorow
BUT I NEED HELP WITH STRINGS BADLY
My weakness keeps kicking me in the balls. Does anyone know how to find string 'ABC' in 'AD IADJ NE XXABCH EIORJA'?