Usar Magia para Atacar


const

Delay = 1000;
Magic = exori con; // nome da magia
MinimumManaToCast = 40; // mana que precisa para soltar a magia
MinimumMonsterHealth = 0; // ate x porcentagem vai usar a magia
SpellRange = 8; // distancia do monstro

function GetCreatureByID(ID: integer): TCreature;
var
x: integer;
begin
Result := nil;
for x := 0 to Creatures.Count - 1 do
if Creatures.Creature[x].ID = ID then
Result := Creatures.Creature[x];
end;

var
Attacking : TCreature;
Range: Integer;
begin
while not Terminated do
begin
UpdateWorld;

Attacking:=GetCreatureByID(Self.Attacking);
if (Assigned(Attacking)) then
begin
Range := Round(Sqrt(Sqr(Self.X - Attacking.X) + Sqr(Self.Y - Attacking.Y)));
if (Range <= SpellRange) and (Attacking.Health >= MinimumMonsterHealth) and (Self.Mana >= MinimumManaToCast) then
Self.Say('Magic');
end;

Sleep(Delay);
end;
end;