SRL Archive - Help and Support

Can someone please


Torrent of Flame

2009-02-15 14:28:01

Just go through my half-finished script and fix anything that is crap, like make sure everything would work, tell me how I could do things differently, etc, etc. It complies and such but doesnt work functionally.

If you could, could you annotate what you have changed aswell? :D

Naike

2009-02-15 14:32:04

You lazy bastard xD
Ask me over msn then post it here haha :P

If no one does it until tommorow i can do a quick check.

NCDS

2009-02-15 14:32:15

I looked through it and everything that I know looked alright. Like I've told you before I dont know much reflection but from what I can see everything looks pretty good.

Torrent of Flame

2009-02-15 14:36:12

N1ke, im not being lazy..

I dont understand why it isnt working

Nava2

2009-02-15 16:43:42

program LumbyCowLobotomizer;
{.include SRL/SRL/Misc/SMART.scar}
{.include SRL/SRL.scar}
{.include SRL/SRL/Reflection/Reflection.Scar}

var
Path: TPointArray;
LumbyTile: TPoint;
Hide, x, y: integer;
Kills: integer;

procedure DeclarePlayers;
begin

HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;

end;


{*******************************************************************************
procedure LoadDTMs;
Description: Er... Loads DTM's..
By: Torrent of Flame
*******************************************************************************}
procedure LoadDTMs;
begin
Hide := DTMFromString('78DA63E4656060E06640012B66CD04D38C503' +
'EA30490E0445533B7AF17550D489E1955CDC6E54B51D53001095E' +
'543507766C4555C30E244450D5ECDBB219558D20909044B76B25A' +
'A1A71202180AA66F9DCB9286A00E8050E93');
end;

{*******************************************************************************
function CheckRun: boolean;
Description: Checks your run % and clicks on run if it is above your percentage
By: Torrent of Flame
*******************************************************************************}
function CheckRun(WhatPercent: integer): boolean;
var
Energy: Integer;
Runcolor: string;

begin
Energy:= GetMMLevels('run', runcolor);
if(Energy > WhatPercent) then SetRun(True);
Result := True;
end;

{*******************************************************************************
function R_InLumby
Description: Checks if you are in Lumby
By: Torrent of Flame
*******************************************************************************}
function R_CheckLumby: boolean;
begin
LumbyTile := Point(3222, 3209); // I'd do a distance check here. Result := DistanceFrom(Point(3222, 3209));
Result := TileOnMM(LumbyTile); // also, make LumbyTile global, and declare it w/ you dtms or path. :)
end;

function R_GetToLumby: boolean;
begin
Wait(2000 + Random(500));
R_CheckLumby;
if (Result = TileOnMM(LumbyTile)) then // you haven't set result to anything... AKA you are asking if TileOnMM is false?
begin
WriteLn('In lumby');
end else

if not (Result = TileOnMM(LumbyTile)) then // you else would do the opposite, no need for this second if.
begin
GameTab(7);
Mouse(573, 225, 4, 4, true);
if FindBlackChatMessage('inutes') then
Writeln('Cant tele to lumby..'); // missed a begin end nest.
Exit;
Wait(5000 + random(500));
end;
end;

{*******************************************************************************
function R_TowCowfield/R_WalkToCowfield
Description: Walks to the cowfield from Lumby
By: Torrent of Flame
*******************************************************************************}
function R_ToCowfield: TPointArray;
begin
SetLength(Result, 16);
Result[0] := Point(3233, 3218);
Result[1] := Point(3236, 3222); // declare your path like: Path := [Point(3233, 3218), Point(3236, 3222)]; Looks niceer, and smaller.
Result[2] := Point(3230, 3232); // why is this a function? why not just leave the path loaded as a global?
Result[3] := Point(3222, 3242);
Result[4] := Point(3218, 3252);
Result[5] := Point(3216, 3265);
Result[6] := Point(3213, 3274);
Result[7] := Point(3202, 3279);
Result[8] := Point(3192, 3282);
Result[9] := Point(3188, 3289);
Result[10] := Point(3189, 3299);
Result[11] := Point(3184, 3306);
Result[12] := Point(3177, 3314);
Result[13] := Point(3176, 3321);
Result[14] := Point(3165, 3326);
Result[15] := Point(3157, 3333);
end;

