Code: Select all
Program BlackSmithy;
var
ItemType, HammerType, MaxWeight, ItemCost:word;
ForgeObj,TempIngots:cardinal;
stime : TDateTime;
ItemGump:string;
i:integer;
{$Include 'all.inc'}
procedure CheckDead;
begin
WaitConnection(3000);
CheckSave;
if Dead then
begin
SetWarMode(true);
WaitGump('1');
wait(5000);
while (Dead) do Wait (1000);
wait (2000);
Hungry(1, ground);
end;
end;
function timer(var acttimer:integer;actafter:integer):boolean;
begin
result:=false;
acttimer:=acttimer+1;
if acttimer>=actafter then
begin
acttimer:=0;
result:=true;
end;
end;
procedure FullDisconnect;
begin
SetARStatus(false);
Disconnect;
end;
procedure Resmelt;
begin
while count(ItemType) > 0 do begin
checksave;
CheckTargetError(2,2);
if targetpresent then canceltarget;
useobject(ForgeObj);
WaitForTarget(5000);
if targetpresent then targettoobject(findtype(ItemType,backpack));
wait(4000);
end;
Stack($1BF2,getcolor(findtype($1BF2,backpack)));
end;
procedure checktools;
begin
WaitConnection(3000);
checksave;
if (GetType(ObjAtLayer(RHandLayer)) <> HammerType) then unequip(RHandLayer)
else Exit;
findtype(HammerType,backpack);
if (findcount > 0) then begin equip(RHandLayer,finditem); Exit; end;
findtype(HammerType,ground);
if (findcount > 0) then begin equip(RHandLayer,finditem); Exit; end;
Addtosystemjournal('Не нашел молоток заданного типа в приделах досягаемости, чара в лагаут');
FullDisconnect;
while true do wait(1000);
end;
procedure checkingots;
Label a1st;
begin
WaitConnection(3000);
checksave;
if (GetQuantity(TempIngots) >= ItemCost) then Exit;
Resmelt;
a1st:
WaitConnection(3000);
findtype($1BF2,ground);
if findcount = 0 then begin
Addtosystemjournal('Закончилось железо, либо оно не найдено, чара в лагаут');
FullDisconnect;
while true do wait(1000);
end;
if findquantity < ItemCost then begin
Ignore(finditem);
goto a1st;
end
else TempIngots:=finditem;
end;
procedure CheckWeight;
begin
WaitConnection(3000);
if Weight >= MaxWeight then begin
Resmelt;
end;
end;
begin
{==================================}
ItemGump:='5141'; {Нагрудник}
ItemType:=$1415; {Нагрудник}
ItemCost:=25;
ForgeObj:=$530CCA53;
HammerType:=$13E3;
MaxWeight:=250;
{==================================}
Finddistance:=2;
SetARStatus(true);
TempIngots:=0;
Hungry(1,ground);
while true do begin
CheckDead;
CheckTools;
CheckIngots;
CheckWeight;
WaitConnection(2000);
checksave;
if timer(i,40) then Hungry(1,ground);
CheckTargetError(2,2);
stime := Now;
WaitGump(ItemGump);
WaitTargetObject(TempIngots);
UseObject(ObjAtLayer(RHandLayer));
wait(200);
WaitJournalline(stime,'create|make|destroy',10000);
wait(100);
end;
end.