Code: Select all
//Made by Shinma
{Просто выведите чара за дверь на улицу и включите скрипт. Когда он закончится вам будет сообщено в журнале стелса.}
program jail;
type
region= record
minX:word;
minY:word;
maxX:word;
maxY:word;
end;
var
MinTile:array of word;
start_p: TFoundTile;
i,j:word;
RegArr: array [0..0] of region;
sum:word;
arr_sum:word;
rs:word;
tfta:TFoundTilesArray;
k:word;
temp:TFoundTilesArray;
res_arr:TFoundTilesArray;
function prochnost:integer;
var
aa : TClilocRec;
begin
aa := GetToolTipRec(ObjAtLayer(rhandLayer));
Result :=strtoint(aa.Items[2].Params[0]);
end;
procedure init;
begin
start_p.X:=GetX(Self);
start_p.Y:=GetY(Self);
MinTile:=[6004,6008,6007,6012];
RegArr[0].minX:=start_p.X-60;
RegArr[0].minY:=start_p.Y-60;
RegArr[0].maxX:=start_p.X+60;
RegArr[0].maxY:=start_p.Y+60;
end;
procedure cancel;
begin
CloseMenu;
CancelMenu;
If TargetPresent Then CancelTarget;
end;
procedure check_war;
begin
if IsWarMode(self) then
begin
setWarMode(false);
end;
end;
procedure Wait_Target(time_ms:Cardinal);
var
TempTime,SumTime:Cardinal;
begin
SumTime:=0;
repeat
wait(500);
TempTime:=Timer;
SumTime:=SumTime+(Timer-TempTime);
until ((targetpresent) or (dead) or (not connected) or (SumTime>time_ms));
end;
function sqr(a:LongInt):LongInt;
begin
result:=a*a;
end;
function vector_length(c_1,c_2:TFoundTile):LongInt;
begin
result:=Round(sqrt(sqr(c_1.X-c_2.X)+sqr(c_1.Y-c_2.Y)));
end;
procedure QuickSort(var item:TFoundTilesArray; count:integer; point:TFoundTile);
var
temp_index,temp_value, tempo,i,j:LongInt;
t_c:TFoundTile;
begin
t_c:=point;
temp_index:=0;
temp_value:=vector_length(t_c,item[temp_index]);
for i:=0 to count-2 do
begin
for j:=i to count-1 do
begin
tempo:=vector_length(t_c,item[j]);
if tempo<temp_value then
begin
temp_index:=j;
temp_value:=tempo;
end;
end;
t_c:=item[temp_index];
item[temp_index]:=item[i];
item[i]:=t_c;
temp_value:=vector_length(item[i],item[i+1]);
end;
i:=0;
end;
procedure poisk_ore;
begin
SetArStatus(true);
init;
sum:=0;
arr_sum:=0;
rs:=0;
j:=0 ;
AddToSystemJournal(inttostr(GetArrayLength(MinTile)-1));
for i:=0 to (GetArrayLength(MinTile)-1) do
begin
rs:=GetStaticTilesArray(RegArr[j].minX,RegArr[j].minY,RegArr[j].maxX,RegArr[j].maxY,1,MinTile[i],tfta);
if rs>0 then
for k:=0 to rs-1 do temp[arr_sum+k]:=tfta[k];
arr_sum:=arr_sum+rs;
end;
QuickSort(temp,arr_sum,start_p);
for k:=0 to arr_sum-1 do res_arr[sum+k]:=temp[k];
sum:=sum+arr_sum;
end;
Procedure DoitBaby(f_tile:TFoundTile);
var
ctime : TDateTime;
save:integer;
begin
cancel;
save:=0;
repeat
save:=save+1;
UseObject(ObjAtLayer(rhandLayer));
Wait_Target(5000);
TargetToTile(f_tile.Tile,f_tile.X,f_tile.Y,f_tile.Z);
ctime := Now;
repeat
wait(2000);
check_war;
until (InJournalBetweenTimes('already mined enough to become free|too far away|no more rock|not swing hard|rock crumbles', ctime, Now)>= 0) or dead or (save>6);
until (InJournalBetweenTimes('already mined enough to become free|too far away|no more rock', ctime, Now)>= 0)or dead or (save>3);
end;
begin
while (prochnost>0)and(Not Dead) do
begin
poisk_ore;
j:=sum-1;
i:=0;
AddToSystemJournal('Всего камней найдено = '+inttostr(sum));
while (i<j)and(Not Dead) and(prochnost>0)do
begin;
AddToSystemJournal('Подходим к = '+inttostr(i+1)+' камню из '+ inttostr(sum));
AddToSystemJournal('Прочность кирки ='+inttostr(prochnost));
NewMoveXY(res_arr[i].X,res_arr[i].Y,true,1,true);
DoitBaby(res_arr[i]);
i:=i+1;
end;
end;
NewMoveXY(303,762,true,1,true);
AddToSystemJournal('Прочность кирки ='+inttostr(prochnost));
AddToSystemJournal('ТЕПЕРЬ СНОВА МОЖНО МАТЕРИТЬСЯ!!!');
end.