SRL Archive - First Scripts

First script! Cowkiller!


Wizkid

2011-07-21 22:05:56

Trying to learn your include, coming from a somewhat similliar language :redface:

Been looking a lot into other scripts and used what I can. Also managed to read some tutorials on arrays(TStringArray := ['', ''] ect)

All feedback is gladly received! :D

program VerySimpleCowKiller;
{$DEFINE SMART}
{$i srl\srl.scar}
{$i reflection\reflection.simba}

procedure SetupScript;
begin
MouseSpeed := 20;
LampSkill := 'mining';

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

With Players[0] do
begin
Name := '';
Pass := '';
Active := True;
BoxRewards := ['lamp']
end;


end;

Function FindClosestCow: Boolean;
var
NPCs: TNPCArray;
P: TPoint;
I, T: Integer;
begin
NPCs := R_SortNPCs(R_GetNPCsMulti([12365, 12363, 12362], False));
For I:=0 to High(NPCs)do
begin

If NPCs[I].InCombat then
Continue;

If Not R_TileOnMS(NPCs[I].Tile, Round(NPCs[I].Height div 2))then
begin
R_WalkToTile(NPCs[I].Tile, 2, 2);
Flag;
Result := FindClosestCow;
Exit;
end;

Repeat
P := R_TileToMSEx(NPCs[I].Tile, 0, 0, Round(NPCs[I].Height div 2));

MMouse(P.X, P.Y, 4, 4);
Inc(T);
Until(R_WaitUpText('Attack Cow', 90+Random(60)))or(T = 3);

If Not (T = 3)then
begin
GetMousePos(P.X, P.Y);
Mouse(P.X, P.Y, 0, 0, True);
Result := R_WaitCrossHairColor(CROSSHAIR_RED, 800+Random(200));
end;

If Not Result then
begin
R_FindRandoms;
Result := FindClosestCow;
end;

Exit
end;
end;

Procedure PickupItems;
var
Ground: TGroundItemArray;
P: TPoint;
I: Integer;
begin
If InvFull then
Exit;

If R_FindGroundItemsEx([526, 1739], 6, Ground)then
begin
For I:=0 to High(Ground)do
begin
P := R_TileToMS(Ground[I].Tile, 0);
Mouse(P.X, P.Y, 2, 2, False);
R_WaitOptionMulti(['Take Bones', 'Take Cowhide'], 200+Random(100));
Wait(900+Random(600));
Flag;
end;
end;
end;

Procedure BuryBones;
var
Inv: TInvItemArray;
I: Integer;
begin
If R_ItemExistsEx([526], Inv)then
For I:=0 to High(Inv)do
begin
R_ClickItem(Inv[I].Slot, 'Bury');
Wait(1400+Random(400));
end;
end;

function Fight: boolean;
var
T: Integer;
begin
T := GetSystemTime + 2567;
repeat
wait(66)
if (R_GetAnimation > -1) then
Result := true;
until Result or (GetSystemTime > T);
end;

Procedure WaitFight;
var
T: integer;
Begin
If(Not LoggedIn)Then
Exit;

While IsMoving do
Wait(100+Random(100));

T := GetSystemTime + 3500;
Repeat
Wait(100);
if (GetSystemTime > T) then
Exit;
R_FindRandoms;
until Fight;

repeat
wait(50+random(100));
R_FindRandoms;
until(not Fight);
End;


Procedure Report;
begin
end;

begin
SMART_Members := False;
SMART_Server := 32;
SMART_Signed := True;

{Setup}
SetupSRL;
SetupScript;

If Not LoggedIn then
LoginPlayer;

SetAngle(True);
Repeat
If Not LoggedIn then
begin
NextPlayer(False);
SetAngle(True);
end;

If Not R_InCombat then
begin

If FindClosestCow then
begin
Wait(1500+Random(1000));
Flag;
WaitFight;
Wait(700+Random(600));

PickupItems;
If Random(3) = 0 then
BuryBones;
end;
end;
Until(AllPlayersInactive);

end.

Huthaifah

2011-07-21 22:10:24

Very nice, add declare players, would really help. Will try checking out soon.

Wizkid

2011-07-21 22:12:47

Do I have to make a special procedure for declaring my players?
I do declare one? Or is that way wrong? :(

~ WizKid

Huthaifah

2011-07-21 22:15:20

OH sorry never read. But make a special procedure, it's easier to see it lol.

Smarter Child

2011-07-21 23:02:40

This is good for a first script, however I think you should have started with colour. It is more complex, and imo better to learn first so that you do not get lazy and use reflection all the time.

Harry

2011-07-21 23:04:35

Looking cool, I'd suggest more randomness on the mouse though. Also something to tell when someone else is fighting the cow (so you wouldn't attack something that's already in a fight with someone else).

BraK

2011-07-22 04:45:58

From: Smarter Child
This is good for a first script, however I think you should have started with colour. It is more complex, and imo better to learn first so that you do not get lazy and use reflection all the time.


^ this is some very good advice.

From: Harry
Looking cool, I'd suggest more randomness on the mouse though. Also something to tell when someone else is fighting the cow (so you wouldn't attack something that's already in a fight with someone else).


Isn't there a way to see if the NPC is interacting with something already in reflection?

~BraK

litoris

2011-07-22 09:38:00

[Error] (33:11): Unknown identifier 'R_SortNPCs' at line 32
Compiling failed.

Is this R2 or something?

masterBB

2011-07-22 10:04:01

Wooot, looking great! Nice script.

From: litoris
Is this R2 or something?


Yes it is: https://github.com/Drags111/Reflection_Dev/blob/master/lib/animable/characters/NPCs.simba