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

Задержка при копке

тут можно задать вопрос по скриптингу
Post Reply
Vargul
Neophyte
Neophyte
Posts: 49
Joined: 16.09.2010 10:30

Задержка при копке

Post by Vargul »

Code: Select all

program mining;

{$Include 'all.inc'}
const
pickaxe = $0E85;
pickaxe_color=$0000;
sunduk=$400B360E;//Сундук с регами, кирками и т.д.
sunduk2=$4022FCD3; // Сундук для руды
Sumkadrop = $0E75; //Сумка в паке для руды
Sumka = $4026C264;//ID сумки для руды
RB=$4040D772; // рунбука
RunaHome = 8; // номер руны домой
Xhome=4249;
Yhome=736;
trash=$400B360E; // pomoyka dl9 sbrosa mapov <Need Setup>
tonaj=990;
recal=$1F4C;
BM=$0F7B;//Blood Moss
MR=$0F86;//Mandrake Root
BP=$0F7A;//Black Pearl
Invis=$0F0E;//Invis potion
InvisColor=$09F2;
bottle=$0F0E;
bColor=$0000;
HowGet=3;
Rune=$1F14;//руна для быстрого рекола

  // Журнал
M_nothing1 = 'no ore here to mine';
M_nothing2 = 'That is too far';
M_nothing3 = 'Try mining in rock';
M_nothing4 = 'elsewhere';
M_nothing5 = 'location';
M_nothing6 = 'reach';
M_fizzles1 = 'You loosen some rocks';
M_needwait = 'must wait';
M_success = 'in your pack.';

var L,x,y,k,g,p,r:integer;
mn1, mf1, mw1, ms1 : Integer;
ctime:TDateTime;
Enemy : array[1..13] of cardinal;
Ruda : array[1..4] of cardinal;
Runa : array[1..21] of integer;

procedure CheckDead;
Begin
     if Dead then
     begin
      AddToSystemJournal('Персонаж мертв: '+TimeToStr(now));
      SetARStatus(False);
      Disconnect;
     end
end;

procedure Recall;
begin
Runa[1] := 22; 
Runa[2] := 2; 
Runa[3] := 3;
Runa[4] := 4;
Runa[5] := 10;
Runa[6] := 6;
Runa[7] := 7;
Runa[8] := 9;
Runa[9] := 11;
Runa[10] := 19;
Runa[11] := 12
Runa[12] := 1;
Runa[13] := 14;
Runa[14] := 6;
Runa[15] := 22;
Runa[16] := 4;
Runa[17] := 7;
Runa[18] := 13;
Runa[19] := 3;
Runa[20] := 21;
Runa[21] := 22;
UseObject(RB);
WaitGump(IntToStr(Runa[r]));
wait(10000);
r:=r+1;
if (r > 21) then r:=1;
end;

procedure Home;
   begin
     repeat
      checksave;
      disarm;
      wait(200);
      UseObject(RB);
      WaitGump(IntToStr(RunaHome));
      wait(10000);
      NewMoveXY(Xhome, Yhome, false, 0, false);
     until (GetX(self) = Xhome) and (GetY(self) = Yhome) or dead
   end;

function CheckPickaxe : Boolean;
   var tmpser : Cardinal;
   begin
      Result := true;
      if (ObjAtLayer(RhandLayer) = 0) then
      begin
        tmpser := findtype(pickaxe,backpack);
        if tmpser = 0 then
         begin
            Result := false;
            exit;
         end;
         wait(500);
         checksave;
      end;
   end;

procedure CheckHide;
   begin
      if Hidden then exit;
      if WarMode = true then SetWarMode(false);
      repeat
         if WarMode = true then SetWarMode(false);
         UseSkill('Hiding');
         wait(7000);
         checksave;
      until Hidden or (not Connected);
   end;

function CheckEnemy : Boolean;
begin
Result := false;
for  p:=1  to 13  do
    begin
     findtype(Enemy[p],ground)
     if (findcount > 0) then
        begin
         Result := true;
         Addtosystemjournal('Тут кто-то есть, валим отсюда!');
         exit;
        end;
     wait(100)
     checksave;
    end;
end;

