SRL Archive - Research & Development Lounge

King's WaterFiends Rewrite Progress


King

2013-04-01 23:49:02

Decided to re-write my Waterfiend script over the course of spring break, Ill be posting regular updates here as I do coding, this is what Ive done so far

E* Today the script was made to accurately fight and loot waterfiends and eat. I dont see the point in prayer at this point, will be made to handle it later. It will use momentum as at 88 range with Royal Crossbow and Royal D hide, I can 2-3 hit them. Im getting 150 ish charms an hour if not more. I will support imp charm grabber. Basically just needs walking back to the bank, GPS (Keep it in a certain area) and Some fixes through the main loop to make it faster, not much as I want it to be like a person afking. It will not loot 100% of charms (occasionally misses the red health bar). Loots all valuables, walks to bank when out of food. Progress reports will be put in tomorrow as well.


Script:
program KingsWaterFiends; //Made by SRLKing
{$DEFINE SMART8}
{$I SRL/SRL.simba}
{$I SPS/SPS.simba}
{$I SRL/SRL/skill/prayer.simba}
{$i SRL/srl/misc/smartgraphics.simba}
{.Include SRL\SRL\Misc\Debug.simba}
{$i SRL-OSR/SRL/misc/MouseHandler.simba}
{$i su_surfaces.simba}

var
Status: string;
x, y, fx, fy: Integer;
Shark, Rocktail, DramenStaff, PrayerFlask, PrayerPotion, BunyipPouch, FairyRing: Integer;
RoyalCrossbow: Integer;
obj_fairyring: TSurfaceObject;
GoToBank:Boolean;

const
Debug = True;

//////////////************Settings************//////////////////
FoodAmount = 15; //Amount of Food to Withdraw

FoodType = 'Shark';//Type of food to use, (RockTail or Shark)

FoodBound = '=';

PrayerPotAmount = 1; //Prayer Potions to Bring

PType = 'Flask';//Flask or potion?

Prayer = False; //Use Quick Prayers?

OtherPotions = False; //Bring another potion? (Ranging, Overload ect..)

OtherPotAmount = 1; //Amount of other potions to bring

LevelToRepotAt = 99;//Level to repot at?

LevelBoosted = 'Range';//What level is being boosted? (Range or defence)

HpToEatAt = 4000; //Hp To Eat Food At?

NeedStaff = True;//If you need a dramen staff for fairy-rings, put true.

Weapon = 'RoyalCrossbow'; //Weapon you will be using (needed to re-equip), see supported weapons.

procedure DeclarePlayers;
var
FileNum: integer;
s: string;
usrInfo: TStringArray;
begin
FileNum := OpenFile('C:\acc.txt', true); //Credit Goes to Football for this, I liked the idea :P
ReadFileString(FileNum, s, FileSize(FileNum));
CloseFile(FileNum);
usrInfo := Explode(chr(10), s);
NumberOfPlayers(1);
CurrentPlayer := 0;
with Players[0] do
begin
Name := usrInfo[0];
Pass := usrInfo[1];
Pin := usrInfo[2];
// Nick := usrInfo[3];
Active := True;
end;
end;

procedure Init(); //Credit goes to SuperUser for his surface object include
begin
SMART_ClearMS();

CreateSurfaceParts(obj_fairyring, 2);

with obj_fairyring do begin
parts[0].c := 10268853;
parts[0].hm := 0.13;
parts[0].sm := 0.56;
parts[0].t := 4;
parts[0].minw := 50;
parts[0].maxw := 110;
parts[0].minh := 50;
parts[0].maxh := 110;
parts[0].step := 32;
parts[0].max_distance := 999;

parts[1].c := 14545330;
parts[1].hm := 0.03
parts[1].sm := 4.32;
parts[1].t := 6;
parts[1].filter := @SurfaceFilterClosest;
parts[1].minw := 5;
parts[1].maxw := parts[0].maxw;
parts[1].minh := 5;
parts[1].maxh := parts[0].maxh;
parts[1].step := 32;
parts[1].max_distance := parts[0].max_distance;

