const
MiniCreatureHP = 90; //Ilosc % przy ktorym cie leczy.
Targetlist = ['Chansey']; //nick.
Range = 8 //Bez zmian
Pot = 3161
var
Creature: TCreature;
CreatureName: string;
function GetCreatureByName: TCreature;
var
x: integer;
begin
Result := nil;
for x := 0 to Creatures.Count - 1 do
begin
if x >= Creatures.Count then Break;
if Creatures.Creature[x].Z = Self.Z then
for i := low(TargetList) to high(targetlist) do
if Creatures.Creature[x].Name = TargetList then
begin
Result := Creatures.Creature[x];
Exit;
end;
end;
end;
function IsCreatureAttackable(c: TCreature): boolean;
begin
UpdateWorld;
Result := False;
if (c.Z = self.Z) and (abs(c.X-self.X) <= Range) and (abs(c.Y-self.Y) <= Range) and (c.outfit<>0) then
begin
Result := True;
end;
end;
begin
while not Terminated do
begin
UpdateWorld;
Creature := GetCreatureByName;
for i := low(targetlist) to high(targetlist) do
if Creature <> nil then
if (TargetList = Creature.Name) and (IsCreatureAttackable(Creature)) then
if ((Creature.Health) <(MiniCreatureHP)) then
Self.Containers.UseItemWithCreature(Pot,Creature);
Sleep(50);
end;
end;
Jak to zrobić żeby używał potiona gdy nie ma potwora na ekranie lub gdy wszystko zabite???