Log in

View Full Version : Improvement? Enough for members?



Wizkid
07-23-2011, 10:20 PM
Hi again!

Been trying to learn your include for over a week now, been going pretty solid I'd say :)

Here's the code!
Reflection 2, SRL. It uses a form, only single player! (I only got one account).

This script is an ogre ranger. (I saw it was a request, so I might as well start with it)


program VerySimpleCowKiller;
{$DEFINE SMART}
{$i srl\srl.scar}
{$i reflection\reflection.simba}
{$i srl\srl\skill\magic.scar}
{$i srl\srl\misc\paintsmart.scar}

var
Form: TVariantArray;
MyForm : TForm;
Edits: Array [0..2] of TEdit;
List: TComboBox;
CBoxs: Array [0..1] of TCheckBox;
SArr: TStringArray;
BArr: TBooleanArray;
Terminate: Boolean;

procedure OnStart(Sender : TObject);
var
Run: Boolean;
begin;
Run := True;

If Lowercase(List.Text) = 'lampskill' then
begin
Run := False;
Writeln('Choose a lampskill!');
end;

If (Edits[0].Text = '')or(Edits[1].Text = '')or(Edits[0].Text = 'Username')or(Edits[1].Text = 'Password')or(Edits[2].Text = 'World') then
begin
Run := False;
Writeln('Please fill in the form correctly!');
end;

If Run then
begin
SArr := [Edits[0].Text, Edits[1].Text, Edits[2].Text, List.Text];
BArr := [CBoxs[0].Checked, CBoxs[1].Checked];

WriteINI('userinfo', 'user', SArr[0], ScriptPath + 'wizform.ini');
WriteINI('userinfo', 'pass', SArr[1], ScriptPath + 'wizform.ini');

WriteINI('otherinfo', 'lampskill', SArr[3], ScriptPath + 'wizform.ini');

WriteINI('smartinfo', 'world', SArr[2], ScriptPath + 'wizform.ini');
WriteINI('smartinfo', 'member', BoolToStr(CBoxs[0].Checked), ScriptPath + 'wizform.ini');
WriteINI('smartinfo', 'signed', BoolToStr(CBoxs[1].Checked), ScriptPath + 'wizform.ini');

MyForm.ModalResult:= mrOk;
end;
end;

procedure OnExit(Sender : TObject);
begin;
MyForm.ModalResult:= mrOk;
Terminate := True;
end;

function FormInit: Boolean;
var
Button: Array [0..1] of TButton;
I: Integer;
tSArr: TStringArray;
begin;
Result := false;
MyForm := TForm.Create(nil);
MyForm.Width := 150;
MyForm.Height := 240;
MyForm.BorderStyle := bsSingle;
MyForm.Color := clWhite;
MyForm.Position := poDesktopCenter;

For I:=0 to 2 do
begin
Edits[I] := TEdit.Create(MyForm);
Edits[I].Parent := MyForm;
end;

For I:=0 to 1 do
Edits[I].SetBounds(20, 10+(I*35), 105, 30);

Edits[2].SetBounds(20, 90, 105, 30);
Edits[1].PasswordChar := '*';

List := TComboBox.Create(MyForm);
List.Parent := MyForm;
List.SetBounds(20, 180, 105, 25);
tSArr := ['Lampskill', 'Attack', 'Strength', 'Defence', 'Range', 'Magic', 'Hitpoints',
'Prayer', 'runecrafting', 'Agility', 'Herblore', 'Theiving', 'Crafting',
'Fletching', 'Slayer', 'Mining', 'Smithing', 'Fishing', 'Cooking',
'Firemaking', 'Woodcutting', 'Farming', 'Construction', 'Hunter', 'Summoning'];
For I:=0 to High(tSArr)do
List.ITEMS.Add(tSArr[I]);

For I:=0 to 1 do
begin
CBoxs[I] := TCheckBox.Create(MyForm);
CBoxs[I].Parent := MyForm;
CBoxs[I].SetBounds(32, 115+(22*I), 25, 25);
end;
CBoxs[0].Caption := 'Members';
CBoxs[1].Caption := 'Signed';