name := 'Fairy ring';
uptext := 'ring';
filter := @SurfaceFilterClosest;
end;
end;


procedure DeclareDTMz;
begin
Shark := DTMFromString('mlwAAAHicY2dgYMhkYmBIBOJkIC4B4iogLoCKmTMyMHgCsQ4Q60PZHkBsD8RBdrpA3UwYmJeHh0GOATdgxIOhAACh5AXF');
Rocktail := DTMFromString('mggAAAHicY2NgYJjNxMAwDYhnAvEyIO4E4kVALM7IwMAHxIpAzAPECkAsBsS9VdVAXUwYWI4BO2DEgSEAAFt8Bew=');
PrayerFlask := DTMFromString('mwQAAAHic42RgYDjIxMBwCIi3A/EpID4OxDug+CRUrpWRgaGUEUK3AHEtENcDcQ8QdwPxBCA2XFoFNI0JL1ZmIAwYicBwAADRlg0d');
PrayerPotion := DTMFromString('mlwAAAHicY2dgYDjIxMBwAIq3A/EpIN4JxMeAuJWRgaEUiCcAcTcQdwFxDRQbLq0C6mbCipUZcANGPBgKANdLCns=');
BunyipPouch := DTMFromString('mrAAAAHic42BgYDjABMGbgPg8EJ8A4p1AvBWIzwKxGCMDgwojhJYCYg4gZgdiBSBWBGIvL0OgKUw4sRwDfsBIAMMAAGekB9g=');
FairyRing := DTMFromString('mrAAAAHic42BgYLBkZGBgAeIyIDYAYicgNgViWyDeDsQvgGp6gVgVyH4GpO8D8Ucg/gDEf4A4qjSW4e/nWwznj29m8ArzYjj4+yWDT4QPw6G/rxh6O6oY5IBq8GFGAhgGAMEnGIo=');
RoyalCrossBow := DTMFromString('mlwAAAHicY2dgYJjOxMDQC8UzgXg+EE8F4gVAvJKRgWEWEC8F4oVAvAqI1wHxZiCebqIH1M2EFcsx4AaMeDAUAACGNgn5');
end;

procedure FreeDTMz;
begin
FreeDTM(Shark);
FreeDTM(Rocktail);
FreeDTM(DramenStaff);
FreeDTM(PrayerFlask);
FreeDTM(PrayerPotion);
FreeDTM(BunyipPouch);
FreeDTM(FairyRing);
FreeDTM(RoyalCrossbow);
end;

function FindRedBar : Boolean; //Credit to ShatterHand
var
RedBarDTM1, RedBarDTM2, RedBarDTM3 : Integer;
begin
Result := False;
RedBarDTM1 := DTMFromString('mlwAAAHicY2dgYDBnZmCQBWIZKB0ExQpA3AiUr2OA0C1QDOPvZOBgsGZnwsBdDIwM+AAjHgwFAAvPB5w={mlwAAAHicY2dgYDBnZmCQBWIZKB0ExQpA3AiUr2OA0C1QDOPvZOBgsGZnwsBdDIwM+AAjHgwFAAvPB5w=}');
RedBarDTM2 := DTMFromString('mlwAAAHicY2dgYDBnZmCQBWIZKB0ExQpA3AiUr2OA0C1QDOPvZOBgsGZnwsBdDIwM+AAjHgwFAAvPB5w={mlwAAAHicY2dgYDBnZmCQBWIZKB0ExQpA3AiUr2OA0C1QDOPvZOBgsGZnwsBdDIwM+AAjHgwFAAvPB5w=}');
RedBarDTM3 := DTMFromString('mbQAAAHicY2VgYFAHYicg5oay1YCYEwmzATEPEO9k4GCwZmdCwXJAcS40zIgFgwEAz+gDEA==');

