Feroc1ty
2011-03-22 21:19:24
Hey, here is a script I've been working on for the past while… learned a few new things here and there too; shoutout to Harry! (I looked at his auto updater script to get an idea of what to do)
What the script does:
Takes brand new characters from tutorial runner, or at lumbridge castle, and moves them to the closest chicken pen, trains combat stats until the desired combat stats are reached, at which point it goes down to goblins, kill them until it finds a sling, and than heads back to chickens and trains range.
During the whole runtime it takes breaks, has antiban, and timely picks up the feathers on the ground.
Features SRL stats!
The script requires an include I have created for my personal ease of coding, if you don't want it you don't have to run it. To get the include (since you'll get an error telling you need the include) simply comment out the include in the script, run it, and you'll be given the option to download it.
This is the second release of the script [beta], I want to find all the bugs, so you posting bugs and debug text is very helpful!
What the script does:
Takes brand new characters from tutorial runner, or at lumbridge castle, and moves them to the closest chicken pen, trains combat stats until the desired combat stats are reached, at which point it goes down to goblins, kill them until it finds a sling, and than heads back to chickens and trains range.
During the whole runtime it takes breaks, has antiban, and timely picks up the feathers on the ground.
Features SRL stats!
program CharacterSelfStart;
// -------- include settings --------
const
// SMART client settings
CLIENT_MEMBERS = false;
CLIENT_SERVER = 75;
CLIENT_SIGNED = true;
CLIENT_DETAIL = false;
{$i Feroc1ty_General.simba}
{$IFNDEF Feroc1ty}
procedure DownloadInclude;
var current:string;
include,version:integer;
begin
current := GetPage('http://feroc1ty.frihost.net/feroc1ty_general_latest.txt');
include := RewriteFile(AppPath + '/includes/feroc1ty_general.simba',true);
try
WriteFileString(include, current);
except
writeln('Failed to get the updated script, you can get it manually at:');
writeln('http://feroc1ty.frihost.net/feroc1ty_general_latest.txt');
TerminateScript;
end;
version := StrToInt(GetPage('http://feroc1ty.frihost.net/feroc1ty_general_version.txt'));
writeln('Feroc1ty''s include was successfully downloaded with the most recent version, ' + tostr(version) +'.');
writeln('Click play again!');
TerminateScript;
end;
begin
writeln('You need feroc1ty''s include to run this script.');
if (MessageDlg('MISSING ESSENTIAL INCLUDE', 'Would you like to download the include?', mtConfirmation, [mbYes, mbNo]) = mrYes) then
begin
DownloadInclude;
end;
end.
{$ENDIF}
{$i SRL/SRL/Misc/stats.simba}
// ----------------------------------
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);
with Players[0] do
begin
name := '';
nick := '';
pass := '';
pin := '';
active := true;
end;
end;
// -------- script settings --------
const
TARGET_ATTACK = 20;
TARGET_STRENGTH = 50;
TARGET_DEFENSE = 10;
TARGET_RANGE = 50;
MAX_PEOPLE_IN_PEN = 3; // how many people (besides you) inside the pen needed to switch world
ENABLE_DEBUG = true;
FREQUENT_UPDATES = true;
// ---------------------------------
// -------- script constants --------
const
SRLStats_UserID = '';
SRLStats_Password = '';
SCRIPT_NAME = 'CharacterSelfStart';
SCRIPT_VERSION = 102;
FEATHER_ID = 314;
SLING_ID = 19830;
// ----------------------------------
// -------- script variables --------
var
starting_location:TTile;
lumby_location:TTile;
pen_location:TTile;
starting_path:TPointArray;
sling_path:TPointArray;
last_attack_type:string;
pen_area:TBox;
house_area:TBox;
goblins_area:TBox;
gate:fObject;
door:fObject;
checkworld_timeout:longint;
updatestats_timeout:longint;
total_exp_gained:longint;
total_feathers_gained:longint;
// ----------------------------------
// ,
//---__-----__----)__------------__---_/_-
// (_ ` / ' / ) / / ) /
//_(__)__(___ __/______/______/___/__(_ __
// /
// /
procedure WriteUpdate;
var current:string;
include,version:integer;
begin
current := GetPage(CURRENT_HOST + SCRIPT_NAME + '_latest.txt');
include := RewriteFile(AppPath + '/scripts/' + SCRIPT_NAME + '.simba',true);
try
WriteFileString(include, current);
except
writeln('Failed to get the updated script, you can get it manually at:');
writeln(CURRENT_HOST + SCRIPT_NAME + '_latest.txt');
TerminateScript;
end;
version := StrToInt(GetPage(CURRENT_HOST + SCRIPT_NAME + '_version.txt'));
fDebug('WriteUpdate',SCRIPT_NAME + ' was successfully updated to version ' + tostr(version) +'.');
fDebug('WriteUpdate','Please close and re-open all instances of this script for proper functionality!');
TerminateScript;
end;
procedure CheckScriptForUpdate;
var version,include:integer;
current:string;
begin
fDebug('CheckScriptUpdate','Checking for script updates.');
version := StrToInt(GetPage(CURRENT_HOST + SCRIPT_NAME + '_version.txt'));
if (SCRIPT_VERSION < version) then
begin
fDebug('CheckScriptUpdate',SCRIPT_NAME + ' was found to be out of date, checking compatability!');
end else
begin
fDebug('CheckScriptUpdate',SCRIPT_NAME + 'script is up to date!');
exit;
end;
if SubStr(1,1,tostr(SCRIPT_VERSION)) <> SubStr(1,1,tostr(version)) then
begin
fDebug('CheckScriptUpdate','New version of the script requires an update!');
Update('WriteUpdate');
end else
begin
if FREQUENT_UPDATES then Update('WriteUpdate');
fDebug('CheckScriptUpdate','Newer version of ' + SCRIPT_NAME + ' is available, set FREQUENT_UPDATES to true to download!');
end;
end;
procedure Initialize;
begin
// general
fInitialize(FREQUENT_UPDATES,ENABLE_DEBUG);
CheckScriptForUpdate;
// points/locations
starting_location := Tile(3204, 3245);
lumby_location := Tile(3222, 3217);
pen_location := Tile(3188, 3276);
// areas/boxes
pen_area := IntToBox(3185,3276,3191,3279);
house_area := IntToBox(3184,3270,3192,3275);
goblins_area := IntToBox(3242,3219,3264,3252);
// paths
SetArrayLength(starting_path,7);
starting_path := [Point(3215, 3246), Point(3218, 3255), Point(3216, 3267),
Point(3214, 3278), Point(3203, 3278), Point(3195, 3278),
Point(3189, 3281)];
SetArrayLength(sling_path,10);
sling_path := [Point(3197, 3279), Point(3209, 3279), Point(3217, 3270),
Point(3218, 3259), Point(3219, 3249), Point(3224, 3238),
Point(3230, 3229), Point(3237, 3224), Point(3246, 3224),
Point(3257, 3224)];
// fObjects
gate := CreateFOBJ('gate',45206,1,70,Tile(3188,3279),IntToBox(3188,3279,3189,3280));
door := CreateFOBJ('door',45476,1,70,Tile(3189,3276),IntToBox(3189,3275,3189,3276));
//SRL Stats
SetupSRLStats(67,SRLStats_UserID,SRLStats_Password);
end;
procedure AntiBan;
begin
case Random(600) of
0: IdleTime(2000, 1000, 0.2);
1: HoverSkill(Players[CurrentPlayer].Skill, False);
2: RandomRClick;
3: PickUpMouse;
4: LevelUp;
5: BoredHuman;
6: ExamineInv;
7: R_DropAllItemsBy(2138);
end;
end;
function BrandNewCharacter():boolean;
begin
result := IsNearbyPoint(starting_location, 5);
end;
procedure WalkToPen;
begin
fWalkPath(starting_path, false);
end;
function NearbyPen:boolean;
begin
result := IsNearbyPoint(pen_location, 15);
end;
function IsCharacterInPen:boolean;
begin
result := PointInBox(GetMyPos, pen_area);
end;
function IsCharacterInHouse:boolean;
begin
result := PointInBox(GetMyPos, house_area);
end;
function IsCharacterAtGoblins:boolean;
begin
result := PointInBox(GetMyPos, goblins_area);
end;
function IsCharacterAtLumby:boolean;
begin
result := IsNearbyPoint(lumby_location, 15);
end;
function MoveInsidePen:boolean;
begin
result := true;
if IsCharacterInPen then exit;
if IsCharacterInHouse then
begin
while not InteractWithFOBJ('open',door) do
begin
R_MakeCompass('r');
end;
end else
begin
while not InteractWithFOBJ('open',gate) do
begin
R_MakeCompass('r');
end;
end;
WalkToTile(Tile(3188,3277),1,0);
R_MakeCompass('n');
result := IsCharacterInPen;
end;
function MoveToLoc(location:string):boolean;
begin
case location of
'pen':begin
fWalkPath(sling_path,true);
result := MoveInsidePen;
end;
'goblins':fWalkPath(sling_path,false);
end;
end;
function InGrimsDen:boolean;
begin
result := ValidNPC('Grim Reaper');
end;
procedure TalkToGrim;
var portal,grimtile:TTile;
begin
SetAngle(true);
R_MakeCompass('N');
portal := GetMyPos;
portal.x := portal.x + 3;
grimtile := GetMyPos;
grimtile.x := grimtile.x - 4;
InteractWithTile('talk',Point(-15,-15),grimtile);
repeat
Wait(250+Random(1250));
until not R_ClickToContinue;
Wait(250+Random(1250));
InteractWithTile('enter',Point(0,0), portal);
Wait(4000+random(2000));
end;
procedure GetSling;
var t:integer;
begin
while IsCharacterInPen do InteractWithFOBJ('open',gate);
R_DropAllItemsBy(2138);
fWalkPath(sling_path,false);
repeat
if InGrimsDen then TalkToGrim;
if IsCharacterAtLumby then MoveToLoc('goblins');
FightNPC('goblin');
wait(1500+random(750));
PickUpItemNear(SLING_ID,'sling',6,t);
if R_CountItem(SLING_ID) > 0 then break;
until false
fWalkPath(sling_path,true);
end;
procedure InitializeCharacter;
begin
repeat
if AllPlayersInactive then break;
fDebug('InitializeCharacter','Beggining to initialize '+Players[CurrentPlayer].nick+'.');
if not R_LoggedIn then LogInPlayer;
wait(4000+random(4000));
SetAngle(true);
R_MakeCompass('n');
R_FindRandoms;
if BrandNewCharacter then WalkToPen;
if InGrimsDen then TalkToGrim;
if IsCharacterAtLumby then MoveToLoc('pen');
if IsCharacterAtGoblins then GetSling;
if not NearbyPen then
begin
writeln('Player['+tostr(CurrentPlayer)+'] is not near the pen, please relocate him.');
Players[CurrentPlayer].status := 'relocate';
NextPlayer(false);
continue;
end;
if not MoveInsidePen then
begin
WriteLn('Attempted to move inside the pen but failed, switching players.');
Players[CurrentPlayer].status := 'failed';
NextPlayer(true);
continue;
end;
last_attack_type := '';
Players[CurrentPlayer].status := 'initialized';
fDebug('InitializeCharacter','Character was fully initialized!');
until Players[CurrentPlayer].status = 'initialized';
end;
function WhatToTrain:string;
var temp:string;
char:TMe;
begin
char := GetMe;
if char.Levels[SKILL_RANGE] < TARGET_RANGE then temp := 'range';
if char.Levels[SKILL_DEFENCE] < TARGET_DEFENSE then temp := 'defense';
if char.Levels[SKILL_ATTACK] < TARGET_ATTACK then temp := 'attack';
if char.Levels[SKILL_STRENGTH] < TARGET_STRENGTH then temp := 'strength';
if (char.Levels[SKILL_ATTACK] < 10) and (char.Levels[SKILL_ATTACK] < TARGET_ATTACK) then temp := 'attack';
if (char.Levels[SKILL_STRENGTH] < 5) and (char.Levels[SKILL_STRENGTH] < TARGET_STRENGTH) then temp := 'strength';
result := temp;
end;
procedure ChangeAttack;
var sling:TInvItem;
begin
if not (Players[CurrentPlayer].Skill = last_attack_type) then
begin
last_attack_type := Players[CurrentPlayer].Skill;
if last_attack_type <> 'range' then
begin
if HasItemEquipped(EQUIPMENT_WEAPON) then
TakeOff(5);
case last_attack_type of
'attack' : SetFightMode(1);
'strength': SetFightMode(2);
'defense' : SetFightMode(4);
end;
end else
begin
if R_ItemExists('sling',sling) then
R_ClickItem(sling.slot, true, '')
else
GetSling;
end;
end;
end;
function TooCrowded:boolean;
var people:TPlayerArray;
i,y:integer;
begin
people := GetAllPlayers;
y := 0;
for i := 0 to high(people) do
begin
if PointInBox(people[i].tile,pen_area) then
begin
y := y + 1;
end;
end;
y := y - 1;
fDebug('TooCrowded','Found '+tostr(y)+' people inside the pen.');
if y >= MAX_PEOPLE_IN_PEN then result := true;
end;
function CheckWorld:boolean;
begin
if GetSystemTime > checkworld_timeout + 4*60*1000 then
begin
checkworld_timeout := GetSystemTime;
if TooCrowded then
begin
while not R_LobbyScreen do
begin
if R_LoggedIn then
ExitToLobby
else
LoginPlayerToLob;
end;
result := true;
OpenWorldScreen;
while not SelectWorld(RandomWorld(CLIENT_MEMBERS, false)) do Wait(3000);
LoginPlayer;
repeat
Wait(1000);
until R_LoggedIn;
end;
end;
end;
function FightChicken:boolean;
var mobs:TNPCArray;
index:integer;
exp:longint;
begin
index := 0;
exp := R_GetSkillExperience(Players[CurrentPlayer].Skill);
mobs := SortNPCs(GetNPCs('chicken'));
for index := 0 to high(mobs) do
begin
if (mobs[index].fighting or mobs[index].moving or not NpcInBox(mobs[index],pen_area)) then
continue;
result := InteractWithNPC('attack',mobs[index]);
if result then FinishFight(200);
exp := R_GetSkillExperience(Players[CurrentPlayer].Skill) - exp;
total_exp_gained := total_exp_gained + exp;
Stats_IncVariable('Total EXP Gained',exp);
break;
end;
end;
procedure PickupFeathers;
var ground:TGroundItemArray;
feather:TInvItem;
index,gained:integer;
begin
ground := GetItemsNear(4);
R_ItemExists(FEATHER_ID,feather);
gained := feather.StackSize;
for index := 0 to high(ground) do
begin
if (ground[index].ID = FEATHER_ID) and PointInBox(ground[index].tile,pen_area) then
begin
ClickBox(PtToBox(TileToMS(ground[index].tile,30),8),false);
R_WaitOption('eather',300);
wait(100+random(75));
r_Flag;
R_ItemExists(FEATHER_ID,feather);
gained := feather.StackSize - gained;
total_feathers_gained := gained;
break;
end;
end;
wait(random(50));
end;
procedure CheckHouseForChickens;
var chickens:TNPCArray;
i:integer;
begin
if CountNPCsInBox('chicken',house_area) > 1 then
begin
InteractWithFOBJ('open',door);
chickens := GetNpcs('chicken');
for i := 0 to high(chickens) do
begin
if NpcInBox(chickens[i],house_area) then InteractWithNPC('attack',chickens[i]);
end;
MoveInsidePen;
end;
end;
procedure UpdateStats;
begin
if GetSystemTime > updatestats_timeout + 5*60*1000 then
begin
updatestats_timeout := GetSystemTime;
Stats_Commit;
end;
end;
procedure MainLoop;
begin
InitializeCharacter;
while true do
begin
TakeABreak;
if not R_LoggedIn then
begin
WriteLn('Character not logged in for unknown reason, switching player.');
NextPlayer(false);
Break;
end;
R_FindRandoms;
FindNormalRandoms;
if not MoveInsidePen then
begin
WriteLn('Character failed to move inside the pen, switching player.');
NextPlayer(true);
Break;
end;
CheckWorld;
R_MakeCompass('n');
Players[CurrentPlayer].Skill := WhatToTrain;
ChangeAttack;
if not FightChicken then PickupFeathers;
CheckHouseForChickens;
UpdateStats;
Antiban;
PrintOnSmart(['Feroc1ty''s ' + SCRIPT_NAME + ' v' + tostr(SCRIPT_VERSION),'Experience: '+tostr(total_exp_gained),'Feathers: '+tostr(total_feathers_gained),'Time('+TimeFromStart+')'],Point(30, 15), 16777088, 15790080);
Wait(100);
end;
end;
begin
Initialize;
while not R_LoginScreen do Wait(3000);
while not (AllPlayersInactive) do
begin
MainLoop;
end;
writeln('The script has succesfully finished running, ran for ['+TimeFromStart+'].');
end.The script requires an include I have created for my personal ease of coding, if you don't want it you don't have to run it. To get the include (since you'll get an error telling you need the include) simply comment out the include in the script, run it, and you'll be given the option to download it.
This is the second release of the script [beta], I want to find all the bugs, so you posting bugs and debug text is very helpful!