Forum in READ ONLY mode! All questions and discussions on Discord official server, invite link: https://discord.gg/VxsGzJ7

Помогите пожалуйста по записи в файл

тут можно задать вопрос по скриптингу
Post Reply
reynard
Posts: 7
Joined: 04.06.2016 0:00

Помогите пожалуйста по записи в файл

Post by reynard »

Подскажите пожалуйста как сохранить в файл тайлы, которые находит эта процедура

Code: Select all

Program GetTilesToMine;

const
SeekRange = 10;
 
type
 MinTile = record
 x, y, z, Tile : Word;
end;

var
 MinTiles_Array : Array of MinTile;
 x, y, i : Integer;
 TileInfo : TStaticCell;

 
begin
 SetLength(MinTiles_Array, 0);
 for x := (-1 * SeekRange) to SeekRange do
  for y := (-1 * SeekRange) to SeekRange do
   begin
    TileInfo := ReadStaticsXY(GetX(self)+x, GetY(self)+y, WorldNum);
    if TileInfo.StaticCount > 0 then
    for i := Low(TileInfo.Statics) to High(TileInfo.Statics) do
     if (TileInfo.Statics[i].Tile >= 1339) and (TileInfo.Statics[i].Tile <= 1359) and (TileInfo.Statics[i].z = GetZ(self)) then
      begin
       SetLength(MinTiles_Array, Length(MinTiles_Array) + 1);
       MinTiles_Array[High(MinTiles_Array)].Tile := TileInfo.Statics[i].Tile;
       MinTiles_Array[High(MinTiles_Array)].x := TileInfo.Statics[i].x;
       MinTiles_Array[High(MinTiles_Array)].y := TileInfo.Statics[i].y;
       MinTiles_Array[High(MinTiles_Array)].z := TileInfo.Statics[i].z;
      end;                           
   end;
 AddToSystemJournal('Found ' + IntToStr(Length(MinTiles_Array)) + ' tiles to mine.');   
end.;
drabadan
Expert
Expert
Posts: 730
Joined: 13.12.2012 17:35
Contact:

Re: Помогите пожалуйста по записи в файл

Post by drabadan »

reynard wrote:Подскажите пожалуйста как сохранить в файл тайлы, которые находит эта процедура

Code: Select all

Program GetTilesToMine;

const
SeekRange = 10;
 
type
 MinTile = record
 x, y, z, Tile : Word;
end;

var
 MinTiles_Array : Array of MinTile;
 x, y, i : Integer;
 TileInfo : TStaticCell;

 
begin
 SetLength(MinTiles_Array, 0);
 for x := (-1 * SeekRange) to SeekRange do
  for y := (-1 * SeekRange) to SeekRange do
   begin
    TileInfo := ReadStaticsXY(GetX(self)+x, GetY(self)+y, WorldNum);
    if TileInfo.StaticCount > 0 then
    for i := Low(TileInfo.Statics) to High(TileInfo.Statics) do
     if (TileInfo.Statics[i].Tile >= 1339) and (TileInfo.Statics[i].Tile <= 1359) and (TileInfo.Statics[i].z = GetZ(self)) then
      begin
       SetLength(MinTiles_Array, Length(MinTiles_Array) + 1);
       MinTiles_Array[High(MinTiles_Array)].Tile := TileInfo.Statics[i].Tile;
       MinTiles_Array[High(MinTiles_Array)].x := TileInfo.Statics[i].x;
       MinTiles_Array[High(MinTiles_Array)].y := TileInfo.Statics[i].y;
       MinTiles_Array[High(MinTiles_Array)].z := TileInfo.Statics[i].z;
      end;                           
   end;
 AddToSystemJournal('Found ' + IntToStr(Length(MinTiles_Array)) + ' tiles to mine.');   
end.;
а зачем?
reynard
Posts: 7
Joined: 04.06.2016 0:00

Re: Помогите пожалуйста по записи в файл

Post by reynard »

Нет сил думать как впилить эту процедуру в скрипт майнинга, который берёт тайлы из файла.
drabadan
Expert
Expert
Posts: 730
Joined: 13.12.2012 17:35
Contact:

Re: Помогите пожалуйста по записи в файл

Post by drabadan »

У кого нет сил? Может скрипт в студию и попросить умельцев соеденить...
reynard
Posts: 7
Joined: 04.06.2016 0:00

Re: Помогите пожалуйста по записи в файл

Post by reynard »

Code: Select all