if FindDTM(RedBarDTM1, X, Y, MSX1, MSY1, MSX2, MSY2) or FindDTM(RedBarDTM2, X, Y, MSX1, MSY1, MSX2, MSY2) or FindDTM(RedBarDTM3, X, Y, MSX1, MSY1, MSX2, MSY2) then
if Distance(x, y, fx, fy) <= 80 then
begin
SMART_DrawBoxEx(false,false,IntToBox(X-30,Y-10,X+30,Y+10),ClYellow);
Wait(50);
SMART_ClearCanvasArea(IntToBox(0,MSY1+49,520,MSY2+50));
Result := True;
end
else
exit;
FreeDTM(RedBarDTM1);
FreeDTM(RedBarDTM2);
end;

procedure Looting();
begin
wait(RandomRange(500, 600));
if (FindRedBar) then
begin
wait(RandomRange(1100, 1200));
if (FindRedBar) then
begin
wait(RandomRange(150, 200));
MMouse(X + random(1), Y + 21, 0, 0);
wait(RandomRange(800, 1200));
ClickMouse2(False);
WaitOptionMulti(['ake Crims', 'ake Gold c', 'ake Green', 'ake Blue c', 'ake Sea', 'ake Water or', 'ake Snap', 'ake Shar', 'ake Mithril', 'une elm'], 1000);
wait(RandomRange(400, 600));
repeat
wait(RandomRange(200, 400));
until (not IsMoving)
repeat
wait(RandomRange(500, 750));
MMouse(259, 187, 0, 0);
ClickMouse2(False);
until (not (WaitOptionMulti(['ake Crims', 'ake Gold c', 'ake Green', 'ake Blue c', 'ake Sea', 'ake Water or', 'ake Snap', 'ake Shar', 'ake Mithril', 'une elm'], 1000)));
end
else
begin
exit;
writeln('No Red Bar Detected');
end;
end;
end;

function FindArrow: Boolean;
var
tmpCTS: integer;
ArrowTPA: TPointArray;
begin
if not LoggedIn then
exit;
tmpCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(1.88, 1.16);
if FindColorsTolerance(ArrowTPA, 13032391, 706, 230, 730, 247, 16) then
begin
SetColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);
Result := True;
end
else
begin
SetColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);
Result := False;
end;
end;

function Fighting: Boolean;
begin
if not LoggedIn then
exit;
if not (GetCurrentTab = tab_Combat) then
begin
GameTab(tab_Combat);
wait(RandomRange(1000, 1200));
end
else
if FindArrow then
begin
writeln('We still have a target');
Result := True;
exit;
end
else
begin
Result := False;
looting;
writeln('No longer fighting');
exit;
end;
end;

function FairyScreen: Boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
i, L, X, Y: Integer;
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.03, 0.18);
if InvFull then
Exit;
if FindColorsSpiralTolerance(x, y, TPA, 3948686, MSX1, MSY1, MSX2, MSY2, 14) then
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.00, 0.00);
ATPA := TPAtoATPAEx(TPA, 40, 40);
SortATPAFrom(ATPA, Point(MSCX, MSCY));
if debug then
DebugATPA(ATPA, '');
L := High(ATPA) for i := 0 to L do
if GetArrayLength(ATPA[i]) >= 25 then
begin
status := 'Found fairy screen';
if debug then
writeln(status);
result := true;
exit;
end
else
begin
status := 'Did not find fairy screen';
if debug then
writeln(status);
result := false;
exit;
end;
end;
end;

