HarryJames
2011-02-24 09:41:58
Fight Cave Runner!
Setup
Fill in the Consts and the Declare players, make sure that you're pretty much outside the caves.
NOTES!
Setting the combat style currently does not work, so neither does the target levels. sorry.
I will be adding a lot more failsafes, don't worry!
Setup
Fill in the Consts and the Declare players, make sure that you're pretty much outside the caves.
program FightCaveRunner;
{$DEFINE SMART}
{$i SRL/SRL.scar}
{$i Reflection/Reflection.simba}
Const
RUNS_TO_COMPLETE = 3;
ANTI_BAN_CHANCE = 225;
// Keep it above or equal
// to 150, I'd say to not
// go over 300 just to be
// on the safe side ^^
{ SMART_SERVER_TO_USE = 34;
// Set this to 0 to use a
// random server.I've got
// it as 34, soo i do not
// have to keep reloading
// the client with every
// tiny change to a code }
var { ---- GLOBAL VARS ---- }
playerAtCaves : boolean;
tmp, Runs, Debug, LevelsGained, antibanCount : integer;
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Nick := 'ake';
Active:= True;
Debug := 1;// 1 for debugging
// 0 for not debug
// I'd suggest keeping it on
// while the scripts in beta
{ TARGET LEVELS }
Integers[0] := 40; // Attack
Integers[1] := 0; // Strength
Integers[2] := 0; // Defence
// NOTE FOR SETTING LEVEL TARGETS
// Becuase of the way I set it
// up, it will do the def lvls
// first, then str then att
Integers[3] := 0; // For error codes in
// use throughout the
// script.
// 0 = No error
// 1 = Lost
end;
end;
function outCaveYet: Boolean;
var
TPA: TPointArray;
begin
Result := ClickToContinue;
if (not Result) then
Result := FindSymbolsMulti(TPA, ['minigame', 'bank']);
end;
Procedure myLevelUp;
Begin
if (LevelUp) then
LevelsGained := LevelsGained + 1;
Writeln('Gained a level, woot woot!');
// Some code will be going in here, but it's a secret for now ^^
End;
Function setCombatMode : Integer;
var
Skills:TIntegerArray;
i : integer;
attackReached, strengthReached, defenceReached : boolean;
Begin
if not (LoggedIn) then exit;
Skills:= [R_GetSkillLevel(Skill_Attack), R_GetSkillLevel(Skill_Strength), R_GetSkillLevel(Skill_Defence)];
if ( Skills[0] < Players[0].Integers[0] ) then
Begin
//Writeln('Needs to be set to Attack');
Result := 1;
End else
Begin
attackReached := true;
End;
if ( Skills[1] < Players[0].Integers[1] ) then
Begin
//Writeln('Needs to be set to Strength');
Result := 2;
End else
Begin
strengthReached := true;
End;
if ( Skills[2] < Players[0].Integers[3] ) then
Begin
//Writeln('Needs to be set to Defence');
Result := 4;
End else
Begin
defenceReached := true;
End;
if (attackReached and strengthReached and defenceReached) then
// nextPlayer(false);
End;
Procedure atCaves;
var
x, y : integer;
begin
if not (LoggedIn) then exit;
if (DistanceFrom(Tile(2438, 5168)) < 6) then
begin
if (Debug = 1) then writeln('We''re at the caves!');
playerAtCaves := True;
end else
begin
if (Debug = 1) then writeln('looks like we''re not at the caves, attempting to fix.');
if not (findsymbol(x,y,'minigame')) then
begin
findsymbol(x,y,'bank');
mouse(x,y,4,4,true);
wait (1000+Random(500));
findsymbol(x,y,'minigame');
mouse(x-8,y-10,4,4,true);
end;
wait(1750 + random(1000));
if (DistanceFrom(Tile(2438, 5168)) < 6) then
begin
playerAtCaves := False;
Players[0].Integers[4] := 1;
nextPlayer(false);
exit;
end;
if (Debug = 1) then writeln('We Got there in the end!');
end;
end;
function EnterCave: Boolean; // Credits goto TomTuff for writing this from scratch for me!
var
i: Integer;
Objs: TRSObjectArray;
Pt: TPoint;
begin
if not(LoggedIn) then
Exit;
Objs := SortObjects(GetObjectsByID(9356, OBJECT_TYPE_INTERACTABLE,10));
for i := 0 to High(Objs) do
begin
if (Objs[i].Tile <> Tile(2439, 5167)) then
Continue;
if not(TileOnMS(Objs[i].Tile, 0)) then //May have to use Objs[i].RealTile instead
if not(WalkToTile(Objs[i].Tile, 2, 0)) then
Continue;
Pt := TileToMS(Objs[i].Tile, 0);
MMouse(Pt.x - 10, Pt.y - 10, 20, 20);
if R_WaitUptextMulti(['nter','ave','ntrance','alk'], 900) then
begin
Wait(50 + Random(80));
ClickMouse2(False);
Wait(50 + Random(80));
Result := r_WaitOptionMulti(['nter'], 900);
end;
if Result then
Break;
end;
for i := 0 to High(Objs) do //
Objs[i] := NULL_RSOBJECT; //These 3 lines should prevent memory leaks
SetLength(Objs, 0); //
Runs := Runs + 1;
wait(550 + Random(300));
ClickToContinue;
end;
Procedure AntiRandoms;
Begin
R_FindRandoms;
End;
Procedure AntiBans;
var
i : integer;
Begin
i := Random(ANTI_BAN_CHANCE);
case (i) of
0..9: RandomAngle(False);
10..20: BoredHuman;
21..30: RandomMovement;
31..40: PickUpMouse;
41..50: GameTab(23); // Stats
51..60: GameTab(25); // Inv
61..70: Begin
GameTab(26); // Equipped
wait(500 + Random(600));
GameTab(23);
End;
71..73: HoverSkill(Random(25), false);
74: HoverSkill(1, True);
75: HoverSkill(2, True);
76: HoverSkill(3, True);
77: HoverSkill(10, True);
78..83: ExamineInv;
100..108: RandomAngle(false);
109..115: RandomAngle(true);
116..120: GameTab(30);
121..130: RandomRClick;
131..150: GameTab(Random(17));
end;
antibanCount := antibanCount + 1;
End;
procedure HandleCave;
Begin
if not(LoggedIn) then
Exit;
clickToContinue;
WalkToTile(Tile(11489, 3945),10,10); // 7843 9696
wait(1000 + Random(800));
while not (outCaveYet) do
Begin // Loops that continues while we're in the cave.
//myLevelUp;
AntiRandoms;
AntiBans;
if (Debug = 1) then writeln('We''re in the cave!!');
wait(4000);
End;
if (Debug = 1) then writeln('Cave should be finished');
outCaveYet;
end;
procedure proggy;
Begin
Writeln('|-------- 05hartor''s cave runner ---------|');
Writeln('|=========================================|');
Writeln( Padr('| Character: ' + Players[0].Name , 42) + '|');
Writeln( Padr('|', 42) + '|');
Writeln( Padr('| Runs: ' + ToStr(Runs) + '/' + ToStr(RUNS_TO_COMPLETE), 42) + '|');
Writeln( Padr('| Running Time: ' + MsToTime(GetTimeRunning, Time_short), 42) + '|');
Writeln( Padr('| Antibans peformed: ' + ToStr(antibanCount), 42) + '|');
if not (LevelsGained = 0) then
Writeln( Padr('| Levels Gained: ' + ToStr(LevelsGained), 42) + '|');
if not (Players[0].Integers[4] = 0 ) then
Writeln( Padr('| Error Code: ' + ToStr(Players[0].Integers[4]), 42) + '|');
Writeln('|-----------------------------------------|');
end;
Procedure setupScript;
Begin
Smart_Signed := true;
Smart_Server := 34;
Smart_Members := True;
Smart_SuperDetail := false;
SetupSRL;
DeclarePlayers;
LoginPlayer;
wait(750+Random(750));
MakeCompass('S');
proggy;
end;
Procedure MainLoop;
Begin
setupScript;
While not (PlayersActive = 0) do
Begin
while ( Runs <= RUNS_TO_COMPLETE ) do
Begin
atCaves;
EnterCave;
//SetFightMode(setCombatMode);
HandleCave;
proggy;
if (Runs >= RUNS_TO_COMPLETE) then
nextplayer(false);
End;
End;
end;
begin
MainLoop;
proggy;
Writeln(' The script has finished now!');
end.
{
|------------- Todo list; (Not ordered)
Fix the attack styles so it doesn't go through them in reverse order
Better Antibans (Such as looking through quests and stats etc etc)
Average time per run
Fix levels gained
Save Proggy to text file
Wave detection (which wave are we on?!)
MAYBE (MAYBE, Not definately) but Multiplayer support
Exit on a timer as well as number of runs or levels reached
Checks if infight, rotates towards nearest enemy, and attacks them (instead of waiting for them to get to the player, and needing auto retaliate)
@~@~@~@~@~@ LOTS OF FAILSAFES
}NOTES!
Setting the combat style currently does not work, so neither does the target levels. sorry.
I will be adding a lot more failsafes, don't worry!