procedure pk_save; //: Boolean;
 var mx, my, Res : Integer;
 begin
        Ruda[1] := $19B7;
        Ruda[2] := $19BA;
        Ruda[3] := $19B8;
        Ruda[4] := $19B9;
  Repeat
     Res:=0;
       If not Dead then
       begin
         for k := 1 to 4 do
           begin
            repeat
              findtype(Ruda[k],BackPack);
              if (findcount > 0) then MoveItems(backpack, Ruda[k], $FFFF, Sumka, 0, 0, 0, 500);
              wait(500);
              checksave;
              until findcount = 0;
           end;
        Addtosystemjournal('Реколимся при помощи магии');
        FindType(Sumkadrop, Backpack)
        DropHere(FindItem);
        cast('Recall');
        WaitTargetType(Rune);
        wait(1500);
        UseObject(FindType(Invis,Backpack));
        wait(1000);
        FindType(Sumkadrop,Ground);
        DragItem(FindItem,1);
       end;
        mx := GetX(self);
        my := GetY(self);
        k := 0;
          Repeat
           wait(500);
           k := k + 1;
          until (mx<>GetX(self)) or (my<>GetY(self)) or Dead or (k=10)

      if (GetX(self) = 4249) and (GetY(self) = 737) then Res :=1;
  Until Res = 1;
  Addtosystemjournal('Фуф, свалили.');
  DropItem(backpack,0,0,0);
  Repeat
    checksave;
    disarm;
    wait(200);
    NewMoveXY(Xhome, Yhome, false, 0, false);
  Until (GetX(self) = Xhome) and (GetY(self) = Yhome) or dead
 end;

procedure Min;
var Kletka : integer;
begin
        Ruda[1] := $19B7;
        Ruda[2] := $19BA;
        Ruda[3] := $19B8;
        Ruda[4] := $19B9;

while (connected) do
begin
    Kletka :=80;
    if (ObjAtLayer(RHandLayer) = 0) then equipt(RHandLayer,pickaxe);
    for x := -4 to 4 do
    begin
        for y := -4 to 4 do
        begin
     repeat
        wait(100);
        ctime := Now;
        if (CheckEnemy) then
          begin
           pk_save;
           Kletka:=80;
           exit;
          end;
        CheckHide;
        if (CheckEnemy) then
          begin
           pk_save;
           Kletka:=80;
           exit;
          end;
        UseObject(ObjAtLayer(RHandLayer));
        WaitForTarget(1000);
        checksave;
        Addtosystemjournal(IntToStr(Kletka));
        If TargetPresent then TargetToTile(0, GetX(self)+x, GetY(self)+y, GetZ(self));
            k:=0
            repeat
            checksave;
            wait(100);
            k:= k+1;
                  mn1 := InJournalBetweenTimes('think of a way to use this item|Rusty|Old Copper|Dull Copper|Copper|Bronze|Steel|Silver|Gold|Shadow|Bluesteel|Rose|Agapite|Blood|Verite|Moon|no ore here to mine|location|elsewhere|in rock|far|У этой кирки', ctime, Now);
                  mf1 := InJournalBetweenTimes('loosen', ctime, Now);
                  ms1 := InJournalBetweenTimes('Iron|Realsilver|Valorite|Mytheril|Blackrock|Fire|Water|Earth|Air|Kvendenjare', ctime, Now);
                  mw1 := InJournalBetweenTimes('think of a way to use this item|location|elsewhere|in rock|far|no ore here to mine|must wait', ctime, Now);
               until (mn1<>-1) or (mf1<>-1) or (ms1<>-1) or (mw1<>-1) or Dead or (k > 50);
             if (CheckEnemy) then
             begin
               pk_save;
               Kletka:=80;
               exit;
             end;
             if (weight > tonaj) then
                begin
                 wait(300);
                 Home;
                 Kletka:=80;
                 exit;
             end;       
          for g := 1 to 4 do
           begin
            repeat
              findtype(Ruda[g],BackPack);
              if (findcount > 0) then MoveItems(backpack, Ruda[g], $FFFF, Sumka, 0, 0, 0, 600);
              wait(100);
              checksave;
              until findcount = 0;
           end;
             if (ObjAtLayer(RHandLayer) = 0) then
                begin
                if (not CheckPickaxe) then exit;
                equipt(RHandLayer,pickaxe);
                end;
            until (mn1<>-1);
            Kletka:=Kletka-1;  