function FindCrossbow: Boolean;
var
OldCTS, x, y, I: integer;
RoyalTPA: TPointArray;
RoyalATPA: T2DPointArray;
begin
Result := False;
OldCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.03, 0.22);
if FindColorsSpiralTolerance(x, y, RoyalTPA, 7833743, MIX1, MIY1, MIX2, MIY2, 13) then
begin
SetColorToleranceSpeed(OldCTS);
if Length(RoyalTPA) = 0 then
begin
writeln('Could not find Bow, exiting');
Result := false;
exit;
end;
RoyalATPA := TPAToATPAEx(RoyalTPA, 10, 5);
SortATPASize(RoyalATPA, true);
SortATPAFromMidPoint(RoyalATPA, point(MICX, MICY));
for I := 0 to High(RoyalATPA) do
if GetArraylength(RoyalATPA[i]) > 5 then
begin
MiddleTPAEx(RoyalATPA[i], x, y);
AL_BrakeMMouse(point(x, y), 2, 2, false);
if WaitUpTextMulti(['Royal', 'cross'], 250) then
begin
AL_FastClick(1);
Status := 'Wielding Bow';
if debug then
writeln(status);
result := true;
exit;
end
else
begin
Status := 'Could not find the bow uptext';
if debug then
writeln(status);
result := false;
exit;
end;
end
else
begin
Status := 'Could not find the bow uptext';
if debug then
writeln(status);
result := false;
exit;
end;
end
else
begin
Status := 'Could not find the bow';
if debug then
writeln(status);
result := false;
exit;
end;
end;

function CheckFood: Boolean;
var
FoodCount: Integer;
begin
case Lowercase(FoodType) of
'shark':
begin
FoodCount := CountItems('dtm', shark, []);
writeln(IntToStr(FoodCount) + 'Shark in inventory');
Result := (FoodCount > 0);
exit;
end;
'rocktail':
begin
FoodCount := CountItems('dtm', Rocktail, []);
writeln(IntToStr(FoodCount) + 'Rocktail in inventory');
Result := (FoodCount > 0);
exit;
end;
end;
end;

function CheckPrayerPotions: Boolean;
var
PotionCount: Integer;
begin
case Lowercase(PType) of
'flask':
begin
PotionCount := CountItems('dtm', PrayerFlask, []);
if debug then
writeln(IntToStr(PotionCount) + 'Flask in inventory');
Result := (PotionCount >= PrayerPotAmount);
exit;
end;
'potion':
begin
PotionCount := CountItems('dtm', PrayerPotion, []);
if debug then
writeln(IntToStr(PotionCount) + 'Potions in inventory');
Result := (PotionCount >= PrayerPotAmount);
exit;
end;
end;
end;

procedure ReEquipWeapon;
var
angle: Extended;
begin
wait(RandomRange(1100, 1500));
case Lowercase(Weapon) of
'royalcrossbow':
begin
if FindCrossbow then
begin
status := 'Found Bow';
if debug then
writeln(status);
exit;
end
else
begin
status := 'Could not find the ' + weapon + 'uptext';
if debug then
writeln(status);
TerminateScript;
end;
end
else
begin
status := 'Could not find the' + weapon;
if debug then
writeln(status);
TerminateScript;
end;
end;
end;

function NeedToBank: Boolean;
begin
if not CheckFood then
begin
result := true;
GoToBank := true;
end;
end;

function FindStaff: Boolean;
var
OldCTS, x, y, I: integer;
StaffTPA: TPointArray;
StaffATPA: T2DPointArray;
begin
Result := False;
OldCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.02, 0.13);
if FindColorsSpiralTolerance(x, y, StaffTPA, 1002858, MIX1, MIY1, MIX2, MIY2, 10) then
begin
SetColorToleranceSpeed(OldCTS);
if Length(StaffTPA) = 0 then
begin
writeln('Could not find Seer, exiting');
Result := false;
exit;
end;
StaffATPA := TPAToATPAEx(StaffTPA, 2, 2);
SortATPASize(StaffATPA, true);
SortATPAFromMidPoint(StaffATPA, point(MICX, MICY));
for I := 0 to High(StaffATPA) do
if GetArraylength(StaffATPA[i]) > 2 then
begin
MiddleTPAEx(StaffATPA[i], x, y);
AL_BrakeMMouse(point(x, y), 2, 2, false);
if WaitUpTextMulti(['Dramen', 'staff', 'ramen st', 'men staf'], 250) then
begin
AL_FastClick(1);
wait(RandomRange(450, 600));
Status := 'Wielding staff';
if debug then
writeln(status);
result := true;
exit;
end
else
begin
Status := 'Could not find the staff uptext';
if debug then
writeln(status);
result := false;
TerminateScript;
end;
end
else
begin
Status := 'Could not find the staff uptext';
if debug then
writeln(status);
result := false;
TerminateScript;
end;
end
else
begin
Status := 'Could not find the staff';
if debug then
writeln(status);
result := false;
TerminateScript;
end;
end;