function R_GateOpen: boolean; forward;

function R_WalkToCowfield: boolean;
var
i: integer;
Loc: string;
begin
CheckRun(60);
Writeln('Checked run..');
Path := R_ToCowfield;
Writeln('Loaded path..');
for i := 0 to 13 do
begin
WalkToTile(Path[i], 2, 2)//; // your path walker could use some... erm.. spunk?
end;
end;

{*******************************************************************************
function R_KillCow: boolean;
By: Torrent of Flame
Description: Finds and attacks cows
*******************************************************************************}
function R_KillCow: boolean;
var
Cow: array of TNPC;
P: TPoint;
i, ii: integer;
Loc: string;
begin
ii := 0
if not LoggedIn or not (Loc = 'Cowfield') then
Exit;
repeat
Inc(ii);
Wait(500 + random(500));
Cow := SortNPCs(GetNPCs);
if(GetArrayLength(Cow) = 0) then
Exit;
begin
for i := 0 to High(Cow) do
begin // if InIntArray([1767, 1766], Cow[I].NPCType) then
if (Cow[i].NPCType = 1767) or (Cow[i].NPCType = 1766) and (Cow[i].Name = 'Cow') and // no need for these three, one would be suffice. The milking cow won't be picked up, as its an object not an NPC
not Cow[i].InFight then
begin
if not TileOnMS(Cow[i].Tile, Cow[i].Height/2) then
WalkToTile(Cow[i].Tile, 0, 0); // the cow might have moved, you will need to refresh your tile.. GetNPCIndex would be good.. since you already have the index! :)
if TileOnMS(Cow[i].Tile, Cow[i].Height/2) then // do Cow[I].Height * 2/3 also, you could just use else and save time.
begin
P := TileToMS(Cow[i].Tile, 2);
MMouse(P.x, P.y, 5, 5);
Wait(200 + Random(300));
if OptionExists('Attack Cow') then // nice use of it. :)
begin
case Random(2) of
0: begin
Mouse(P.x, P.y, 5, 5, false);
Wait(500 + random(400));
R_ChooseOption('Attack Cow');
Wait(700 + random(700));
Result := True;
end;
1: begin
Mouse(P.x, P.y, 5, 5, true);
Wait(700 + Random(700));
Result := True;
end;
end;
end;
end;
end;
end;
end;
until (Result = True) or (i >= 10);
if (ii >= 10) then
begin
Writeln('Cant find cows');
Wait(1000 + Random(1000));
TerminateScript;
end;
end;

{*******************************************************************************
function R_CheckForHides: boolean;
By: Torrent of Flame
Description: Checks for Cowhides in the inventory
*******************************************************************************}
function R_CheckForHides: boolean;
var
CowHides: integer;
begin
CowHides := CowHides + CountItems(Hide, 'dtm', [1]); // you could use item ids. why would you return a boolean here?
Result := True;
end;

{*******************************************************************************
function R_TakeHides: boolean;
By: Torrent of Flame
Description: Takes hides off the floor
*******************************************************************************}
function R_TakeHides: boolean;
var
CowHide: TGroundItemArray;
P: TPoint;
begin
P:= TileToMS(CowHide[0].Tile, 0);
if FindGroundItems(CowHide, [1739], 0) then // you have to find the items before you try and pick them up xD
begin
Mouse(P.x, P.y, 2, 2, false);
R_ChooseOption('owhide'); // need a wait..
end; // this will ALWAYS return true, since you never exit anywhere in the procedure
Result := True;
end;