For I:=0 to 1 do
begin
Button[I] := TButton.Create(MyForm);
Button[I].Parent := MyForm;
Button[I].SetBounds(25+(I*50), 213, 50, 25);
end;

Button[0].OnClick := @OnStart;
Button[0].Caption := 'Start';
Button[1].OnClick := @OnExit;
Button[1].Caption := 'Exit';

If ReadINI('userinfo', 'user', ScriptPath + 'wizform.ini') = '' then
begin
Edits[0].Caption := 'Username';
Edits[1].Caption := 'Password';
Edits[2].Caption := 'World';
List.Caption := 'Lampskill';
end else
begin
Edits[0].Caption := ReadINI('userinfo', 'user', ScriptPath + 'wizform.ini');
Edits[1].Caption := ReadINI('userinfo', 'pass', ScriptPath + 'wizform.ini');
Edits[2].Caption := ReadINI('smartinfo', 'world', ScriptPath + 'wizform.ini');
List.Caption := ReadINI('otherinfo', 'lampskill', ScriptPath + 'wizform.ini');

CBoxs[0].Checked := (ReadINI('smartinfo', 'member', ScriptPath + 'wizform.ini') = 'True');
CBoxs[1].Checked := (ReadINI('smartinfo', 'signed', ScriptPath + 'wizform.ini') = 'True');
end;

MyForm.ShowModal;
MyForm.Free;
end;

Procedure ShowForm;
begin
ThreadSafeCall('FormInit', Form);
end;

Procedure Setup;
begin
HowManyPlayers:= 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := SArr[0];
Players[0].Pass := SArr[1];
Players[0].Active := True;

LampSkill := SArr[3];
end;

Function InArea: Boolean;
begin
Result := R_SelfInBox(IntToBox(2521, 3374, 2533, 3369));
end;

Procedure SwitchOgreWorld;
begin
ChangeWorld(RandomWorld(True, False));
end;

Function IsCannonUp: Boolean;
var
Obj: TRSObject;
begin
Result := R_FindObject(6, OBJ_INTERACTABLE, 9, Obj);
end;

Procedure DealWithCannon;
begin
If IsCannonUp then
SwitchOgreWorld;
end;

Procedure Telegrab;
var
gItems: TGroundItemArray;
ItemIDs: TIntegerArray;
ItemNames: TStringArray;
I, H, Index: Integer;
P: TPoint;
begin
gItems := R_GetAllGroundItems(7);

If GetArrayLength(gItems) = 0 then
Exit;

ItemIDs := [987, 985, 5304, 5300, 5303, 5302, 5295];
ItemNames := ['Loop half', 'Tooth half', 'Torstol seed', 'Snapdragon seed', 'Dwarf weed seed', 'Lantadyme seed', 'Ranarr seed'];

H := High(gItems);
For I:=0 to H do
If InIntArrayEx(ItemIDs, Index, gItems[I].ID)then
begin
P := R_TileToMS(gItems[I].Tile, 0);

If Not Cast('telekinetic grab', False)then
Continue;

Mouse(P.X, P.Y, 2, 2, False);
WaitOption('-> ' + ItemNames[Index], 150+Random(140));
Wait(900+Random(1400));
end;

end;

Function Ranging: Boolean;
var
NPC: TNPC;
P: TPoint;
T: Integer;
begin
T := GetSystemTime + 2567;
repeat
wait(66)
if (R_GetAnimation > -1)then
Result := true;

until Result or (GetSystemTime > T);

end;

Function FindOgre: Boolean;
var
NPCs: TNPCArray;
NPC: TNPC;
I: Integer;
P: TPoint;
begin
If Not LoggedIn then
Exit;

NPCs := R_GetNPCs('Ogre', False);
If (GetArrayLength(NPCs) = 0) then
Exit;

If R_AreWeInteracting(NPC, False)then
P := R_TileToMSEx(NPC.Tile, 0, 0, 100+Random(400))
else
For I:=0 to High(NPCs)do
If (NPCs[I].HPRatio = 0)And(NPCs[I].Animation = -1) then
begin
P := R_TileToMSEx(NPCs[I].Tile, 0, 0, 100+Random(400));

Break;
end;

If (InRange(P.X, -5, 5))then
begin
MakeCompass(Random(361));
Exit;
end;