function FindWaterFiend: Boolean;
var
OldCTS, x, y, I: integer;
FiendTPA: TPointArray;
FiendATPA: T2DPointArray;
begin
if Fighting then
exit;
Result := False;
OldCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.23, 1.80);
if FindColorsSpiralTolerance(x, y, FiendTPA, 5653788, 45, 45, 499, 242, 10) then
begin
SetColorToleranceSpeed(OldCTS);
if Length(FiendTPA) = 0 then
begin
writeln('Could not find Fiend, exiting');
Result := false;
exit;
end;
FiendATPA := TPAToATPAEx(FiendTPA, 10, 20);
SortATPASize(FiendATPA, true);
SortATPAFromMidPoint(FiendATPA, point(MSCX, MSCY));
for I := 0 to High(FiendATPA) do
if GetArraylength(FiendATPA[i]) > 2 then
begin
MiddleTPAEx(FiendATPA[i], x, y);
AL_BrakeMMouse(point(x, y), 2, 2, false);
if WaitUpTextMulti(['Water', 'fiend', 'Waterfiend'], 250) then
begin
AL_FastClick(1);
GetMousePos(fx, fy);
MarkTime(x);
repeat
wait(RandomRange(50, 60));
until(Fighting or (TimeFromMark(x) >= 10000));
if Fighting then
begin
Status := 'Fighting Fiend';
if debug then
writeln(status);
result := true;
exit;
end
else
begin
Status := 'Could not find the Fiend uptext';
if debug then
writeln(status);
result := false;
exit;
end;
end
else
begin
Status := 'Could not find the Fiend uptext';
if debug then
writeln(status);
result := false;
exit;
end;
end
else
begin
Status := 'Could not find the Fiend';
if debug then
writeln(status);
result := false;
exit;
end;
end;
end;

procedure EquipStaff;
var
angle: Extended;
begin
if not NeedStaff then
exit;
if FindStaff then
begin
Status := 'Staff Equiped';
if debug then
writeln(status);
exit;
end
else
begin
Status := 'Could not find the staff';
if debug then
writeln(status);
exit;
end;
end;

function WalkToRing: Boolean;
var
ToRing: TPointArray;
begin
ToRing := [Point(123, 138), Point(131, 143), Point(140, 147), Point(152, 154), Point(163, 159), Point(172, 162), Point(181, 166), Point(193, 171), Point(204, 178), Point(213, 183), Point(224, 192), Point(229, 200), Point(232, 210), Point(232, 222), Point(230, 231), Point(224, 237)];
if SPS_WalkPath(ToRing) then
begin
while ismoving do
wait(RandomRange(25, 45));
Status := 'At the ring';
if debug then
writeln(status);
result := true;
exit;
end
else
begin
Status := 'Did not walk to the fairy ring';
if debug then
WriteLn(status);
TerminateScript;
end;
end;

function WalkToBank: Boolean;
var
ToBank: TPointArray;
begin
ToBank := [Point(230, 213), Point(226, 194), Point(224, 187), Point(218, 183), Point(207, 177), Point(197, 176), Point(187, 175), Point(170, 173), Point(159, 169), Point(147, 161), Point(142, 154), Point(137, 144), Point(135, 141), Point(130, 139), Point(127, 138), Point(126, 138)];
if SPS_WalkPath(ToBank) then
begin
Status := 'At the bank';
if debug then
writeln(status);
result := true;
exit;
end
else
begin
Status := 'Did not walk to the bank';
if debug then
WriteLn(status);
TerminateScript;
end;
end;

