Results 1 to 6 of 6

Thread: teleport.simba

  1. #1
    Join Date
    Nov 2011
    Posts
    1,532
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default teleport.simba

    I have been working on an include that handles the most common teleport equipment and items to save reinventing the wheel. I haven't scripted something for a month when I decided to make this, so my work is really messy and this is barely include-ready material.

    Suggestions and feedback are most welcomed. You can also test it if you feel like doing it I hope people will find it useful or at least get inspired.

    Simba Code:
    //-----------------------------------------------------------------//
    //--               SRL Resource Library                          --//
    //--                     Teleport routines                       --//
    //-----------------------------------------------------------------//
    type teleInfo = record
      constant, dtm: integer;
      dtmString: string;
      rub: boolean;
    end;

    //Global variables
    var srlTeleInfo: array of teleInfo;     //Store static data
    var SRL_TeleItemsInUse: TIntegerArray;  //Store items in use
    var SRL_TeleDTMs: TIntegerArray;        //Store DTMs in use

    //Use these to declare which teles are needed in a script
    const
      SRL_TELE_KINSHIP = 1;   //done
      SRL_TELE_DUELLING = 2;  //done
      SRL_TELE_ECTOPHIAL = 3; //done
      SRL_TELE_VEXILUM = 4;   //done
      SRL_TELE_GLORY = 5;
      SRL_TELE_WEALTH = 6;    //done
      SRL_TELE_GAMES = 7;     //done
      SRL_TELE_DIGSITE = 8;   //done
      SRL_TELE_COMBAT = 9;    //done
      SRL_TELE_SKILLS = 10;
      SRL_TELE_EXPLORER3 = 11;//done
      SRL_TELE_EXPLORER4 = 12;

      SRL_TELE_TOTAL = 12;

    {*******************************************************************************
    procedure DeclareTeleInfo;
    By: DTM
    Description: Declare all teleport data
    *******************************************************************************}

    procedure DeclareTeleInfo;
    begin

      setLength(srlTeleInfo, SRL_TELE_TOTAL);

      //Ring of kinship
      with srlTeleInfo[SRL_TELE_KINSHIP - 1] do
      begin
        constant:= SRL_TELE_KINSHIP;
        dtmString:= 'mrAAAAHic42BgYLBhZmBwZobQpkBsCcROQGwBxLZAPJGJgWEKEHcDcT8QTwfiOUA8D4gXA/G3ABWgKUw4sQgDfsBIAMMAABY4CFg=';
        rub:= false;
      end;
      //Ring of duelling
      with srlTeleInfo[SRL_TELE_DUELLING - 1] do
      begin
        constant:= SRL_TELE_DUELLING;
        dtmString:= 'mrAAAAHic42BgYGBngAA2IOaG8lmhYixQWgiKeYGYC4j5oBikVrBcGEgy4cQiDPgBIwEMAwCUgwFU';
        rub:= true;
      end;
      //Ectophial
      with srlTeleInfo[SRL_TELE_ECTOPHIAL - 1] do
      begin
        constant:= SRL_TELE_ECTOPHIAL;
        dtmString:= 'mggAAAHicY2NgYHjMxsDwDIhfAvFzIL4P5e9hYmDYBsR7gfgYEJ+EYr+eOKAuJgwswoAdMOLAEAAAi1gLeA==';
        rub:= false;
      end;
      //Clan vexilum
      with srlTeleInfo[SRL_TELE_VEXILUM - 1] do
      begin
        constant:= SRL_TELE_VEXILUM;
        dtmString:= 'm6wAAAHic42ZgYGACYmYgZoPSHEDMB8RcDBAAkmeF8kGYBYg5oXKMUHmQXkkgFoLq5YTqdPGfw+AaMA+qCh9GmE8IMJKAkQAA0QADQA==';
        rub:= false;
      end;
      //Amulet of glory
      with srlTeleInfo[SRL_TELE_GLORY - 1] do
      begin
        constant:= SRL_TELE_GLORY;
        dtmString:= 'mrAAAAHic42BgYEhkY2CIA+JkIE4D4jwgzgLiGKj4AiYGhqVQvBCIe4F4FhAvAuI5QJwu3AU0hQknlmTADxgJYBgAANhVCYY=';
        rub:= true;
      end;
      //Ring of wealth
      with srlTeleInfo[SRL_TELE_WEALTH - 1] do
      begin
        constant:= SRL_TELE_WEALTH;
        dtmString:= 'mrAAAAHic42BgYHjOxsDwBIgfAPFTNgj/NRA/g4r1MDEwTAbiWVA8DYhnAvE8KA7izwWawoQTizDgB4wEMAwAABfoDSc=';
        rub:= true;
      end;
      //Games Necklace
      with srlTeleInfo[SRL_TELE_GAMES - 1] do
      begin
        constant:= SRL_TELE_GAMES;
        dtmString:= 'mlwAAAHicY2dgYEhgY2DIBeIiIM4A4mQgjgHiaCA+xMTAsBGItwPxQSA+BsTHgXg/EAuJNgF1M2HFkgy4ASMeDAUAB/4JDQ==';
        rub:= true;
      end;
      //Digsite Pendant
      with srlTeleInfo[SRL_TELE_DIGSITE - 1] do
      begin
        constant:= SRL_TELE_DIGSITE;
        dtmString:= 'mlwAAAHicY2dgYEhgY2DIBeIiIM4A4mQgjgHiaCA+xMTAsBGItwPxQSA+BsTHgXg/EK9UlgDqZsKKJRlwA0Y8GAoAHb0JSA==';
        rub:= false;
      end;
      //Combat Bracelet
      with srlTeleInfo[SRL_TELE_COMBAT - 1] do
      begin
        constant:= SRL_TELE_COMBAT;
        dtmString:= 'mggAAAHicY2NgYOhlY2CYCsQzgHgaEPcBcTcQb2NiYNgOxHuA+AgQHwbi/UCcLzoFqIsJA0syYAeMODAEAACXhAlQ';
        rub:= true;
      end;
      //Skills Necklace
      with srlTeleInfo[SRL_TELE_SKILLS - 1] do
      begin
        constant:= SRL_TELE_SKILLS;
        dtmString:= 'mlwAAAHicY2dgYGBlgABGIOYAYl4gFgdiISAWBGI+IBYDYlEgFgBiNqj6QP4cIMmEFUsy4AaMeDAUAACiPQGk';
        rub:= true;
      end;

      with srlTeleInfo[SRL_TELE_EXPLORER3 - 1] do
      begin
        constant:= SRL_TELE_EXPLORER3;
        dtmString:= 'm6wAAAHic42ZgYJjGyMCwCIjnAPFyKF4IxNOBeD5UfB6UDmViYAgBYi8gDgDiKCCOh+JwIA4CYj8gjgViBgYmgnjlRHGGr5cVGYgBXFDMSAJGAgCEzA4W';
        rub:= false;
      end;

      with srlTeleInfo[SRL_TELE_EXPLORER4 - 1] do
      begin
        constant:= SRL_TELE_EXPLORER4;
        dtmString:= 'mAAEAAHic42FgYJjDxMCwHIiXAvFKIF4PxGuBeC4QLwPiRVB6DVQ+GYiTgDgPiHOBOA2I45DYkUAcBVWTDsQMDExE4YycHIaaxiYGYoEIFDOSiJEBANqED8Q=';
        rub:= false;
      end;

    end;

    {*******************************************************************************
    procedure FreeSRLTeleportDTMs;
    By: DTM
    Description: Free all DTMs in use
    *******************************************************************************}

    procedure FreeSRLTeleportDTMs;
    var i: integer;
    begin
      if length(SRL_TeleDTMs) = 0 then Exit;
      for i:=0 to high(SRL_TeleDTMs) do
        FreeDTM(SRL_TeleDTMs[i]);
    end;

    {*******************************************************************************
    function GetSRLTeleInfo(item: integer): teleInfo;
    By: DTM
    Description: Return teleport info for item
    *******************************************************************************}

    function GetSRLTeleInfo(item: integer): teleInfo;
    var i: integer;
    begin
      for i:=0 to high(srlTeleInfo) do
        if srlTeleInfo[i].constant = item then
        begin
          result:= srlTeleInfo[i];
          break;
        end;
    end;

    {*******************************************************************************
    procedure SetupTeleports(items: integer);
    By: DTM
    Description: Setup SRL teleports
    *******************************************************************************}

    procedure SetupTeleports(items: TIntegerArray);
    var i: integer;
    begin
      DeclareTeleInfo;
      SRL_TeleItemsInUse := items;
      SetLength(SRL_TeleDTMs, length(SRL_TeleItemsInUse));

      //Load items DTM
      for i:=0 to high(SRL_TeleDTMs) do
      begin
        SRL_TeleDTMs[i] := DTMFromString(GetSRLTeleInfo(items[i]).dtmString);
        srlTeleInfo[items[i]-1].dtm := SRL_TeleDTMs[i];
      end;

      for i:=0 to high(SRL_TeleDTMs) do
        writeln(SRL_TeleDTMs[i]);

      writeln(srlTeleInfo[SRL_TELE_ECTOPHIAL-1].dtm);

      //Register FreeDTM procedure
      AddOnTerminate('FreeSRLTeleportDTMs');
    end;

    {*******************************************************************************
    function UseTeleportEx(item: integer; checkInv: boolean; options: TStringArray): boolean;
    By: DTM
    Description: Teleport using the item
                 checkInv to check inventory tab
                 options for chooseOption / TypeSendEx
    *******************************************************************************}

    function UseTeleportEx(item: integer; checkInv: boolean; options: TStringArray): boolean;
    var ti: teleInfo;
        tb: TBox;
        x, y, i: integer;
        action: string;
        v: TVariantArray;
    begin
      result:= false;
      writeln(item);
      ti:= getSRLTeleInfo(item);
      GetMousePos(x, y);
      if PointInBox(Point(x, y), IntToBox(MIX1, MIY1, MIX2, MIY2)) then
        Mouse(MSCX, MSCY, randomRange(-50, 50), randomRange(-50, 50), mouse_move);
      if length(options) = 0 then
        options:= ['ele', 'ub ', 'bba'];
      if length(options) >= 2 then
        action := options[1];
      //Special cases
      case ti.constant of
        //Left click ectophial
        SRL_TELE_ECTOPHIAL: begin
                              if FTab(tab_inv) then
                                if WaitFindDTM(x, y, ti.dtm, 1000) then
                                begin
                                  MouseItem(coordstoItem(x, y), mouse_left);
                                  result:=true;
                                end;
                              Exit;
                            end;
      end;

      //General tele equipment
      if checkInv then
      begin
        writeln('Checking inventory for item...');
        if FTab(tab_inv) then
        begin
          if WaitFindDTM(x, y, ti.dtm, 1000) then
          begin
            if ti.rub then
            begin
              MouseItem(coordstoItem(x, y), mouse_right);
              result:= WaitOption('ub ', 500);
              if result then
              begin
                case action of
                  '1',
                  '2',
                  '3',
                  '4': begin
                         //wait for the teleoption
                         v:=[['re.', 'e.'], nothing];
                         if WaitFuncEx('FindNPCChatTextMulti', v, 500, 2000) then
                         begin
                           writeln('here');
                           TypeSendEx(action, false);
                           result:= true;
                         end
                         else result:=false;
                       end;
                  else result:=false;
                end;
              end;
            end
            else
            begin
              case ti.constant of
                SRL_TELE_KINSHIP: begin
                                    MouseItem(coordstoItem(x, y), mouse_right);
                                    result:=WaitOption('ele', 500);
                                    exit;
                                  end;
                SRL_TELE_VEXILUM: begin
                                    MouseItem(coordstoItem(x, y), mouse_left);
                                    wait(1500+random(500));
                                  end;
                SRL_TELE_DIGSITE: begin
                                    MouseItem(coordstoItem(x, y), mouse_right);
                                    result:=WaitOption('ub ', 500);
                                    exit;
                                  end;
                SRL_TELE_EXPLORER3,
                SRL_TELE_EXPLORER4: begin
                                    MouseItem(coordstoItem(x, y), mouse_right);
                                    result:=WaitOption('bba', 500);
                                    exit;
                                  end;
              end;
            end;
          end
          else writeln('Item not found in inventory...');
        end;
      end;

      if not result then
      begin
        writeln('Checking equipment tab for item...');
        if Ftab(tab_equip) then
        begin
          if WaitFindDTM(x, y, ti.dtm, 2000) then
          begin
            for i:=1 to 11 do
            begin
              tb:= GetEquippedItemBounds(i);
              if PointInBox(Point(x, y), tb) then
              begin
                MouseBox(tb.X1, tb.Y1, tb.X2, tb.Y2, mouse_right);
                result:= WaitOptionMulti(options, 1000);
                if result then
                begin
                  case ti.constant of
                    SRL_TELE_VEXILUM: begin
                                        v:=['es', nothing];
                                        if WaitFuncEx('FindNPCChatText', v, 500, 2000) then
                                        begin
                                          TypeSendEx('1', false);
                                          result:= True;
                                        end;
                                      end;
                  end;
                end;
              end;
            end;
          end;
        end
        else writeln('Item not found in equipment...');
      end;
      writeln(booltostr(result));
    end;

    function UseTeleport(item: integer; options: TStringArray): boolean;
    begin
      result:= UseTeleportEx(item, true, options);
    end;

    function SRLTeleLocation(location: variant): boolean;
    begin
      case location of
        //Ring of Duelling
        'duel': result:= UseTeleport(SRL_TELE_DUELLING, ['uel', '1']);
        'cw'  : result:= UseTeleport(SRL_TELE_DUELLING, ['ast', '2']);
        'ma'  : result:= UseTeleport(SRL_TELE_DUELLING, ['ili', '3']);
        'fog' : result:= UseTeleport(SRL_TELE_DUELLING, ['ist', '4']);

        //Amulet of glory
        'edgeville': result:= UseTeleport(SRL_TELE_GLORY, ['dge', '1']);
        'karamja'  : result:= UseTeleport(SRL_TELE_GLORY, ['amj', '2']);
        'draynor'  : result:= UseTeleport(SRL_TELE_GLORY, ['ayn', '3']);
        'alkharid' : result:= UseTeleport(SRL_TELE_GLORY, ['ari', '4']);

        //Games Necklace
        'troll'  : result:= UseTeleport(SRL_TELE_GAMES, ['hor', '1']);
        'outpost': result:= UseTeleport(SRL_TELE_GAMES, ['ara', '2']);
        'games'  : result:= UseTeleport(SRL_TELE_GAMES, ['rot', '3']);
        'corp'   : result:= UseTeleport(SRL_TELE_GAMES, ['por', '4']);
        //corp beast todo - don't have quest reqs
        //burgh todo - don't have quest reqs

        //Skills Necklace
        'fish' : result:= UseTeleport(SRL_TELE_SKILLS, ['ish', '1']);
        'mine' : result:= UseTeleport(SRL_TELE_SKILLS, ['ini', '2']);
        'craft': result:= UseTeleport(SRL_TELE_SKILLS, ['raf', '3']);
        'cook' : result:= UseTeleport(SRL_TELE_SKILLS, ['ook', '4']);

        //Combat Bracelet
        'warrior'  : result:= UseTeleport(SRL_TELE_COMBAT, ['rri', '1']);
        'champion' : result:= UseTeleport(SRL_TELE_COMBAT, ['ham', '2']);
        'monastery': result:= UseTeleport(SRL_TELE_COMBAT, ['nas', '3']);
        'range'    : result:= UseTeleport(SRL_TELE_COMBAT, ['ang', '4']);

        //Ring of wealth
        'misc': result:= UseTeleport(SRL_TELE_WEALTH, ['ell', '1']);
        'ge'  : result:= UseTeleport(SRL_TELE_WEALTH, ['ran', '2']);

        //Simple teleports
        SRL_TELE_KINSHIP,
        SRL_TELE_VEXILUM,
        SRL_TELE_DIGSITE,
        SRL_TELE_WEALTH,  //use this if your wealth ring has one option!
        SRL_TELE_ECTOPHIAL,
        SRL_TELE_EXPLORER3,
        SRL_TELE_EXPLORER4: result:= UseTeleport(location, []);
      end;
    end;

    To use the include, you need to declare which items you are using and then call SetupTeleports. A sample script that uses the include is attached below for you to see how it works.

    Simba Code:
    program Tele;
    {$DEFINE SMART}
    {.include SRL/SRL.simba}
    {.include custom/teleport.simba}

    //{$DEFINE DEBUG}      //uncomment if you need debug info
    //{$DEFINE DEBUG_DRAW} //uncomment if you need debug info

    {
    const
          ;
    var
          ;
    }


    procedure DeclarePlayers;
    var i:integer;
    begin
      NumberOfPlayers(1);
      CurrentPlayer := 0;
      for i := 0 to 0 do
        Players[i].BoxRewards  := ['mote', 'ostume', 'XP', 'Gem', 'ithril', 'oal', 'une', 'oins'];

      with Players[0] do
      begin
        Name        := '';     //Player username.
        Pass        := '';     //Player password.
        Nick        := ''; //Player nickname - 3-4 letters of Player username.
        Active      := True;
      end;

    end;

    begin
      Smart_Server := 7;
      Smart_Members := False;
      Smart_Signed := True;
      Smart_SuperDetail := False;

      setupSRL();
      DeclarePlayers;
      SetupTeleports([SRL_TELE_ECTOPHIAL, SRL_TELE_DUELLING, SRL_TELE_GAMES,
                      SRL_TELE_DIGSITE, SRL_TELE_WEALTH, SRL_TELE_COMBAT, SRL_TELE_EXPLORER3,
                      SRL_TELE_EXPLORER4]);
    //  SRLTeleLocation(SRL_TELE_KINSHIP);
    //  writeln(booltostr(SRLTeleLocation(SRL_TELE_ECTOPHIAL)));
      writeln(booltostr(SRLTeleLocation(SRL_TELE_EXPLORER4)));
    end.
    Current activity: Recovering from vacation
    - Nulla pars vitae vacare officio potest -
    SRL membership? Can I buy that?
    Scripts - AGS - SWF - WAR - EMS - W100S-EM
    If you need scripting help, you can pm me. Remember, if you need help you have to ask for it properly though

  2. #2
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    Wouldn't this be better in the magic.simba file?
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


  3. #3
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by Kyle Undefined View Post
    Wouldn't this be better in the magic.simba file?
    ins't this already covered by magic.simba ?

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  4. #4
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    No, this isn't with the use of spells, this is with items.

  5. #5
    Join Date
    Nov 2011
    Posts
    1,532
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    As Sin has said, these teleports are those with items, like glory, duelling and so on.
    Current activity: Recovering from vacation
    - Nulla pars vitae vacare officio potest -
    SRL membership? Can I buy that?
    Scripts - AGS - SWF - WAR - EMS - W100S-EM
    If you need scripting help, you can pm me. Remember, if you need help you have to ask for it properly though

  6. #6
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Although many may find this useful, as of this time, I feel it belongs 'better' in the snippets section.

    There are plenty of useful mini includes and functions there that many people use. I just feel that this being included provides a bit too much, and in turn simply bloats the include.

    Nice bit of code though.

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
  •