A
Anime
Guest
I'm a beginner at scar scripting. I started yesterday and seroko has been teaching me quite a few things about it. He helped me write the beginning portion of this script (GetMobileLocation, GetItemLocation, & The TalkTo's)
There is still a lot that needs to be done to this to make it fully function-able. I just wrote the main loop under ten minutes and wondering if it looks right. I still need to add code to finish the conversation's with the NPCs and I also need to add some fail-safes.
What I'm wondering is what else can I do to this script to improve its function-ability? I don't know how to complete conversations with NPCs nor write the fail-safes neccasary to avoid the script mucking up.
Here is the Code:
Any help would be appreciated.
PM for my MSN
There is still a lot that needs to be done to this to make it fully function-able. I just wrote the main loop under ten minutes and wondering if it looks right. I still need to add code to finish the conversation's with the NPCs and I also need to add some fail-safes.
What I'm wondering is what else can I do to this script to improve its function-ability? I don't know how to complete conversations with NPCs nor write the fail-safes neccasary to avoid the script mucking up.
Here is the Code:
Code:
program Snapegrass;
{.include srl/srl/misc/smart.scar}
{.include srl/srl.scar}
{.include srl/srl/reflection/reflection.scar}
var
Player : TMe;
Total : Integer;
procedure Configure;
begin
NumberOfPlayers( 1 );
CurrentPlayer := 0;
Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active := True;
end;
procedure Report;
begin
if not LoggedIn then
Exit;
Writeln('');
Writeln('Report:');
Writeln('Total: ' + IntToStr( Total ) );
Writeln('');
end;
function GetMobileLocation( mobile : Integer ) : TPoint;
var
Mobiles : array of TNPC;
Index : Integer;
begin
Mobiles := GetNPCsByID( mobile );
for Index := 0 to GetArrayLength( Mobiles ) do
begin
if not TileOnMS( Mobiles[Index].tile, Player.Height ) then
begin
WalkToTile( Mobiles[Index].tile, 5, 1 );
Wait( 500 + Random( 250 ) );
end;
end;
Result := TileToMS( Mobiles[0].tile, Player.Height );
end;
function GetItemLocation( item : Integer ): TPointArray;
var
Items : array of TGroundItem;
Index : Integer;
begin
if FindGroundItems( Items, [item], 5 ) then
begin
SetArrayLength( Result, GetArrayLength( Items ) );
for Index := 0 to High( Result ) do
Result[Index] := Items[Index].tile;
end;
end;
procedure Pickup( item : Integer );
var
Location : TPointArray;
Index : Integer;
begin
Location := GetItemLocation( item );
for Index := 0 to High( Location ) do
begin
Mouse( Location[0].x, Location[0].y, 5, 5, True );
Wait( 500 + Random( 250 ) );
end;
end;
function Drop : Boolean;
var
Gold, slot, x, y : Integer;
begin
Gold := DTMFromString( '78DA6374636060286440010FB6C9806946289' +
'FD102485433A001465435C140A28E08357904D4D803897C026A3C' +
'8144167E35006D880621' );
GameTab(4);
Result := False;
if FindDTM( Gold, x, y, MIX1, MIY1, MIX2, MIY2 ) then
begin
slot := CoordsToItem( x, y );
DropItem( slot );
Wait( 500 + Random( 250 ) );
if not ExistsItem( slot ) then
Result := True;
end;
FreeDTM( Gold );
end;
function TalkToPeer : Boolean;
var
Location : TPoint;
x, y : Integer;
begin
Location := GetMobileLocation( 1288 );
mmouse( Location.x, Location.y, 3, 3 );
if IsUpText( 'alk-to' ) then
begin
getmousepos( x, y );
mouse( x, y, 0, 0, true );
Flag;
wait( 500 + random( 250 ) );
Result := true;
end;
end;
function TalkToJarvald( instance : Integer ) : Boolean;
var
Location : TPoint;
x, y : Integer;
begin
Location := GetMobileLocation( instance );
mmouse( Location.x, Location.y, 3, 3 );
if IsUpText( 'alk-to' ) then
begin
getmousepos( x, y );
mouse( x, y, 0, 0, false );
Flag;
wait( 500 + random( 250 ) );
Result := ChooseOption( 'ay-fa' );
end;
end;
procedure AntiBan( priority : string );
begin
// UNFINISHED
end;
procedure AntiRandom;
begin
// UNFINISHED
end;
begin
SetupSRL;
SmartSetup( 'world58', True, True, False );
Wait( 5000 );
SetTargetDC( SmartGetDC );
Configure;
LoginPlayer;
SetAngle( True );
wait( 10000 + random( 250 ) );
repeat
if ( LoggedIn ) then
begin
wait( 500 + random( 250 ) );
if ( Drop ) then
begin
wait( 500 + random( 250 ) );
if ( TalkToPeer ) then
begin
wait( 500 + random( 250 ) );
Pickup( 1004 );
wait( 50 + random( 250 ) );
AntiBan( 'Minor' );
wait( 500 + random( 250 ) );
end;
end else
Exit;
if TalkToJarvald( 2436 ) then
begin
wait( 50 + random( 250 ) );
AntiBan( 'Normal' );
wait( 500 + random( 250 ) );
while not InvFull do
begin
Pickup( 231 );
Inc( Total );
wait( 50 + random( 250 ) );
AntiBan( 'Major' );
wait( 500 + random( 250 ) );
end;
end else
Exit;
if InvFull then
begin
if TalkToJarvald( 2437 ) then
begin
wait( 50 + random( 250 ) );
AntiBan( 'Normal' );
wait( 500 + random( 250 ) );
Report;
end;
end;
end;
sleep( 1 );
until IsFKeyDown( 2 );
end.
Any help would be appreciated.
PM for my MSN