function FindCaveFloor: Boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
i, L, X, Y: Integer;
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(12.50, 0.27);
if InvFull then
Exit;
if FindColorsSpiralTolerance(x, y, TPA, 3618613, MMX1, MMY1, MMX2, MMY2, 20) then
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.00, 0.00);
ATPA := TPAtoATPAEx(TPA, 40, 40);
SortATPAFrom(ATPA, Point(MMCX, MMCY));
if debug then
DebugATPA(ATPA, '');
L := High(ATPA) for i := 0 to L do
if GetArrayLength(ATPA[i]) >= 150 then
begin
status := 'Found cave floor';
if debug then
writeln(status);
result := true;
exit;
end
else
begin
status := 'Did not find cave floor';
if debug then
writeln(status);
result := false;
exit;
end;
end;
end;

function FindFairyScreen: Boolean;
begin
if FairyScreen then
begin
status := 'At fairy screen';
if debug then
writeln(status);
Result := true;
exit;
end
else
begin
status := 'Not at fairy screen';
if debug then
writeln(status);
result := false;
exit;
end;
end;

function AtCave: Boolean;
begin
if FindCaveFloor then
begin
status := 'At the cave';
if debug then
writeln(status);
Result := true;
exit;
end
else
begin
status := 'Not at the cave';
if debug then
writeln(status);
result := false;
exit;
end;
end;

function ExitCave: Boolean;
begin
end;

function GetToBank: Boolean;
begin
if AtCave and NeedToBank then
begin
if ExitCave then
begin
if WalkToBank then
begin
Result := true;
status := 'Got to the bank';
if debug then
writeln(status);
exit;
end
else
begin
Result := false;
TerminateScript;
end;
end;
end;
if not AtCave and NeedToBank then
begin
if WalkToBank then
begin
Result := true;
status := 'Got to the bank';
if debug then
writeln(status);
exit;
end
else
begin
Result := false;
TerminateScript;
end;
end;
end;

function OpenBankSRLKing: Boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
i, L, X, Y: Integer;
R: TPoint;
begin
while IsMoving do
wait(RandomRange(25, 45));
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.24, 0.60);
if InvFull then
Exit;
if FindColorsSpiralTolerance(x, y, TPA, 9872302, MSX1, MSY1, MSX2, MSY2, 4) then
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.00, 0.00);
ATPA := TPAtoATPAEx(TPA, 20, 10);
SortATPAFrom(ATPA, Point(MSCX, MSCY));
if debug then
DebugATPA(ATPA, '');
L := High(ATPA) for i := 0 to L do
if GetArrayLength(ATPA[i]) > 50 then
begin
R := MiddleTPA(ATPA[i]);
AL_HumanMMouse(point(r.x, r.y), 0, 0);
if WaitUptext('ank', 350) then
begin
ClickMouse2(false);
wait(RandomRange(250, 300));
ChooseOption('ank');
MarkTime(x)
repeat
wait(RandomRange(25, 45));
until (BankScreen or (TimeFromMark(x) >= 20000));
if BankScreen then
begin
result := true;
exit;
end
else
begin
result := false;
exit;
end;
end;
end;
end;
end;

function AtBank: boolean;
begin
Result := FindSymbolIn(x, y, Symbol_Bank, 550, 10, 700, 150) and (Distance(x, y, 627, 84) <= 30);
end;

function OpenZBank: Boolean;
begin
if OpenBankSRLKing then
begin
if PinScreen then
InPin(Players[0].Pin);
if BankScreen then
begin
status := 'Bank Open' if debug then
writeln(status);
result := true;
exit;
end
else
begin
status := 'Could not open bank' if debug then
writeln(status);
result := false;
TerminateScript;
end;
end;
end;

procedure DepositLoot;
begin
if BankScreen then
Deposit(1, 23, true);
end;

