Results 1 to 5 of 5

Thread: help with procedure

  1. #1
    Join Date
    Sep 2007
    Posts
    143
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default help with procedure

    procedure Cast;
    begin
    GameTab(28);
    if not FindDTMRetry(Enchant, x, y, 556, 214, 731, 426, 0) then
    restart('more runes');
    begin
    Mouse(x, y, 3, 3, True);
    Wait(100 + Random(100));
    if not FindDTMRetry(diamond, x, y, 560, 210, 725, 317, 0) then
    restart('need diamond amulet');
    Mouse(x, y, 10, 10, True);
    end;
    end;

    this is what happens, it runs but will only cast the 1st amulet and keep casting on the 1st amulet.. i would like it to cast on the rest of the amulets :P

  2. #2
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by weby View Post
    SCAR Code:
    procedure Cast;
    begin
      GameTab(28);
      if not FindDTMRetry(Enchant, x, y, 556, 214, 731, 426, 0) then
          restart('more runes');
          begin
        Mouse(x, y, 3, 3, True);
      Wait(100 + Random(100));
         if not FindDTMRetry(diamond, x, y, 560, 210, 725, 317, 0) then
          restart('need diamond amulet');
      Mouse(x, y, 10, 10, True);
         end;
      end;

    this is what happens, it runs but will only cast the 1st amulet and keep casting on the 1st amulet.. i would like it to cast on the rest of the amulets :P
    Try FindDTMs() or alternatively you can search each slot for the DTM instead of the entire Inventory, as it's finding the closest which is slot one.

    Meaning you need to do something like...

    SCAR Code:
    for I := 1 to 28 do
    begin
      m := InvBox(I);
      FindDTMRetry(x, y, DTM, M.x1, M.y1, M.x2, M.y2, etc);
    end;

    or...

    SCAR Code:
    var
      TPA: tPointArray;
    begin
      FindDTMS(TPA, DTM, MIx1, MIy1, MIx2, MIy2, etc);
      for I := 0 to high(TPA) do
      begin
        // click each DTM
      end;
    end;

    make sense?

  3. #3
    Join Date
    Sep 2007
    Posts
    143
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ok but the dtm for power and diamd amulet are the same :P how would i add upchecktext?

  4. #4
    Join Date
    Nov 2009
    Location
    Seattle, WA
    Posts
    589
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Lol UpText is very simple. As blumblebee said, move the mouse onto the DTM. Then call this line.

    Simba Code:
    if (WaitUpText({Object UpText}, RandomRange(200, 400))) then
      //Do What You Want :D
    There are several functions for checking uptext

    There are plenty of ways of making it know which amulet it is, just gotta use your imagination

    As for Casting on each amulet, just take your time and think it through

    Simba Code:
    function FindItemsInInventory(ItemDTMs:TIntegerArray): TIntegerArray; // ItemDTM's will be the Item DTMs :D The Result will be the slot numbers of all the items it found.
    var
      a, i, X, Y: Integer;
      InventorySlot: TBox;
      SlotsFound: Integer;
    begin
      SlotsFound := 0;
      for I := 1 to 28 do // 28 inventory slots. starting from the 1st...
      begin
        InventorySlot := InvBox(I); // gets the inv slot.
        {scans the slot for each dtm in the array}
        for a := 0 to High(DTM) do
          if FindDTM(ItemDTMs[a], X, Y, InventorySlot.X1, InventorySlot.Y1, InventorySlot.X2, InventorySlot.Y2) then
          begin
            {SlotsFound is simply used to set the result array length}
            Inc(SlotsFound);
            SetLength(Result, SlotsFound); // Sets the Results Length to the amount of items it found.
            Result[SlotsFound - 1] := i; // saves the slot number to the result array.
            Break; // Breaks out of the loop since we can only have 1 item in each slot.
          end;
      end;
    end;            

    function CastOnAllAmulets(SpellName: string): Boolean;
    var
      a, CGT: Integer;  // CGT = Current Game Tab.
      i: TBox; // Used for inventory slots.
      AmuletDTM: Integer; // amulet DTM.
      Amulets: TIntegerArray; // Our slot array.
    begin
      {Setup}
      CGT := GetCurrentTab;
      GameTab(25);
      Amulets := FindItemsInInventory([AmuletDTM]); // Saves the Slot Numbers of all the amulets.

      {Attempts to cast spell}  
      try  // I like using Try loops ^^.
        for a := 0 to High(Amulets) do
        begin
          {Search for items}
          i := InvBox(Amulets[a]); // Gets the Inventory slot of our amulet.
          GameTab(28); // switches to magic tab.

          {Attempt To Cast Spell}
          Result := Cast(SpellName, False); // casts spell.
          if (not(Result)) then
          begin
            srl_Warn('CastOnAllAmulets', 'Failed to activate spell ' +SpellName, 0);
            Exit;
          end;

          {Uhm.. Casts the spell on the item?? I think <.<}
          GameTab(25); // switches back to Inv.
          MouseBox(i.X1, i.Y1, i.X2, i.Y2, 1); // I dunno how enchanting/magic works =P But MouseBox clicks on a random point in a TBox, so this should work.. i think =/ lol
        end;
      finally  // Regardless of what happens..
        GameTab(CGT); // Switch back to the initial gametab.
      end;

    end;

    Just an example, i don't know if that will compile or not xD, or if that will work in theory, but its just to give some ideas :P. Plenty of ways of doing this . Blumblebee's methods work very well for this situation ^^. Pretty much any method for anything can do a job just make your you failsafe it ^^.
    Last edited by Heavenguard; 09-02-2010 at 07:05 AM.
    Don't Troll, Don't Fight, Just keep the Respect
    Status : Offline

    Feel free to re-make my scripts ;D
    Community Member

  5. #5
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Change Mouse to MMouse (and change the parameters accordingly) and then do something like.. if(IsUpText('iamon'))then Mouse(x, y, 0, 0, True);.

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
  •