J J
2012-06-07 08:34:01
function CheckIfInCombat(XpCounter, MaxTime: Integer): Boolean;
var
X, Y, OldXp, NewXp, ShieldBitmap, SwordBitmap, t: Integer;
begin
ShieldBitmap := BitmapFromString(6, 6, 'meJxzMmU1Pv7PyZS1MpIdSNbf/lcY' +
'zAZkFIeAuOEXQVIbazggghCVzfHsQBEgQ2Q/QuPOZk6IGrjK/W2cQ' +
'EGgSiCCmAYAgGAjCw==');
SwordBitmap := BitmapFromString(5, 5, 'meJxzv/svNiEBiC5durRz9Xr3u/+A' +
'qLu7G8iGcFW3gRCQzVK1hSFkM4QLREAuu0U6kIRzAaL/Koo=');
OldXp := GetXpBar(XpCounter);
if Debug then
begin
SMART_ClearCanvas;
WriteLn('OldXp: '+IntToStr(OldXp)+'');
SMART_DrawBoxes(False, [IntToBox(MSCX-15, MSCY-50, MSCX+15, MSCY)], clRed); // Shield
SMART_DrawBoxes(False, [IntToBox(MSCX-20, MSCY-50, MSCX+10, MSCY)], clYellow); // Sword
end;
MarkTime(t);
repeat
Wait(50 + Random(50));
NewXp := GetXpBar(XpCounter);
if Debug then
WriteLn('NewXp: '+IntToStr(NewXp)+'');
until (FindBitmapToleranceIn(ShieldBitmap, X, Y, MSCX-15, MSCY-50, MSCX+15, MSCY, 20)) or (FindBitmapToleranceIn(SwordBitmap, X, Y, MSCX-20, MSCY-50, MSCX+10, MSCY, 20)) or (NewXp > OldXp) or (TimeFromMark(t)>MaxTime);
if TimeFromMark(t)<MaxTime then
Result := True;
FreeBitmap(ShieldBitmap);
FreeBitmap(SwordBitmap);
end;Debug when found xp increase
OldXp: 1337192
NewXp: 1337192
NewXp: 1337192
NewXp: 1337192
NewXp: 1337192
NewXp: 1337192
NewXp: 1337192
NewXp: 1337192
NewXp: 1337260
In combat!Debug when found a bitmap
OldXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
NewXp: 1337309
In combat!Shield bitmap

Weapon bitmap

In action
if CheckIfInCombat(1, 5000) then
WriteLn('In combat!');XpCounter is set to number #1Checks if it is in combat for max of 5000 ms
Yellow box: searches for shield bitmap thereRed box: searches for attack bitmap there
Xp counter: checks for xp changes
It has been very accurate for me so far, let me know what you think.