{*******************************************************************************
function R_WalkToBooth: boolean;
By: Torrent of Flame
Description: Goes to the bank from Cowfield
*******************************************************************************}
function R_WalkToBooth: boolean;
var
CowFieldTile: TPoint;
i: integer;
Loc: string;
begin
CowFieldTile := Point(3222, 3218);
if TileOnMM(CowFieldTile) then
Result := True;
if (Result = True) then // if (Result) then no need for the = true.
Path := R_ToCowfield; // *cough* global *cough*
for i := 13 to 15 do
begin
if WalkToTile(Path[i], 2, 2) then
Loc := 'Bank'; // begin end nest.
Result := True;
end;
Wait(500+Random(300));
end;

{*******************************************************************************
function R_GateOpen: boolean;
By: Torrent of Flame
Description: Checks if the gate is open.
*******************************************************************************}
function R_GateOpen : Boolean;
var
GatePoint, TP: TPoint;
begin
FindObject(GatePoint, 36914);
Result := TileOnMS(GatePoint, 1);
if not (Result) then
begin
TP := TileToMS(Point(3177, 3316), 5); // may want to use a TTile to get halfway between the two tiles.
Mouse(TP.x, TP.y, 1, 1, True);
end;
end;

{*******************************************************************************
function R_DepositAtBooth: boolean;
By: Torrent of Flame
Description: Deposits at the bank
*******************************************************************************}
function R_DepositAtBooth: boolean;
var
z: integer;
P: TPoint;
Tiles: TPointArray;
begin // use ROpenBank?
z := 0
if not LoggedIn then Exit;
repeat
Tiles := [Point(3156, 3331)];
SortTPAFrom(Tiles, GetMyPos);
z := z + 1;
P := TileToMS(Tiles[0], 2);
MMouse(P.x, P.y, 5, 5);
Wait(200+Random(200));
if IsUpText('ooth') then
begin
Mouse(P.x, P.y, 5, 5, true);
Wait(100 + Random(100))
if not FindDTM(Hide, x, y, 93, 58, 441, 262) then
begin
if not FindDTM(Hide, x, y, MSX1, MSY1, MSX2, MSY2) then
begin
Writeln('Cant Deposit Hides');
TerminateScript;
end else
Mouse(x, y, 3, 3, false);
R_ChooseOption('osit-All');
Result := True;
end else
Mouse(x, y, 3, 3, false);
R_ChooseOption('osit-All');
end;
until (Result) or (z >= 10);
if z >= 10 then
begin
Players[CurrentPlayer].Active := False;
Writeln('Cant find bankbooth');
end;
end;

{*******************************************************************************
function R_BankBooth: boolean;
By: Torrent of Flame
Description: If hides are above 20, it will bank.
*******************************************************************************}
function R_BankBooth: boolean; // silly name.
var
CowHides: integer;
begin
R_CheckForHides;
if CowHides >= 20 then
R_WalkToBooth; //begin end nest
R_DepositAtBooth;
Result := True;
end;

procedure SetupSmart;
begin
SmartSetupEx(81, False, True, False);
WriteLn('Setting up Smart... Please Hold...');
Wait(3000);
SetTargetDC(SmartGetDC);
end;

begin
SetupSRL;
DeclarePlayers; // dont forget SetupReflection;
SetupSmart;
LoginPlayer;
R_GetToLumby;
R_WalkToCowfield; // why all the R_'s btw?
repeat
R_KillCow;
R_TakeHides;
R_BankBooth;
Inc(Kills);
until Kills = 10;
end.

<3

Torrent of Flame

2009-02-16 03:48:29

OMG! Maybe thats why my script is failing?! It has no Setup Reflection..?

It has all the R_ because I'm doing it colour and reflection in the same script!

Thank you Nava! VERY much appreciated! :D <33


Also, I didnt know R_OpenBank works for bank booths?

Nava2

2009-02-16 10:04:22

how about the other comments? :)

Torrent of Flame

2009-02-16 12:45:06

Well I dont understand what you mean about R_GetToLumby

And how to declare the points as Global, same with the path.

Nava2

2009-02-18 06:43:47

Use global variables for them. Then you don't have to continuously redeclare them.