Autor Wiadomość
jabol123
PostWysłany: Czw 20:48, 05 Mar 2009    Temat postu: Ignore Monster

Skrypt będzie ignorował monstera uprzednio wpisanego w jego treść.


Kod:

Const
 Ignore='Monk'; // wpisujemy nazwe potwora ktorego nie bedzie attakowac
var x : integer;
Looting:boolean;

function Attacking : boolean;
var x : integer;
begin
Result := False;
for x := 0 to Creatures.Count - 1 do
begin
if x >= Creatures.Count then Break;
if Creatures.Creature[x].Attacking then
begin
Result := True;
Exit;
end;
end;
end;

function PlayerOnScreen : Boolean;
var
  x: integer;
begin
  Result := False;
  for x := 0 to Creatures.Count - 1 do
  begin
    if x >= Creatures.Count then Break;
    if Creatures.Creature[x].z=self.z then
    if Creatures.Creature[x].Name<>Self.Name then
    if not Creatures.Creature[x].NPC then
    begin
      Result :=true;
      Exit;
    end;
  end;
end;

function GetCreatureByID(ID: integer): 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].ID = ID then
    begin
      Result := Creatures.Creature[x];
      Exit;
    end;
  end;
end;


function FindClosest : integer;
var i, l, closest_num, closest_range, last_closest_range : integer;
begin
if not attacking then
begin
closest_num := -1;
last_closest_range := 5000;
for i := 0 to Creatures.Count - 1 do
if (Creatures.Creature[i].Z = Self.Z) then
if (Creatures.Creature[i].NPC = true) then
if (Ignore<>Creatures.Creature[i].Name) then
begin
closest_range := Round(Sqrt(Sqr(Self.X - Creatures.Creature[i].X)) + Sqr(Self.Y - Creatures.Creature[i].Y));
if (closest_range < last_closest_range) then
begin
last_closest_range := closest_range;
closest_num := i;
end;
end;
Result := closest_num;
Exit;
end;
end;

var found, Bla,y : integer;
begin
updateworld;
Bla:=Self.Containers.Count;
Looting:=false;
while not terminated do
begin
UpdateWorld;
if Self.Containers.Count>Bla then begin D:=Self.Containers.Count; Looting:=true; end;
if (Looting=true) then
                begin
                updateworld;
                Z:=self.x;
                y:=self.y;
                Self.DisplayText('Looting');
                repeat
                sleep(200);
                updateworld;
                until (Z<>Self.x) or (y<>self.y);
                Looting:=false;
                Self.DisplayText('Finished looting');
                end;
updateworld;
found := FindClosest;
if (found <> -1) then
if (attacking=false) and (PlayerOnScreen=false) and (Looting=false) then
Creatures.Creature[found].Attacking := true;
Sleep(1000);
end;
end;


Uwagi dodatkowe:
Jeżeli skrypt by nie działał możliwe jest ze trzeba odznaczyć Target All

Powered by phpBB © 2001, 2005 phpBB Group