Mouse(P.X, P.Y, 7, 7, False);

Result := ChooseOption('ttack');
If Result then
Exit;
end;

Procedure AntiBan;
begin
If Not LoggedIn then
Exit;

Case Random(100)of
0: SleepAndMoveMouse(1000+Random(4000));
6..11: MakeCompass(Random(360));
12: GameTab(tab_Inv);
13..16: GameTab(tab_Stats);
end;
end;

Procedure FindFight;
var
I, iTime: Integer;
begin
Repeat
Inc(I);
Wait(400+Random(400));
Until(Not LoggedIn)or(I > 9)or(FindOgre);

iTime := GetSystemTime;
Repeat
Wait(100+Random(100));
If TimeFromMark(iTime) > 5000 then
Break;
Until(Ranging);
end;

Procedure WaitRanging;
begin
Repeat
Wait(250+Random(200));
AntiBan;

If Not InArea then
R_FindRandoms;

ClickToContinue;
Until(Not Ranging);

If (Random(10) = 0)then
Wait(1000+Random(2000));
end;

Procedure PlayersAround;
var
OtherPlayers: array of TPlayer;
begin
OtherPlayers := R_GetAllPlayers;
If (Length(OtherPlayers) > 3)then
SwitchOgreWorld;
end;

Procedure SetupPlayer;
begin
SetAngle(True);
GameTab(tab_Inv);
end;

begin
ShowForm;
If Terminate then
TerminateScript;

SMART_Members := BArr[0];
SMART_Server := StrToIntDef(SArr[2], -1);
SMART_Signed := BArr[1];

{Setup}
SetupSRL;
Setup;

If Not LoggedIn then {Make sure we login}
begin
LoginPlayerToLob;
ChangeWorld(RandomWorld(True, False));
end;

SetupPlayer;
Repeat
If Not LoggedIn then
begin
Writeln('Not LoggedIn');
NextPlayer(False);
SetupPlayer;
end;

PlayersAround;
DealWithCannon;
Telegrab;

If Not InArea then
begin
Writeln('Not in area!');
If Not R_TileOnMM(Point(2527, 3371))then
If Not r_FindRandoms then
LogOut;

end else
begin
FindFight;

If LoggedIn then
WaitRanging;
end;

Until(AllPlayersInactive);
end.

Awkwardsaw
07-23-2011, 10:31 PM
try learning about TPAs, dtms, and walking(preferably color, or reflection with color back up)

tbh, your script is to short to show your knowledge of SRL :)

BraK
07-23-2011, 10:43 PM
Nice usage of arrays on your form. Might I suggest using Arrays with your buttons and making Onstart and OnExit part of the same procedure.

I also agree it's quite short....

~BraK

TomTuff
07-24-2011, 05:30 AM
program VerySimpleCowKiller;

lol :P

Mr. Freeweed
07-24-2011, 06:12 AM
Hey I commend you for spending a week figuring out the basics and I think your on the road. As you write over time your going to keep picking up more as you go.

spruce up your script with dtms. small bmp (they hate those) and youll be in. Another week of figuring it out and you'll have it.

FYI your missing nothing in the members area.

Mr. Freeweed

Smarter Child
07-24-2011, 07:18 AM
Hey I commend you for spending a week figuring out the basics and I think your on the road. As you write over time your going to keep picking up more as you go.

spruce up your script with dtms. small bmp (they hate those) and youll be in. Another week of figuring it out and you'll have it.

FYI your missing A LOT in the members area.

Mr. Freeweed

Yes, members is awesome[and we all know it :p] and it is good to see a user learning to script and trying to become an SRL member :)

As for your script:

- Multiplayer: Simple but quite important.
- (D)DTMs: IMO, this is needed for your app.
- TPA: Shows good colour knowledge and is highly recommended.
- Mapwalk: Whether you use TPA/DTM/FindSymbol/RadialWalk this is a good addition for a members application.
- Failsafes: This is big, I think you will have this covered easily though ;)

I would recommend a colour only script for your members application, however if you DO CHOOSE to INCLUDE REFLECTION, use it as a FAILSAFE.

Any ways, I look forward to voting 'Yes' on your future member application :)