SRL Archive - SRL Archives

New Magic (SetUpAutoCast)


Narcle

2008-10-07 17:25:42

CastPoint really isn't needed. But I made it on a wim for fast casting for some scripts (no bmp searching).
AutoCastPoint is required for the new SetUpAutoCast.
SetUpAutoCast is based off Wizzup's in Magic.scar. I haven't fully tested it - I haven't confirmed that the colors work for all.

I mainly redid/made these so I can eventually use it in couple of my fighters. (hint hint)


{*******************************************************************************
function CastPoint(i: integer): TPoint;
By: Narcle
Description: Returns TPoint of cast location (Regular spells)
1 - 63; 1 = Home Teleport, 7 = Earth Strike, 63 = Teleother Camelot, etc.
*******************************************************************************}
function CastPoint(i: integer): TPoint;
var
ModX, ModY: integer;
begin
if (i < 1) or (i > 63) then
begin
srl_Warn('CastPoint', 'Incorrect index: ' + IntToStr(i), warn_AllVersions);
Exit;
end;
ModX := i mod 7;
if ModX = 0 then ModX := 7;
ModY := (i - 1) / 7 + 1;
Result.x := 546 + ModX * 24;
Result.y := 214 + ModY * 24;
end;

{*******************************************************************************
function AutoCastPoint(i: integer): TPoint;
By: Narcle
Description: Returns TPoint of auto cast location (Regular spells)
*******************************************************************************}
function AutoCastPoint(i: integer): TPoint;
var
ModX, ModY: integer;
begin
if (i < 1) or (i > 16) then
begin
srl_Warn('AutoCastPoint', 'Incorrect index: ' + IntToStr(i), warn_AllVersions);
Exit;
end;
ModX := i mod 4;
if ModX = 0 then ModX := 4;
ModY := (i - 1) / 4 + 1;
Result.x := 542 + ModX * 40;
Result.y := 176 + ModY * 62;
end;

{*******************************************************************************
function SetUpAutoCast(AutoSpell: string; Defensive: Boolean): Boolean;
By: Narcle, Based off Wizzup?'s
Description: Set's up the spell you want to autocast, wielding a staff is
required. Returns true if spell was setup.
*******************************************************************************}
function SetUpAutoCast(AutoSpell: string; Defensive: Boolean): Boolean;
var
P, M: TPoint;
SpellNum, Color: integer;
begin
GameTab(1);
case Defensive of
True: Mouse(660, 260, 56, 32, True);
False: Mouse(660, 320, 56, 32, True);
end;
Wait(1000 + Random(500));
Case LowerCase(AutoSpell) of
'wind strike', '1': SpellNum := 1;
'water strike', '2': SpellNum := 2;
'earth strike', '3': SpellNum := 3;
'fire strike', '4': SpellNum := 4;
'wind bolt', '5': SpellNum := 5;
'water bolt', '6': SpellNum := 6;
'earth bolt', '7': SpellNum := 7;
'fire bolt', '8': SpellNum := 8;
'wind blast', '9': SpellNum := 9;
'water blast', '10': SpellNum := 10;
'earth blast', '11': SpellNum := 11;
'fire blast', '12': SpellNum := 12;
'wind wave', '13': SpellNum := 13;
'water wave', '14': SpellNum := 14;
'earth wave', '15': SpellNum := 15;
'fire wave', '16': SpellNum := 16;
else
begin
srl_Warn('SetUpAutoCast', 'Incorrect Spell: ' + AutoSpell, warn_AllVersions);
Exit;
end;
end;
P := AutoCastPoint(SpellNum);
Case ((P.x - 542) / 40) of
1: Color := 12632764;//Wind
2: Color := 16349818;//Water
3: Color := 307460;//Earth
4: Color := 225773;//Fire
end;
if FindColor(M.x, M.y, Color, P.x-12, P.y-12, P.x+12, P.y+12) then
begin
Mouse(P.x-6, P.y-6, 12, 12, True);
Wait(500 + Random(500));
Result := True;
end
else
Mouse(692, 450, 22, 10, true);//Clicks Cancel
end;

Naike

2008-10-08 16:56:25

Nice work really needed :)
Looks really good :o