Results 1 to 3 of 3

Thread: [Magic] RuneAmount() CastingMagic()

  1. #1
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default [Magic] RuneAmount() CastingMagic()

    Self explanatory.
    I really don't know why there aren't functions like these in Magic.scar already... IsCasting-function has been discussed many many times.

    SCAR Code:
    function RuneCount(Slots: TIntegerArray): Integer;
    var
      B: TBox;
      I: Integer;
    begin
      if (not LoggedIn) then Exit;
      GameTab(Tab_Inv);
      for I := 0 to High(Slots) do
      begin
        B := InvBox(Slots[I]);
        IncEx(Result, GetAmount(B.X1 + (B.X2 - B.X1) div 2, B.Y1 + (B.Y2 - B.Y1) div 2));
      end;
    end;

    function CastingMagic(RuneSlots: TIntegerArray): Boolean;
    var
      I, T: Integer;
    begin
      if (not LoggedIn) then Exit;
      I := RuneCount(RuneSlots);
      T := GetSystemTime + 3700 + Random(100);
      repeat
        Wait(10);
        if (RuneCount(RuneSlots) < I) then
        begin
          Result := True;
          Exit;
        end;
      until(GetSystemTime > T);
    end;

    E: Oh, I forgot these 3 I made for combat spells:
    SCAR Code:
    procedure m_FixSpellBookCombat;
    var
      X, Y: Integer;
    begin
      GameTab(tab_Magic);
      Y := 441;
      if GetColor(591, 441) <> 16777215 then
      begin
        Mouse(592, 450, 4, 4, True);
        Wait(600 + Random(100));
      end;
      for X := 0 to 2 do
      begin
        if GetColor(613 + X*22, Y) = 16777215 then
        begin
          Mouse(613 + X*22, Y + 11, 3, 3, True);
          Wait(600 + Random(100));
        end;
      end;
      if GetColor(705, 441) <> 16777215 then
      begin
        Mouse(703, 450, 3, 3, True);
        Wait(600 + Random(100));
      end;
    end;

    function m_SpellCoords(Spell: String): TPoint;
    var
      Spells: TStringArray;
      Num: Integer;
      B: TBox;
    begin
      Spells := ['wind strike', 'water strike', 'earth strike', 'fire strike',
        'wind bolt', 'water bolt', 'earth bolt', 'fire bolt', 'wind blast',
        'water blast', 'earth blast', 'fire blast', 'wind wave',
        'water wave', 'earth wave', 'fire wave'];
       
      if not InStrArrEx(LowerCase(Spell), Spells, Num) then
        if (StrToIntDef(GetNumbers(Spell), -1) > 0) then
          Num := StrToInt(GetNumbers(Spell)) -1;
      if Num < 0 then
      begin
        WriteLn('*** m_SpellCoords failed! ''');
        Exit;
      end;
      case Num of
        0..3: begin
                B.X1 := 563 + 23*Num;
                B.Y1 := 221;
              end;
        4..7:begin
                B.X1 := 563 + 23*(Num-4);
                B.Y1 := 248;
              end;
        8..10:begin
                B.X1 := 563 + 23*(Num - 8);
                B.Y1 := 270;
               end;
        11..13:begin
                B.X1 := 563 + 23*(Num - 11);
                B.Y1 := 293;
               end;
        end;
        B.X2 := B.X1 + 23;
        B.Y2 := B.Y1 + 15;
        Result := Point(B.X1 + (B.X2-B.X1)/2, B.Y1 + (B.Y2-B.Y1)/2);
    end;

    procedure m_SetUpAutoCast(Spell: string);
    var
      D, X, Y: Integer;
      P: TPoint;
    begin
      D := DTMFromString('78DA6334666260B8CD00064C108AE1FFFFFF0' +
           'C22409A11CA67B425428D0B116ADC80320F8950F382801A47A0CC' +
           '7B026A4C8850630494798A5B0D90FD1F002C8B25B9');
      GameTab(tab_Magic);
      P := m_SpellCoords(Spell);
      if (not FindDTM(D, X, Y, P.x-22, P.y-22, P.x+22, P.y+22)) then
      begin
        Mouse(P.X, P.Y, 3, 3, False);
        WaitOption('uto', 1000 + Random(200));
        Wait(200 + Random(100));
      end;
      FreeDTM(D);
    end;
    Last edited by marpis; 09-23-2009 at 03:01 AM.

  2. #2
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Looks good, however if you want to find the middle of a box, instead of :

    SCAR Code:
    B.X1 + (B.X2 - B.X1) div 2, B.Y1 + (B.Y2 - B.Y1) div 2

    You can do:

    SCAR Code:
    (B.x1 + B.x2) Shr 1, (B.y1 + B.y2) Shr 1

    Secondly for your Spell Cords Idea you could have used one string array of the element then another one for the type.Then srl_imploded them. Furthermore, n1ke added a type for each spell, maybe it can be used in conjunction with one of yours?

    Good work, anyways

  3. #3
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    Looks good, however if you want to find the middle of a box, instead of :

    SCAR Code:
    B.X1 + (B.X2 - B.X1) div 2, B.Y1 + (B.Y2 - B.Y1) div 2

    You can do:

    SCAR Code:
    (B.x1 + B.x2) Shr 1, (B.y1 + B.y2) Shr 1

    Secondly for your Spell Cords Idea you could have used one string array of the element then another one for the type.Then srl_imploded them. Furthermore, n1ke added a type for each spell, maybe it can be used in conjunction with one of yours?

    Good work, anyways
    I did the old-fashion-style :> uglyish but works

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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