end;
end;
end;
end;

BEGIN

SetARStatus(true);
r:=1;
Ruda[1] := $19B7;
Ruda[2] := $19BA;
Ruda[3] := $19B8;
Ruda[4] := $19B9;
Enemy[1] := $0191;
Enemy[2] := $0190;
Enemy[3] := $0F0D;
Enemy[4] := $0005;
Enemy[5] := $0006;
Enemy[6] := $00D0;
Enemy[7] := $00C9; 
Enemy[8] := $00D9; 
Enemy[9] := $0015; 
Enemy[10] := $0009;
Enemy[11] := $000A;
Enemy[12] := $0004;
Enemy[13] := $003C; 
ignore(self);
finddistance := 20;

if (not dead) then home;

while true do
 begin
    while Connected do
    begin
    if (GetX(self) = Xhome) and (GetY(self) = Yhome) and not dead then
        begin
          Addtosystemjournal('Home, sweet home');

              useobject(sunduk2);
              wait(1000);
              UseObject(Sumka);
               for k := 1 to 4 do
               begin
                repeat
                  findtype(Ruda[k],Sumka);
                  if (findcount > 0) then MoveItems(Sumka, Ruda[k], $FFFF, sunduk2, 0, 0, 0, 1000);
                  wait(1000);
                  checksave;
                until findcount = 0;
               end;
              wait(1000);
              useobject(sunduk);
              Hungry(0,-1);
              wait(1000);
              checksave;
              findtype(recal,sunduk);
               if (findcount > 0) then
                 begin
                   MoveItem(FindItem, 65, Backpack, 0, 0, 0)
                   wait(1000);
                   UOSAY('.travelbook_recharge');
                   WaitTargetType(recal);
                   wait(1000);
                   WaitTargetObject(RB);
                   wait(1000);
                   checksave;
                   MoveItems(Backpack, recal, $FFFF, sunduk, 0, 0, 0, 500);
                   wait(1000);
                 end;
              checksave;
              wait(1000);
              //Добор регов              
              FindType(BM,Backpack);
              if (FindCount = 0) or (Count(BM) < 2) then
               begin
                FindType(BM,Sunduk);
                  if FindCount > 0 then
                    begin
                     MoveItem(FindItem,5,Backpack,0,0,0);
                     wait(1000);
                    end;
               end;
               FindType(MR,Backpack);
               if (FindCount = 0) or (Count(MR) < 2) then
                 begin
                  FindType(MR,Sunduk);
                    if FindCount > 0 then
                      begin
                        MoveItem(FindItem,5,Backpack,0,0,0);
                        wait(1000);
                      end;
                 end;
               FindType(BP,Backpack);
               if (FindCount = 0) or (Count(BP) < 2) then
                 begin
                  FindType(BP,Sunduk);
                    if FindCount > 0 then
                      begin
                       MoveItem(FindItem,5,Backpack,0,0,0);
                       wait(1000);                       
                      end;
                 end;
               FindTypeEx(Invis,InvisColor,Backpack,False);
                if (FindCount < 3) or (Count(FindItem) < 3) then  
                 begin
                   FindTypeEx(Invis,InvisColor,Sunduk,False);
                       MoveItem(FindItem,3,Backpack,0,0,0);
                       wait(1000);                       
                 end;

               FindTypeEx(bottle,bColor,Backpack,False)
               If Findcount > 0 then
               begin
                 DropHere(FindItem);
               end;
///////////////////////////////////////////              
         FindTypeEx(pickaxe,pickaxe_color,Backpack,False);
          if findcount < 5 then         
           begin
            FindTypeEx(pickaxe,pickaxe_color,sunduk,False);
            if findcount > 0 then
                begin
                  FindTypeEx(pickaxe,pickaxe_color,backpack,False);
                  L:=Findcount;
                  While L < 5 do
                   begin
                       FindTypeEx(pickaxe,pickaxe_color,sunduk,False);
                       MoveItem(FindItem, 1, BackPack, 0, 0, 0);
                       wait(1000);
                       FindTypeEx(pickaxe,pickaxe_color,backpack,False);
                       L:=Findcount;
                   end;
                end;   
           end; 
         wait(1000);
        disarm;
        recall;
        end;
    if CheckPickaxe and (not dead) then Min
        else
        begin
        if dead then
            begin
              Addtosystemjournal('y6uJIu!!!');
              SetARStatus(False);
              Disconnect;            
            end;
        end;
    end;
   wait(100);
 end;
