PROGRAM Test; CONST idContWithRes = $400829F5; tIngots = $1BF2; delayMoveItem = 1000; //>>>> Процедура открытия контейнера. ========================================== VAR idDrawContainer: Cardinal; Procedure EventDrawContainer(ID, ModelGump: Cardinal); Begin idDrawContainer := ID; End; Function OpenContainer(idContainer: Cardinal): Boolean; Var k: Integer; Begin if not Connected or Dead then EXIT; SetEventProc(evDrawContainer,'EventDrawContainer'); k := 0; idDrawContainer := 0; UseObject(idContainer); while Connected and not Dead and (idDrawContainer = 0) and (k < 100 ) do begin k := k + 1; Wait(100); end; SetEventProc(evDrawContainer,''); if idDrawContainer = idContainer then Result := TRUE else Result := FALSE; End; //<<<< Конец процедуры открытия контейнера. ==================================== //== Проверить имеется ли что-нибудь из списка предметов. ====================== Function IsAnyItemInList(arItems: array of Word; idContainerStorage: Cardinal): Boolean; Var i: Integer; Begin Result := FALSE; if Length(arItems) > 0 then for i := 0 to Length(arItems) - 1 do if FindType(arItems[i], idContainerStorage) > 0 then begin Result := TRUE; EXIT; end; End; Procedure TakeIngot(); Var idIngots: Cardinal; countIngots: Integer; Begin repeat if not Connected or Dead then EXIT; AddToSystemJournal('Берем металл для крафта ...'); if FindTypeEX(tIngots, $0000, idContWithRes, FALSE) = 0 then begin AddToSystemJournal(' Нет ресурсов для изготовления инструментов.'); EXIT; end; idIngots := FindItem; CheckLag(10000); //Думаю 50 слитков металла для крафта инструментов с учетом физлов должно хватить. MoveItem(idIngots, 50, Backpack, 0, 0, 0); Wait(delayMoveItem); CheckLag(10000); //Проверяем сколько металла в сумке персонажа. FindTypeEX(tIngots, $0000, Backpack, FALSE); idIngots := FindItem; countIngots := GetQuantity(idIngots); //countIngots := Count(tIngots); //заменил GetQuantity(idIngots) AddToSystemJournal(' idIngots in Backpack: $' + IntToHex(idIngots, 8)); AddToSystemJournal(' Металла взято: ' + IntToStr(countIngots)); if (idIngots >= 0) and (countIngots = 0) then begin if not Connected or Dead then EXIT; FillNewWindow( DateTimeToStr(Now) + #13#10 + 'Поиск металла в бекпаке во время появления лщибки:' + #13#10 + 'ID: $' + IntToHex(idIngots, 8) + #13#10 + 'Type: $' + IntToHex(GetType(idIngots), 4) + #13#10 + 'Color: $' + IntToHex(GetColor(idIngots), 4) + #13#10 + 'Quantity: ' + IntToStr(GetQuantity(idIngots)) + #13#10 + 'X: ' + IntToStr(GetX(idIngots)) + #13#10 + 'Y: ' + IntToStr(GetY(idIngots)) + #13#10 + 'Z: ' + IntToStr(GetZ(idIngots)) + #13#10 + 'Location: $' + IntToHex(GetParent(idIngots), 8) + ' (my Backpack ID: $' + IntToHex(Backpack, 8) + ')' + #13#10 + 'Tooltip: ' + GetTooltip(idIngots) + #13#10 + 'Результат функции Count(tIngots): ' + IntToStr(Count(tIngots)) + #13#10); CheckLag(1000); UseObject(Backpack); Wait(500); countIngots := GetQuantity(idIngots); FillNewWindow( DateTimeToStr(Now) + #13#10 + 'Поиск металла в бекпаке после переоткрытия бекпака:' + #13#10 + 'ID: $' + IntToHex(idIngots, 8) + #13#10 + 'Type: $' + IntToHex(GetType(idIngots), 4) + #13#10 + 'Color: $' + IntToHex(GetColor(idIngots), 4) + #13#10 + 'Quantity: ' + IntToStr(GetQuantity(idIngots)) + #13#10 + 'X: ' + IntToStr(GetX(idIngots)) + #13#10 + 'Y: ' + IntToStr(GetY(idIngots)) + #13#10 + 'Z: ' + IntToStr(GetZ(idIngots)) + #13#10 + 'Location: $' + IntToHex(GetParent(idIngots), 8) + ' (my Backpack ID: $' + IntToHex(Backpack, 8) + ')' + #13#10 + 'Tooltip: ' + GetTooltip(idIngots) + #13#10 + 'Результат функции Count(tIngots): ' + IntToStr(Count(tIngots)) + #13#10 + '-------------------------------------------------------'); end; //if Count(tIngots) > 200 then HALT; if Count(tIngots) > 200 then BREAK; until countIngots >= 50; End; Procedure UnloadResources(); Var arResources: array of Word; i: Integer; Begin //РЕСУРСЫ КОТОРЫЕ МОЖНО ДОБЫТЬ: arResources := [ //Слитки металла: $1BF2, //ingots //Руда (ore): $19B9, //12 stones $19BA, //7 stones $19B8, //7 stones $19B7, //2 stones //Редкие драгоценные камни: $3194, //Perfect Emerald $3195, //Ecru Citrine $3197, //Fire Ruby $3198, //Blue Diamond $3193, //Turquoise $3192, //Dark Sapphire //Обычные драгоценные камни: $0F2D, //tourmaline $0F19, //sapphire $0F13, //ruby $0F26, //diamond $0F21, //star sapphire $0F10, //emerald $0F16, //amethyst $0F15, //citrine $0F25, //amber //Гранит: $1779, //high quality granite //Деньги: $0EED ]; if not Connected or Dead then EXIT; if GetDistance(idContWithRes) > 2 then begin AddToSystemJournal('Рядом нет контейнера для ресурсов.'); EXIT; end; if not IsAnyItemInList(arResources, Backpack) then begin AddToSystemJournal('Нет ресурсов для выгрузки.'); EXIT; end; AddToSystemJournal('Выгружаем ресурсы ...'); for i := 0 to Length(arResources) - 1 do while Connected and not Dead and (FindType(arResources[i], Backpack) > 0) do begin //MoveItem(FindItem, GetQuantity(FindItem), idContWithRes, 0, 0, 0); MoveItem(FindItem, FindQuantity, idContWithRes, 0, 0, 0); Wait(delayMoveItem); end; AddToSystemJournal(' Ресурсы выгружены.'); End; BEGIN while TRUE do begin OpenContainer(idContWithRes); //Wait(1000); TakeIngot(); //Wait(1000); UnloadResources(); end; END.