ahmednageib
New Member
- Joined
- Mar 5, 2010
- Messages
- 4
- Reaction score
- 0

by slime

function IsCreatureBesideYou(c: TCreature): boolean;
begin
UpdateWorld;
if (abs(c.X-self.X) <= 1) and (abs(c.Y-self.Y) <= 1) then begin
if c.Z = self.Z then begin
Result := True;
Exit;
end;
end;
Result := False;
end;
function GetCreatureByName(Name: string): 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].Name = Name) and (not IsCreatureBesideYou(Creatures.Creature[x])) and (Creatures.Creature[x].Visible) then
begin
Result := Creatures.Creature[x];
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;
begin
While not Terminated do
begin
UpdateWorld;
if not Self.Attacking then
begin
Monster := GetCreatureByName('Slime');
if Monster <> nil then Monste****ttacking := True;
end else begin
Creature := GetCreatureByID(Self.Attacking);
if Creature <> nil then
begin
if not Creature.Visible then
begin
Monster := GetCreatureByName('Slime');
if Monster <> nil then Monste****ttacking := True;
end;
end;
end;
Sleep(1000);
end;
end;
function Attacking: boolean;
begin
UpdateWorld;
for x := 0 to Creatures.Count - 1 do
begin
UpdateWorld;
if Creatures.Creature[x].Attacking then
begin
Result := True;
Exit;
end;
end;
Result := False;
Exit;
end;
function GetFollowedCreatureID: integer;
begin
UpdateWorld;
for x := 0 to Creatures.Count - 1 do
begin
UpdateWorld;
if Creatures.Creature[x].Following then
begin
Result := Creatures.Creature[x].ID;
Exit;
end;
end;
end;
var
MotherSlime, X1, Y1: integer;
begin
MotherSlime := GetFollowedCreatureID;
while not Terminated do
begin
UpdateWorld;
if not Attacking then
begin
UpdateWorld;
for x := 0 to Creatures.Count - 1 do
begin
UpdateWorld;
if Creatures.Creature[x].ID <> MotherSlime then
begin
if (Creatures.Creature[x].Name <> Self.Name) and Creatures.Creature[x].NPC then
begin
UpdateWorld;
X1 := Creatures.Creature[x].X;
Y1 := Creatures.Creature[x].Y;
if (X1 - Self.X = 1) or (X1 - Self.X = 0) or (X1 - Self.X = -1) then
begin
UpdateWorld;
if (Y1 - Self.Y = 1) or (Y1 - Self.Y = 0) or (Y1 - Self.Y = -1) then
begin
Creatures.Creature[x].Attacking := true;
Break;
end;
end;
end;
end;
end;
end;
Sleep(1000);
end;
end;