Hi mate.
Is certainly a good attempt at the script.
Have some feedback for you
Flight added a magic include that I wrote to Aerolib a while back. You can find it in
..Simba\Includes\AeroLib\core\gametabs\magic.simba
This include has all of the current spells listed for standard, lunar and ancient spell books.
You can use it like so:
Simba Code:
procedure SelectSpell;
begin
if not IsSpellSelected then
if CastSpell('Curse') then
writeln('We have now selected the spell');
end;
This will check to see if we already have a spell selected, and if not, will select 'Curse' from the spell book.
Another way to do it, is to use the include to get the spellbox and then use your own mouse functions to click on it, like so:
Simba Code:
function BoxMidPoint(Box:TBox):tpoint;
begin
Result.x := Round((Box.x2 - Box.X1) / 2);
Result.y := Round((Box.y2 - Box.y1) / 2);
end;
procedure SelectSpell;
begin
if not IsSpellSelected then
begin
MissMouse(BoxMidPoint(getSpellBox('Curse')), 2, 2);
FastClick(MOUSE_LEFT);
writeln('Moved our mouse to the spell and selected it.');
end;
end;
The first function
BoxMidPoint is to simply get the mid point of a TBox. There is probably a simpler way to do this but I thought I would make my own
The procedure
SelectSpell will check to see if a spell is selected, and if not, use the
MissMouse function to select the spell, using the co-ordinates it got from the
GetSpellBox function and the
BoxMidPoint function.
Also, for future reference, you are loading your DTM and then immediately freeing it, before trying to call it with .interact on a type that does not support that function.
A better way to do it would have been to declare
MagicM as a
TItem and then declared its DTM at the start of your script
Simba Code:
MagicM.DTM := DTMFromString('BlahBlahBlah');
The only issue is this will no work with spells, as the TItem type is used exclusively with inventory (and sometimes bank).
If you wanted to create a DTM for the spell, you could declare if as you have, by setting the type for MagicM as an integer, and declaring the DTM at the start of your script (not every loop).
You could then use a build in function to find the DTM on the magic tab:
Simba Code:
program new;
{$i AeroLib/AeroLib.Simba}
var
MagicM:integer;
function FindCurseSpell:boolean;
var
x, y:integer;
begin
if GameTab(TAB_MAGIC) then
if FindDTM(MagicM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
MissMouse(Point(x, y), 2, 2);
exit(true);
end;
end;
begin
InitAL;
MagicM := DTMFromString('BlahBlahBlah');
FindCurseSpell;
FreeDTM(MagicM);
end.
I will post more feedback when I am home from work.