Self explanatory.
I really don't know why there aren't functions like these in Magic.scar already... IsCasting-function has been discussed many many times.
SCAR Code:
function RuneCount(Slots: TIntegerArray): Integer;
var
B: TBox;
I: Integer;
begin
if (not LoggedIn) then Exit;
GameTab(Tab_Inv);
for I := 0 to High(Slots) do
begin
B := InvBox(Slots[I]);
IncEx(Result, GetAmount(B.X1 + (B.X2 - B.X1) div 2, B.Y1 + (B.Y2 - B.Y1) div 2));
end;
end;
function CastingMagic(RuneSlots: TIntegerArray): Boolean;
var
I, T: Integer;
begin
if (not LoggedIn) then Exit;
I := RuneCount(RuneSlots);
T := GetSystemTime + 3700 + Random(100);
repeat
Wait(10);
if (RuneCount(RuneSlots) < I) then
begin
Result := True;
Exit;
end;
until(GetSystemTime > T);
end;
E: Oh, I forgot these 3 I made for combat spells:
SCAR Code:
procedure m_FixSpellBookCombat;
var
X, Y: Integer;
begin
GameTab(tab_Magic);
Y := 441;
if GetColor(591, 441) <> 16777215 then
begin
Mouse(592, 450, 4, 4, True);
Wait(600 + Random(100));
end;
for X := 0 to 2 do
begin
if GetColor(613 + X*22, Y) = 16777215 then
begin
Mouse(613 + X*22, Y + 11, 3, 3, True);
Wait(600 + Random(100));
end;
end;
if GetColor(705, 441) <> 16777215 then
begin
Mouse(703, 450, 3, 3, True);
Wait(600 + Random(100));
end;
end;
function m_SpellCoords(Spell: String): TPoint;
var
Spells: TStringArray;
Num: Integer;
B: TBox;
begin
Spells := ['wind strike', 'water strike', 'earth strike', 'fire strike',
'wind bolt', 'water bolt', 'earth bolt', 'fire bolt', 'wind blast',
'water blast', 'earth blast', 'fire blast', 'wind wave',
'water wave', 'earth wave', 'fire wave'];
if not InStrArrEx(LowerCase(Spell), Spells, Num) then
if (StrToIntDef(GetNumbers(Spell), -1) > 0) then
Num := StrToInt(GetNumbers(Spell)) -1;
if Num < 0 then
begin
WriteLn('*** m_SpellCoords failed! ''');
Exit;
end;
case Num of
0..3: begin
B.X1 := 563 + 23*Num;
B.Y1 := 221;
end;
4..7:begin
B.X1 := 563 + 23*(Num-4);
B.Y1 := 248;
end;
8..10:begin
B.X1 := 563 + 23*(Num - 8);
B.Y1 := 270;
end;
11..13:begin
B.X1 := 563 + 23*(Num - 11);
B.Y1 := 293;
end;
end;
B.X2 := B.X1 + 23;
B.Y2 := B.Y1 + 15;
Result := Point(B.X1 + (B.X2-B.X1)/2, B.Y1 + (B.Y2-B.Y1)/2);
end;
procedure m_SetUpAutoCast(Spell: string);
var
D, X, Y: Integer;
P: TPoint;
begin
D := DTMFromString('78DA6334666260B8CD00064C108AE1FFFFFF0' +
'C22409A11CA67B425428D0B116ADC80320F8950F382801A47A0CC' +
'7B026A4C8850630494798A5B0D90FD1F002C8B25B9');
GameTab(tab_Magic);
P := m_SpellCoords(Spell);
if (not FindDTM(D, X, Y, P.x-22, P.y-22, P.x+22, P.y+22)) then
begin
Mouse(P.X, P.Y, 3, 3, False);
WaitOption('uto', 1000 + Random(200));
Wait(200 + Random(100));
end;
FreeDTM(D);
end;