function DoBanking: Boolean;
begin
while IsMoving do
wait(RandomRange(25, 45));
if BankScreen then
begin
DepositLoot;
Withdraw(0, 0, FoodAmount);
wait(RandomRange(250, 500));
if Prayer then
Withdraw(1, 0, PrayerPotAmount);
wait(RandomRange(250, 500));
if OtherPotions then
Withdraw(2, 0, OtherPotAmount);
wait(RandomRange(250, 500));
if NeedStaff then
Withdraw(3, 0, 1);
wait(RandomRange(250, 500));
CloseBank;
wait(RandomRange(250, 500));
if not BankScreen then
begin
result := true;
Status := 'Banked';
if Debug then
writeln(status);
exit;
end;
end
else
begin
result := False;
Status := 'Couldnt Bank';
if Debug then
writeln(status);
TerminateScript;
end;
end;

function PickLocation: Boolean;
begin
if FindFairyScreen then
begin
AL_HumanMMouse(point(53, 222), 2, 2);
ClickMouse2(true);
wait(RandomRange(1800, 2200));
AL_HumanMMouse(point(206, 216), 2, 2);
ClickMouse2(true);
wait(RandomRange(1800, 2200));
AL_HumanMMouse(point(371, 217), 2, 2);
ClickMouse2(true);
wait(RandomRange(1800, 2200));
AL_HumanMMouse(point(260, 284), 2, 2);
ClickMouse2(true);
wait(RandomRange(1800, 2200));
result := true;
status := 'Picked the location';
if debug then
writeln(status);
exit;
end
else
begin
result := false;
status := 'Fairy ring screen is not open';
if debug then
writeln(status);
TerminateScript;
end;
end;

function UseFairyRing: Boolean;
begin
Init();
if ClickSurfaceObject(obj_fairyring, false) then
begin
while IsMoving do
wait(RandomRange(25, 50));
MarkTime(x);
repeat
wait(RandomRange(25, 55));
until ((TimeFromMark(x) >= 20000) or FindFairyScreen);
if FindFairyScreen then
begin
if PickLocation then
begin
MarkTime(x);
repeat
wait(RandomRange(25, 55));
until (AtCave or (TimeFromMark(x) >= 25000));
if AtCave then
begin
result := true;
status := 'Taveled to the cave';
if debug then
writeln(status);
exit;
end
else
begin
result := false;
status := 'Did not use the fairy ring correctly, exiting..';
if debug then
writeln(status);
TerminateScript;
end;
end;
end;
end
else
begin
result := false;
status := 'Could not find the fairy ring';
if debug then
writeln(status);
TerminateScript;
end;
end;

Function KillFiends: Boolean;
begin
if FindWaterFiend then
begin
MarkTime(x);
repeat
wait(RandomRange(50, 75));
until((TimeFromMark(x) >= 2500) or Fighting);
if Fighting then
begin
Status := 'Fighting Fiend';
if debug then
writeln(status);
result := true;
exit;
end
else
begin
Status := 'Not Fighting Fiend';
if debug then
writeln(status);
result := false;
exit;
end;
end;
end;



function Eating: Boolean;
var
currentHP: integer;
colorsign: string;
begin
if not LoggedIn then
exit;
CurrentHP := GetMMLevels('hp', colorsign);
wait(RandomRange(50, 150));
if CurrentHP < HpToEatAt then
begin
SendKeys(FoodBound, 50, 5);
begin
MarkTime(x);
repeat
wait(RandomRange(30, 60));
until ((CurrentHP < GetMMLevels('hp', colorsign)) or (TimeFromMark(x) >= 15000));
if GetMMLevels('hp', colorsign) > HpToEatAt then
begin
Result := True;
exit;
end
else
begin
if (GetMMLevels('hp', colorsign) < 2000) then
begin
Result := false;
GoToBank := True;
writeln('Banking because we are out of food and low on health');
exit;
end;
end;
end;
end;
end;


Procedure FightFiends;
begin
while not Fighting do
FindWaterFiend;
if Fighting then
begin
MarkTime(x);
repeat
Eating;
Looting;
wait(RandomRange(50, 60));
until((TimeFromMark(x) >= 45000) or not Fighting);
looting;
wait(RandomRange(250, 300));
end;
end;


