HAI. Please comment.
1:
SCAR Code:
function FindDead: Boolean;
begin
if not LoggedIn then exit;
Result := FindTextTPA(0, 0, MCX1, MCY1, MCX2, MCY2, 'dear', SmallChars, Nothing);
if not Result then exit;
Inc(Deaths);
SaveToChatLog;
if Reincarnate then exit;
if ScreenShots then
TakeScreen('Found Dead');
if not LogOut then
repeat
Wait(1000 + Random(1000));
until not LoggedIn;
Players[CurrentPlayer].Rand := 'Died';
Players[CurrentPlayer].Active := False;
end;
Shortened.
2: FindLamp skill coords can be shortened using simple maths.
3:
SCAR Code:
function InBlack: Boolean;
var
I: Byte;
begin
if not LoggedIn then exit;
for I := 1 to 4 do
begin
case I of
1: Result := ((GetColor(650, 155) = 65536) and (GetColor(650, 145) = 65536)
and (GetColor(650, 135) = 65536) and (GetColor(650, 125) = 65536));
2: Result := ((GetColor(650, 15) = 65536) and (GetColor(650, 25) = 65536)
and (GetColor(650, 35) = 65536) and (GetColor(650, 45) = 65536));
3: Result := ((GetColor(580, 82) = 65536) and (GetColor(590, 82) = 65536)
and (GetColor(600, 82) = 65536) and (GetColor(610, 82) = 65536));
4: Result := ((GetColor(714, 82) = 65536) and (GetColor(704, 82) = 65536)
and (GetColor(694, 82) = 65536) and (GetColor(684, 82) = 65536));
end;
if Result then exit;
end;
end;
Shortened by lots.
4:
SCAR Code:
function NoGameTab: Boolean;
var
I: Byte;
begin
Result := False;
if not LoggedIn then exit;
for I := 1 to 14 do
if not TabExists(I) then
begin
Result := True;
Exit;
end;
end;
I really don't understand the current NoGameTab in Rev#20. No randomness in waiting, and why wait a second if it finds a missing GameTab?
5:
SCAR Code:
function IntArrayMatch(Ar1, Ar2: TIntegerArray): Boolean;
var
I, L: Integer;
begin
Result := False;
L := High(Ar1);
if L <> High(Ar2) then exit;
for I := 0 to L do
if not InIntArray(Ar2, Ar1[I]) then exit;
Result := True;
end;
Minor fixes.
6: I think DwarfItem should be added to Dwarf Handler.
7:
SCAR Code:
function FindNonInventoryRandoms: Boolean;
var
I: Byte;
begin
if not LoggedIn then exit;
for I := 1 to 5 do
begin
case I of
1: Result := SolveNonTalkingRandoms; // Why not "Result := .." ?
2: Respond;
3: Result := FindTalk;
4: Result := FindDead;
5: Result := RC;
end;
if Result then exit;
end;
end;
Minor fixes again.
8:
SCAR Code:
function FindNormalRandoms: Boolean;
var
I: Byte; // 0..255 and -2147483648..2147483648.
begin
Result := False;
if not LoggedIn then exit;
for I := 1 to 8 do
begin
case I of
1: Result := SolveNonTalkingRandoms; // Again, why not "Result := .." ?
2: Respond;
3: Result := FindTalk;
4: Result := FindDead;
5: Result := FindLamp(LampSkill);
6: Result := (FindBox) and (SolveBox);
7: Result := RC;
8: Result := FindMod;
end;
if Result then exit;
end;
end;
Again, just small fixes..
9
was a fail.
10: What's the use of GambleNewBox?
11:
SCAR Code:
{*******************************************************************************
Description: Results: 0 if nothing found, 1 for first and 2 for second screen.
Coords are taken from current TradeScreen and TradeScreen2 functions.
*******************************************************************************}
function TradeScreen: Byte;
begin
Result := 0;
if GetColor(90, 61) = 2070783 then
Result := 1
else
if GetColor(142, 55) = 0 then
Result := 2;
end;
Combined the two TradeScreen functions.
12:
SCAR Code:
function CheckArea(Area: string): Boolean;
begin
Result := False;
case LowerCase(Area) of
'inv', 'inventory': Result := (BankScreen or ShopScreen or TradeScreen or GameTab(4));
'shop': Result := ShopScreen;
'bank': Result := BankScreen; // What if user doesn't want to fix bank..?
'trade', 'your trade': Result := TradeScreen;
else
srl_Warn('CheckArea', Area + ' is an invalid option', warn_AllVersions);
end;
if not Result then
WriteLn('PROBLEM: ' + Area + ' interface not open'); // I'm not sure if thats
end; // even needed.
Shortened.
13:
SCAR Code:
procedure RandomRClick; // Why evade simplicity?
var
M: Byte;
begin
if not LoggedIn then exit;
M := MouseSpeed;
MouseSpeed := 7 + Random(4);
ActivateClient;
MouseBox(MSX1, MSY1, MIX2, MIY2, 2);
MouseSpeed := M;
end;
Replaced with one single MouseBox.
14:
SCAR Code:
procedure FixBank;
var
X, Y, T: Integer;
begin
if (BankScreen) and (GetColor(486, 103) = 1975337) then
begin
MMouse(486, 105, 3, 3);
GetMousePos(X, Y);
HoldMouse(X, Y, True); // Random(1) allways returns 0..
T := GetSystemTime;
repeat
Wait(30 + Random(50));
if GetSystemTime - T > 10000 then break;
until GetColor(486, 103) <> 1975337;
Wait(300 + Random(300));
ReleaseMouse(X, Y, True);
end;
end;
UUh. Shortened and removed the Random(1)'s.
15:
SCAR Code:
function Flag: Boolean; // Small change..
var
timeout, x, y: Integer;
begin
if not LoggedIn then exit;
Result := FindColor(X, Y, 255, MMX1, MMY1, MMX2, MMY2);
if Result then
repeat
Wait(100);
Inc(Timeout);
until (not FindColor(x, y, 255, MMX1, MMY1, MMX2, MMY2)) or (Timeout > 300);
end;
Shortened.
16:
SCAR Code:
procedure MouseFlag(CX, CY, RandX, RandY, Dist: Integer); // <- Uses FFlag(Dist)
var
I: Byte;
begin
if not LoggedIn then exit;
Mouse(CX, CY, RandX, RandY, True);
repeat
Wait(50 + Random(50));
Inc(i);
until (FlagPresent) or (I < 15);
FFlag(Dist);
Wait(500 + Random(350));
end;
I think I shortened it? And more importantly, replaced Flag with FFlag and added dist parameter.
17:
SCAR Code:
Procedure ChatsOff;
var
I: Byte; // INTEGER NAZI PEOPLE!!!11
begin
if not LoggedIn then exit;
for I := 1 to 5 do
SetChat('off', I);
end;
Very small change.
18: GetCurrentTab and TabExists can be shortened with simple maths.
19: Please remove my name from the "Retaliate" function credits.
20: SkillToCoords should also be shortened using maths.
21:
SCAR Code:
{*******************************************************************************
Replaces MouseItem and MMouseItem. 8D
*******************************************************************************}
procedure MouseItem(I, ClickType: Byte);
var
TB: TBox;
begin
if not LoggedIn then exit;
if not GetCurrentTab = 4 then
begin
if not GameTab(4) then exit;
Wait(500 + Random(350));
end;
GetInvItemBounds(I, TB);
MouseBox(TB.X1 + 4, TB.Y1 + 4, TB.X2 - 4, TB.Y2 - 4, ClickType);
end;
Small function to replace both MouseItem and MMouseItem.
SCAR Code:
{*******************************************************************************
Small fix + "uptated" for use with new MouseItem, if it will be used.
*******************************************************************************}
procedure DragItem(Inv1, Inv2: Byte);
var
X, Y: Integer;
begin
if not LoggedIn then exit;
MouseItem(Inv1, 3);
GetMousePos(X, Y);
HoldMouse(X, Y, True);
Wait(150 + Random(150));
MouseItem(Inv2, 3);
GetMousePos(X, Y);
ReleaseMouse(X, Y, True);
Wait(350 + Random(350));
end;
"Updated" for the new MouseItem, if you people decide to use it..
SCAR Code:
{*******************************************************************************
If the items are unloaded, they'll appear a little later than the gametab switch..
*******************************************************************************}
function ExistsItem(I: Byte): Boolean;
var
X, Y: Integer;
TB: TBox;
begin
Result := False;
if not LoggedIn then exit;
if not GetCurrentTab = 4 then
begin
if not GameTab(4) then exit;
Wait(500 + Random(350));
end;
TB := InvBox(i);
Result := FindColor(x, y, 65536, TB.x1 + 5, TB.y1 + 5, TB.x2 - 5, TB.y2 - 5);
end;
I noticed a lot of use of Integers where Bytes could be used. An integer has a value of -2147483648..2147483648, while a Byte has a value of 0..255. Saves soem memory and looks prettier. IMO. And also, SmallInt could be used in some places, but I'm currently experiencing some trouble with that, so I decided not to use that var type, in case the problam was global.
Anyway, see proc description.
SCAR Code:
{*******************************************************************************
Same as above + more small fixes.
*******************************************************************************}
function InvCount: Byte;
var
I: Byte;
begin
Result := 0;
if not LoggedIn then exit;
if not GetCurrentTab = 4 then
begin
if not GameTab(4) then exit;
Wait(500 + Random(350));
end;
for I := 1 to 28 do
if ExistsItem(I) then Inc(Result);
end;
@Description();
SCAR Code:
function InvFull: Boolean; // ^^^
begin
Result := False;
if not LoggedIn then exit;
if not GetCurrentTab = 4 then
begin
if not GameTab(4) then exit;
Wait(500 + Random(350));
end;
Result := InvCount = 28;
end;
@DescriptionOfProcAbove();
SCAR Code:
function DropItem(i: Byte): Boolean;
begin
Result := False;
if (not LoggedIn) or (not ExistsItem(i)) then exit;// Existsitem switches gametabs..
MouseItem(I, 2); // New MouseItem..
Wait(170 + Random(150));
Result := ChooseOption('rop');
Wait(RandomRange(50, 200));
end;
All I had time for, please leave comments for me to read when I get back. 
Thanks.