Results 1 to 7 of 7

Thread: Magic.scar

  1. #1
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,683
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Magic.scar

    I thought I finally would have something to do when i saw a system update!
    But ofc not, Magic.scar still works with the new magic interface.

    But I still managed to find some stuff

    • Updated SetUpAutoCast to work with the whole spellbook.
    • Shorten CastOn using CastOnCustom.


    Not much, but still some ^^

    The updated Magic.scar.
    SCAR Code:
    //-----------------------------------------------------------------//
    //--               Scar Standard Resource Library                --//
    //--                        Mage routines                        --//
    //-----------------------------------------------------------------//

    //  * function SetUpAutoCast(AutoSpell: string; Defensive: Boolean): Boolean;  | By Wizzup?/EvilChicken!, Updated to full spellbook by N1ke!.
    //  * procedure FixSpells;                                                     | By ZephyrsFury
    //  * function Cast(Spell:String): Boolean;                                    | By ZephyrsFury & Cazax
    //  * function CastSpell(SpellNumber: Integer): Boolean;                       | By Spky
    //  * function CastOnCustom(Spell: string; Monsters: TStringArray; MonsterColors: TIntegerArray; Tolerance: Integer): Boolean; | by Spky idea by trojan
    //  * function CastOn(Spell, Monster: string; MonsterColor: Integer; Tolerance: Byte): Boolean; | By Spky modified by N1ke!
    //  * function GetLumbridgeMins(JustCheck: Boolean): Integer;                  | By EvilChicken!

    {*******************************************************************************
    procedure SetUpAutoCast(AutoSpell: string; Defensive: Boolean);
    By: Wizzup?/EvilChicken! Updated to full spellbook by N1ke!.
    Description: Sets up the spell you want to autocast, wielding a staff is
    required.
    Defensive: Set to True for a defensive fighting style, False for a normal style.
    *******************************************************************************}

    function SetUpAutoCast(AutoSpell: string; Defensive: Boolean): Boolean;
    var
      X, Y: Integer;

    begin
      Result := False;
      If not GameTab(1) then Exit;

      if Defensive then
        Mouse(655, 253, 50, 25, True)
      else Mouse(665, 320, 50, 25, True);

      Wait(2000 + Random(1500));
      case LowerCase(AutoSpell) of
        'wind strike',  '1': Result := FindColor(X, Y, 16579836, 577, 236, 588, 246);
        'water strike', '2': Result := FindColor(X, Y, 16563743, 617, 236, 628, 246);
        'earth strike', '3': Result := FindColor(X, Y, 3003805, 657, 236, 668, 246);
        'fire strike',  '4': Result := FindColor(X, Y, 835570, 696, 236, 707, 246);

        'wind bolt',  '5': Result := FindColor(X, Y, 16579836, 577, 295, 590, 309);
        'water bolt', '6': Result := FindColor(X, Y, 16563743, 617, 295, 630, 309);
        'earth bolt', '7': Result := FindColor(X, Y, 3003805, 656, 295, 669, 309);
        'fire bolt',  '8': Result := FindColor(X, Y, 835570, 697, 295, 710, 309);

        'wind blast',   '9': Result := FindColor(X, Y, 16579836, 573, 356, 587, 371);
        'water blast', '10': Result := FindColor(X, Y, 16563743, 614, 356, 628, 371);
        'earth blast', '11': Result := FindColor(X, Y, 3003805, 654, 356, 668, 371);
        'fire blast',  '12': Result := FindColor(X, Y, 835570, 694, 357, 708, 372);
       
        'wind wave',  '13': Result := FindColor(X, Y, 16579836, 574, 414, 591, 435);
        'water wave', '14': Result := FindColor(X, Y, 16563743, 614, 414, 631, 435);
        'earth wave', '15': Result := FindColor(X, Y, 3003805, 655, 414, 672, 435);
        'fire wave',  '16': Result := FindColor(X, Y, 835570, 694, 414, 711, 435);
      else
        begin
          srl_Warn('SetUpAutoCast', '"' + AutoSpell + '" is not a valid autocasting spell.', -2);
          Mouse(687, 584, 4, 4, True); // Exits the autocasting spells setup 'popup'.
          Exit;
        end;
      end;
      if Result then
      begin
        Mouse(X, Y, 2, 2, True);
        Wait(1750 + Random(1500));
      end;
    end;

    {*******************************************************************************
    procedure FixSpells;
    By: ZephyrsFury
    Description: Orders the spellbook by level.
    *******************************************************************************}

    procedure FixSpells;
    begin
      if (GetCurrentTab <> 7) then
      begin
        GameTab(7);
        Wait(500 + Random(500));
      end;
      if (CountColorTolerance(2370867, 676, 444, 690, 458, 13) < 10) then
        Mouse(676, 444, 14, 14, True);
    end;

    {*******************************************************************************
    function Cast(Spell: String): Boolean;
    By: ZephyrsFury ideas and suggestions by Cazax
    Description: Casts the selected spell, returns true if successful. Spell Names
      are the same as those in the GameTab 7 including numbers and symbols.
    *******************************************************************************}

    function Cast(Spell: string): Boolean;
    var
      spArr: TStringArray;
      spNo, X, Y, II, CTS: Integer;
      B: TBox;
      Lum, H, S, L: Extended;
      colArr: TIntegerArray;
    begin
      Spell := Lowercase(Spell);
      spArr := ['lumbridge home teleport', 'wind strike', 'confuse', 'enchant crossbow bolt', 'water strike', 'lvl-1 enchant',
        'earth strike', 'weaken', 'fire strike', 'bones to bananas', 'wind bolt', 'curse', 'bind', 'low level alchemy',
        'water bolt', 'varrock teleport', 'lvl-2 enchant', 'earth bolt', 'lumbridge teleport', 'telekinetic grab',
        'fire bolt', 'falador teleport', 'crumble undead', 'teleport to house', 'wind blast', 'superheat item', 'camelot teleport',
        'water blast', 'lvl-3 enchant', 'iban blast', 'snare', 'magic dart', 'ardougne teleport', 'earth blast', 'high level alchemy',
        'charge water orb', 'lvl-4 enchant', 'watchtower teleport', 'fire blast', 'charge earth orb', 'bones to peaches',
        'saradomin strike', 'claws of guthix', 'flames of zamorak', 'trollheim teleport', 'wind wave', 'charge fire orb',
        'teleport to ape atoll', 'water wave', 'charge air orb', 'vulnerability', 'lvl-5 enchant', 'earth wave', 'enfeeble',
        'teleother lumbridge', 'fire wave', 'entangle', 'stun', 'charge', 'teleother falador', 'teleport block', 'lvl-6 enchant',
        'teleother camelot'];

      if (GetNumbers(Spell) = Spell) and (InRange(StrToIntDef(GetNumbers(Spell), -1), 1, Length(spArr))) then
        spNo := StrToInt(Spell) - 1
      else
      if (not(InStrArrEx(Spell, spArr, spNo))) then
      begin
        srl_Warn('Cast', 'Invalid Spell Name/Number: ''' + Spell + '''', warn_AllVersions);
        Exit;
      end;

      if (GetCurrentTab <> 7) then
      begin
        GameTab(7);
        Wait(500 + Random(500));
      end;

      B.X1 := spNo mod 7 * 24 + 560;
      B.Y1 := spNo div 7 * 24 + 217;
      B.X2 := B.X1 + 23;
      B.Y2 := B.Y1 + 23;
      if (FindColor(X, Y, 2070783, MIX1, MIY1, MIX2, MIY2)) then MouseBox(MMX1, MMY1, MMX2, MMY2, 3);
      FixSpells;

      colArr := GetColors(TPAFromBox(B));
      ClearSameIntegers(colArr);
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.72, 1.05);
      for II := 0 to High(colArr) do
      begin
        if (SimilarColors(colArr[II], 3292228, 3)) then Continue;
        ColorToHSL(colArr[II], H, S, L);
        Lum := MaxE(Lum, L);
      end;
      SetColorSpeed2Modifiers(0.2, 0.2);
      ColorToleranceSpeed(CTS);
      Result := (Lum > 20.0);
      if (Result) then
      begin
        MouseBox(B.X1, B.Y1, B.X2, B.Y2, 1);
        Wait(500 + Random(500));
      end;
    end;

    {*******************************************************************************
    function CastSpell(SpellNumber: Integer): Boolean;
    By: Spky
    Description: Cast's the selected spell specified by SpellNumber, returns true if
      enough runes to complete.
    *******************************************************************************}

    function CastSpell(SpellNumber: Integer): Boolean;
    begin
      Result := Cast(IntToStr(SpellNumber));
    end;

    {*******************************************************************************
    function CastOnCustom(Spell: string; Monsters: TStringArray; MonsterColors: TIntegerArray; Tolerance: Integer): Boolean;
    By: Spky idea by trojan
    Description: Casts the selected spell specified by Spell, on the specified
      monster. Returns true if successful.
    *******************************************************************************}

    function CastOnCustom(Spell: string; Monsters: TStringArray; MonsterColors: TIntegerArray; Tolerance: Integer): Boolean;
    var
      X, Y: Integer;

    begin
      Result := False;
      if not Cast(Spell) then exit;
      Result := FindObjCustom(X, Y, Monsters, MonsterColors, Tolerance);
      if Result then
        Mouse(X, Y, 0, 0, True);
    end;

    {*******************************************************************************
    function CastOn(Spell, Monster: string; MonsterColor: Integer; Tolerance: Byte): Boolean;
    By: Spky modified by N1ke!
    Description: Casts the selected spell specified by Spell, on the specified monster.
      Returns true if successful.
    *******************************************************************************}

    function CastOn(Spell, Monster: string; MonsterColor: Integer; Tolerance: Byte): Boolean;
    begin
      Result := CastOnCustom(Spell, [Monster], [MonsterColor], Tolerance);
    end;

    {*******************************************************************************
    Function GetLumbridgeMins(JustCheck: Boolean): Integer;
    By: EvilChicken!
    Description: Returns the number of ramaining minutes until you can cast the home
    teleport spell. Returns 0 if you can cast it, or -1 if failed to get amount.
    If you want to actually teleport to Lumbridge if you have 0 minutes left,
    set JustCheck to True, otherwise have it set to False.
    *******************************************************************************}


    function GetLumbridgeMins(JustCheck: Boolean): Integer;
    var
      X, Y, MagicMark: Integer;

    begin
      Result := 0;
      if not LoggedIn then exit;
      if GetCurrentTab <> 7 then
      begin
        if not GameTab(7) then exit;
        Wait(750 + Random(750));
      end;
      if not Cast('1') then
      begin
        Result := -1;
        Exit;
      end;
      MagicMark := GetSystemTime;
      repeat
        if FindBlackChatMessage('another') then
        begin
          Result := StrToIntDef(Trim(Between('another', 'minutes', GetBlackChatMessage)), -1);
          Exit;
        end;
        Wait(350 + Random(250));
      until (TimeFromMark(MagicMark) <= 4000);
      if not JustCheck then exit;
      MouseBox(719, 102, 758, 117, 1); // Coordinates taken from SetRun.
      Wait(1500 + Random(1750)); // Changes run state to interrupt home teleport ..
      GetMousePos(X, Y);
      Mouse(X, Y, 0, 0, True);   // .. and sets run back to original state.
    end;

    {*******************************************************************************
    procedure SetupMagic;
    By: SRL
    Description: Declares Global Bitmaps.
    *******************************************************************************}


    procedure SetupMagic;
    begin
    end;
    Last edited by Naike; 06-09-2009 at 11:49 PM.

  2. #2
    Join Date
    May 2007
    Location
    Netherlands, Amersfoort
    Posts
    2,701
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    looks nice once again

  3. #3
    Join Date
    Nov 2007
    Location
    I live in Slovenia! :)
    Posts
    837
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Wow that was fast!

    Could you do the hooks to?
    I'm not really sure what needs to be done but i guess they need to be updated.

  4. #4
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,683
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by tico2 View Post
    Wow that was fast!

    Could you do the hooks to?
    I'm not really sure what needs to be done but i guess they need to be updated.
    Our hooks are updated by Method, simply wait for him.

  5. #5
    Join Date
    Nov 2007
    Location
    I live in Slovenia! :)
    Posts
    837
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by N1ke! View Post
    Our hooks are updated by Method, simply wait for him.
    Ok thanks for the info.

  6. #6
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  7. #7
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,683
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Shuttleu View Post
    and methood wont give the hook grabbing script to anyone -_-'

    ~shut
    That's not 100% true.
    He can give it to people, but they wouldn't understand a cent.
    And if one of the (Fields?) break, you wouldn't be able to fix it anyways.
    So it be the same with it.


    Now, No more hook-related posts.

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
  •