Simba Code:
program RunespanSiphoner;
{$define SMART}
{$I SRL-6/SRL.Simba}
{
vwxz's Runespan Siphoner
in development - not a release
very likely to go all kersplodey on you
}
{
Many thanks to the following:
}
type
TSiphonTarget = record
Name: String;
IsNode: Boolean;
Colors: Array of Integer;
ColorTolerance: Integer;
end;
var
LastExpSeen, TotalExpGained: Integer;
StartTime, LastExpChangeTime: TTimeMarker;
SiphonTimeout: Integer;
TargetSoul: TSiphonTarget;
procedure InitTargetData
begin
//Soul Esswraith
TargetSoul.Name := 'Soul esswraith';
TargetSoul.IsNode := False;
TargetSoul.Colors := [12494138, 5480907];
TargetSoul.ColorTolerance := 10;
end;
{
TRSChatBox.GetXP
by Ashaman88, Janilabo, and others
from http://villavu.com/forum/showthread.php?t=107292
Gets the current exp value from the exp counter.
The counter must be placed in the top right of the chat box header bar.
}
function TRSChatBox.getXP: Integer;
var
b: TBox;
s: String;
tpa : TPointArray;
atpa : T2DPointArray;
i,cts,p: Integer;
begin
b := self.getBounds();
b.edit(+(b.x2-b.x1)-140, +10, -5, -94);
findColorsTolerance(tpa, 14013909, b, 4,colorSetting(2, 0.00, 0.00));
if length(tpa) < 2 then
begin
print('chatBox.getXP(): No XP found', TDebug.SUB);
Exit;
end;
atpa := tpa.cluster(5);
b:= atpa.getbounds;
b.edit(-2,-2,+2,+3);
s:=Replace(tesseractgettext(b.x1,b.y1,b.x2,b.y2, FILTER_SMALL_CHARS), ' ', '', [rfReplaceAll]);
P := Pos('x', S);
if P > 0 then
Result := StrToIntDef(ExtractFromStr(Copy(s, P, Length(S)), Numbers), 0)
else
Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);
print('chatBox.getXP(): XP found: ' + tostr(result), TDebug.SUB);
end;
{
UpdateExpSeen
Checks current exp displayed in exp counter and
update the internal totals and timers regarding experience gain.
}
procedure UpdateExpSeen;
var
CurrentExpSeen, CurrentExpGained: Integer;
begin
CurrentExpSeen := ChatBox.GetXP;
CurrentExpGained := CurrentExpSeen - LastExpSeen;
if (CurrentExpGained > 0) then begin
LastExpChangeTime.Start;
end
LastExpSeen := CurrentExpSeen;
TotalExpGained := TotalExpGained + CurrentExpGained;
end;
{
IsCurrentlySiphoning
Whether or not we believe we are currently siphoning something,
inferred from recent experience gain as reported by UpdateExpSeen.
}
function IsCurrentlySiphoning: Boolean;
begin
UpdateExpSeen;
Result := LastExpChangeTime.GetTime <= SiphonTimeout;
end;
{
}
function FindTarget(TargetToFind: TSiphonTarget; var ResultTPA: TPointArray): Boolean;
var
PrimaryColor, SecondaryColor: Integer;
PrimaryColorTPA, SecondaryColorTPA: TPointArray;
PrimaryColorATPA: T2DPointArray;
PrimaryIdx, SecondaryIdx: Integer;
CandidateTPA: TPointArray;
CandidatePoint: TPoint;
CandidateBox: TBox;
SecondariesFound: Boolean;
begin
Result := False;
PrimaryColor := TargetToFind.Colors[Low(TargetToFind.Colors)];
if FindColorsTolerance(PrimaryColorTPA, PrimaryColor, MainScreen.GetBounds, TargetToFind.ColorTolerance) then begin
PrimaryColorATPA := PrimaryColorTPA.ToATPA(40);
SortATPAFromMidPoint(PrimaryColorATPA, MainScreen.PlayerPoint);
//SmartImage.DebugATPA(PrimaryColorATPA);
for PrimaryIdx := Low(PrimaryColorATPA) to High(PrimaryColorATPA) do begin
CandidateTPA := PrimaryColorATPA[PrimaryIdx];
//SmartImage.DebugTPA(CandidateTPA);
CandidatePoint := MedianTPA(CandidateTPA);
CandidateBox := IntToBox(CandidatePoint.X - 30, CandidatePoint.Y - 30, CandidatePoint.X + 30, CandidatePoint.Y + 30);
SecondariesFound := True;
for SecondaryIdx := Low(TargetToFind.Colors) + 1 to High(TargetToFind.Colors) do begin
SecondaryColor := TargetToFind.Colors[SecondaryIdx];
FindColorsTolerance(SecondaryColorTPA, SecondaryColor, CandidateBox, TargetToFind.ColorTolerance);
//SmartImage.DebugTPA(SecondaryColorTPA);
if Length(SecondaryColorTPA) < 5 then begin
SecondariesFound := False;
break;
end;
end;
if SecondariesFound then begin
Result := True;
ResultTPA := CandidateTPA;
SmartImage.DebugTPA(ResultTPA);
break;
end;
end;
end;
end;
procedure SetUpAll;
begin
ClearDebug;
SmartEnableDrawing := True;
SetUpSRL;
InitTargetData;
SiphonTimeout := 5000;
StartTime.Start;
LastExpChangeTime.Start;
LastExpSeen := ChatBox.GetXP;
TotalExpGained := 0;
end;
procedure MainLoopIteration;
begin
UpdateExpSeen;
Print(IntToStr(TotalExpGained));
Print(BoolToStr(IsCurrentlySiphoning));
Sleep(5000 + Random(1000));
end;
var
TestPoints: TPointArray;
begin
SetUpAll;
FindTarget(TargetSoul, TestPoints);
end.