Results 1 to 16 of 16

Thread: Magic.scar (2nd)

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

    Default Magic.scar (2nd)

    Made a new function in Magic.scar, not much.
    Note: Made a new thread so it wouldn't confuse people.

    • Added SetSpellbook
    • Edited FixSpells to work with SetSpellBook.


    New 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 SetSpellbook(I: Integer);                                      | 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 SetSpellbook(I: Integer);
    By: N1ke!
    Description: Orders the spellbook by choice.
     1: Level order
     2: Combat first
     3: Teleports first
    *******************************************************************************}

    Procedure SetSpellbook(I: Integer);
    begin
      If (I < 1) or (I > 3) then
      begin
        srl_Warn('SetSpellbook', 'Invalid parameter [1..3].', warn_AllVersions);
        Exit;
      end;

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

      if (CountColorTolerance(2370867, 676+((I-1)*14), 444, 690+((I-1)*14), 458, 5) < 13) then
        Mouse(683+((I-1)*20), 450, 5, 5, True);
    end;

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

    procedure FixSpells;
    begin
      SetSpellbook(1);
    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 > 40.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;

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

    Default

    Make a TVariant array of spells, then Do

    SCAR Code:
    For I := 0 to High(TVr) Do
      Case blah of
        TVr[I], IntToStr(I)  : FindColor(x, y, TVr[I*2], TVr[I*2 + 1], TVr[I*3], TVr[I*3 + 1], TVr[I*4]);

    But you are helping so much .
    Last edited by Naum; 06-14-2009 at 03:51 AM.

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

    Default

    Naum, why make it so damn advanced?
    TVariants ain't always the answer.

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

    Default

    Damn advanced:
    Ahem :
    SCAR Code:
    SmartSetup('http://'+prefix+'.runescape.com/', 'plugin.js?param=o0,a' + IntToStr((Integer(not(Signed)) + 1) * Integer(not((SuperDetail and Signed)))) + ',m' + IntToStr(Integer(Members)));
    where did that come from?? (SMART.scar)...

    Btw, its not advanced, it's just simple maths which someone will point out is wrong .

    Plus, it saves much more time, why make something big when it can be shortened by 15 or so lines ?

    Of course TVariants ain't always the answer. But when did I say they were (the answer to everything)?


    Again, 'i will make it damn advanced':

    SCAR Code:
    Procedure SetSpellbook(I: Integer);
    begin
      If (I < 1) or (I > 3) then
      begin
        srl_Warn('SetSpellbook', 'Invalid parameter [1..3].', warn_AllVersions);//
        Exit;
      end;

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

      if (CountColorTolerance(2370867, 676+((I-1)*14), 444, 690+((I-1)*14), 458, 5) < 13) then
        Mouse(683+((I-1)*20), 450, 5, 5, True);
    end;

    I think this is shorter and much more reader friendly.

    SCAR Code:
    Procedure SetSpellbook(I: Integer);
    begin
      If Not InRange(I, 1, 3) then
      begin
        srl_Warn('SetSpellbook', 'Valid parameter [1..3].', warn_AllVersions);
        Exit;
      end;

      if (GetCurrentTab <> 7) then GameTab(7);
     
      Wait(500 + Random(500));
      Dec(I);
     
      if (CountColorTolerance(2370867, 676+(I*14), 444, 690+(I*14), 458, 5) < 13) then
        Mouse(683+(I*20), 450, 5, 5, True);
    end;

    I still <3 you for your countless contributions to the Pub SVN
    Last edited by Naum; 06-14-2009 at 05:03 AM.

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

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    Damn advanced:
    Ahem :
    SCAR Code:
    SmartSetup('http://'+prefix+'.runescape.com/', 'plugin.js?param=o0,a' + IntToStr((Integer(not(Signed)) + 1) * Integer(not((SuperDetail and Signed)))) + ',m' + IntToStr(Integer(Members)));
    where did that come from?? (SMART.scar)...

    Btw, its not advanced, it's just simple maths which someone will point out is wrong .

    Plus, it saves much more time, why make something big when it can be shortened by 15 or so lines ?

    Of course TVariants ain't always the answer. But when did I say they were (the answer to everything)?


    Again, 'i will make it damn advanced':

    SCAR Code:
    Procedure SetSpellbook(I: Integer);
    begin
      If (I < 1) or (I > 3) then
      begin
        srl_Warn('SetSpellbook', 'Invalid parameter [1..3].', warn_AllVersions);//
        Exit;
      end;

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

      if (CountColorTolerance(2370867, 676+((I-1)*14), 444, 690+((I-1)*14), 458, 5) < 13) then
        Mouse(683+((I-1)*20), 450, 5, 5, True);
    end;

    I think this is shorter and much more reader friendly.

    SCAR Code:
    Procedure SetSpellbook(I: Integer);
    begin
      If Not InRange(I, 1, 3) then
      begin
        srl_Warn('SetSpellbook', 'Valid parameter [1..3].', warn_AllVersions);
        Exit;
      end;

      if (GetCurrentTab <> 7) then GameTab(7);
     
      Wait(500 + Random(500));
      Dec(I);
     
      if (CountColorTolerance(2370867, 676+(I*14), 444, 690+(I*14), 458, 5) < 13) then
        Mouse(683+(I*20), 450, 5, 5, True);
    end;

    I still <3 you for your countless contributions to the Pub SVN
    Last one wouldn't really do the same as mine did.
    As it waits 500+Random(500) even tho it's on Gametab(7).
    And how come you didn't put a TVariant in there now? ^^
    Ohh right, not needed.

    My point, Mine is shorten and easy to understand if you're a skilled Jr.memb

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

    Default

    1. The majority of people on SRL are not 'skilled-jr.memb '. And why test the limits of a 'skilled jr. memb' when it can be made easier?

    2. The TVariantArray was not needed, at most a TInteger array (but that would and will provoke a fight). I find it ironic how you answered your own question.

    3. I added that wait(500 + Random(500)) because it needs some randomness 'even tho it's on GameTab(7)'
    Last edited by Naum; 06-14-2009 at 05:05 PM.

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

    Default

    The old FixSpells had no Randomness and was doing quite fine.

    But please dear, show me how you would put a TIntegerArray into SetSpellBook as I just don't get it..

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

    Default

    Store the cords to a TInt array son

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

    Default

    NaumanAkhlaQ, you have been drinking.
    Putting a TIntegerArray into SetSpellbook?

    Please show me, so I can laugh, son.

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

    Default

    Firstly, I do not drink.

    Secondly
    TInteger array (but that would and will provoke a fight)
    I also said At Most this means it would be impractical. Of course cords can be stored (to a TIntegerArray) but I never said they needed to.

    And guess what?
    It did provoke a fight..

    Secondly, I'm working on a variant of SetUpAutoCast, but it doesn't contain a TVariantarray (although it could (but this would and will provoke a fight)).
    Last edited by Naum; 06-14-2009 at 05:07 PM.

  11. #11
    Join Date
    Feb 2007
    Location
    South East England
    Posts
    2,906
    Mentioned
    2 Post(s)
    Quoted
    8 Post(s)

    Default

    Cool it guys. It doesn't really matter.

    Naum, alot of the time when you say you 'shorten' things, you change like 2 lines then chop 20 lines off by making stuff like

    SCAR Code:
    if findthis then
      Dothis1;
      Exit;

    to

    SCAR Code:
    if findthis then Dothis1; Exit;

    You dont really do anything to the code, just make it all on one line.
    Jus' Lurkin'

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

    Default

    Quote Originally Posted by Torrent of Flame View Post
    Cool it guys. It doesn't really matter.

    Naum, alot of the time when you say you 'shorten' things, you change like 2 lines then chop 20 lines off by making stuff like

    SCAR Code:
    if findthis then
      Dothis1;
      Exit;

    to

    SCAR Code:
    if findthis then Dothis1; Exit;

    You dont really do anything to the code, just make it all on one line.
    Tof, I did not shorten it this time, I just made it more friendly to the reader. . Your example wouldn't work, unless you want it to exit.

  13. #13
    Join Date
    Feb 2007
    Location
    South East England
    Posts
    2,906
    Mentioned
    2 Post(s)
    Quoted
    8 Post(s)

    Default

    Please tell me how yours is more friendly?
    Jus' Lurkin'

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

    Default

    I ain't fighting no one,
    Just think it's silly to add a TIntegerArray .

    One little thing tho,
    People don't have the same standards and look on code(In any language),
    the code you seem to have done more "friendly" could actully be worse to some
    and in some cases good.
    It's all about what the person using it thinks.

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

    Default

    Well, I think mine was. Because I separated it out.

  16. #16
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    Well done N1ke You are great!


    ( I can see SRL Dev coming )

    (Just a little twink to Admins )


    ~Home

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
  •