var
koniec:boolean;
mon1,mon2:creature;
function HowMuchAtk:integer;
var
x,i:integer;
begin
UpdateWorld;
i:=0;
result:=0;
for x := 0 to Creatures.Count - 1 do
begin
if (Abs(Creatures.Creature[x].X - Self.X) <= 1) and
(Abs(Creatures.Creature[x].Y - Self.Y) <= 1) and
(Creatures.Creature[x].Z = Self.Z) and
(Creatures.Creature[x].NPC) then result:=result+1;
end;
end;
procedure checklife;
var
i,x:integer;
cont:tcontainer;
begin
updateworld;
for i:=0 to self.Containers.count-1 do
begin
for x:=0 to self.containers.container[i].count-1 do
begin
if self.containers.container[i].item[x].id = 2874 then
begin
cont:=self.containers.container[i];
self.containers.container[i].item[x].usewithself;
sleep(100);
if cont.count = 20 then cont.item[cont.count-1].movetoground(self.x,self.y,self.z,0);
cont.item[cont.count-1].movetocontainer(cont,0,0);
break;
exit;
end;
end;
end;
end;
procedure Event_Message(Channel: integer; Name, Text: String);
begin
if (name=self.name) and (text='stop') then koniec:=true;
end;
procedure GetMonsters;
var
x,i:integer;
begin
UpdateWorld;
i:=0;
for x := 0 to Creatures.Count - 1 do
begin
if (Abs(Creatures.Creature[x].X - Self.X) <= 1) and
(Abs(Creatures.Creature[x].Y - Self.Y) <= 1) and
(Creatures.Creature[x].Z = Self.Z) and
(Creatures.Creature[x].NPC) then
begin
if i=0 then
begin
mon1:=Creatures.Creature[x];
i:=i+1;
end
else if i=1 then
begin
mon2:=creatures.creature[x];
i:=i+1;
end;
end;
end;
end;
function getmom:creature;
var i:integer;
begin
updateworld;
result:=0;
for i:=0 to creatures.count-1 do
if creatures.creature[i].following=true then result:=creatures.creature[i];
if result=0 then self.displaytext('Musisz pierw dac followa na matke!');
end;
var
id:integer;
mom:creature;
begin
for i:=0 to 30 do
begin
mom:=getmom;
if mom>0 then break;
end;
if mom=0 then
begin
self.displaytext('nie znaleziono matki! Koniec petli');
exit;
end;
self.displaytext('matka znaleziona!');
koniec:=false;
id:=mom.id;
while koniec=false do
begin
if self.health > 150 then
begin
GetMonsters;
if HowMuchAtk=2 then
if mon1.id=id then mon2.attacking := true else mon1.attacking:=true;
ProcessEvents;
sleep(1000);
end
else
begin
checklife;
sleep(2010);
end;
end;
end;