Naum
2009-06-15 21:31:24
function SetUpAutoCast(AutoSpell: string; Defensive: Boolean): Boolean;
var
X, Y, Col, Row, Msk: Integer;
TB : TBox;
Spells, ColArray : TVariantArray;
begin
if not GameTab(1) then exit;
if Defensive then
Mouse(655, 253, 50, 25, True)
else Mouse(665, 320, 50, 25, True);
Wait(2000 + Random(1500));
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'];
ColArray := [16579836, 16579836, 3003805, 835570];
Try Msk := StrToIntDef(AutoSpell, -1) Except end;
If Msk <> -1 Then
Row := Trunc(Msk Div 4) + 1
Else
For Msk := 0 to High(Spells) Do
If AutoSpell = Spells[Msk] Then
Row := Trunc(Msk Div 4) + 1;
If (Msk Mod 4) = 0 Then Dec(Row);
Col := Msk Mod 4;
If Col = 0 Then Col := 4;
TB.x1 := 571 + 40 * (Col - 1);
TB.y1 := 229 + 60 * (Row - 1);
TB.x2 := TB.x1 + 40;
TB.y2 := TB.y1 + 60;
For Msk := 0 to High(Spells) Do
case LowerCase(AutoSpell) of
Spells[Msk], IntToStr(Msk) : Result := FindColor(X, Y, ColArray[Msk Mod 4], TB.x1, TB.y1, TB.x2, TB.y2);
end;
If Result <> True Then
begin
srl_Warn('SetUpAutoCast', '"' + AutoSpell + '" is not a valid autocasting spell.', -2);
Mouse(687, 448, 9, 4, True); // Exits the autocasting spells setup 'popup'.
end;
if Result then Mouse(X, Y, 2, 2, True);
end;The old one went through all the find colors. It is also a bit faster. :). Moreover, I changed the co-ords a bit so it would actually cancel the pop-up correctly.
Open to any criticism.
Also this has only been tested on around 7 prayers as that's all the quick prayers my character can do. Testing would be appreciated :)