SRL Archive - SRL Archives

Shortening for some functions in AntiBan.scar


JAD

2009-08-17 05:32:21

Well I'm just getting back into scripting and haven't used the public SvN much, so I hope that this is the right section. Some of these may be wrong I don't know, but I was bored so this is what I found in AntiBan.scar:




procedure HoverSkill(Skill: string; Click: Boolean);
var
TP: TPoint;
Skills: TStringArray;
TheSkill: string;

begin
if not GameTab(tab_Stats) then exit;
if Skill <> 'random' then
TP := SkillToCoords(True, Skill)
else
repeat
Skills := ['attack','defence','strength','hitpoints','mining','smithing','woodcutting','firemaking','magic',
'fletching','hunter', 'summoning','fishing','construction','herblore','agility','thieving','crafting',
'ranged','slayer','farming', 'prayer', 'runecrafting', 'cooking'];
TheSkill := Skills[Random(Length(Skills))];
TP := SkillToCoords(True, TheSkill);
until (TP.x > 0) and (GetSkillLevel(TheSkill) > 1);
if Click then
begin
Mouse(Tp.X, TP.Y, 10, 10, True)
Wait(5000 + Random(9000));
CloseWindow;
end else
begin
MMouse(TP.x, TP.y, 10, 10)
Wait(1000 + Random(3000));
end;
end;

To:


procedure HoverSkill(Skill: string; Click: Boolean);
var
TP: TPoint;
Skills: TStringArray;

begin
if not GameTab(tab_Stats) then exit;
if Skill <> 'random' then
TP := SkillToCoords(True, Skill)
else
repeat
Skills := ['attack','defence','strength','hitpoints','mining','smithing','woodcutting','firemaking','magic',
'fletching','hunter', 'summoning','fishing','construction','herblore','agility','thieving','crafting',
'ranged','slayer','farming', 'prayer', 'runecrafting', 'cooking'];
TP := SkillToCoords(True, Skills[Random(Length(Skills))]);
until (TP.x > 0) and (GetSkillLevel(Skills[Random(Length(Skills))]) > 1);
if Click then
begin
Mouse(Tp.X, TP.Y, 10, 10, True)
Wait(5000 + Random(9000));
CloseWindow;
end else
begin
MMouse(TP.x, TP.y, 10, 10)
Wait(1000 + Random(3000));
end;
end;





procedure PickUpMouse;
var
cx, cy, XX, YY: Integer;

begin
if not LoggedIn then exit;
GetMousePos(cx, cy);
XX := cx;
YY := cy;
if Random(2) = 0 then
MMouse(cx - 3 - Random(5), cy - 8 - Random(17), 0, 0)
else MMouse(cx + 3, cy - 8 - Random(17), 5, 0);
Wait(1131 + Random(358));
if Random(2) = 0 then
MMouse(XX + 3, YY + 8, 5, 9)
else
MMouse(XX - 3 - Random(5), YY + 8, 0, 9);
end;

To:


procedure PickUpMouse;
var
cx, cy: Integer;

begin
if not LoggedIn then exit;
GetMousePos(cx, cy);
if Random(2) = 0 then
MMouse(cx - 3 - Random(5), cy - 8 - Random(17), 0, 0)
else MMouse(cx + 3, cy - 8 - Random(17), 5, 0);
Wait(1131 + Random(358));
if Random(2) = 0 then
MMouse(cx + 3, cy + 8, 5, 9)
else
MMouse(cx - 3 - Random(5), cy + 8, 0, 9);
end;





procedure SayCurrentLevels(Which: string);
var
I: Integer;

begin
if not LoggedIn then exit;
I := 0;
case LowerCase(Which) of
'attack': I := 1;
'strength': I := 2;
'defence': I := 3;
'range': I := 4;
'prayer': I := 5;
'magic': I := 6;
'runecrafting': I := 7;
'hitpoints': I := 8;
'agility': I := 9;
'herblore': I := 10;
'thieving': I := 11;
'crafting': I := 12;
'fletching': I := 13;
'slayer': I := 14;
'mining': I := 15;
'smithing': I := 16;
'fishing': I := 17;
'cooking': I := 18;
'firemaking': I := 19;
'woodcutting': I := 20;
'farming': I := 21;
else
srl_Warn('SayCurrentLevels', '"' + which + ' " is not a valid level', 0);
end;
if I < 1 then exit;
Players[CurrentPlayer].Level[I] := GetSkillInfo(Which, False);
TypeSend(IntToStr(Players[CurrentPlayer].Level[i]));
end;

To:


procedure SayCurrentLevels(Which: string);
var
I: Integer;
Skills: TStringArray;

begin
if not LoggedIn then exit;
Skills := ['attack','defence','strength','hitpoints','mining','smithing','woodcutting','firemaking','magic',
'fletching','hunter', 'summoning','fishing','construction','herblore','agility','thieving','crafting',
'ranged','slayer','farming', 'prayer', 'runecrafting', 'cooking'];
for i := 0 to 20 do
if(Skills[i] = LowerCase(Which))then
begin
Players[CurrentPlayer].Level[I] := GetSkillInfo(Which, False);
TypeSend(IntToStr(Players[CurrentPlayer].Level[i]));
Exit;
end;
srl_Warn('SayCurrentLevels', '"' + which + ' " is not a valid level', 0);
end;

Neehosoft

2009-08-17 05:52:33

Nice. Compiles for me.

ZephyrsFury

2009-08-17 06:45:07

I added the last one. The other two are just remove variables which I'm not too interested in. Thanks anyway. Good to see you getting back into this. :)

JAD

2009-08-17 06:53:02

From: ZephyrsFury
I added the last one. The other two are just remove variables which I'm not too interested in. Thanks anyway. Good to see you getting back into this. :)


Yeah wasn't too big of changes on the first 2, but I just thought those variables were pretty unnecessary from what I saw.

Smarter Child

2009-08-18 02:28:21

Yes, good job, the first two aren't much of a change, but the last one is great :).