Переработка шерсти в рулоны
Posted: 02.03.2006 14:40
Code: Select all
Program Sheep;
var stime : TDateTime;
Wheel, Loom : cardinal;
q,c : Integer;
Const
PilesOfWoolType = $0DF8; {Шерсть}
BallsOfYarnType = $0E1F; {Катушки}
BoltsOfClothType = $0F95; {Рулоны}
WheelType = $1019; {Колесо}
LoomType = $1062; {Прялка}
{$Include 'all.inc'}
procedure MakeBoltsOfCloth;
begin
FindType(BallsOfYarnType, BackPack);
q := FindQuantity;
while q >= 5 do
begin
checksave;
WaitConnection(5000);
stime := Now;
WaitTargetObject(Loom);
UseObject(FindItem);
WaitJournalLine(stime, 'You use some thread and create a bolt of cloth', 20000);
wait(200);
FindType(BallsOfYarnType, BackPack);
q := FindQuantity;
end;
end;
procedure MakeBallsOfYarn;
begin
FindType(PilesOfWoolType, BackPack);
q := FindQuantity;
while q >= 3 do
begin
checksave;
WaitConnection(5000);
stime := Now;
WaitTargetObject(Wheel);
UseObject(FindItem);
WaitJournalLine(stime, 'You spin some wool and create some yarn', 20000);
wait(200);
FindType(PilesOfWoolType, BackPack);
q := FindQuantity;
end;
end;
Begin
WaitConnection(5000);
wait(5000);
FindDistance := 2;
checksave;
Wheel := findtype(WheelType, Ground);
Loom := findtype(LoomType, Ground);
if (Wheel = 0) then AddToSystemJournal('Error: Wheel not finded!');
if (Loom = 0) then AddToSystemJournal('Error: Loom not finded!');
if (Wheel = 0) or (Loom = 0) then Exit;
SetARStatus(true);
while not dead do
begin
checksave;
WaitConnection(5000);
Hungry(1, -1);
checksave;
WaitConnection(5000);
Stack(BoltsOfClothType, -1);
wait(500);
FindType(BoltsOfClothType, Ground);
AddToSystemJournal('There are ' + IntToStr(FindQuantity) + ' bolts of cloth ');
checksave;
WaitConnection(5000);
FindType(BallsOfYarnType, Ground);
q := FindQuantity;
while q > 10 do
begin
FindType(BallsOfYarnType, BackPack);
c := FindQuantity;
if c < 100 then
begin
stime := Now;
checksave;
WaitConnection(5000);
grab(FindType(BallsOfYarnType, Ground), 100 - c);
repeat
wait(500);
FindType(BallsOfYarnType, BackPack);
until (FindQuantity >= 100) or (Now > stime + (1.0/1440));
end;
MakeBoltsOfCloth;
wait(500);
checksave;
WaitConnection(5000);
Stack(BoltsOfClothType, -1);
wait(500);
FindType(BoltsOfClothType, Ground);
AddToSystemJournal('There are ' + IntToStr(FindQuantity) + ' bolts of cloth ');
FindType(BallsOfYarnType, Ground);
q := FindQuantity;
end; {End while q > 10 do}
FindType(BallsOfYarnType, BackPack);
c := FindQuantity;
if c > 10 then
begin
MakeBoltsOfCloth;
wait(500);
checksave;
WaitConnection(5000);
Stack(BoltsOfClothType, -1);
wait(500);
FindType(BoltsOfClothType, Ground);
AddToSystemJournal('There are ' + IntToStr(FindQuantity) + ' bolts of cloth ');
end;
FindType(PilesOfWoolType, Ground);
q := FindQuantity;
if q > 10 then
begin
FindType(PilesOfWoolType, BackPack);
c := FindQuantity;
if c < 100 then
begin
stime := Now;
checksave;
WaitConnection(5000);
grab(FindType(PilesOfWoolType, Ground), 100 - c);
repeat
wait(500);
FindType(PilesOfWoolType, BackPack);
until (FindQuantity >= 100) or (Now > stime + (1.0/1440));
end;
MakeBallsOfYarn;
wait(500);
end; {End if q > 10 then}
end; {End while not dead do}
End.