Program Mining;
type MiningR = record
tile:word;
px,py,pz:integer;
end;
Var MiningP: array [0..312] of MiningR;
ItemCount,b:Integer;
Const
Forge = $40D38DC8;
pointX = 2558;
pointY = 478;
eda = $097B;
point1X = 2561;
point1Y = 529;
point2X = 2557;
point2Y = 501;
point3X = 2577;
point3Y = 430;
nearX = 2563;
nearY = 537;
onboadx = 2559;
onboady = 540;
onboadz = -2;
Trap = $430c2f10;
waightlimit = 200;
OreType = $19B9;
PickType = $0E85;
PickGump = '3717';
Tinktype = $1EBC;
CopperType = $1BF2;

{$Include 'all.inc'}

 Procedure GetMiningTiles(s:String;WPos:Integer);
 begin
 s := s + ' ';
 MiningP[WPos].tile:=StrToInt(Copy(s,1,Pos(' ',s)-1));
 Delete(s,1,Pos(' ',s));
 MiningP[WPos].px:=StrToInt(Copy(s,1,Pos(' ',s)-1));
 Delete(s,1,Pos(' ',s));
 MiningP[WPos].py:=StrToInt(Copy(s,1,Pos(' ',s)-1));
 Delete(s,1,Pos(' ',s));
 MiningP[WPos].pz:=StrToInt(Copy(s,1,Pos(' ',s)-1));
 Delete(s,1,Pos(' ',s));
 end;
 
 Procedure GetCoord;
 var
 List:TStringList;
 b:integer;
 begin
 List:=TStringList.Create;
 List.LoadFromFile('E:\v.txt');
 for b := 0 to List.Count-1 do
 GetMiningTiles(List.strings[b],b);
 ItemCount:=b;
 end; 
 Procedure autoloops;
begin
UoSay('.autoloop 5')
wait(1000)
end; 

 procedure checkcoord;
 begin
 CheckSave;
 checkdead;
 if (GetZ(self) = onboadz) then
 begin
 repeat
 UseObject(Trap);
 wait(500);
 Raw_Move(2, True);
 Raw_Move(2, True);
 wait(500);
 until (GetZ(self) <> onboadz);
 AddToSystemJournal('Сошел на берег успешно!');
 MoveXY(point1X,point1Y, True, 0, True);
 if (GetX(self) = point1X) then
 begin
 MoveXY(point2X,point2Y, True, 0, True);
 if (GetX(self) = point2X) then
 begin
 MoveXY(point3X,point3Y, True, 0, True);
 autoloops;
 end;
 end;
 end;
 end;
 
procedure CheckCooper;
begin
FindType(CopperType, Backpack);
if (FindFullQuantity < 10) then
 begin
 FindTypeEx(CopperType,$0602,Ground,true);
 MoveItem(finditem, 25, backpack, 0,0,0);
 wait(1000);
 end;
end;

Procedure make_item;
Begin
CancelMenu;
WaitMenu('What', 'Deadly Tools'); 
WaitMenu('make', 'Pickaxe'); 
if TargetPresent then CancelTarget; 
WaitTargetType(CopperType);
usetype(Tinktype,$ffff);
end; 

procedure CheckPick;
begin
CheckSave;
checkdead;
CheckCooper;
if (Count(PickType) < 1) then
 begin
 repeat
 ClearJournal;
 make_item;
 WaitGump(PickGump);
 WaitTargetobject(findtype(CopperType, backpack));
 UseObject(FindType(TinkType, backpack));
 WaitJournalLine(Now, 'You create|destroy|You put', 30000);
 wait(500);
 until (Count(PickType) >= 1);
 end;
end; 
procedure DropOre;
 var g : integer;
 OreCol : Array [0..17] of Word;
