Le Jingle
2012-10-16 01:29:40
Meh, probably could be moved to snippets, but I thought it may be useful enough to make the include considering it's a nice fail safe to check with before trying to teleport with some DTM or such. I've a feeling I've seen the idea before in another script, but I can't remember where. :s (probably is better than this too). Not to mention, feel free to mod the code for easier readability and/or less code (could be done, but I'm not that pro).
Anywho, hope this helps.
(ex. visually of what this exactly organizes)

Cheers,
Lj
Edit : could replace the out-dated code in "Includes\SRL\SRL\skill\magic.simba", specifically the ClickSpellMode & SetSpellMode procedures.
Anywho, hope this helps.
(ex. visually of what this exactly organizes)

{
Regular Spell's = Cmb/Tele/Misc/Skill
Lunar Spell's = Cmb/Tele/Misc
Ancient Spell's = Cmb/Tele
Example of Useage:
TBoolArray paramater;
- false = no white outline expected, hence we'll make sure it's not outlined
- true = white outline expcected, hence we'll make sure it's outlined/used.
if OrganizeSpellBook('regular', [false, false, false, true]) then
writeln('Only showing the last regular magic spells [which is skills]');
}
function OrganizeSpellBook(Spells:String; FilterOrder:TBoolArray): boolean;
var
i: integer;
cc: integer; // color count (white color color count)
indexBool: array of boolean; // stores the temp state of the filter boxes
begin
result := false;
if not loggedin then
exit;
if (GetCurrentTab <> tab_magic) then
GameTab(tab_magic);
case Spells of
'regular':
begin
if (Length(FilterOrder) <> 4) then
begin
SRL_Warn('OrganizeSpellBook', 'Faulty amount of True/False in '
+ 'TBoolArray', Warn_AllVersions);
exit;
end;
SetLength(indexBool, 4); // There are 4 options in regular spell book.
for i := 0 to 3 do
begin
cc := CountColorTolerance(16711422, MIX1+35+(i*21), MIY2-31,
MIX1+56+(i*21), MIY2-1, 1);
if (inRange(cc, 75, 78)) then
indexBool[i] := True;
if (not FilterOrder[i]) and indexBool[i] then
begin
MouseBox(MIX1+35+(i*21), MIY2-31, MIX1+56+(i*21), MIY2-1, mouse_left);
result := true;
end else
if FilterOrder[i] and (not indexBool[i]) then
begin
MouseBox(MIX1+35+(i*21), MIY2-31, MIX1+56+(i*21), MIY2-1, mouse_left);
result := true;
end;
end;
end;
'lunar':
begin
if (Length(FilterOrder) <> 3) then
begin
SRL_Warn('OrganizeSpellBook', 'Faulty amount of True/False in '
+ 'TBoolArray', Warn_AllVersions);
exit;
end;
SetLength(indexBool, 3); // There are 3 options in lunar spell book.
for i := 0 to 2 do
begin
cc := CountColorTolerance(16711422, MIX1+37+(i*27), MIY2-31,
MIX1+64+(i*27), MIY2-1, 1);
if (inRange(cc, 75, 78)) then
indexBool[i] := True;
if (not FilterOrder[i]) and indexBool[i] then
begin
MouseBox(MIX1+37+(i*27), MIY2-31, MIX1+64+(i*27), MIY2-1, mouse_left);
result := true;
end else
if FilterOrder[i] and (not indexBool[i]) then
begin
MouseBox(MIX1+37+(i*27), MIY2-31, MIX1+64+(i*27), MIY2-1, mouse_left);
result := true;
end;
end;
end;
'ancient':
begin
if (Length(FilterOrder) <> 2) then
begin
SRL_Warn('OrganizeSpellBook', 'Faulty amount of True/False in '
+ 'TBoolArray', Warn_AllVersions);
exit;
end;
SetLength(indexBool, 2); // There are 2 options in ancient spell book.
for i := 0 to 1 do
begin
cc := CountColorTolerance(16711422, MIX1+49+(i*36), MIY2-31,
MIX1+84+(i*36), MIY2-1, 1);
writeln(cc);
if (inRange(cc, 75, 78)) then
indexBool[i] := True;
if (not FilterOrder[i]) and indexBool[i] then
begin
MouseBox(MIX1+49+(i*36), MIY2-31, MIX1+69+(i*36), MIY2-1, mouse_left);
result := true;
end else
if FilterOrder[i] and (not indexBool[i]) then
begin
MouseBox(MIX1+49+(i*36), MIY2-31, MIX1+69+(i*36), MIY2-1, mouse_left);
result := true;
end;
end;
end;
end;
end;
Cheers,
Lj
Edit : could replace the out-dated code in "Includes\SRL\SRL\skill\magic.simba", specifically the ClickSpellMode & SetSpellMode procedures.