END.

Смысл скрипта, летать по шахтам, при выкапывании руды указанной в переменной mn1 переходить к след.тайлу, складывать руду в сумку в бэкпаке, при появлении кого либо кидает сумку с рудой на пол, рекол по руне, подбор сумки - у меня на шарде по руне, с рудой в бэкпаке, нельзя реколиться.
Все норм, один минус, при копке почему то большая задержка между попытками в 4 секунды, была вообще 8, поигрался с until (mn1<>-1) or (mf1<>-1) or (ms1<>-1) or (mw1<>-1) or Dead or (k > 50).
k>300 было, попробовал так - until (mn1<>-1) or (mf1<>-1) or (ms1<>-1) or (mw1<>-1) or Dead, не помогает, поставил k>50, более мене терпимо, но все равно 4 сек много. Подскажите где косяк.
Lietman
Novice
Novice
Posts: 74
Joined: 12.12.2010 14:17
Contact:

Re: Задержка при копке

Post by Lietman »

может у тебя лаги ?)))
Vargul
Neophyte
Neophyte
Posts: 49
Joined: 16.09.2010 10:30

Re: Задержка при копке

Post by Vargul »

неее, я тут в корне переписал фильтр журнала, стало намного лучше :)
Это все сообщения какие получаю при копке

Code: Select all

M_nothing1  = 'There is no ore here to mine.';
M_nothing2  = 'That is too far away.';
M_nothing3  = 'Try mining in rock';
M_nothing4  = 'You have no line of sight to that location';
M_nothing5  = 'reach';
M_nothing6  = 'elsewhere';
M_nothing7  = 'think of a way to use this item';
M_nothing8  = 'You put the Rusty Ore in your pack.';
M_nothing9  = 'You put the Old Copper Ore in your pack.';
M_nothing10 = 'You put the Dull Copper Ore in your pack.';
M_nothing11 = 'You put the Copper Ore in your pack.';
M_nothing12 = 'You put the Bronze Ore in your pack.';
M_nothing13 = 'You put the Steel Ore in your pack.';
M_nothing14 = 'You put the Silver Ore in your pack.';
M_nothing15 = 'You put the Gold Ore in your pack.';
M_nothing16 = 'You put the Shadow Ore in your pack.';
M_nothing17 = 'You put the Bluesteel Ore in your pack.';
M_nothing18 = 'You put the Rose Ore in your pack.';
M_nothing19 = 'You put the Agapite Ore in your pack.';
M_nothing20 = 'You put the Bloodrock Ore in your pack.';
M_nothing21 = 'You put the Verite Ore in your pack.';
M_nothing22 = 'You put the Moon Stone Ore in your pack.';

M_success0 = 'You put the Realsilver Ore in your pack.';
M_success1 = 'You put the Valorite Ore in your pack.';
M_success2 = 'You put the Mytheril Ore in your pack.';
M_success3 = 'You put the Blackrock Ore in your pack.'; 
M_success4 = 'You put the Fire Ore in your pack.'; 
M_success5 = 'You put the Water Ore in your pack.';
M_success6 = 'You put the Earth Ore in your pack.';
M_success7 = 'You put the Air Ore in your pack.';
M_success8 = 'You put the Kvendenjare Rock Ore in your pack.';
M_success9 = 'You put the Iron Ore in your pack.';
M_success10 = 'Your mining tool just wanished';

M_fizzles1 = 'You loosen some rocks but fail to find any useable ore.';
M_fizzles2 = 'У этой кирки';
M_needwait = 'You must wait';
а потом проверяю

