Results 1 to 5 of 5

Thread: Need help developing construction script

  1. #1
    Join Date
    Dec 2011
    Location
    Lithuania
    Posts
    71
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Question Need help developing construction script

    I have written some construction script (makes oak larders), but it needs upgrade, since i am not very good scripter (it's my first script). I decided to write it cause I had free time due my bronken arm. Now I am getting better and going back to work.
    Longest run of script about 20 mins, but room has to be not made of wood, I used polished rock.
    Simba Code:
    program Con;
    {$define SMART}
    {$i srl/srl.scar}
    var
      xSer, ySer, x, y, sr, LarderCount :integer;
      LoadBack :Boolean;
    procedure DeclarePlayers;
    Begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      With Players[0] Do
      Begin
        Name        := '';     //Player username.
        Pass        := '';     //Player password.
        Nick        := ''; //Player nickname - 3-4 letters of Player username.
        Active      := True;
      End;
    End;

    procedure Startup;
    begin
      Smart_Server := 54;
      Smart_Members:= true;
      Smart_Signed := true;
      Smart_SuperDetail := false;
      SetupSRL;
      DeclarePlayers;
      LogInPlayer;
      wait(100+random(100));
    end;

    Procedure Setup;
      begin
      ToggleXPBar( True);
      Wait(500);
      LoadBack:= False;
      LarderCount:=0;
      end;

    Procedure SRock;
    var xSR, ySR:integer;
    Begin
    if FindObjEx(xSR, ySR, ['trange'], [7171954], 15, 30, 570, 210, 720, 460) then
      Begin
        Mouse(xSR, ySR, 2, 2, false);
        Wait(RandomRange(100,200));
        ChooseOption('estroy');
        Wait(800);
        Mouse(RandomRange(345,405), RandomRange(395,410), 2, 2, True);
      end;
    end;

    Procedure Servant;
    begin
      Mouse(xSer, ySer, 2, 2, false);
      Wait(RandomRange(100,200));
      ChooseOption('etch');
      Wait(850);
      If FindNPCChatText('If', Nothing) then
        begin
        ClickToContinue;
        Wait(RandomRange(1100,1500));
        FindNPCChatText ('coins.', ClickLeft);
        Wait(250);
        Mouse(xSer, ySer, 2, 2, false);
        Wait(RandomRange(400,700));
        ChooseOption('etch');
        Wait(600);
        end;
      If not FindNPCChatText ('etch', nothing) then
        begin
        Wait(300);
        FindNPCChatText ('Oak', ClickLeft);
        Wait(500)
        TypeSend('20');
        Wait(150);
        end;
      FindNPCChatText ('etch', ClickLeft);
      LoadBack:=False;
      Wait(500 + Random(300));
      end;

    Procedure FServant;
    var SColors: TIntegerArray;
        i: integer;
    begin
      SColors:= [989748, 1451339, 2174831, 1845343, 1779290];
      //FindObjCustom(xSer, ySer, ['Butler', 'utler'], [790871, 988466], 25);
      For i:=0 to 4 do
      begin
        FreeSRLBitmaps;
      If FindObjTPA(xSer, ySer, SColors[i], 30, -1, 10, 15, 1, ['utler', 'Butler']) then
        begin
        Servant;
        Break;
        end;
        end;
    end;


    Procedure FLadder;
    var LColors:TIntegerArray;
        t:integer;
    begin
    Inc(x); Inc(y);
        LColors:=[4613503, 2838371, 2574426];
        Writeln('Search ladder');
        if FindObjCustom(x, y, ['earch', 'Larder'], [2904421, 8423046], 5)then
        begin
        Mouse(x, y, 2, 2, false);
        Wait(150)
        ChooseOptionMultiEx(['Remove','emove'], 'Object', ClickLeft);
        Wait(1000 + Random(200));
        FindNPCChatText ('Yes', ClickLeft);
        Wait(800);
        end;
        {For t:=0 to 2 do
        begin
        If FindObjTPA(x, y, LColors[t], 15, -1, 15, 15, 3, ['Larder', 'arder']) then
        begin
        Remove;
       Writeln('aaaa');
       Break;
        end;
        end;}

    end;

    Procedure Build;
    var OXP, NXP:integer;
    begin
      Inc(x); Inc(y);
      //If IsXPBarOpen Then
      //OXP:= GetXPBarTotal;
      //Writeln(OXP);
      Mouse(x, y, 2, 2, false);
      Wait(RandomRange(400,600));
      ChooseOptionMultiEx(['Build','uild'], 'Object', ClickLeft);
      Wait(650);
      //WaitColor(197, 64, 2070783, 10, 2500);
      Mouse(RandomRange(105,115), RandomRange(135,145) , 2, 2, True);
      Wait(250)
      {NXP:= GetXPBarTotal;
      Writeln(NXP);
      if NXP>OXP then
      begin
      LarderCount:=LarderCount+1;
      Writeln(LarderCount);
      end;}

    end;

    begin
        Startup;
      //Setup;
      sr:=1;
       Inc(x); Inc(y);
      repeat
        If CountItemsArea ('inv')<16 then FServant;
        Wait(500 + Random(300));
        if CountItemsArea ('inv')>7 then
        begin
        FLadder;
        Build;
        SRock;
        Wait(600);

        end;
        If Not LoadBack then
        begin
        Repeat
        Wait(1000)
        if CountItemsArea ('inv')>19 then LoadBack:= True;
        Until(LoadBack);
        end;
        sr:=sr+1;
      until(sr=30);
    end.
    Script needs:
    Timing function, like wait till construction interface opens;
    Improve larder finding (I find built larder, then remove and use same X, y to build new one);
    Few failsafes, I tried to use XP counter failsafe, but it didn't work (this failsafe is in comments at script file);

    If anybody could help or have some ideas write it here.

  2. #2
    Join Date
    May 2007
    Location
    UK
    Posts
    4,007
    Mentioned
    1 Post(s)
    Quoted
    12 Post(s)

    Default

    Simba Code:
    {$i srl/srl.scar}
    to
    Simba Code:
    {$i srl/srl.simba}

    Randomize some of your waits,
    Simba Code:
    Wait(850);
    Simba Code:
    Wait(250);
    Simba Code:
    Wait(600);
    Simba Code:
    If not FindNPCChatText ('etch', nothing) then
        begin
        Wait(300);
        FindNPCChatText ('Oak', ClickLeft);
        Wait(500)
        TypeSend('20');
        Wait(150);
        end;

    Other than that, looks good

    -Boom

  3. #3
    Join Date
    Dec 2011
    Location
    Lithuania
    Posts
    71
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Function Servant1:Boolean;
    begin
    Result:=False;
    If FindNPCChatText('3750', Nothing) then
    Result:=True;
    end;
    WaitFunc(@Servant1, 100, 20000);
    Function Servant1 always return false. Any ideas and sugestions?
    Last edited by SantWrong; 01-20-2012 at 04:13 PM.

  4. #4
    Join Date
    Jan 2012
    Location
    Minneapolis, Mn
    Posts
    185
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by SantWrong View Post
    Function Servant1 always return false. Any ideas and sugestions?
    Try this out:

    Simba Code:
    Function Servant1:Boolean;
    begin
        Result := FindNPCChatText('3750', Nothing)
    end;

  5. #5
    Join Date
    Dec 2011
    Location
    Lithuania
    Posts
    71
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well I've found out that
    If FindNPCChatText('Yes', Nothing) then Writeln('bb');
    Always return false and dont write line
    While
    If FindNPCChatText('Yes', ClickLeft) then Writeln('bb');
    Manages to click Yes, but still returns false.
    At same situation, instead of usin 'Yes', I use 'No', works fine, returns True.

    What function I should use to make sure if text "Really remove it" appears.
    I tried
    FindTextTpa(7913190,35,150, 350 ,380, 370, 'rem', 'CharsNpc', Nothing)
    Attachment 13244
    Last edited by SantWrong; 01-20-2012 at 06:55 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •