rj
02-09-2014, 10:37 PM
So I have a set up loot procedure
procedure _loot_array.init;
begin
setLength(self, 3);
with self[0] do
begin
name := 'Gold charm';
options := ['ake old','ld cha'];
value := 0;
end;
with self[1] do
begin
name := 'Green charm';
options := ['ake Gr','en cha'];
value := 0;
end;
with self[2] do
begin
name := 'Coins';
options := ['ake Coi','oins'];
value := 1;
end;
end;
The properties name and value are only for tracking/cosmetic purposes. Options in the getChoose options
Now my looting function is supposed to work like this:
1) Use the horridly inaccurate mmtoMS function that I got a hold of that works 30% of the time to find a loot pile because I probably did some math wrong
2) Right click.
3) Find the number of desirable items.
4) If there are > 1 desirable items, after moving it will click under the player to loot the rest.
Now what my looting function actually does:
1) If the planets align and somehow the MMtoMs function successfully projects the correct lootpile it right clicks
2) If it sees 'Gold charm' it will pick it up
3) It will never pick up coins or green charms
I know it's not my isText function because it works
options represents the found choose options, the 2d string array represents the _loot_array record
var
options:TStringArray;
LookFor:T2DStringArray;
_count, k:integer;
function isText(Text, theText: TStringArray): Boolean;
var
i, k: Integer;
begin
for i := 0 to High(Text) do
for k := 0 to high(theText) do
if (Pos(Text[i], TheText[k]) > 0) then
exit(true);
end;
begin
options := ['Take Magic seed', 'Take Gold charm', 'Take Bones', 'Take Coins', 'Walk here', 'Examine Magic seed', 'Examine Gold charm', 'Examine Bones', 'Examine Coins'];
LookFor := [['ake Coi', 'oins'], ['ake old','ld cha'], ['ake Gr','en cha']];
for k := 0 to high(LookFor) do
if isText(LookFor[k], options) then
_count := _count + 1;
writeln(_count);
end.
My looting function:
function isText(Text, theText: TStringArray): Boolean;
var
i, k: Integer;
begin
for i := 0 to High(Text) do
for k := 0 to high(theText) do
if (Pos(Text[i], TheText[k]) > 0) then
exit(true);
end;
procedure _loot_array.pickUp();
var
_dots:TPointArray;
options:array of TOptions;
i, k, e, _count:integer;
opt_strs:TStringArray;
_ls:TPoint;
t:integer;
moved:boolean;
begin
_dots := GetMiniMapDotsIn('item',539, 61, 708, 217);//getRedDots();
filterpointspie(_dots, 0, 360, 0, _loot_distance * 4, 627, 138);
sortTPAFrom(_dots, point(627, 138));
setLength(_dots, 2);
for i := 0 to high(_dots) do
begin
if moved then
exit();
_ls := ss_MMtoMsPoint(_dots[i]);
mouse(_ls.x, _ls.y, 0, 0, mouse_right);
t := getSystemTime;
options := _ss.getOptions();
setLength(opt_strs, length(options));
for k := 0 to high(options) do
opt_strs[k] := options[k].Str;
for k := 0 to high(self) do
if isText(opt_strs, self[k].options) then
_count := _count + 1;
for k := 0 to _count do
begin
if moved then
mouse(258, 230, 0, 0, mouse_right);
for e := 0 to high(self) do
if not _ss.waitOptionMulti(self[e].options, 150) then
if debug then
writeln('Did not find ' , self[e].options)
else
moved := true;
end;
end;
end;
{$I RSPS/srlRSPS.Simba}
const
_timeout = 15000;
_loot = true;
_loot_distance = 5;
xpRate = 200;
type
_monster = record
color, tol:tintegerarray;
health, filter:integer;
hue, sat:textendedarray;
uptext, options:tstringarray;
rightClick, useUptext, checkCombat:boolean;
name:string;
end;
_loot_item = record
options:TStringArray;
name:string;
Value, count:Integer;
end;
_loot_array = array of _loot_item;
var
_pickUps:_loot_array;
_zone:TBoxArray;
procedure _loot_array.init;
begin
setLength(self, 3);
with self[0] do
begin
name := 'Gold charm';
options := ['ake old','ld cha'];
value := 0;
end;
with self[1] do
begin
name := 'Green charm';
options := ['ake Gr','en cha'];
value := 0;
end;
with self[2] do
begin
name := 'Coins';
options := ['ake Coi','oins'];
value := 1;
end;
end;
var
_ss:_rsps_server;
m:_monster;
debug:boolean;
cs:tpoint;
failed, kills:integer;
ld:integer;
procedure _monster.init;
begin
with self do
begin
color := [9148055];
tol := [15];
health := 22;
filter := 140;
hue := [0.10];
sat := [0.15];
uptext := ['ave','rawl','raw'];
options := ['ttack','tack'];
rightClick := true;
useUptext := true;
checkCombat := false;
name := 'Cave crawler';
end;
end;
function center(bx: TBox): TPoint;
begin
if ((bx.X1 > bx.X2) or (bx.Y1 > bx.Y2)) then
begin
if (bx.X1 > bx.X2) then
Swap(bx.X1, bx.X2);
if (bx.Y1 > bx.Y2) then
Swap(bx.Y1, bx.Y2);
end;
Result := Point(Round(bx.X1 + ((bx.X2 - bx.X1) div 2)), Round(bx.Y1 + ((bx.Y2 - bx.Y1) div 2)));
end;
function perHour(what:integer):integer;
begin
result := Round(what * (3600.0 / (GetTimeRunning / 1000.0)));
end;
procedure _monster.progress(state:string);
begin
clearDebug();
writeln('Overall Progress');
writeln('- State: ', state);
writeln('- ', kills, ' ', self.name, ' Killed ');
writeln('- XP: ', (kills * xpRate * self.health));
writeln('Hourly Progress');
writeln('- XP: ', perHour(kills * self.health * xpRate));
writeln('- Kills: ', perHour(kills));
writeln('=====================');
end;
function FindColorsPie(var Points: TPointArray; Color, Tol: Integer; StartD,
EndD, MinR, MaxR: Extended; x1, y1, x2, y2, Mx, My: Integer): Boolean;
begin
Result := FindColorsTolerance(Points, Color, x1, y1, x2, y2, Tol);
if (Result) then
FilterPointsPie(Points, StartD, EndD, MinR, MaxR, Mx, My);
end;
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
var
I, Dif, Radius, Hi, C: Integer;
TPA: TPointArray;
begin
case LowerCase(WhatDot) of
'npc', 'n', 'yellow', 'y': Dif := 4369;
'item', 'i', 'red', 'r': Dif := 29;
'player', 'p', 'white', 'w': Dif := 1907997;
'friend', 'f', 'green', 'g': Dif := 5376;
'team', 't', 'blue', 'b', 'cape': Dif := 2171941;
{'clan', 'c', 'orange', 'o': Dif := -1;}
else
writeln('');// srl_Warn('GetMiniMapDotsIn', '"' + WhatDot + '" is not a valid dot type', warn_AllVersions);
end;
Freeze;
Radius := Max((x2-x1)div 2, (y2-y1)div 2);
FindColorsPie(TPA, 65536, 0, 0, 360, 0, radius, x1, y1, x2, y2, (x1+x2)div 2, (y1+y2)div 2);
Hi := High(TPA);
SetLength(Result, Hi + 1);
if (Hi < 0) then
begin
UnFreeze;
Exit;
end;
C := 0;
for I := 0 to Hi do
begin
if (GetColor(TPA[I].X-1, TPA[I].Y-1) - GetColor(TPA[I].X, TPA[I].Y-1) = Dif) then
begin
Result[C] := Point(TPA[I].x, TPA[i].y - 2);
Inc(C);
end;
end;
Unfreeze;
SetLength(Result, C);
end;
procedure ss_MMToMS(var X, Y:Integer);
var
x1, y1 : Integer;
begin
x1 := X;
y1 := X;
X := Round((X-627)*255/40) + 252;
Y := Round((Y-139)*176/28) + 224;
if X < 3 then X := 3;
if Y < 3 then Y := 3;
if X > 516 then X := 516;
if Y > 337 then Y := 337;;
end;
function ss_MMtoMsPoint(p:TPoint):TPoint;
var
x, y:integer;
begin
x := p.x;
y := p.y;
ss_MMToMS(x, y);
result := Point(x, y);
end;
function isText(Text, theText: TStringArray): Boolean;
var
i, k: Integer;
begin
for i := 0 to High(Text) do
for k := 0 to high(theText) do
if (Pos(Text[i], TheText[k]) > 0) then
exit(true);
end;
procedure _loot_array.pickUp();
var
_dots:TPointArray;
_possible_loot:T2DPointArray;
options:array of TOptions;
i, k, e, _count:integer;
opt_strs:TStringArray;
_ls:TPoint;
t:integer;
moved:boolean;
begin
_dots := GetMiniMapDotsIn('item',539, 61, 708, 217);//getRedDots();
filterpointspie(_dots, 0, 360, 0, _loot_distance * 4, 627, 138);
sortTPAFrom(_dots, point(627, 138));
setLength(_dots, 2);
for i := 0 to high(_dots) do
begin
if moved then
exit();
_ls := ss_MMtoMsPoint(_dots[i]);
mouse(_ls.x, _ls.y, 0, 0, mouse_right);
t := getSystemTime;
options := _ss.getOptions();
setLength(opt_strs, length(options));
for k := 0 to high(options) do
opt_strs[k] := options[k].Str;
for k := 0 to high(self) do
if isText(opt_strs, self[k].options) then
_count := _count + 1;
for k := 0 to _count do
begin
if moved then
mouse(258, 230, 0, 0, mouse_right);
for e := 0 to high(self) do
if not _ss.waitOptionMulti(self[e].options, 150) then
if debug then
writeln('Did not find ' , self[e].options)
else
moved := true;
end;
end;
end;
function healthBar(b:tbox):boolean;
var
red, green, bar:tpointarray;
healthbar:t2dpointarray;
i:integer;
bx:tbox;
begin
if ((mainscreen.bounds.x1 + (b.x1 - 2)) < 0) then
exit(false);
findColors(green, 65280, b.x1 - 2, b.y1-7, b.x2, b.y2);
findColors(red, 255, b.x1 - 2, b.y1 - 7, b.x2, b.y2);
bar := mergeAtpa([green, red]);
if (length(bar) > 0) then
begin
healthbar := clustertpa(bar, 1);
if (length(healthbar) = 0) then
exit(false);
for i := 0 to high(healthbar) do
begin
bx := gettpabounds(healthbar[i]);
if ((bx.x1 - bx.x1) > 25) then
exit(true);
end;
end;
end;
function specOn:boolean;
var
tpa:TPointArray;
begin
result := false;
findcolorstolerance(tpa, 1210821, 471, 221, 509, 259, 53);
if (length(tpa) > 25) then
exit(true);
end;
function specPercentage:extended;
var
greentpa:tpointarray;
barOpen:boolean;
begin
if specOn then
begin
mouse(491, 241);
wait(200);
end;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.55, 0.59);
findcolorstolerance(greentpa, 4176530, 475, 224, 507, 258, 38);
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.02, 0.02);
if (length(greentpa) > 1) then
result := ((length(greentpa) / 917) * 100)
else
result := 0;
end;
function xpBarOpen:boolean;
begin
result := (countColorTolerance(3885388, 410, 110, 508, 123, 5) >= 300) and (countColorTolerance(16777215, 410, 110, 508, 123, 5) >= 150);
end;
function differentCount(time:integer): Boolean;
var
_white_count:integer;
begin
if not xpBarOpen then
mouse(534, 117);
_white_count := countColorTolerance(16777215, 410, 110, 508, 123, 5);
wait(time);
result := (_white_count <> countColorTolerance(16777215, 410, 110, 508, 123, 5));
end;
function inCombat:boolean;
begin
result := differentCount(2700);
end;
function _monster.find:boolean;
var
mtpas, matpa:t2dpointarray;
mtpa:tpointarray;
i, x, y:integer;
bx:tbox;
dx, dy, dx2, dy2:integer;
begin
ColorToleranceSpeed(2);
setLength(mtpas, length(self.color));
for i := 0 to high(self.color) do
begin
SetColorSpeed2Modifiers(hue[i], sat[i]);
findColorsTolerance(mtpas[i], color[i], mainscreen.bounds, tol[i]);
end;
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.02, 0.02);
if (length(mtpas) > 1) then
mtpa := mergeAtpa(matpa)
else
mtpa := mtpas[0];
if (length(mtpa) > 0) then
begin
matpa := clustertpa(mtpa, 3);
filtertpasbetween(matpa, 0, self.filter);
SortATPAFromFirstpoint(matpa, Point(256, 216));
if debug then
debugatpa(matpa, 'bmp');
for i := 0 to high(matpa) do
begin
if (checkCombat) then
begin
bx := gettpabounds(matpa[i]);
if not healthBar(bx) then
continue;
end;
if (i > 2) then
exit(false);
if self.useUptext then
if (_ss.waitUpTextMulti(self.uptext, 150)) then
continue
else
if debug then
writeln('Uptext ' , self.uptext, ' not found');
MiddleTPAEx(matpa[i], x, y);
if self.rightClick then
begin
Mouse(x, y, 0, 0, Mouse_right);
if _ss.waitOptionMulti(self.options, 1200) then
exit(true);
end else
begin
mouse(x, y);
exit(true);
end;
end;
end;
end;
function diff300:boolean;
begin
result := differentCount(300);
end;
procedure _ssFight;
var
t, reply:integer;
begin
if (failed > 5) then
begin
m.progress('Script failed');
reply := messageBox('The script has failed more then 5 times, would you like to enter Debug mode?', 'ATTENTION', 2);
writeln('The script has failed more then 5 times');
if (reply = 4) then
begin
debug := true;
failed := 0
end
else if (reply = 3) then
terminateScript
else
failed := 0;
end else begin
if (m.find) then
begin
m.progress('Waiting to get into combat');
if waitFunc(@diff300, 50, 4500) then
begin
failed := 0;
marktime(t);
while (inCombat) do
begin
m.progress('Fighting ' + m.name);
wait(100 + random(100));
if (timeFromMark(t) > _timeout) then
exit;
end;
if (not differentCount(10)) then
begin
m.progress('Killed ' + m.name);
kills := kills + 1;
if _loot then
begin
m.progress('Looting');
_PickUps.pickUp();
exit();
end;
end;
end else
m.progress('Unexpected out of combat');
end else
m.progress('Failsafe, waiting, failedcount = ' + toStr(failed));
failed := failed + 1;
if (failed < 2) then
exit();
wait(random(3000));
end;
end;
begin //65319
clearDebug();
debug := false;
_ss.init('soulsplit');
mainscreen.bounds := intToBox(2, 57, 514, 392);
m.init;
_pickUps.init;
mousespeed := 35;
map.bounds := intToBox(545, 62, 702, 216);
map.center := point(627, 138);
_zone := [intToBox(237,216,255,238), intToBox(264, 218, 282, 234),
intToBox(224, 184, 258, 225), intToBox(250, 174, 281, 224)];
repeat
_ssFight;
until isKeyDown(113);
end.
procedure _loot_array.init;
begin
setLength(self, 3);
with self[0] do
begin
name := 'Gold charm';
options := ['ake old','ld cha'];
value := 0;
end;
with self[1] do
begin
name := 'Green charm';
options := ['ake Gr','en cha'];
value := 0;
end;
with self[2] do
begin
name := 'Coins';
options := ['ake Coi','oins'];
value := 1;
end;
end;
The properties name and value are only for tracking/cosmetic purposes. Options in the getChoose options
Now my looting function is supposed to work like this:
1) Use the horridly inaccurate mmtoMS function that I got a hold of that works 30% of the time to find a loot pile because I probably did some math wrong
2) Right click.
3) Find the number of desirable items.
4) If there are > 1 desirable items, after moving it will click under the player to loot the rest.
Now what my looting function actually does:
1) If the planets align and somehow the MMtoMs function successfully projects the correct lootpile it right clicks
2) If it sees 'Gold charm' it will pick it up
3) It will never pick up coins or green charms
I know it's not my isText function because it works
options represents the found choose options, the 2d string array represents the _loot_array record
var
options:TStringArray;
LookFor:T2DStringArray;
_count, k:integer;
function isText(Text, theText: TStringArray): Boolean;
var
i, k: Integer;
begin
for i := 0 to High(Text) do
for k := 0 to high(theText) do
if (Pos(Text[i], TheText[k]) > 0) then
exit(true);
end;
begin
options := ['Take Magic seed', 'Take Gold charm', 'Take Bones', 'Take Coins', 'Walk here', 'Examine Magic seed', 'Examine Gold charm', 'Examine Bones', 'Examine Coins'];
LookFor := [['ake Coi', 'oins'], ['ake old','ld cha'], ['ake Gr','en cha']];
for k := 0 to high(LookFor) do
if isText(LookFor[k], options) then
_count := _count + 1;
writeln(_count);
end.
My looting function:
function isText(Text, theText: TStringArray): Boolean;
var
i, k: Integer;
begin
for i := 0 to High(Text) do
for k := 0 to high(theText) do
if (Pos(Text[i], TheText[k]) > 0) then
exit(true);
end;
procedure _loot_array.pickUp();
var
_dots:TPointArray;
options:array of TOptions;
i, k, e, _count:integer;
opt_strs:TStringArray;
_ls:TPoint;
t:integer;
moved:boolean;
begin
_dots := GetMiniMapDotsIn('item',539, 61, 708, 217);//getRedDots();
filterpointspie(_dots, 0, 360, 0, _loot_distance * 4, 627, 138);
sortTPAFrom(_dots, point(627, 138));
setLength(_dots, 2);
for i := 0 to high(_dots) do
begin
if moved then
exit();
_ls := ss_MMtoMsPoint(_dots[i]);
mouse(_ls.x, _ls.y, 0, 0, mouse_right);
t := getSystemTime;
options := _ss.getOptions();
setLength(opt_strs, length(options));
for k := 0 to high(options) do
opt_strs[k] := options[k].Str;
for k := 0 to high(self) do
if isText(opt_strs, self[k].options) then
_count := _count + 1;
for k := 0 to _count do
begin
if moved then
mouse(258, 230, 0, 0, mouse_right);
for e := 0 to high(self) do
if not _ss.waitOptionMulti(self[e].options, 150) then
if debug then
writeln('Did not find ' , self[e].options)
else
moved := true;
end;
end;
end;
{$I RSPS/srlRSPS.Simba}
const
_timeout = 15000;
_loot = true;
_loot_distance = 5;
xpRate = 200;
type
_monster = record
color, tol:tintegerarray;
health, filter:integer;
hue, sat:textendedarray;
uptext, options:tstringarray;
rightClick, useUptext, checkCombat:boolean;
name:string;
end;
_loot_item = record
options:TStringArray;
name:string;
Value, count:Integer;
end;
_loot_array = array of _loot_item;
var
_pickUps:_loot_array;
_zone:TBoxArray;
procedure _loot_array.init;
begin
setLength(self, 3);
with self[0] do
begin
name := 'Gold charm';
options := ['ake old','ld cha'];
value := 0;
end;
with self[1] do
begin
name := 'Green charm';
options := ['ake Gr','en cha'];
value := 0;
end;
with self[2] do
begin
name := 'Coins';
options := ['ake Coi','oins'];
value := 1;
end;
end;
var
_ss:_rsps_server;
m:_monster;
debug:boolean;
cs:tpoint;
failed, kills:integer;
ld:integer;
procedure _monster.init;
begin
with self do
begin
color := [9148055];
tol := [15];
health := 22;
filter := 140;
hue := [0.10];
sat := [0.15];
uptext := ['ave','rawl','raw'];
options := ['ttack','tack'];
rightClick := true;
useUptext := true;
checkCombat := false;
name := 'Cave crawler';
end;
end;
function center(bx: TBox): TPoint;
begin
if ((bx.X1 > bx.X2) or (bx.Y1 > bx.Y2)) then
begin
if (bx.X1 > bx.X2) then
Swap(bx.X1, bx.X2);
if (bx.Y1 > bx.Y2) then
Swap(bx.Y1, bx.Y2);
end;
Result := Point(Round(bx.X1 + ((bx.X2 - bx.X1) div 2)), Round(bx.Y1 + ((bx.Y2 - bx.Y1) div 2)));
end;
function perHour(what:integer):integer;
begin
result := Round(what * (3600.0 / (GetTimeRunning / 1000.0)));
end;
procedure _monster.progress(state:string);
begin
clearDebug();
writeln('Overall Progress');
writeln('- State: ', state);
writeln('- ', kills, ' ', self.name, ' Killed ');
writeln('- XP: ', (kills * xpRate * self.health));
writeln('Hourly Progress');
writeln('- XP: ', perHour(kills * self.health * xpRate));
writeln('- Kills: ', perHour(kills));
writeln('=====================');
end;
function FindColorsPie(var Points: TPointArray; Color, Tol: Integer; StartD,
EndD, MinR, MaxR: Extended; x1, y1, x2, y2, Mx, My: Integer): Boolean;
begin
Result := FindColorsTolerance(Points, Color, x1, y1, x2, y2, Tol);
if (Result) then
FilterPointsPie(Points, StartD, EndD, MinR, MaxR, Mx, My);
end;
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
var
I, Dif, Radius, Hi, C: Integer;
TPA: TPointArray;
begin
case LowerCase(WhatDot) of
'npc', 'n', 'yellow', 'y': Dif := 4369;
'item', 'i', 'red', 'r': Dif := 29;
'player', 'p', 'white', 'w': Dif := 1907997;
'friend', 'f', 'green', 'g': Dif := 5376;
'team', 't', 'blue', 'b', 'cape': Dif := 2171941;
{'clan', 'c', 'orange', 'o': Dif := -1;}
else
writeln('');// srl_Warn('GetMiniMapDotsIn', '"' + WhatDot + '" is not a valid dot type', warn_AllVersions);
end;
Freeze;
Radius := Max((x2-x1)div 2, (y2-y1)div 2);
FindColorsPie(TPA, 65536, 0, 0, 360, 0, radius, x1, y1, x2, y2, (x1+x2)div 2, (y1+y2)div 2);
Hi := High(TPA);
SetLength(Result, Hi + 1);
if (Hi < 0) then
begin
UnFreeze;
Exit;
end;
C := 0;
for I := 0 to Hi do
begin
if (GetColor(TPA[I].X-1, TPA[I].Y-1) - GetColor(TPA[I].X, TPA[I].Y-1) = Dif) then
begin
Result[C] := Point(TPA[I].x, TPA[i].y - 2);
Inc(C);
end;
end;
Unfreeze;
SetLength(Result, C);
end;
procedure ss_MMToMS(var X, Y:Integer);
var
x1, y1 : Integer;
begin
x1 := X;
y1 := X;
X := Round((X-627)*255/40) + 252;
Y := Round((Y-139)*176/28) + 224;
if X < 3 then X := 3;
if Y < 3 then Y := 3;
if X > 516 then X := 516;
if Y > 337 then Y := 337;;
end;
function ss_MMtoMsPoint(p:TPoint):TPoint;
var
x, y:integer;
begin
x := p.x;
y := p.y;
ss_MMToMS(x, y);
result := Point(x, y);
end;
function isText(Text, theText: TStringArray): Boolean;
var
i, k: Integer;
begin
for i := 0 to High(Text) do
for k := 0 to high(theText) do
if (Pos(Text[i], TheText[k]) > 0) then
exit(true);
end;
procedure _loot_array.pickUp();
var
_dots:TPointArray;
_possible_loot:T2DPointArray;
options:array of TOptions;
i, k, e, _count:integer;
opt_strs:TStringArray;
_ls:TPoint;
t:integer;
moved:boolean;
begin
_dots := GetMiniMapDotsIn('item',539, 61, 708, 217);//getRedDots();
filterpointspie(_dots, 0, 360, 0, _loot_distance * 4, 627, 138);
sortTPAFrom(_dots, point(627, 138));
setLength(_dots, 2);
for i := 0 to high(_dots) do
begin
if moved then
exit();
_ls := ss_MMtoMsPoint(_dots[i]);
mouse(_ls.x, _ls.y, 0, 0, mouse_right);
t := getSystemTime;
options := _ss.getOptions();
setLength(opt_strs, length(options));
for k := 0 to high(options) do
opt_strs[k] := options[k].Str;
for k := 0 to high(self) do
if isText(opt_strs, self[k].options) then
_count := _count + 1;
for k := 0 to _count do
begin
if moved then
mouse(258, 230, 0, 0, mouse_right);
for e := 0 to high(self) do
if not _ss.waitOptionMulti(self[e].options, 150) then
if debug then
writeln('Did not find ' , self[e].options)
else
moved := true;
end;
end;
end;
function healthBar(b:tbox):boolean;
var
red, green, bar:tpointarray;
healthbar:t2dpointarray;
i:integer;
bx:tbox;
begin
if ((mainscreen.bounds.x1 + (b.x1 - 2)) < 0) then
exit(false);
findColors(green, 65280, b.x1 - 2, b.y1-7, b.x2, b.y2);
findColors(red, 255, b.x1 - 2, b.y1 - 7, b.x2, b.y2);
bar := mergeAtpa([green, red]);
if (length(bar) > 0) then
begin
healthbar := clustertpa(bar, 1);
if (length(healthbar) = 0) then
exit(false);
for i := 0 to high(healthbar) do
begin
bx := gettpabounds(healthbar[i]);
if ((bx.x1 - bx.x1) > 25) then
exit(true);
end;
end;
end;
function specOn:boolean;
var
tpa:TPointArray;
begin
result := false;
findcolorstolerance(tpa, 1210821, 471, 221, 509, 259, 53);
if (length(tpa) > 25) then
exit(true);
end;
function specPercentage:extended;
var
greentpa:tpointarray;
barOpen:boolean;
begin
if specOn then
begin
mouse(491, 241);
wait(200);
end;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.55, 0.59);
findcolorstolerance(greentpa, 4176530, 475, 224, 507, 258, 38);
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.02, 0.02);
if (length(greentpa) > 1) then
result := ((length(greentpa) / 917) * 100)
else
result := 0;
end;
function xpBarOpen:boolean;
begin
result := (countColorTolerance(3885388, 410, 110, 508, 123, 5) >= 300) and (countColorTolerance(16777215, 410, 110, 508, 123, 5) >= 150);
end;
function differentCount(time:integer): Boolean;
var
_white_count:integer;
begin
if not xpBarOpen then
mouse(534, 117);
_white_count := countColorTolerance(16777215, 410, 110, 508, 123, 5);
wait(time);
result := (_white_count <> countColorTolerance(16777215, 410, 110, 508, 123, 5));
end;
function inCombat:boolean;
begin
result := differentCount(2700);
end;
function _monster.find:boolean;
var
mtpas, matpa:t2dpointarray;
mtpa:tpointarray;
i, x, y:integer;
bx:tbox;
dx, dy, dx2, dy2:integer;
begin
ColorToleranceSpeed(2);
setLength(mtpas, length(self.color));
for i := 0 to high(self.color) do
begin
SetColorSpeed2Modifiers(hue[i], sat[i]);
findColorsTolerance(mtpas[i], color[i], mainscreen.bounds, tol[i]);
end;
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.02, 0.02);
if (length(mtpas) > 1) then
mtpa := mergeAtpa(matpa)
else
mtpa := mtpas[0];
if (length(mtpa) > 0) then
begin
matpa := clustertpa(mtpa, 3);
filtertpasbetween(matpa, 0, self.filter);
SortATPAFromFirstpoint(matpa, Point(256, 216));
if debug then
debugatpa(matpa, 'bmp');
for i := 0 to high(matpa) do
begin
if (checkCombat) then
begin
bx := gettpabounds(matpa[i]);
if not healthBar(bx) then
continue;
end;
if (i > 2) then
exit(false);
if self.useUptext then
if (_ss.waitUpTextMulti(self.uptext, 150)) then
continue
else
if debug then
writeln('Uptext ' , self.uptext, ' not found');
MiddleTPAEx(matpa[i], x, y);
if self.rightClick then
begin
Mouse(x, y, 0, 0, Mouse_right);
if _ss.waitOptionMulti(self.options, 1200) then
exit(true);
end else
begin
mouse(x, y);
exit(true);
end;
end;
end;
end;
function diff300:boolean;
begin
result := differentCount(300);
end;
procedure _ssFight;
var
t, reply:integer;
begin
if (failed > 5) then
begin
m.progress('Script failed');
reply := messageBox('The script has failed more then 5 times, would you like to enter Debug mode?', 'ATTENTION', 2);
writeln('The script has failed more then 5 times');
if (reply = 4) then
begin
debug := true;
failed := 0
end
else if (reply = 3) then
terminateScript
else
failed := 0;
end else begin
if (m.find) then
begin
m.progress('Waiting to get into combat');
if waitFunc(@diff300, 50, 4500) then
begin
failed := 0;
marktime(t);
while (inCombat) do
begin
m.progress('Fighting ' + m.name);
wait(100 + random(100));
if (timeFromMark(t) > _timeout) then
exit;
end;
if (not differentCount(10)) then
begin
m.progress('Killed ' + m.name);
kills := kills + 1;
if _loot then
begin
m.progress('Looting');
_PickUps.pickUp();
exit();
end;
end;
end else
m.progress('Unexpected out of combat');
end else
m.progress('Failsafe, waiting, failedcount = ' + toStr(failed));
failed := failed + 1;
if (failed < 2) then
exit();
wait(random(3000));
end;
end;
begin //65319
clearDebug();
debug := false;
_ss.init('soulsplit');
mainscreen.bounds := intToBox(2, 57, 514, 392);
m.init;
_pickUps.init;
mousespeed := 35;
map.bounds := intToBox(545, 62, 702, 216);
map.center := point(627, 138);
_zone := [intToBox(237,216,255,238), intToBox(264, 218, 282, 234),
intToBox(224, 184, 258, 225), intToBox(250, 174, 281, 224)];
repeat
_ssFight;
until isKeyDown(113);
end.