Code: Select all

            mn1 := InJournalBetweenTimes(M_nothing1, ctime, Now);
            mn2 := InJournalBetweenTimes(M_nothing2, ctime, Now);
            mn3 := InJournalBetweenTimes(M_nothing3, ctime, Now);
            mn4 := InJournalBetweenTimes(M_nothing4, ctime, Now);
            mn5 := InJournalBetweenTimes(M_nothing5, ctime, Now);
            mn6 := InJournalBetweenTimes(M_nothing6, ctime, Now);
            mn7 := InJournalBetweenTimes(M_nothing7, ctime, Now);
            mn8 := InJournalBetweenTimes(M_nothing8, ctime, Now);
            mn9 := InJournalBetweenTimes(M_nothing9, ctime, Now);
            mn10 := InJournalBetweenTimes(M_nothing10, ctime, Now);
            mn11 := InJournalBetweenTimes(M_nothing11, ctime, Now);
            mn12 := InJournalBetweenTimes(M_nothing12, ctime, Now);
            mn13 := InJournalBetweenTimes(M_nothing13, ctime, Now);
            mn14 := InJournalBetweenTimes(M_nothing14, ctime, Now);
            mn15 := InJournalBetweenTimes(M_nothing15, ctime, Now);
            mn16 := InJournalBetweenTimes(M_nothing16, ctime, Now);
            mn17 := InJournalBetweenTimes(M_nothing17, ctime, Now);
            mn18 := InJournalBetweenTimes(M_nothing18, ctime, Now);
            mn19 := InJournalBetweenTimes(M_nothing19, ctime, Now);
            mn20 := InJournalBetweenTimes(M_nothing20, ctime, Now);
            mn21 := InJournalBetweenTimes(M_nothing21, ctime, Now);
            mn22 := InJournalBetweenTimes(M_nothing22, ctime, Now);

            ms0 := InJournalBetweenTimes(M_success0, ctime, Now);
            ms1 := InJournalBetweenTimes(M_success1, ctime, Now);            
            ms2 := InJournalBetweenTimes(M_success2, ctime, Now);
            ms3 := InJournalBetweenTimes(M_success3, ctime, Now);
            ms4 := InJournalBetweenTimes(M_success4, ctime, Now);
            ms5 := InJournalBetweenTimes(M_success5, ctime, Now);
            ms6 := InJournalBetweenTimes(M_success6, ctime, Now);
            ms7 := InJournalBetweenTimes(M_success7, ctime, Now); 
            ms8 := InJournalBetweenTimes(M_success8, ctime, Now);
            ms9 := InJournalBetweenTimes(M_success9, ctime, Now);
            ms10 := InJournalBetweenTimes(M_success10, ctime, Now);
            mf1 := InJournalBetweenTimes(M_fizzles1, ctime, Now);
            mf2 := InJournalBetweenTimes(M_fizzles2, ctime, Now);
            
            mw  := InJournalBetweenTimes(M_needwait, ctime, Now);
            until (mn1<>-1) or (mn2<>-1) or (mn3<>-1) or (mn4<>-1) or (mn5<>-1) or (mn6<>-1) or (mn7<>-1) or (mn8<>-1) or (mn9<>-1) or (mn10<>-1) or (mn11<>-1) or (mn12<>-1) or (mn13<>-1) or (mn14<>-1) or (mn15<>-1) or (mn16<>-1) or (mn17<>-1) or (mn18<>-1) or (mn19<>-1) or (mn20<>-1) or (mn21<>-1) or (mn22<>-1) or (ms0<>-1) or (ms1<>-1) or (ms2<>-1) or (ms3<>-1) or (ms4<>-1) or (ms5<>-1) or (ms6<>-1) or (ms7<>-1) or (ms8<>-1) or (ms9<>-1) or (ms10<>-1) or (mf1<>-1) or (mf2<>-1) or (mw<>-1) or Dead or (k>300);

Может подскажите вариант упростить? Но так копает быстрее
Miralex
Developer
Developer
Posts: 656
Joined: 11.03.2005 19:12
Contact:

Re: Задержка при копке

Post by Miralex »

Все "You put ...." можно проверять просто как InJournalBetweenTimes('You put', ctime, Now);

Да и через разделительную черту можно просто перечислить куски твоих заветных фраз, например:
InJournalBetweenTimes('You put|loose|try|there is|must|и тд', ctime, Now);
Post Reply