begin
SetupSRL;
SPS_Setup(RUNESCAPE_OTHER, ['zanaris']);
DeclarePlayers;
MouseSpeed := 25;
DeclareDTMz;
AddOnTerminate('FreeDTMz');
Init();
FindWaterFiend;
if not LoggedIn then
begin
LogInPlayer;
wait(RandomRange(1000, 6000));
end;
if not NeedToBank and AtCave then
begin
repeat
FightFiends;
until(GoToBank);
end;
if AtBank and NeedToBank then
begin
OpenZBank;
DoBanking;
end;
if not AtBank and NeedToBank then
begin
GetToBank;
OpenZBank;
DoBanking;
end;
if not NeedToBank and not AtCave then
begin
EquipStaff;
WalkToRing;
UseFairyRing;
ReEquipWeapon;
end;
end.

Silentcore

2013-04-02 00:14:12

Goodjob, keep it up. You may want to add a good GUI to make setting declaration easier…

King

2013-04-02 00:26:48

From: Silentcore
Goodjob, keep it up. You may want to add a good GUI to make setting declaration easier…


I will definitely add this in, I was also thinking auto-updating, and a nice onscreen proggy :P

Silentcore

2013-04-02 00:54:49

From: SRLKing
I will definitely add this in, I was also thinking auto-updating, and a nice onscreen proggy :P


If you want, I can give it a try on the screen paint..I liked the one you had but I can try to fail at making it better..

dzpliu

2013-04-02 10:10:45

so this is for OSR?

King

2013-04-02 19:59:44

From: dzpliu
so this is for OSR?


No, it is for EOC.

King

2013-04-19 01:25:11

Bump, come check out the progress!

The Mayor

2013-04-19 01:36:40

Looking good! Too bad I got 99 range yesterday :crying: I will definitely use this with the charm impling though, need 99 summoning :) Let us know if/when you need testers.

King

2013-04-19 11:30:51

From: The Mayor
Looking good! Too bad I got 99 range yesterday :crying: I will definitely use this with the charm impling though, need 99 summoning :) Let us know if/when you need testers.



I should be able to finish the majority of the script and will post my thread with it tonight, then its ready for testing(: I need to improve looting slightly, sometimes doesnt detect the red bar. It also gives me a DTM index does not exist error even when not calling them, I was too tired to find it last night, would you mind checking and seeing if I call a DTM where I shouldnt?

dzpliu

2013-05-06 01:38:01

was editting seanstar's script to fit my liking, but your script seems simpler and easier to use :D

btw at start of your script>
{.Include SRL\SRL\Misc\Debug.simba}
<<<<what does the '.' means here? or you accidentally placed it there?

rj

2013-05-06 06:09:08

You should clean your main loop and use cases :p

if not LoggedIn then LogInPlayer;

case (NeedToBank) of

False:

case(AtCave) of

True:
begin
repeat
FightFiends;
until(GoToBank)
end;

False:
begin
EquipStaff;
WalkToRing;
UseFairyRing;
ReEquipWeapon;
end;
end;

True:

case(atBank) of

True:
begin
OpenZBank;
DoBanking;
end;

False:
begin
GetToBank;
OpenZBank;
DoBanking;
end;
end;
end;
end.

I hope I didn't miss anything!

King

2013-05-06 10:40:21

From: Officer Barbrady
You should clean your main loop and use cases :p

if not LoggedIn then LogInPlayer;

case (NeedToBank) of

False:

case(AtCave) of

True:
begin
repeat
FightFiends;
until(GoToBank)
end;

False:
begin
EquipStaff;
WalkToRing;
UseFairyRing;
ReEquipWeapon;
end;
end;

True:

case(atBank) of

True:
begin
OpenZBank;
DoBanking;
end;

False:
begin
GetToBank;
OpenZBank;
DoBanking;
end;
end;
end;
end.

I hope I didn't miss anything!



I'll put in cases, I need to update this read when I get home, I wrote a couple new parts