Готовый скрипт на мининг для минока.
На земле или в ресурсном паке должны лежать бинты, еда, реколы.
Старт скрипта из дома...
Какие инклюды использует скрипт, я не помню... проверяйте, если не пашет, выкладывайте сюда эррор-лог
Функционал:
сам жрёт
сам ресается у хиллера
сам тпешится домой, сбрасывает руду и пополняет запасы, летит в шахту
гвардит элементалей и атаку на чара
Program Mining_Minoc_by_nepret;
const
HomeLoc = '1915,2114'; //Координаты точки в доме ХY(Пример: HomeLoc = 'xxxx,yyyy';)
MineLoc = '2568,484'; //Координаты точки в шахте XY(Пример: MineLoc = 'xxxx,yyyy';)
HomeRune = 3; // Номер руны в дом.
MineRune = 1; // Номер руны в шахту.
VarGetRes = 0; // Где будем искать бинты с едой? ID контейнера или 0 если на земле.
CountBandage = 50; // Колличество бинтов которое будем брать с собой.
CountFood = 20; // Колличество еды которое будем брать с собой.
MaxVes = 10000; //Максимальный вес при котором лететь домой на разгрузку
DebugMode = 0;
type
TileRecord = Record
t,x,y,z : integer;
end;
var
XH, YH, XM, YM, RuneBook, Error, TCount, LocPoint, Pickaxe, CheckBlock : integer;
Tile : array [0..5000] of TileRecord;
mdtime, htime : TDateTime;
{$Include 'all.inc'}
function GetCoorLoc : Boolean;
var
SL : TStringList;
begin
SL := TStringList.Create;
StrBreakApart(HomeLoc, ',', SL);
if SL.Count > 0 then
begin
XH := StrToInt(SL.Strings[0]);
YH := StrToInt(SL.Strings[1]);
if (XH <= 0) or (YH <= 0) then
begin
AddToSystemJournal('Не смог определить координаты дома... X='+IntToStr(XH)+' Y='+IntToStr(YH));
AddToSystemJournal('1');
exit;
end;
end;
SL.Free;
SL := TStringList.Create;
StrBreakApart(MineLoc, ',', SL);
if SL.Count > 0 then
begin
XM := StrToInt(SL.Strings[0]);
YM := StrToInt(SL.Strings[1]);
if (XM <= 0) or (YM <= 0) then
begin
AddToSystemJournal('Не смог определить координаты шаты... X='+IntToStr(XM)+' Y='+IntToStr(YM));
AddToSystemJournal('2');
exit;
end;
end;
SL.Free;
result := true;
end;
function RunSettings : boolean;
begin
OpenBackpack;
FindTypeEx($0EFA, $021E, Backpack, false);
if FindCount <> 1 then
begin
AddToSystemJournal('>>> В бекпаке нет рунбук или их больше 1!');
AddToSystemJournal('>>> В бекпаке должна находиться только 1 рунбука!')
AddToSystemJournal('3');
exit;
end;
RuneBook := finditem;
FindTypeEx($0E85, $FFFF, Backpack, false);
if FindCount > 0 then
begin
Pickaxe := finditem;
end
else
begin
AddToSystemJournal('В бекпаке Pickaxe!');
exit;
end;
if TargetPresent then CancelTarget;
UseObject(RuneBook);
WaitGump(IntToStr(500+HomeRune));
repeat
if IsGump then CloseSimpleGump(0);
until not IsGump;
result := true;
end;
function Recharge(RC : integer) : boolean;
begin
if dead then exit;
if not Connected then exit;
FindTypeEx($1F4C, $FFFF, RC, false);
if FindQuantity < 2 then
begin
AddToSystemJournal('>>> Не достаточное кол-во Recall-скролов!');
exit;
end;
if TargetPresent then CancelTarget;
UseObject(RuneBook);
WaitGump(IntToStr(500+HomeRune));
UseObject(RuneBook);
WaitGump('800');
FindTypeEx($1F4C, $FFFF, RC, false);
if FindQuantity < 2 then
begin
AddToSystemJournal('>>> Не достаточное кол-во Recall-скролов!');
exit;
end;
WaitTargetObject(finditem);
repeat
wait(1000);
UseObject(RuneBook);
if not Connected then exit;
until IsGump;
repeat
if IsGump then CloseSimpleGump(0);
if not Connected then exit;
until not IsGump;
FindVertical := 1;
result := true;
end;
procedure Recall(L : integer); // 1-Домой; 0-К шахте;
var
t, x, y : integer;
begin
if not Connected then exit;
if dead then exit;
repeat
if IsGump then CloseSimpleGump(0);
if not Connected then exit;
until not IsGump;
if TargetPresent then CancelTarget;
x := GetX(self);
y := GetY(self);
if L = 1 then
begin
repeat
if not Connected then exit;
UOSay('.Recall');
t := 0;
repeat
t := t + 1;
wait(100);
checksave;
if not Connected then exit;
until (x <> GetX(self)) or (y <> GetY(self)) or (t >= 100);
until (x <> GetX(self)) or (y <> GetY(self));
wait(3000);
exit;
end;
repeat
if not Connected then exit;
UseObject(RuneBook);
t := 0;
repeat
if not Connected then exit;
checksave;
wait(100);
t := t + 1;
until (IsGump) or (t >= 50);
until IsGump;
if not Connected then exit;
WaitGump(IntToStr(600+MineRune));
repeat
if not Connected then exit;
wait(100);
checksave;
until (x <> GetX(self)) or (y <> GetY(self));
end;
function CheckLocation(xp, yp : integer) : String;
var
x, y : integer;
begin
if not Connected then exit;
for x := GetX(self) - xp to GetX(self) + xp do
begin
for y := GetY(self) - yp to GetY(self) + yp do
begin
if (x = XH) and (y = YH) then
begin
result := 'Home';
//UOSay('Home');
exit;
end;
if (x = XM) and (y = YM) then
begin
result := 'Mine';
//UOSay('Mine');
exit;
end;
end;
end;
result := 'NotLoc';
end;
function RulesDead : Boolean;
var
i : integer;
Go : array [0..13] of cardinal;
begin
if not Connected then exit;
if CheckLocation(50,50) = 'Home' then exit;
if dead then
begin
if IsGump then
begin
GumpAutoCheckBox(10,211);
NumGumpButton(GetGumpsCount-1,0);
end;
if IsGump then
begin
CloseSimpleGump(GetGumpsCount-1);
end;
if not (NewMoveXY(2550,622,True,0,True)) and (NewMoveXY(2578,622,True,0,True)) then exit;
repeat
if not Connected then exit;
CheckSave;
Step(0, true);
if GetGumpsCount > 0 then
begin
NumGumpButton(GetGumpsCount-1,1);
repeat
if not Connected then exit;
wait(1000);
until not dead;
result := true;
exit;
end;
until (GetX(self) = 2578) and (GetY(self) = 601);
if PredictedDirection <> 0 then Step(0, true);
repeat
if not Connected then exit;
CheckSave;
Step(6, true);
if GetGumpsCount > 0 then
begin
NumGumpButton(GetGumpsCount-1,1);
repeat
if not Connected then exit;
wait(1000);
until not dead;
result := true;
exit;
end;
until (GetX(self) = 2575) and (GetY(self) = 601);
repeat
if not Connected then exit;
CheckSave;
Step(0, true);
if GetGumpsCount > 0 then
begin
NumGumpButton(GetGumpsCount-1,1);
repeat
if not Connected then exit;
wait(1000);
until not dead;
result := true;
exit;
end;
until (GetX(self) = 2575) and (GetY(self) = 593);
Go[0] := 0;
Go[1] := 0;
Go[2] := 0;
Go[3] := 0;
Go[4] := 0;
Go[5] := 6;
Go[6] := 6;
Go[7] := 4;
Go[8] := 4;
Go[9] := 4;
Go[10] := 4;
Go[11] := 4;
Go[12] := 2;
Go[13] := 2;
while dead do
begin
if not Connected then exit;
for i := 0 to 13 do
begin
if GetGumpsCount > 0 then
begin
NumGumpButton(GetGumpsCount-1,1);
repeat
if not Connected then exit;
wait(1000);
until not dead;
result := true;
exit;
end;
if (PredictedDirection <> 0) and (i = 0) then Step(Go[i], true);
if (PredictedDirection <> 6) and (i = 5) then Step(Go[i], true);
if (PredictedDirection <> 4) and (i = 7) then Step(Go[i], true);
if (PredictedDirection <> 2) and (i = 12) then Step(Go[i], true);
CheckSave;
Step(Go[i], true);
wait(1000);
end;
end;
end;
result := true;
end;
procedure DropAll;
var
i, BID, GID, BCount, GCount, MCount, BColor : integer;
Color : array [0..13] of cardinal;
begin
if not Connected then exit;
if dead then exit;
OpenBackpack;
FindTypeEx($19B9, $FFFF, Backpack, false);
if FindCount > 0 then
begin
Color[0] := $0488; // purtit
Color[1] := $0698; // deep
Color[2] := $05D2; // aqua
Color[3] := $0482; // silver
Color[4] := $0253; // valorit
Color[5] := $0949; // druidsilver
Color[6] := $0577; // air
Color[7] := $051E; // celestit
Color[8] := $0457; // ereirit
Color[9] := $08EA; //ppk
Color[10] := $052D; //mythril
Color[11] := $0944; //sun
Color[12] := $0942; //wyrm
Color[13] := $0481; //adamant
for i := 0 to 13 do
begin
if not Connected then exit;
FindTypeEx($19B9, Color[i], Backpack, false);
if FindCount > 0 then
begin
BCount := FindQuantity;
BID := finditem;
repeat
if not Connected then exit;
FindTypeEx($19B9, Color[i], Ground, false);
if FindQuantity >= 60000 then Ignore(finditem);
until FindQuantity < 60000;
if FindQuantity = 0 then
begin
MoveItem(BID, 0, Ground, GetX(self),GetY(self),GetZ(self));
end;
if FindQuantity < 60000 then
begin
GCount := FindQuantity;
GID := finditem;
end;
if GCount > 0 then
begin
MCount := 60000 - GCount;
if MCount >= BCount then MCount := 0;
MoveItem(BID, MCount, GID, 0,0,0);
end;
end;
end;
repeat
if not Connected then exit;
FindTypeEx($19B9, $FFFF, Backpack, false);
if FindCount > 0 then
begin
BCount := FindQuantity;
BID := finditem;
BColor := GetColor(finditem);
end;
repeat
if not Connected then exit;
FindTypeEx($19B9, BColor, Ground, false);
if FindQuantity >= 60000 then Ignore(finditem);
until FindQuantity < 60000;
if FindQuantity = 0 then
begin
MoveItem(BID, 0, Ground, GetX(self),GetY(self),GetZ(self));
GCount := 0;
end;
if (FindQuantity < 60000) and (FindQuantity > 0) then
begin
GCount := FindQuantity;
GID := finditem;
end;
if GCount > 0 then
begin
MCount := 60000 - GCount;
if MCount >= BCount then MCount := 0;
MoveItem(BID, MCount, GID, 0,0,0);
end;
FindTypeEx($19B9, $FFFF, Backpack, false);
until FindCount <= 0;
end;
end;
function GetRes(VGR : cardinal) : Boolean;
var
i, t, Count, GetCount : integer;
ResItem : array [0..1] of cardinal;
NameItem : array [0..1] of string;
begin
ResItem[0] := Food;
ResItem[1] := $0E21;
NameItem[0] := 'еды';
NameItem[1] := 'бинтов';
if not Connected then exit;
if dead then exit;
OpenBackpack;
if VGR > 0 then
begin
if (GetX(VGR) <= 0) and (GetY(VGR) <= 0) then
begin
result := False;
if not Connected then exit;
AddToSystemJournal('>>> Не могу найти контейнер с ресурсами!');
exit;
end
else
begin
newMoveXY(GetX(VGR), GetY(VGR), True, 1, True);
repeat
UseObject(VGR);
t := 0;
repeat
if not Connected then exit;
wait(100);
t := t + 1;
CheckSave;
until (LastContainer = VGR) or (t >= 30);
until LastContainer = VGR;
end;
end;
if VGR = 0 then
begin
FindDistance := 2;
VGR := Ground;
for i := 0 to 1 do
begin
if not Connected then exit;
FindTypeEx(ResItem[i], $FFFF, Ground, False);
if FindCount < 1 then
begin
result := False;
if not Connected then exit;
AddToSystemJournal('>>> На полу нет: '+NameItem[i]+'!');
exit;
end;
end;
end;
for i := 0 to 1 do
begin
if not Connected then exit;
if i = 0 then Count := CountFood;
if i = 1 then Count := CountBandage;
FindTypeEx(ResItem[i], $FFFF, VGR, False);
if FindFullQuantity < Count then
begin
result := False;
if not Connected then exit;
AddToSystemJournal('>>> Не достаточное колличество: '+NameItem[i]+'!');
exit;
end;
repeat
if not Connected then exit;
FindTypeEx(ResItem[i], $FFFF, backpack, False);
if FindFullQuantity < Count then
begin
GetCount := Count-FindFullQuantity;
FindTypeEx(ResItem[i], $FFFF, VGR, False);
MoveItem(finditem, GetCount, backpack, 0,0,0);
t := 0;
repeat
if not Connected then exit;
t := t + 1;
Checksave;
wait(100);
FindTypeEx(ResItem[i], $FFFF, backpack, False);
until (FindFullQuantity >= GetCount) or (t >= 50);
if t >= 50 then AddToSystemJournal('a');
end;
until FindFullQuantity >= GetCount;
end;
result := True;
end;
procedure GetPoint;
var
a : TFoundTilesArray;
i, i0, b : integer;
TyleType : array [0..24] of cardinal;
begin
if not NewMoveXY(XM,YM,True,0,True) then exit;
TyleType[0] := 1339; //Тайлы шахты
TyleType[1] := 1340;
TyleType[2] := 1341;
TyleType[3] := 1342;
TyleType[4] := 1343;
TyleType[5] := 1344;
TyleType[6] := 1345;
TyleType[7] := 1346;
TyleType[8] := 1347;
TyleType[9] := 1348;
TyleType[10] := 1349;
TyleType[11] := 1350;
TyleType[12] := 1351;
TyleType[13] := 1352;
TyleType[14] := 1353;
TyleType[15] := 1354;
TyleType[16] := 1355;
TyleType[17] := 1356;
TyleType[18] := 1357;
TyleType[19] := 1358;
TyleType[20] := 1359;
TyleType[21] := 1386;
TyleType[22] := 1361;
TyleType[23] := 1362;
TyleType[24] := 1363;
for i := 0 to 24 do
begin
b := GetStaticTilesArray(GetX(self)-30,GetY(self)-30,GetX(self)+30,GetY(self)+30, 0, TyleType[i], a);
if b > 1 then
begin
for i0 := 0 to b do
begin
if a[i0].Z = GetZ(self) then
begin
Tile[TCount].t := a[i0].Tile;
Tile[TCount].x := a[i0].X;
Tile[TCount].y := a[i0].y;
Tile[TCount].z := a[i0].Z;
TCount := TCount + 1;
end;
end;
end;
end;
LocPoint := 1;
TCount := TCount - 1;
//AddToSystemJournal('Tile: '+IntToStr(Tile[TCount].t)+' X: '+IntToStr(Tile[TCount].x)+' Y: '+IntToStr(Tile[TCount].y)+' Z: '+IntToStr(Tile[TCount].z)+' Z-SELF: '+IntToStr(GetZ(self)));
end;
function CheckDead : Boolean;
var
x, y : integer;
begin
if not Connected then exit;
if dead and (CheckLocation(50,50) = 'Home') and (Error = 0) then Error := 1;
if Dead and (Error = 0) then
begin
if Error = 1 then exit;
x := GetX(self);
y := GetY(self);
if not RulesDead then
begin
Error := 1;
exit;
end;
Recall(1);
DropAll;
if not GetRes(VarGetRes) then Error := 1;
if not Recharge(VarGetRes) then Error := 1;
if Error = 0 then
begin
Recall(0);
if not (NewMoveXY(x, y, True, 0, False)) then Error := 1;
end;
if Error = 1 then exit;
end;
result := True;
end;
procedure CheckWeight;
var
x, y : integer;
begin
if not Connected then exit;
if Weight >= MaxVes then
begin
x := GetX(self);
y := GetY(self);
Recall(1);
if not CheckDead then
begin
Error := 1;
exit;
end;
DropAll;
if (GetRes(VarGetRes) = False) and (Error = 0) then Error := 1;
if (Recharge(VarGetRes) = False) and (Error = 0) then Error := 1;
if Error = 0 then
begin
Recall(0);
NewMoveXY(x, y, True, 0, True);
end;
end;
end;
procedure Heal;
var
t : integer;
begin
if not Connected then exit;
while Life < MaxHP do
begin
if dead then exit;
if not Connected then exit;
FindTypeEx($0E21, $FFFF, backpack, False);
if FindCount > 0 then
begin
if targetpresent then canceltarget;
htime := Now;
if not Connected then exit;
UseObject(finditem);
t := 0;
repeat
if not Connected then exit;
CheckSave;
if dead then exit;
t := t + 1;
until TargetPresent or (t >= 50);
if not Connected then exit;
WaittargetSelf;
end;
t := 0;
repeat
wait(100);
if not Connected then exit;
CheckSave;
t := t + 1;
until (InJournalBetweenTimes('You were|You have healed|The patient|You must', htime, Now) <> -1) or (t >= 300) or dead;
htime := Now;
end;
end;
procedure MobDetected;
begin
if not Connected then exit;
if not dead then
begin
if (InJournalBetweenTimes('slime|elemental|attacking you', mdtime, Now) <> -1) and (LineName = 'System') or (Life < MaxHP) then
begin
if (FoundedParamID <= 2) and (LineTextColor = 1000) then UOSay('.guards');
if (FoundedParamID = 3) and (LineTextColor = 38) then UOSay('.guards');
if Life < MaxHP then UOSay('.guards');
mdtime := Now;
end;
Heal;
end;
end;
procedure mining;
var
i, t : integer;
u : TDateTime;
begin
if not Connected then exit;
for i := 0 to TCount do
begin
if Tile[i].z = GetZ(self) then
begin
MobDetected;
if NewMoveXY(Tile[i].x, Tile[i].y, True, 2, False) then
begin
if CheckBlock > 0 then CheckBlock := 0;
if not CheckDead then exit;
Hungry(Backpack);
CheckWeight;
if Error = 1 then exit;
repeat
if not Connected then exit;
MobDetected;
if TargetPresent then CancelTarget;
u := Now;
repeat
if not Connected then exit;
if not CheckDead then exit;
UseObject(Pickaxe);
CheckTarget(5);
until TargetPresent or dead;
TargetToTile(Tile[i].t, Tile[i].x, Tile[i].y, Tile[i].z);
MobDetected;
t := 0;
repeat
if not Connected then exit;
checksave;
wait(100);
t := t + 1;
MobDetected;
until (InJournalBetweenTimes('You cannot prospect|There is no ore here to mine|Cancelled|That is too far away', u, Now) <> -1) or (t >= 150) or dead;
until FoundedParamID > 0;
end
else
begin
CheckBlock := CheckBlock + 1;
if CheckBlock >= 50 then
begin
Error := 1;
AddToSystemJournal('>>> Почему то, не могу копать!');
Exit;
end;
end;
end;
end;
end;
begin
SetARStatus(true);
SetPauseScriptOnDisconnectStatus(false);
moveThroughNPC := 0;
if not Connected then waitconnection(3);
if not GetCoorLoc then exit;
if (dead and (CheckLocation(50,50) = 'Home') and (Error = 0)) then Error := 1;
if (dead = true) and (CheckLocation(50,50) = 'Home') and RulesDead then Error := 1;
if (dead = true) and (RunSettings = false) then Error := 1;
if (dead = false) and (MoveXYZ(XH, YH, 46, 0, 0, True) = false) then Recall(1);
mdtime := Now;
repeat
DropAll;
if (GetRes(VarGetRes) = False) and (Error = 0) then Error := 1;
Hungry(Backpack);
if (Recharge(VarGetRes) = False) and (Error = 0) then Error := 1;
if Error = 0 then
begin
Recall(0);
GetPoint;
mining;
if not Connected then waitconnection(1);
RulesDead;
Recall(1);
end;
if Error = 1 then
begin
SetARStatus(false);
Disconnect;
exit;
end;
until false;
end.