Begin
 finddistance := 3;
 CheckSave;
 AddToSystemJournal('Сбрасываем руду');
 oreCol[0] := $0602; // Copper Ore
 oreCol[1] := $0000; // Iron Ore
 oreCol[2] := $0482; // Steel Ore
 oreCol[3] := $045E; // Anra Ore
 oreCol[4] := $07D6; // Valurite Ore
 oreCol[5] := $0852; // Old Britain Ore
 oreCol[6] := $04EA; // Lavarock Ore
 oreCol[7] := $04AB; // Black Dwarf Ore
 oreCol[8] := $07F8; // Spectral Ore
 oreCol[9] := $0948; // Shadow Ore
 oreCol[10] := $095F; // Azurite Ore
 oreCol[11] := $0A09; // Icerock Ore
 oreCol[12] := $094C; // Doom Ore
 oreCol[13] := $0A3D; // Blue Steel Ore
 oreCol[14] := $04B0; // Dark Ruby Ore
 oreCol[15] := $0487; // Crystallite Ore
 oreCol[16] := $094F; // Onyx Ore
 oreCol[17] := $0947; // Mithril Ore
 for g := 0 to 17 do
 begin
 CheckSave;
 FindTypeEx(CopperType,oreCol[g],backpack,true);
 if FindCount > 0 then
 begin
 stack(CopperType,oreCol[g]);
 wait(1000);
 end;
 end;
 hungry (1,-1);
 wait(500);
 Addtosystemjournal('=========================================');
 FindType(CopperType,ground);
 Addtosystemjournal('Всего металла на лодке - '+intToStr(findfullquantity));
 FindTypeEx(CopperType,$0602,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Copper Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$0000,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Iron Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$0482,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Steel Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$045E,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Anra Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$07D6,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Valurite Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$0852,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Old Britain Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$04EA,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Lavarock Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$04AB,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Black Dwarf Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$07F8,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Spectral Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$0948,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Shadow Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$095F,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Azurite Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$0A09,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Icerock Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$094C,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Doom Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$0A3D,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Blue Steel Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$04B0,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Dark Ruby Ore - '+intToStr(findfullquantity));
 end; 
 FindTypeEx(CopperType,$0487,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Crystallite Ore - '+intToStr(findfullquantity));
 end; 
 FindTypeEx(CopperType,$094F,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Onyx Ore - '+intToStr(findfullquantity));
 end;
 FindTypeEx(CopperType,$0947,ground,False);
 if FindCount > 0 then
 begin
 Addtosystemjournal('Mithril Ore - '+intToStr(findfullquantity));
 end;
 
 FindType(TinkType,ground);
 Addtosystemjournal('Тулзов на лодке - '+intToStr(findfullquantity));
 FindType(eda,ground);
 Addtosystemjournal('Еды осталось - '+intToStr(findfullquantity));
 Addtosystemjournal('=========================================');
 
End;
 Procedure gen;
 begin
 UoSay('.autoloop 1')
 wait(1000)
 end; 
 procedure smelting;
 begin
 if (Count(OreType) <> 0) then
 begin
 repeat
 WaitTargetObject(Forge);
 UseObject(FindType(OreType,Backpack));
 WaitJournalLine(Now, 'You create|destroy', 10000);
 wait(500);
 until (Count(OreType) = 0);
 gen;
 end;
 end;
 procedure GotoOnBoad;
 begin
 CheckSave;
 checkdead;
 MoveXY(pointX,pointY, true, 0, True);
 smelting;
 MoveXY(point2X,point2Y, True, 0, True);
 MoveXY(point1X,point1Y, True, 0, True);
 MoveXY(nearX,nearY, True, 0, True);
 wait(100);
 repeat
 UseObject(Trap);
 wait(1000);
 until (GetX(self) = OnBoadX) and (GetY(self) = OnBoadY);
 wait(1000);
 Hungry(1,-1);
 DropOre;
 CheckPick;
 checkcoord;
 end;
 
 procedure checktools;
 begin
 FindType(PickType, Backpack);
 if (FindCount < 1) then
 begin
 GotoOnBoad;
 end;
 end;
 
 procedure CheckEquip;
 Var EquipPick : Cardinal;
 begin
 if (GetType(ObjAtLayer(RhandLayer)) <> PickType) then
 begin
 Disarm;
 wait(500);
 checktools;
 FindType(PickType, Backpack);
 EquipPick := finditem;
 Equip(RhandLayer, EquipPick);
 end;
 end;
 
 procedure Mining(tile:Word;x,y,z:Integer); 
 begin
 CheckSave;
 checkdead;
 WaitTargetTile(tile,x,y,z);
 UseObject(ObjAtLayer(RhandLayer));
 WaitJournalLine(Now, 'no more ore|broke|stop mining|cannot see|far away|cannot mine|what is this?!', 35000); 
 checktools;
 end;
 
 procedure checkweight;
 begin
 if (Weight > waightlimit) then 
 begin
 GotoOnBoad;
 end;
 end;
 
 Begin
 SetArStatus(true);
 checkdead;
 getcoord;
 ClearJournal;
 AddToSystemJournal('Скрипт успешно стартовал.');
 While (not Dead) do
 begin
 for b :=0 to 312 do
 begin
 CheckSave;
 CheckDead;
 CheckCoord;
 CheckWeight;
 MoveXY(MiningP[b].px,MiningP[b].py, True, 1, True);
 Addtosystemjournal('Tile number '+intToStr(b)+'!');
 CheckEquip;
 Mining(MiningP[b].tile,MiningP[b].px,MiningP[b].py,MiningP[b].pz);
 Wait(500);
 end;
 end;
 End.
Это сам скрипт. Как сделать так, чтоб чар сам искал тайлы для копания? Хотя мне и не сложно было добавить их в файл. Но всё-же. Чтобы этого не делать каждый раз в новой пещере.
Post Reply