The PokéCommunity Forums Fan Games Game Development Scripts & Tutorials
Essentials Script Elite Battle 2015: Gen 5 battle skin

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.


Reply
 
Thread Tools
  #826    
Old July 6th, 2017 (10:55 PM).
塗 ゆり's Avatar
塗 ゆり 塗 ゆり is offline
Scripter / RGSS Modder
     
    Join Date: Apr 2011
    Location: France
    Age: 24
    Gender: Other
    Posts: 80
    Hi @Luka S.J. !

    Someone asked me if I could readapt your beautiful battle skin to my Starter Kit "Pokémon SDK". The matter there is that your rules forbid me to readapt your system :
    • You may not re-distribute this system
    • You may not bundle this system with other packs

    My Starter isn't like Essentials I can probably say I totaly works differently so in order to adapt your system to my starter I'll have to "redistribute" your system ^^' (The credit will be respected you can see it in the PSDK topic or in its own credit.txt file.)

    What do you think of the whole thing ? Will I get a "special authorisation" or will you do something like host the result plugin on your website ?
    __________________
    Nuri Yuri
    Pokémon Workshop | Facebook Page
    Reply With Quote

    Relevant Advertising!

      #827    
    Old July 7th, 2017 (1:17 AM).
    Luka S.J.'s Avatar
    Luka S.J. Luka S.J. is offline
    Jealous Croatian
       
      Join Date: Dec 2008
      Location: Croatia
      Age: 24
      Gender: Male
      Nature: Adamant
      Posts: 1,111
      Quote:
      Originally Posted by 塗 ゆり View Post
      What do you think of the whole thing ? Will I get a "special authorisation" or will you do something like host the result plugin on your website ?
      I won't do either. The use conditions are pretty explicit. You're free to write your own battle system for the other kit. Just not with EBS as a base.
      __________________

      Reply With Quote
        #828    
      Old July 7th, 2017 (1:47 AM).
      塗 ゆり's Avatar
      塗 ゆり 塗 ゆり is offline
      Scripter / RGSS Modder
         
        Join Date: Apr 2011
        Location: France
        Age: 24
        Gender: Other
        Posts: 80
        If I asked it's because that's really unclear x)
        If by EBS you mean :
        - Scripts (i wouldn't really use as base)
        - The converter (I wrote a GIF Reader)
        - The Graphical resources (It would be easier with this x))
        - The UI disposition & animation (I think that was why I was asked ^^')

        I won't use it and do something else for the guy who asked.
        __________________
        Nuri Yuri
        Pokémon Workshop | Facebook Page
        Reply With Quote
          #829    
        Old July 7th, 2017 (3:03 AM).
        Luka S.J.'s Avatar
        Luka S.J. Luka S.J. is offline
        Jealous Croatian
           
          Join Date: Dec 2008
          Location: Croatia
          Age: 24
          Gender: Male
          Nature: Adamant
          Posts: 1,111
          Quote:
          Originally Posted by 塗 ゆり View Post
          If I asked it's because that's really unclear x)
          If by EBS you mean :
          - Scripts (i wouldn't really use as base)
          - The converter (I wrote a GIF Reader)
          - The Graphical resources (It would be easier with this x))
          - The UI disposition & animation (I think that was why I was asked ^^')

          I won't use it and do something else for the guy who asked.
          Ok, since it's very unclear: stuff made for EBS, stays with EBS. This includes all the possible EBS scripts and graphics I've made for EBS. Whatever is not explicitly credited in EBS means that it was made by me for EBS, exclusively.

          Any resource I did not make, and is public - those are not up to me to decide. This means that the following things currently in EBS are up for grabs:
          • All the sprites for the 649 Pokemon (including the Egg sprites and cracks)
          • The trainer Red backsprite by Tebited15
          • The Gen 5 Pokeball spritesheet
          • The battle backgrounds and bases by Eli and Lilatraube
          • Sound effects ripped by BadSamaritan
          • GIF to PNG converter (if dragonnite allows it)
          The rest is EBS exclusive stuff. Meaning that it stays with EBS.
          __________________

          Reply With Quote
            #830    
          Old July 7th, 2017 (4:40 AM).
          塗 ゆり's Avatar
          塗 ゆり 塗 ゆり is offline
          Scripter / RGSS Modder
             
            Join Date: Apr 2011
            Location: France
            Age: 24
            Gender: Other
            Posts: 80
            Oki, thanks for the precisions :)
            __________________
            Nuri Yuri
            Pokémon Workshop | Facebook Page
            Reply With Quote
              #831    
            Old July 16th, 2017 (1:23 PM).
            Skyflyer's Avatar
            Skyflyer Skyflyer is offline
               
              Join Date: May 2016
              Posts: 6
              Hi eberyone. I'm a bit new to pokémon essentials and I'm still learning. I recently downloadeed Luka SJ BW EBS, and the battle UI looks something like this:
              http://imgur.com/6Huo1mx

              I've seen there's another one, maybe from a previous version, which is this one:
              https://archive.is/kiDeB/55ed3844e0a0c2642f01cda50dfd7b635af355fb.png

              I really like the second one, and I've been searching a lot where could I find it but haven't finded it. I would be really grateful if someone could tell me how to implement it.
              Reply With Quote
                #832    
              Old July 16th, 2017 (3:36 PM).
              Vendily's Avatar
              Vendily Vendily is offline
                 
                Join Date: Aug 2015
                Gender: Female
                Nature: Calm
                Posts: 752
                It's in the settings. Specifically script section, SJPlugins_Settings. Look for the constant EBUISTYLE and change it from 2 to 1
                __________________
                Resources for ROM hackers has moved.

                Reply With Quote
                  #833    
                Old July 21st, 2017 (7:38 AM).
                Sandor1010's Avatar
                Sandor1010 Sandor1010 is offline
                   
                  Join Date: Aug 2013
                  Gender: Male
                  Posts: 1
                  Okay, so I'm very new to the Pokemon Essentials usage, and have only recently signed up for a coding class, and I have just installed The Pokemon Elite Battle System to my custom game.
                  I attempted to use one of the custom versus sequences that was made, which represents the Sun and Moon sequence for a Youngster on Route 1, just as an experiment, but then, this came up.

                  Code:
                  Exception: RuntimeError
                  Message: Script error within event 6, map 2 (Lappet Town):
                  Exception: NoMethodError
                  Message: Section192:1534:in `smPreBattle'undefined method `width' for nil:NilClass
                  ***Full script:
                  pbTrainerBattle(PBTrainers::YOUNGSTER,"Ben",_I("Aww, I lost."),false,0,false,0)
                  Interpreter:243:in `pbExecuteScript'
                  EliteBattle_EntryAnimations:148:in `pbBattleAnimation'
                  PTrainer_NPCTrainers:343:in `pbTrainerBattle'
                  (eval):1:in `pbExecuteScript'
                  Interpreter:794:in `eval'
                  Interpreter:243:in `pbExecuteScript'
                  Interpreter:794:in `command_111'
                  Interpreter:320:in `execute_command'
                  Interpreter:193:in `update'
                  Interpreter:106:in `loop'
                  
                  Interpreter:276:in `pbExecuteScript'
                  Interpreter:794:in `command_111'
                  Interpreter:320:in `execute_command'
                  Interpreter:193:in `update'
                  Interpreter:106:in `loop'
                  Interpreter:198:in `update'
                  Scene_Map:103:in `update'
                  Scene_Map:101:in `loop'
                  Scene_Map:114:in `update'
                  Scene_Map:68:in `main'
                  It's just experimental, but I know it may become a bigger problem in the forseeable future. It would be much appreciated if anyone could help out.
                  Reply With Quote
                    #834    
                  Old July 21st, 2017 (12:16 PM).
                  Luka S.J.'s Avatar
                  Luka S.J. Luka S.J. is offline
                  Jealous Croatian
                     
                    Join Date: Dec 2008
                    Location: Croatia
                    Age: 24
                    Gender: Male
                    Nature: Adamant
                    Posts: 1,111
                    Quote:
                    Originally Posted by Sandor1010 View Post
                    It's just experimental, but I know it may become a bigger problem in the forseeable future. It would be much appreciated if anyone could help out.
                    You have something in your game's project that is breaking the Graphics module. Currently, I'm aware of 2 scripts that do that:
                    • Drimer's RGSS code injection/cheating tool
                    • Klein's Fast Map Exporter
                    EBS can't generate the the required bitmap from the Graphics module (i.e. taking a screenshot). Either you have some scripts which are giving you grief, or you don't have the rubyscreen.dll required for screenshotting.
                    __________________

                    Reply With Quote
                      #835    
                    Old July 27th, 2017 (11:46 AM).
                    BlazingGold BlazingGold is offline
                       
                      Join Date: Jul 2017
                      Posts: 2
                      In the script list, specifically EliteBattle_EntryAnimations, it speaks about trainer types in the EVIL_TEAM_LIST array. Where can I find this array and how do I add trainer types to it?
                      Reply With Quote
                        #836    
                      Old August 2nd, 2017 (9:36 AM).
                      JackRoland JackRoland is offline
                         
                        Join Date: Jul 2017
                        Posts: 2
                        Hello Luka, I have a problem with your battle system. I tried to change pokedex script but an error occurred in EliteBattle_BitmapWrapper
                        here-->
                        Spoiler:
                        ---------------------------
                        Pokemon Essentials
                        ---------------------------
                        Script 'EliteBattle_BitmapWrapper' line 341: NameError occurred.

                        undefined method `pbStartScene' for class `PokedexFormScene'
                        ---------------------------
                        OK
                        ---------------------------

                        Here is pokedex's script
                        Spoiler:
                        #===============================================================================
                        # * BW2 Pokédex by shiney570 made from scratch.
                        #===============================================================================


                        # Generel Settings.

                        # Whether to use the new Pokedex or not.
                        USE_ADVANCED_BW2_POKEDEX = true

                        # Change to false if you don't use Luka S.J's Elite Battle 2015.
                        USING_BITMAP_WRAPPER = false
                        # Whether you want to see all forms on the form page no matter whether
                        # the player saw them or not.
                        ALWAYSSHOWALLFORMS = false
                        #===============================================================================
                        # * SET UP YOUR REGIONAL DEXES HERE
                        #===============================================================================

                        # - Choose between: Kanto ("Kanto")
                        # Johto ("Johto")
                        # Hoenn ("Hoenn")
                        # Sinnoh ("Sinnoh")
                        # Sinnoh2 ("Sinnoh2")
                        # Unova ("Unova")
                        # Unova2 ("Unova2")
                        # Custom ("Custom")
                        # None ("")

                        REGIONAL_DEX = "Unova2"
                        REGIONAL_DEX2= "Sinnoh2"

                        # This is just a quick example of a Custom Pokédex. Just add and edit values
                        # of the array and change REGIONAL_DEX or REGIONAL_DEX2 to "Custom" to use
                        # your selfmade Pokédex.
                        CUSTOM_DEX = [151,152,153,154,155,156,157,158,159,10,11,12,13,14]


                        # Change to false if you don't use Luka S.J's Elite Battle 2015.
                        USING_BITMAP_WRAPPER = true

                        # Dex Names which will appear in the Pokédex.
                        def pbDexNames
                        return ["UNOVA","SINNOH","NATIONAL"]
                        end
                        #==============================================================================#
                        # * Regional Dex'es of already existing Pokémon Editions. #
                        #==============================================================================#
                        $regional_dex_1=[]
                        $regional_dex_2=[]

                        # Gen 1 Dex.
                        if REGIONAL_DEX=="Kanto" || REGIONAL_DEX2=="Kanto"
                        kanto_dex=[]
                        for dex_num in 1..151
                        kanto_dex.insert(kanto_dex.length,dex_num)
                        end
                        $regional_dex_1=kanto_dex if REGIONAL_DEX=="Kanto"
                        $regional_dex_2=kanto_dex if REGIONAL_DEX2=="Kanto"
                        end

                        # Gen 2 Dex.
                        if REGIONAL_DEX=="Johto" || REGIONAL_DEX2=="Johto"
                        johto_dex=[152,153,154,155,156,157,158,159,160,16,17,18,21,22,163,164,19,
                        20,161,162,172,25,26,10,11,12,13,14,15,165,166,167,168,74,75,76,41,42,169,173,
                        35,36,174,39,40,175,176,27,28,23,24,206,179,180,181,194,195,92,93,94,201,95,
                        208,69,70,71,187,188,189,46,47,60,61,62,186,129,130,118,119,79,80,199,43,44,
                        45,182,96,97,63,64,65,132,204,205,29,30,31,32,33,34,193,469,191,192,102,103,
                        185,202,48,49,123,212,127,214,109,110,88,89,81,82,100,101,190,424,209,210,37,
                        38,58,59,234,183,184,50,51,56,57,52,53,54,55,66,67,68,236,106,107,237,203,128,
                        241,240,126,238,124,239,125,122,83,177,178,211,72,73,98,99,213,120,121,90,91,
                        222,223,223,170,171,86,87,108,463,114,465,133,134,135,136,169,197,116,117,230,
                        207,225,220,221,473,216,217,231,232,226,227,84,85,77,78,104,105,115,111,112,
                        198,228,229,218,219,215,200,137,233,113,242,131,138,139,140,141,142,143,1,2,3,
                        4,5,6,7,8,9,144,145,146,243,244,245,147,148,149,246,247,248,249,250,150,151,251]
                        $regional_dex_1=johto_dex if REGIONAL_DEX=="Johto"
                        $regional_dex_2=johto_dex if REGIONAL_DEX2=="Johto"
                        end

                        # Gen 3 Dex.
                        if REGIONAL_DEX=="Hoenn" || REGIONAL_DEX2=="Hoenn"
                        hoenn_dex=[252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,
                        267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,
                        286,287,288,289,63,64,65,290,291,292,293,294,295,296,297,118,119,129,130,298,
                        183,184,74,75,76,299,300,301,41,42,169,72,73,302,303,304,305,306,66,67,68,307,
                        308,309,310,311,312,81,82,100,101,313,314,43,44,45,182,84,85,315,316,317,318,
                        319,320,321,322,323,218,219,324,88,89,109,110,325,326,27,28,327,227,328,329,
                        330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,
                        174,39,40,349,350,351,120,121,352,353,354,355,356,357,358,359,37,38,172,25,26,
                        54,55,360,202,177,178,203,231,232,127,214,111,112,361,362,363,364,365,366,367,
                        368,369,222,170,171,370,116,117,230,371,372,373,374,375,376,377,378,379,380,
                        381,382,383,384,385,386]
                        $regional_dex_1=hoenn_dex if REGIONAL_DEX=="Hoenn"
                        $regional_dex_2=hoenn_dex if REGIONAL_DEX2=="Hoenn"
                        end


                        # Gen 4 Dex.

                        # Gen 4 V2 Dex.
                        if REGIONAL_DEX=="Sinnoh" || REGIONAL_DEX2=="Sinnoh"
                        sinnoh2_dex=[387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,
                        403,404,405,63,64,65,129,130,406,315,407,41,42,169,74,75,76,95,208,408,409,410,
                        411,66,67,68,54,55,412,413,414,256,266,267,268,269,415,416,417,418,419,420,421,
                        422,423,214,190,424,425,426,427,428,92,93,94,200,429,198,430,431,432,118,119,
                        340,433,358,434,435,307,308,436,437,77,78,438,185,439,122,440,113,242,173,35,
                        36,441,172,25,26,163,164,442,443,444,445,446,143,201,447,448,194,195,278,279,
                        203,449,450,298,183,184,451,452,453,454,455,223,224,456,457,72,73,349,350,458,
                        226,459,460,215,461,480,481,482,483,484]
                        $regional_dex_1=sinnoh2_dex if REGIONAL_DEX=="Sinnoh"
                        $regional_dex_2=sinnoh2_dex if REGIONAL_DEX2=="Sinnoh"
                        end

                        # Gen 4 V2 Dex.
                        if REGIONAL_DEX=="Sinnoh2" || REGIONAL_DEX2=="Sinnoh2"
                        sinnoh2_dex=[387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,
                        403,404,405,63,64,65,129,130,406,315,407,41,42,169,74,75,76,95,208,408,409,410,
                        411,66,67,68,54,55,412,413,414,256,266,267,268,269,415,416,417,418,419,420,421,
                        422,423,214,190,424,425,426,427,428,92,93,94,200,429,198,430,431,432,118,119,
                        340,433,358,434,435,307,308,436,437,77,78,438,185,439,122,440,113,242,173,35,
                        36,441,172,25,26,163,164,442,443,444,445,446,143,201,447,448,194,195,278,279,
                        203,449,450,298,183,184,451,452,453,454,455,223,224,456,457,72,73,349,350,458,
                        226,459,460,215,461,480,481,482,483,484,490,479,207,472,299,476,280,281,282,
                        475,108,463,133,134,135,163,196,197,470,471,333,334,175,176,468,228,229,81,82,
                        462,114,465,193,469,357,111,112,464,355,356,477,137,233,474,123,212,239,125,
                        466,240,126,467,220,221,473,361,362,478,359,487]
                        $regional_dex_1=sinnoh2_dex if REGIONAL_DEX=="Sinnoh2"
                        $regional_dex_2=sinnoh2_dex if REGIONAL_DEX2=="Sinnoh2"
                        end

                        # Gen 5 Dex.
                        if REGIONAL_DEX=="Unova" || REGIONAL_DEX2=="Unova"
                        unova_dex=[]
                        for dex_num in 495..649
                        unova_dex.insert(unova_dex.length,dex_num)
                        end
                        $regional_dex_1=unova_dex if REGIONAL_DEX=="Unova"
                        $regional_dex_2=unova_dex if REGIONAL_DEX2=="Unova"
                        end

                        # Gen 5 V2 Dex.
                        if REGIONAL_DEX=="Unova2" || REGIONAL_DEX2=="Unova2"
                        unova2_dex=[495,496,497,498,499,500,501,502,503,504,505,509,
                        510,519,520,521,540,541,542,191,192,506,507,508,179,180,181,54,55,298,183,184,
                        447,448,206,531,511,512,513,514,515,516,543,544,545,109,110,81,82,462,58,59,
                        240,126,467,239,125,466,19,20,41,42,169,88,89,527,528,524,525,526,95,208,532,
                        533,534,529,530,300,301,427,428,546,547,548,549,517,518,173,35,36,133,134,135,
                        136,196,197,470,471,551,552,553,554,555,550,568,569,572,573,627,628,629,630,27,
                        28,557,558,559,560,556,561,328,329,330,562,563,564,565,566,567,599,600,601,406,
                        315,407,574,575,576,577,578,579,415,416,587,214,127,522,523,418,419,570,571,580,
                        581,588,589,616,617,585,586,590,591,351,299,476,304,305,306,343,344,636,637,595,
                        596,597,598,602,603,604,592,593,594,610,611,612,335,336,605,606,607,608,609,631,
                        632,613,614,615,641,642,645,451,452,227,322,323,325,326,425,426,353,354,278,279,
                        337,338,359,114,465,619,620,207,472,624,625,638,639,640,535,536,537,618,213,458,
                        226,223,224,222,120,121,320,321,131,363,364,365,333,334,37,38,436,437,215,461,
                        225,582,583,584,220,221,473,132,374,375,376,86,87,538,539,626,621,622,623,633,
                        634,635,287,288,289,341,342,174,39,40,108,463,193,469,357,455,453,454,246,247,
                        248,643,644,646,647,648,649]
                        $regional_dex_1=unova2_dex if REGIONAL_DEX=="Unova2"
                        $regional_dex_2=unova2_dex if REGIONAL_DEX2=="Unova2"
                        end

                        # Custom Dex.
                        if REGIONAL_DEX=="Custom" || REGIONAL_DEX2=="Custom"
                        $regional_dex_1=CUSTOM_DEX if REGIONAL_DEX=="Custom"
                        $regional_dex_2=CUSTOM_DEX if REGIONAL_DEX2=="Custom"
                        end

                        # Method which creates an array for the National Dex.
                        def pbNationalDex
                        national_dex=[]
                        for dex_num in 1..PBSpecies.maxValue
                        national_dex.insert(national_dex.length,dex_num)
                        end
                        return national_dex
                        end
                        #===============================================================================
                        # * Updating existing methods to work with the new way of Regional Dex'es.
                        #===============================================================================

                        class PokeBattle_Trainer

                        def pokedexSeen(region=-1) # Number of Pokémon seen
                        ret=0
                        if region==-1
                        for i in 0..PBSpecies.maxValue
                        ret+=1 if @seen[i]
                        end
                        else
                        if pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==0
                        regionlist=$regional_dex_1 # Region A
                        else
                        regionlist=$regional_dex_2 # Region B
                        end
                        regionlist=pbAllRegionalSpecies(region)
                        for i in regionlist
                        ret+=1 if @seen[i]
                        end
                        end
                        return ret
                        end

                        def pokedexOwned(region=-1) # Number of Pokémon owned
                        ret=0
                        if region==-1
                        for i in 0..PBSpecies.maxValue
                        ret+=1 if @owned[i]
                        end
                        else
                        if pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==0
                        regionlist=$regional_dex_1 # Region A
                        else
                        regionlist=$regional_dex_2 # Region B
                        end
                        for i in regionlist
                        ret+=1 if @owned[i]
                        end
                        return ret
                        end
                        end
                        end

                        def pbSetSpritePositionToMiddle(sprite)
                        sprite.x=Graphics.width/2-(sprite.bitmap.width/2)
                        sprite.y=Graphics.height/2-(sprite.bitmap.height/2)
                        end
                        #===============================================================================
                        # * Starting the Pokédex.
                        #===============================================================================
                        class StartPokedex

                        def initialize
                        if !$Trainer.pokedex
                        p "Pokédex isn't obtained yet. The game will return." if $DEBUG
                        return
                        end
                        @bg=Sprite.new
                        @bg.z=999999
                        if $Trainer.isFemale?
                        @bg.bitmap=Bitmap.new("Graphics/Pictures/Pokedex/StartPokedex/OpenDex_f")
                        else
                        @bg.bitmap=Bitmap.new("Graphics/Pictures/Pokedex/StartPokedex/OpenDex")
                        end
                        @load=Sprite.new
                        @load.bitmap=Bitmap.new("Graphics/Pictures/Pokedex/StartPokedex/load2")
                        @load.y= -384
                        @load.z=999999
                        @black_bitmap=Bitmap.new(512,384)
                        @black_sprite=Sprite.new
                        @[email protected]_bitmap
                        @black_sprite.z=999999
                        @black_sprite.opacity=0
                        @black_bitmap.fill_rect(0,0,512,384,Color.new(0,0,0))
                        update
                        end

                        def update(frame=0)
                        loop do
                        Graphics.update
                        Input.update
                        frame+=1
                        break if Input.trigger?(Input::B)
                        break if Input.trigger?(Input::C)
                        if defined?($mouse)
                        break if $mouse.inAreaLeft?(0,0,512,384)
                        end
                        break if frame>=120
                        end
                        startMainPokedex
                        end

                        def startMainPokedex
                        20.times do
                        @load.y+=384/20
                        Graphics.update
                        pbWait(1)
                        end
                        10.times do
                        @black_sprite.opacity+=255/10
                        @[email protected]/20
                        @[email protected]/20
                        @load.zoom_x+=0.1
                        @load.zoom_y+=0.1
                        Graphics.update
                        pbWait(1)
                        end
                        pbWait(25)
                        @bg.dispose
                        @load.dispose
                        @black_sprite.dispose
                        MainPokedex.new(0,0,-46,nil)
                        end
                        end
                        #===============================================================================
                        # * Main Pokédex Window.
                        #===============================================================================
                        class MainPokedex

                        def initialize(dex_index,panel_y,panel_sel_y,pokedex) # 0,0,-46
                        $pokedex=currentDex if panel_sel_y<0
                        $pokedex=pokedex if (pokedex != nil)# <--Only used because of search function.
                        @dex_index=dex_index
                        @index=0
                        @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
                        @viewport.z=99999
                        @sprites={}
                        @sprites["bg"]=Sprite.new(@viewport)
                        @sprites["bg"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/bg")
                        @main_bitmap=Bitmap.new(302,2+$pokedex.length*48)
                        @sprites["panels"]=Sprite.new(@viewport)
                        @sprites["panels"].x=192
                        @sprites["panels"].y=panel_y
                        @sprites["panel_sel"]=Sprite.new(@viewport)
                        @sprites["panel_sel"].y=panel_sel_y
                        drawDexPanels
                        drawPanels
                        @sprites["scroll_bar"]=IconSprite.new(502,18,@viewport)
                        @sprites["scroll_bar"].setBitmap("Graphics/Pictures/Pokedex/scroll_bar")
                        @sprites["slider"]=IconSprite.new(500,16,@viewport)
                        @sprites["slider"].setBitmap("Graphics/Pictures/Pokedex/slider")
                        @sprites["undiscovered"]=IconSprite.new(34,82,@viewport)
                        @sprites["undiscovered"].setBitmap("Graphics/Pictures/Pokedex/undiscovered")
                        @sprites["undiscovered"].visible=false
                        @sprites["pkmn_info"]=IconSprite.new(12,0,@viewport)
                        @sprites["pkmn_info"].setBitmap("Graphics/Pictures/Pokedex/pkmn_info")
                        @sprites["pkmn_info"].visible=false
                        @sprites["pkmn_info"].z+=1
                        @sprites["pkmn_sprite"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                        @sprites["pkmn_sprite"].x=96
                        @sprites["pkmn_sprite"].y=96
                        @sprites["down_bg"]=Sprite.new(@viewport)
                        @sprites["down_bg"].bitmap=Bitmap.new("Graphics/Pictures/Universal/down_bg")
                        @sprites["down_bg"].y=336
                        @sprites["select"]=IconSprite.new(10,340,@viewport)
                        @sprites["select"].setBitmap("Graphics/Pictures/Pokedex/select")
                        @sprites["start"]=IconSprite.new(142,340,@viewport)
                        @sprites["start"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/start")
                        @sprites["leftright"]=IconSprite.new(278,346,@viewport)
                        @sprites["leftright"].setBitmap("Graphics/Pictures/Pokedex/leftright")
                        @sprites["exit"]=IconSprite.new(426,346,@viewport)
                        @sprites["exit"].setBitmap("Graphics/Pictures/Universal/exit")
                        @sprites["return"]=IconSprite.new(474,346,@viewport)
                        @sprites["return"].setBitmap("Graphics/Pictures/Universal/return")
                        @sprites["leftright2"]=IconSprite.new(278,346,@viewport)
                        @sprites["leftright2"].setBitmap("Graphics/Pictures/Pokedex/leftright4")
                        updateLeftRight2Sprite
                        @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                        pbSetSystemFont(@sprites["overlay"].bitmap)
                        update
                        end

                        # Method which returns an array of the current dex.
                        def currentDex
                        if $PokemonGlobal.pokedexUnlocked[0] && pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==0
                        p "Your Regional Dex is empty. Please edit it in the Script-Editor." if REGIONAL_DEX.empty? && $DEBUG
                        return $regional_dex_1 if !REGIONAL_DEX.empty?
                        elsif $PokemonGlobal.pokedexUnlocked[1] && pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==1
                        p "Your Regional Dex is empty. Please edit it in the Script-Editor." if REGIONAL_DEX2.empty? && $DEBUG
                        return $regional_dex_2
                        elsif $PokemonGlobal.pokedexUnlocked[0] && !REGIONAL_DEX.empty?
                        return $regional_dex_1
                        elsif $PokemonGlobal.pokedexUnlocked[1] && !REGIONAL_DEX2.empty?
                        return $regional_dex_2
                        elsif $PokemonGlobal.pokedexUnlocked[-1]
                        return pbNationalDex
                        else
                        p "None of the Dex'es is unlocked yet." if $DEBUG
                        return nil
                        end
                        end

                        # Method for drawing the panels.
                        def drawPanels
                        @main_bitmap=Bitmap.new(302,2+$pokedex.length*48)
                        @main_bitmap.clear
                        @sprites["panels"][email protected]_bitmap
                        for i in 0..$pokedex.length-1
                        species=PokeBattle_Pokemon.new($pokedex[i],1)
                        # Drawing panels.
                        panel=Sprite.new
                        if $Trainer.seen[$pokedex[i]]
                        panel.bitmap=Bitmap.new("Graphics/Pictures/Pokedex/panel_pkmn")
                        @main_bitmap.blt(0,2+i*48,panel.bitmap,Rect.new(0,0,panel.bitmap.width,
                        panel.bitmap.height))
                        # Drawing little Pokémon icon.
                        icon=Sprite.new
                        icon.bitmap=Bitmap.new(sprintf("Graphics/Icons/icon%03d",$pokedex[i]))
                        # icon.src_rect.width=64
                        @main_bitmap.blt(2,i*48-18,icon.bitmap,Rect.new(0,0,
                        icon.bitmap.width/2,icon.bitmap.height))
                        icon.dispose
                        else
                        panel.bitmap=Bitmap.new("Graphics/Pictures/Pokedex/panel")
                        @main_bitmap.blt(64,2+i*48,panel.bitmap,Rect.new(0,0,panel.bitmap.width,
                        panel.bitmap.height))
                        end
                        panel.dispose
                        # Drawing little caught icon.
                        if $Trainer.owned[$pokedex[i]]
                        owned=Sprite.new(@viewport)
                        owned.bitmap=Bitmap.new("Graphics/Pictures/Pokedex/caught")
                        @main_bitmap.blt(82,10+i*48,owned.bitmap,Rect.new(0,0,owned.bitmap.width,
                        owned.bitmap.height))
                        owned.dispose
                        end
                        # Drawing text.
                        text=BitmapSprite.new(Graphics.width, Graphics.height)
                        pbSetSystemFont(text.bitmap)
                        dex_number=(i+1).to_s
                        if dex_number.length==1
                        dex_number.insert(0,"0")
                        end
                        if dex_number.length==2
                        dex_number.insert(0,"0")
                        end
                        textpos=[]
                        textpos.push([dex_number,0,0,0,Color.new(222,222,222),
                        Color.new(132,132,132)])
                        if $Trainer.seen[$pokedex[i]]
                        pkmn_name=species.name
                        else
                        pkmn_name="?????"
                        end
                        textpos.push([pkmn_name,56,0,0,Color.new(222,222,222),
                        Color.new(132,132,132)])
                        pbDrawTextPositions(text.bitmap,textpos)
                        @main_bitmap.blt(112,6+48*i,text.bitmap,Rect.new(0,0,190,32))
                        text.dispose
                        end
                        end

                        # Method for drawing the Dex Panels.
                        def drawDexPanels
                        num=0
                        num+=1 if $PokemonGlobal.pokedexUnlocked[0] # Regional Dex 1
                        num+=1 if $PokemonGlobal.pokedexUnlocked[1] # Regional Dex 2
                        num+=1 if $PokemonGlobal.pokedexUnlocked[-1]# National Dex
                        for i in 1..num
                        @sprites["dex_panel#{i}"]=IconSprite.new(0,290-46*i+46,@viewport)
                        @sprites["dex_panel#{i}"].setBitmap("Graphics/Pictures/Pokedex/leftpanel")
                        end
                        dexnames=pbDexNames
                        base=Color.new(255,255,255)
                        shadow=Color.new(165,165,173)
                        textos=[]
                        if num==3 && pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==0
                        @dexes=[2,1,0]
                        elsif num==3 && pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==1
                        @dexes=[2,0,1]
                        elsif num==3 && pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]>1
                        @dexes=[1,0,2]
                        elsif num==2
                        if pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==0 && $PokemonGlobal.pokedexUnlocked[0]
                        @dexes=[1,0] if $PokemonGlobal.pokedexUnlocked[1]
                        @dexes=[2,0] if $PokemonGlobal.pokedexUnlocked[-1]
                        elsif pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==1 && $PokemonGlobal.pokedexUnlocked[1]
                        @dexes=[0,1] if $PokemonGlobal.pokedexUnlocked[0]
                        @dexes=[2,1] if $PokemonGlobal.pokedexUnlocked[-1]
                        elsif $PokemonGlobal.pokedexUnlocked[0]
                        textos.push([_INTL("{1}", dexnames[0]),4,252,false,base,shadow])
                        @dexes=[1,0] if $PokemonGlobal.pokedexUnlocked[1]
                        @dexes=[2,0] if $PokemonGlobal.pokedexUnlocked[-1]
                        elsif $PokemonGlobal.pokedexUnlocked[1]
                        @dexes=[0,1] if $PokemonGlobal.pokedexUnlocked[0]
                        @dexes=[2,1] if $PokemonGlobal.pokedexUnlocked[-1]
                        end
                        elsif num==1
                        @dexes=[0] if $PokemonGlobal.pokedexUnlocked[0]
                        @dexes=[1] if $PokemonGlobal.pokedexUnlocked[1]
                        @dexes=[2] if $PokemonGlobal.pokedexUnlocked[-1]
                        end
                        textos.push([_INTL("{1}", dexnames[@dexes[0]]),4,298,false,base,shadow])
                        if num>=2
                        textos.push([_INTL("{1}", dexnames[@dexes[1]]),4,252,false,base,shadow])
                        end
                        if num==3
                        textos.push([_INTL("{1}", dexnames[@dexes[2]]),4,206,false,base,shadow])
                        end
                        normal_dexes=[$regional_dex_1,$regional_dex_2,pbNationalDex]
                        y=5000
                        y=290 if num==3 && $pokedex==normal_dexes[@dexes[0]]
                        y=244 if num==3 && $pokedex==normal_dexes[@dexes[1]]
                        y=198 if num==3 && $pokedex==normal_dexes[@dexes[2]]
                        y=290 if num==2 && $pokedex==normal_dexes[@dexes[0]]
                        y=244 if num==2 && $pokedex==normal_dexes[@dexes[1]]
                        y=290 if num==1
                        @sprites["dex_panel_sel"]=IconSprite.new(0,y,@viewport)
                        @sprites["dex_panel_sel"].setBitmap("Graphics/Pictures/Pokedex/leftpanel2")
                        @sprites["dexnames"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                        pbSetSystemFont(@sprites["dexnames"].bitmap)
                        pbDrawTextPositions(@sprites["dexnames"].bitmap,textos)
                        end

                        # Method for checking and updating if a species is in the dex and the
                        # dex has changed.
                        def updateDexIndexIfDexHasChanged(species)
                        return if @dex_index<1
                        #if @dex_index<1
                        # @sprites["panels"].y=0
                        # @sprites["panel_sel"].y= -46
                        # return
                        #end
                        for i in 0...$pokedex.length
                        if $pokedex[i]==species
                        @dex_index=i+1
                        if @dex_index<8
                        @sprites["panels"].y=0
                        @sprites["panel_sel"][email protected]_index*48-46
                        elsif @dex_index>$pokedex.length-8
                        @sprites["panels"].y= -48*($pokedex.length-7)
                        @sprites["panel_sel"].y=290-([email protected]_index)*48
                        else
                        @sprites["panels"].y= -48*(@dex_index-1)
                        @sprites["panel_sel"].y=2
                        end
                        return
                        end
                        end
                        @sprites["panels"].y=0
                        @sprites["panel_sel"].y=2
                        @dex_index=1
                        end

                        # Updates the leftright2 sprite.
                        def updateLeftRight2Sprite
                        @sprites["leftright2"].x=278
                        if @dex_index<8 && (@dex_index>($pokedex.length-7))
                        @sprites["leftright2"].src_rect.x=0
                        @sprites["leftright2"].src_rect.width=96
                        elsif @dex_index<8
                        @sprites["leftright2"].src_rect.x=0
                        @sprites["leftright2"].src_rect.width=48
                        elsif (@dex_index>($pokedex.length-7))
                        @sprites["leftright2"].src_rect.x=48
                        @sprites["leftright2"].src_rect.width=48
                        @sprites["leftright2"].x=278+50
                        else
                        @sprites["leftright2"].src_rect.x=0
                        @sprites["leftright2"].src_rect.width=0
                        end

                        end

                        # Method which checks whether you can scroll down or not.
                        def canScrollDown
                        return (@dex_index>7 && @sprites["panel_sel"].y==290 && ((@sprites["panels"][email protected]["panels"].y)>338))
                        end

                        # Method which checks whether you can scroll up or not.
                        def canScrollUp
                        return (@dex_index>0 && @sprites["panel_sel"].y==2 )
                        end

                        # This method updates the position of the slider.
                        def updateSliderPosition
                        pos=16
                        pos+=300*@dex_index/$pokedex.length
                        @sprites["slider"].y=pos
                        end

                        # Method returning the number of the current selected Pokémon.
                        def currentPokemon
                        return ($pokedex[@dex_index-1])
                        end

                        # Method for updating the background.
                        def updateBackground
                        return if [email protected]["bg"]
                        @sprites["bg"].x-=2
                        @sprites["bg"].x=0 if @sprites["bg"].x <= -512
                        end

                        # Method which is basically pbWait(x) but with a background update added.
                        def waitAndUpdate(x)
                        x.times do
                        updateBackground
                        pbWait(1)
                        end
                        end

                        # Method for scrolling 7 Pokémon up.
                        def scrollToLeft
                        return if @dex_index<8
                        @sprites["leftright"].setBitmap("Graphics/Pictures/Pokedex/leftright2")
                        7.times do
                        @dex_index-=1
                        if @sprites["panel_sel"].y>10
                        @sprites["panel_sel"].y-=48
                        else
                        @sprites["panels"].y+=48
                        end
                        updatePokemonSprite
                        updateSliderPosition
                        waitAndUpdate(1)
                        end
                        waitAndUpdate(3)
                        @sprites["leftright"].setBitmap("Graphics/Pictures/Pokedex/leftright")
                        end

                        # Method for scrolling 7 Pokémon down.
                        def scrollToRight
                        return if (@dex_index>($pokedex.length-7))
                        @sprites["leftright"].setBitmap("Graphics/Pictures/Pokedex/leftright3")
                        7.times do
                        @dex_index+=1
                        if @sprites["panel_sel"].y<280
                        @sprites["panel_sel"].y+=48
                        else
                        @sprites["panels"].y-=48
                        end
                        updatePokemonSprite
                        updateSliderPosition
                        waitAndUpdate(1)
                        end
                        waitAndUpdate(3)
                        @sprites["leftright"].setBitmap("Graphics/Pictures/Pokedex/leftright")
                        end

                        # updates the Pokemon Sprite when called.
                        def updatePokemonSprite
                        @sprites["pkmn_sprite"].bitmap.clear
                        if $Trainer.seen[currentPokemon]
                        @sprites["panel_sel"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/panel_sel_pkmn")
                        @sprites["panel_sel"].x=192
                        if USING_BITMAP_WRAPPER==true && defined?(AnimatedBitmapWrapper)
                        pkmnbitmap=AnimatedBitmapWrapper.new(pbPokemonBitmapFile(currentPokemon,false))
                        else
                        pkmnbitmap=AnimatedBitmap.new(pbPokemonBitmapFile(currentPokemon,false))
                        end
                        @sprites["pkmn_sprite"].bitmap.blt(0,0,
                        pkmnbitmap.bitmap,Rect.new(0,0,pkmnbitmap.bitmap.width,pkmnbitmap.bitmap.height))
                        @sprites["pkmn_sprite"].ox=pkmnbitmap.bitmap.width/2
                        @sprites["pkmn_sprite"].oy=pkmnbitmap.bitmap.height/2
                        @sprites["pkmn_info"].visible=true
                        @sprites["undiscovered"].visible=false
                        else
                        @sprites["panel_sel"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/panel_sel")
                        @sprites["panel_sel"].x=256
                        @pokemon_sprite.visible=false if @pokemon_sprite
                        @sprites["pkmn_info"].visible=false
                        @sprites["undiscovered"].visible=true
                        end
                        end

                        # Function for using the mouse for the scrolling bar.
                        def mouseScrollBar
                        if $mouse.inAreaPress?(494,10,18,315)#16, 300
                        if $mouse.y>316
                        @sprites["slider"].y=316
                        elsif $mouse.y<16
                        @sprites["slider"].y=16
                        else
                        @sprites["slider"].y=$mouse.y
                        end
                        @dex_index=(@sprites["slider"].y-16)*$pokedex.length/300
                        @dex_index=1 if @dex_index<1
                        if @sprites["slider"].y>16
                        @sprites["panels"].y= -48*($pokedex.length-7)
                        @sprites["panels"].y= -48*(@dex_index-1) if @dex_index<($pokedex.length-5)
                        @sprites["panels"].y=0 if ($pokedex.length<7)
                        @sprites["panel_sel"].y=48*(@dex_index-1)[email protected]["panels"].y+2
                        else
                        @sprites["panels"].y=0
                        end
                        end
                        end

                        # Method for updating the Dex Panels.
                        def mouseDexPanels
                        update=false
                        current= -1
                        if @nextDex
                        current=(@sprites["dex_panel_sel"].y-198)/48
                        max=0
                        for i in 0...3
                        max+=1 if @sprites["dex_panel#{i}"]
                        end
                        if max==current
                        current=4-max
                        else
                        current+=1
                        end
                        end
                        if $mouse.leftClick?(@sprites["dex_panel1"]) || current==1
                        return if @sprites["dex_panel_sel"][email protected]["dex_panel1"].y
                        pkmn=currentPokemon
                        if @dexes[0]==0
                        $pokedex=$regional_dex_1
                        elsif @dexes[0]==1
                        $pokedex=$regional_dex_2
                        else
                        $pokedex=pbNationalDex
                        end
                        @sprites["dex_panel_sel"][email protected]["dex_panel1"].y
                        update=true
                        end
                        if @sprites["dex_panel2"]
                        if $mouse.leftClick?(@sprites["dex_panel2"]) || current==2
                        return if @sprites["dex_panel_sel"][email protected]["dex_panel2"].y
                        pkmn=currentPokemon
                        if @dexes[1]==0
                        $pokedex=$regional_dex_1
                        elsif @dexes[1]==1
                        $pokedex=$regional_dex_2
                        else
                        $pokedex=pbNationalDex
                        end
                        @sprites["dex_panel_sel"][email protected]["dex_panel2"].y
                        update=true
                        end
                        end
                        if @sprites["dex_panel3"]
                        if $mouse.leftClick?(@sprites["dex_panel3"]) || current==3
                        return if @sprites["dex_panel_sel"][email protected]["dex_panel3"].y
                        pkmn=currentPokemon
                        if @dexes[2]==0
                        $pokedex=$regional_dex_1
                        elsif @dexes[2]==1
                        $pokedex=$regional_dex_2
                        else
                        $pokedex=pbNationalDex
                        end
                        @sprites["dex_panel_sel"][email protected]["dex_panel3"].y
                        update=true
                        end
                        end
                        return if !update
                        @black=Sprite.new(@viewport)
                        @black.z=9999999
                        black_bitmap=Bitmap.new(512,384)
                        black_bitmap.fill_rect(0,0,512,384,Color.new(0,0,0))
                        @black.bitmap=black_bitmap
                        @black.opacity=0
                        $pokedex2=$pokedex
                        10.times do
                        @black.opacity+=255/10
                        waitAndUpdate(1)
                        end
                        @sprites["dex_panel_sel"].visible=false
                        updateDexIndexIfDexHasChanged(pkmn)
                        drawPanels
                        updateSliderPosition
                        updatePokemonSprite if @dex_index>0
                        @sprites["dex_panel_sel"].visible=true
                        10.times do
                        @black.opacity-=255/10
                        waitAndUpdate(1)
                        end
                        @black.dispose
                        @nextDex=false
                        end

                        # If a Panel was being pressed this will return the current clicked Pokémon.
                        def mousePanelInput
                        return if !$mouse.leftPressed?(@sprites["panels"])
                        # when clicking on a panel and no panel is selected yet.
                        if @sprites["panel_sel"].y<0
                        for i in 0..6
                        if $mouse.inArea?(192,i*48+2,302,42) && Input.releaseex?(Input::Mouse_Left)
                        @sprites["panel_sel"].y+=48*(i+1)
                        @dex_index+=i+1
                        @sprites["panel_sel"].x=192
                        @sprites["panel_sel"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/panel_sel_pkmn")
                        updatePokemonSprite
                        waitAndUpdate(5)
                        @sprites["panel_sel"].visible=false
                        waitAndUpdate(5)
                        @sprites["panel_sel"].visible=true
                        @scene=2 if $Trainer.seen[currentPokemon]
                        return
                        end
                        end
                        end
                        # when clicking on the selected panel.
                        if $mouse.leftPressed?(@sprites["panel_sel"])
                        updatePokemonSprite
                        @sprites["panel_sel"].visible=true
                        waitAndUpdate(5)
                        @sprites["panel_sel"].visible=false
                        waitAndUpdate(5)
                        @sprites["panel_sel"].visible=true
                        @scene=2 if $Trainer.seen[currentPokemon]
                        return
                        end
                        # when clicking on a panel which is not the selected panel.
                        subtract=(@sprites["panel_sel"].y-2)/48
                        for i in 0..6
                        if $mouse.inArea?(192,i*48+2,302,42) && $mouse.leftPressed?(@sprites["panels"])
                        addition=i
                        end
                        end
                        return if !addition
                        species=currentPokemon+addition-subtract
                        @dex_index+=addition-subtract
                        graphic_change=(addition-subtract)*48
                        @sprites["panel_sel"].y+=graphic_change
                        @sprites["panel_sel"].visible=true
                        updatePokemonSprite
                        waitAndUpdate(5)
                        @sprites["panel_sel"].visible=false
                        waitAndUpdate(5)
                        @sprites["panel_sel"].visible=true
                        @scene=2 if $Trainer.seen[currentPokemon]
                        end

                        # Method for ending the scene.
                        def pbEndScene
                        pbFadeOutAndHide(@sprites)
                        pbDisposeSpriteHash(@sprites)
                        @viewport.dispose
                        end

                        def update(current_dex_index=0,current_index=0)
                        @scene= -1 # 0=exit , 1=Search Function , 2=Pokémon information
                        @nextDex=false
                        while @scene<0
                        Graphics.update
                        Input.update
                        # Animating background.
                        updateBackground
                        # Inputs
                        if Input.trigger?(Input::DOWN) && @index==0
                        if @dex_index<$pokedex.length
                        @dex_index+=1
                        if @sprites["panel_sel"].y<290
                        @sprites["panel_sel"].y+=48
                        else
                        @sprites["panels"].y-=48 if canScrollDown
                        end
                        end
                        end
                        if Input.trigger?(Input::UP) && @index==0
                        if @dex_index>1
                        @dex_index-=1
                        if @sprites["panel_sel"].y>2
                        @sprites["panel_sel"].y-=48
                        else
                        @sprites["panels"].y+=48 if canScrollUp
                        end
                        end
                        end
                        if Input.trigger?(Input::C)
                        case @index
                        when 0
                        @scene=2
                        end
                        end

                        if Input.trigger?(Input::B)
                        pbShowAnimation("exit")
                        @scene=0
                        end
                        if defined?($mouse)
                        mousePanelInput
                        mouseScrollBar
                        mouseDexPanels
                        if $mouse.inAreaLeft?(278,346,34,28)
                        scrollToLeft
                        end
                        if $mouse.inAreaLeft?(328,346,34,28)
                        scrollToRight
                        end
                        if $mouse.leftClick?(@sprites["exit"])
                        pbShowAnimation("exit")
                        @scene=0
                        end
                        if $mouse.leftClick?(@sprites["return"])
                        @sprites["return"].setBitmap("Graphics/Pictures/Universal/return2")
                        pbWait(10)
                        @sprites["return"].setBitmap("Graphics/Pictures/Universal/return")
                        pbWait(5)
                        @scene=0
                        $MenuClose=true
                        end
                        if $mouse.leftClick?(@sprites["start"])
                        @sprites["start"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/start2")
                        waitAndUpdate(10)
                        @sprites["start"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/start")
                        waitAndUpdate(5)
                        @scene=1
                        end
                        if $mouse.leftClick?(@sprites["select"])
                        @sprites["select"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/select2")
                        waitAndUpdate(10)
                        @sprites["select"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/select")
                        waitAndUpdate(5)
                        @nextDex=true
                        mouseDexPanels
                        end
                        end
                        # updating if index has changed.
                        if @index != current_index
                        if [email protected]["cursor_1"]
                        drawBW2Cursor(469,339,23,25) if @index==1
                        end
                        [email protected]
                        end
                        # updating if dex index has changed.
                        if @dex_index != current_dex_index
                        updatePokemonSprite
                        updateSliderPosition
                        [email protected]_index
                        updateLeftRight2Sprite
                        end


                        end
                        [email protected]["panels"].y if @scene==2
                        [email protected]["panel_sel"].y if @scene==2
                        pbEndScene
                        PokedexSearch.new if @scene==1
                        if a && b && @dex_index && currentPokemon
                        PokedexPages.new(@dex_index,a,b) if $Trainer.seen[currentPokemon] && @scene==2
                        end

                        end

                        end


                        #===============================================================================
                        # * Four Pokédex Pages
                        #===============================================================================
                        class PokedexPages
                        def initialize(dex_index,panel_y,panel_sel_y)
                        @dex_index=dex_index
                        @old_dex_index=dex_index
                        @species=$pokedex[@dex_index-1]
                        @panel_y=panel_y
                        @panel_sel_y=panel_sel_y
                        @pokemon=PokeBattle_Pokemon.new(@species,1)
                        @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
                        @viewport.z=99999
                        @sprites={}
                        @sprites["bg"]=Sprite.new(@viewport)
                        @sprites["bg"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/bg1")
                        @sprites["down_bg"]=IconSprite.new(0,336,@viewport)
                        @sprites["down_bg"].bitmap=Bitmap.new("Graphics/Pictures/Universal/down_bg")
                        @sprites["updown"]=IconSprite.new(10,342,@viewport)
                        @sprites["updown"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/updown")
                        @sprites["info"]=IconSprite.new(96,340,@viewport)
                        @sprites["info"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/info")
                        @sprites["area"]=IconSprite.new(160,340,@viewport)
                        @sprites["area"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/area")
                        @sprites["forms"]=IconSprite.new(224,340,@viewport)
                        @sprites["forms"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/forms")
                        @sprites["exit"]=IconSprite.new(426,346,@viewport)
                        @sprites["exit"].bitmap=Bitmap.new("Graphics/Pictures/Universal/exit")
                        @sprites["return"]=IconSprite.new(474,346,@viewport)
                        @sprites["return"].bitmap=Bitmap.new("Graphics/Pictures/Universal/return")
                        @page=1
                        @sel=0
                        update
                        end

                        # Method for updating the background.
                        def updateBackground
                        return if [email protected]["bg"]
                        @sprites["bg"].x-=2
                        @sprites["bg"].x=0 if @sprites["bg"].x <= -512
                        end

                        # Method which is basically pbWait(x) but with a background update added.
                        def waitAndUpdate(x)
                        x.times do
                        updateBackground
                        pbWait(1)
                        end
                        end

                        # Method for disposing all necessary sprites if the page changes.
                        def disposeSprites
                        # Page 1 Sprites
                        @sprites["overlay"].dispose if @sprites["overlay"]
                        @sprites["page1"].dispose if @sprites["page1"]
                        @sprites["owned"].dispose if @sprites["owned"]
                        @sprites["pokemon"].dispose if @sprites["pokemon"]
                        @sprites["dexentry"].dispose if @sprites["dexentry"]
                        # Page 2 Sprites
                        @sprites["map"].dispose if @sprites["map"]
                        @sprites["map2"].dispose if @sprites["map2"]
                        @sprites["mapbottom"].dispose if @sprites["mapbottom"]
                        # Page 3 Sprites
                        @sprites["formname_bg"].dispose if @sprites["formname_bg"]
                        @sprites["front"].dispose if @sprites["front"]
                        @sprites["back"].dispose if @sprites["back"]
                        @sprites["select"].dispose if @sprites["select"]
                        @sprites["start"].dispose if @sprites["start"]
                        @sprites["text"].dispose if @sprites["text"]
                        @sprites["leftarrow"].dispose if @sprites["leftarrow"]
                        @sprites["rightarrow"].dispose if @sprites["rightarrow"]
                        end

                        # Method which checks whether you can scroll down or not.
                        def canScrollDown
                        return (@dex_index != ($pokedex.length))
                        end

                        # Method which checks whether you can scroll up or not.
                        def canScrollUp
                        return (@dex_index != 1)
                        end

                        # Method for pressing exit.
                        def pressedExit
                        @sprites["exit"].bitmap=Bitmap.new("Graphics/Pictures/Universal/exit2")
                        waitAndUpdate(10)
                        @sprites["exit"].bitmap=Bitmap.new("Graphics/Pictures/Universal/exit")
                        waitAndUpdate(5)
                        end

                        # Method for ending the scene.
                        def pbEndScene
                        pbFadeOutAndHide(@sprites)
                        pbDisposeSpriteHash(@sprites)
                        @viewport.dispose
                        end


                        # Method for getting the next seen Pokémon in the dex. Will return 0
                        # if there if there is no next seen Pokémon.
                        def searchNextSeenPokemon(dir)
                        if dir==2 # DOWN
                        for i in @dex_index...$pokedex.length
                        return (i+1) if $Trainer.seen[$pokedex[i]]
                        end
                        return 0
                        elsif dir==8 # UP
                        [email protected]_index-2
                        while !$Trainer.seen[$pokedex[i]]
                        i-=1
                        return 0 if i==0
                        end
                        return (i+1)
                        end
                        end

                        def changePokemon(dir)
                        new_index=searchNextSeenPokemon(dir)
                        if dir==2 # DOWN
                        return if !canScrollDown
                        if new_index != @dex_index && new_index != 0 && new_index
                        @dex_index=new_index
                        else
                        return
                        end
                        @sprites["updown"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/updown3")
                        elsif dir==8 # UP
                        return if !canScrollUp
                        if new_index != @dex_index && new_index != 0 && new_index
                        @dex_index=new_index
                        else
                        return
                        end
                        @sprites["updown"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/updown2")
                        end
                        waitAndUpdate(10)
                        @sprites["updown"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/updown")
                        waitAndUpdate(5)
                        disposeSprites
                        @species=$pokedex[@dex_index-1]
                        @pokemon=PokeBattle_Pokemon.new(@species,1)
                        drawPageOne if @page==1
                        drawPageTwo if @page==2
                        @backSprite=nil if @page==3
                        @frontSprite=nil if @page==3
                        drawPageThree if @page==3
                        end

                        # Method for updating Page 2.
                        def updatePage2
                        @numpoints.times {|i|
                        @sprites["point#{i}"].opacity=[64,96,128,160,128,96][(Graphics.frame_count/4)%6] if @sprites["point#{i}"]
                        }
                        end

                        def update
                        @animSprite=false # For Page 3 whether the Pokémon sprite is animated or not.
                        page=0
                        @spriteIsFrontSprite=true
                        loop do
                        Graphics.update
                        Input.update
                        updateBackground
                        updatePage2 if @page==2
                        updatePage3 if @page==3
                        if [email protected]
                        break
                        end
                        # Inputs
                        if Input.trigger?(Input::DOWN)
                        if @sel==0
                        changePokemon(2)
                        end
                        end
                        if Input.trigger?(Input::UP)
                        if @sel==0
                        changePokemon(8)
                        end
                        end
                        if Input.trigger?(Input::RIGHT)
                        @page+=1 if @page<3
                        end
                        if Input.trigger?(Input::LEFT)
                        @page-=1 if @page>1
                        end
                        if Input.trigger?(Input::B)
                        pressedExit
                        break
                        end
                        if defined?($mouse)
                        if $mouse.inAreaLeft?(10,342,28,34) # up arrow
                        changePokemon(8)
                        end
                        if $mouse.inAreaLeft?(58,344,28,34) # down arrow
                        changePokemon(2)
                        end
                        if $mouse.leftClick?(@sprites["exit"])
                        pressedExit
                        break
                        end
                        if $mouse.leftClick?(@sprites["info"])
                        @page=1
                        end
                        if $mouse.leftClick?(@sprites["area"])
                        @page=2
                        end
                        if $mouse.leftClick?(@sprites["forms"])
                        @page=3
                        end
                        if @page==3
                        if @sprites["leftarrow"]
                        if [email protected]["leftarrow"].disposed?
                        if $mouse.leftClick?(@sprites["leftarrow"])
                        switchFormToLeft
                        end
                        end
                        end

                        if @sprites["rightarrow"]
                        if [email protected]["rightarrow"].disposed?
                        if $mouse.leftClick?(@sprites["rightarrow"])
                        switchFormToRight
                        end
                        end
                        end
                        if @sprites["select"]
                        if [email protected]["select"].disposed?
                        if $mouse.leftClick?(@sprites["select"])
                        @sprites["select"].setBitmap("Graphics/Pictures/Pokedex/Pages/turn_sprite2")
                        waitAndUpdate(10)
                        @sprites["front"][email protected]["back"].visible
                        @[email protected]["front"].visible
                        @sprites["back"].visible=(@sprites["front"].visible)? false : true
                        @sprites["select"].setBitmap("Graphics/Pictures/Pokedex/Pages/turn_sprite")
                        waitAndUpdate(5)
                        end
                        end
                        end

                        if @sprites["start"]
                        if [email protected]["start"].disposed?
                        if $mouse.leftClick?(@sprites["start"])
                        @sprites["start"].setBitmap("Graphics/Pictures/Pokedex/Pages/start_sprite2")
                        waitAndUpdate(10)
                        if @animSprite
                        @animSprite=false
                        else
                        @animSprite=true
                        end
                        @sprites["start"].setBitmap("Graphics/Pictures/Pokedex/Pages/start_sprite")
                        end
                        end
                        end
                        end
                        end
                        # If the page changes.
                        if @page != page
                        @sprites["info"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/info") if page==1
                        @sprites["area"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/area") if page==2
                        @sprites["forms"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/forms") if page==3
                        @sprites["info"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/info2") if @page==1
                        @sprites["area"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/area2") if @page==2
                        @sprites["forms"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/forms2") if @page==3
                        disposeSprites
                        drawPageOne if @page==1
                        drawPageTwo if @page==2
                        drawPageThree if @page==3
                        [email protected]
                        end
                        end
                        pbEndScene
                        if @dex_index<8
                        @panel_y=0
                        @[email protected]_index*48-46
                        elsif @dex_index>$pokedex.length-8
                        @panel_y= -48*($pokedex.length-7)
                        @panel_sel_y=290-([email protected]_index)*48
                        else
                        @panel_y= -48*(@dex_index-1)
                        @panel_sel_y=2
                        end
                        MainPokedex.new(@dex_index,@panel_y,@panel_sel_y,$pokedex)
                        end
                        #===============================================================================
                        # * Pokédex INFO
                        #===============================================================================
                        def drawPageOne
                        @sprites["bg"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/bg1")
                        @sprites["page1"]=Sprite.new(@viewport)
                        @sprites["page1"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/page1")
                        @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                        @sprites["dexentry"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                        pbSetSystemFont(@sprites["overlay"].bitmap)
                        pbSetSystemFont(@sprites["dexentry"].bitmap)
                        baseColor=Color.new(90,82,82)
                        baseColor2=Color.new(255,255,255)
                        shadowColor=Color.new(165,165,173)
                        textpos=[
                        [sprintf(_INTL("HT")),288,152,0,baseColor,shadowColor],
                        [sprintf(_INTL("WT")),288,184,0,baseColor,shadowColor]
                        ]
                        [email protected]_index.to_s
                        if dex_num.length==1
                        dex_num.insert(0,"0")
                        end
                        if dex_num.length==2
                        dex_num.insert(0,"0")
                        end
                        textpos.push([_INTL("#{dex_num}"),272,26,0,baseColor,shadowColor])
                        textpos.push([_INTL("#{@pokemon.name}"),352,26,0,baseColor,shadowColor])
                        if $Trainer.owned[@species]
                        @sprites["owned"]=IconSprite.new(204,16,@viewport)
                        @sprites["owned"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/owned")
                        dexdata=pbOpenDexData
                        pbDexDataOffset(dexdata,@species,8)
                        type1=dexdata.fgetb
                        type2=dexdata.fgetb
                        pbDexDataOffset(dexdata,@species,33)
                        height=dexdata.fgetw
                        weight=dexdata.fgetw
                        dexdata.close
                        kind=pbGetMessage(MessageTypes::Kinds,@species)
                        dexentry=pbGetMessage(MessageTypes::Entries,@species)
                        inches=(height/0.254).round
                        pounds=(weight/0.45359).round
                        textpos.push([_ISPRINTF("{1:s} Pokémon",kind),376,60,2,baseColor,shadowColor])
                        if pbGetCountry()==0xF4 # If the user is in the United States
                        textpos.push([_ISPRINTF("{1:d}'{2:02d}"",inches/12,inches%12),490,152,1,baseColor,shadowColor])
                        textpos.push([_ISPRINTF("{1:4.1f} lbs.",pounds/10.0),490,184,1,baseColor,shadowColor])
                        else
                        textpos.push([_ISPRINTF("{1:.1f} m",height/10.0),490,152,1,baseColor,shadowColor])
                        textpos.push([_ISPRINTF("{1:.1f} kg",weight/10.0),490,184,1,baseColor,shadowColor])
                        end
                        drawTextEx(@sprites["dexentry"].bitmap,
                        36,234,Graphics.width-36,3,dexentry,baseColor2,shadowColor)
                        footprintfile=pbPokemonFootprintFile(@species)
                        if footprintfile
                        footprint=BitmapCache.load_bitmap(footprintfile)
                        @sprites["overlay"].bitmap.blt(225,116,footprint,footprint.rect)
                        footprint.dispose
                        end
                        typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
                        type1rect=Rect.new(0,type1*24,64,24)
                        type2rect=Rect.new(0,type2*24,64,24)
                        @sprites["overlay"].bitmap.blt(304,108,typebitmap.bitmap,type1rect)
                        @sprites["overlay"].bitmap.blt(384,108,typebitmap.bitmap,type2rect) if type1!=type2
                        typebitmap.dispose
                        else
                        # if $Trainer.seen[@species]
                        # typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
                        # type1rect=Rect.new(0,type1*24,64,24)
                        # type2rect=Rect.new(0,type2*24,64,24)
                        # @sprites["overlay"].bitmap.blt(304,108,typebitmap.bitmap,type1rect)
                        # @sprites["overlay"].bitmap.blt(384,108,typebitmap.bitmap,type2rect) if type1!=type2
                        # typebitmap.dispose
                        # end

                        textpos.push([_INTL("????? Pokémon"),376,60,2,baseColor,shadowColor])
                        if pbGetCountry()==0xF4 # If the user is in the United States
                        textpos.push([_INTL("???'??""),490,152,1,baseColor,shadowColor])
                        textpos.push([_INTL("????.? lbs."),490,184,1,baseColor,shadowColor])
                        else
                        textpos.push([_INTL("????.? m"),490,152,1,baseColor,shadowColor])
                        textpos.push([_INTL("????.? kg"),490,184,1,baseColor,shadowColor])
                        end
                        end
                        pbDrawTextPositions(@sprites["overlay"].bitmap,textpos)
                        if USING_BITMAP_WRAPPER && defined?(AnimatedBitmapWrapper)
                        pkmnbitmap=AnimatedBitmapWrapper.new(pbPokemonBitmapFile(@species,false))
                        else
                        pkmnbitmap=AnimatedBitmap.new(pbPokemonBitmapFile(@species,false))
                        end
                        @sprites["pokemon"]=BitmapSprite.new(pkmnbitmap.bitmap.width,
                        pkmnbitmap.bitmap.height,@viewport)
                        @sprites["pokemon"].bitmap.blt(0,0,
                        pkmnbitmap.bitmap,pkmnbitmap.bitmap.rect)
                        @sprites["pokemon"].mirror=true
                        @sprites["pokemon"].ox=pkmnbitmap.width/2
                        @sprites["pokemon"].oy=pkmnbitmap.height/2
                        @sprites["pokemon"].x=96
                        @sprites["pokemon"].y=96
                        pkmnbitmap.dispose
                        pbPlayCry(@species)
                        end
                        #===============================================================================
                        # * Pokédex AREA
                        #===============================================================================
                        def drawPageTwo
                        regionmap= -1
                        pbRgssOpen("Data/townmap.dat","rb"){|f|
                        @mapdata=Marshal.load(f)
                        }
                        mappos=!$game_map ? nil : pbGetMetadata($game_map.map_id,MetadataMapPosition)
                        region=regionmap
                        if region<0 # Use player's current region
                        region=mappos ? mappos[0] : 0 # Region 0 default
                        end
                        @sprites["map"]=IconSprite.new(0,0,@viewport)
                        @sprites["map"].setBitmap("Graphics/Pictures/#{@mapdata[region][1]}")
                        @sprites["map"].x+=([email protected]["map"].bitmap.width)/2
                        for hidden in REGIONMAPEXTRAS
                        if hidden[0]==region && hidden[1]>0 && $game_switches[hidden[1]]
                        if [email protected]["map2"]
                        @sprites["map2"]=BitmapSprite.new(480,320,@viewport)
                        @sprites["map2"][email protected]["map"].x; @sprites["map2"][email protected]["map"].y
                        end
                        pbDrawImagePositions(@sprites["map2"].bitmap,[
                        ["Graphics/Pictures/#{hidden[4]}",
                        hidden[2]*PokemonRegionMapScene::SQUAREWIDTH,
                        hidden[3]*PokemonRegionMapScene::SQUAREHEIGHT,0,0,-1,-1]
                        ])
                        end
                        end
                        @point=BitmapWrapper.new(PokemonRegionMapScene::SQUAREWIDTH+4,
                        PokemonRegionMapScene::SQUAREHEIGHT+4)
                        @point.fill_rect(0,0,
                        PokemonRegionMapScene::SQUAREWIDTH+4,
                        PokemonRegionMapScene::SQUAREHEIGHT+4,Color.new(255,0,0))
                        @point2=BitmapWrapper.new(PokemonRegionMapScene::SQUAREWIDTH+4,
                        PokemonRegionMapScene::SQUAREHEIGHT+4)
                        @point2.fill_rect(4,0,
                        PokemonRegionMapScene::SQUAREWIDTH,
                        PokemonRegionMapScene::SQUAREHEIGHT+4,Color.new(255,0,0))
                        @point3=BitmapWrapper.new(PokemonRegionMapScene::SQUAREWIDTH+4,
                        PokemonRegionMapScene::SQUAREHEIGHT+4)
                        @point3.fill_rect(0,4,
                        PokemonRegionMapScene::SQUAREWIDTH+4,
                        PokemonRegionMapScene::SQUAREHEIGHT,Color.new(255,0,0))
                        @point4=BitmapWrapper.new(PokemonRegionMapScene::SQUAREWIDTH+4,
                        PokemonRegionMapScene::SQUAREHEIGHT+4)
                        @point4.fill_rect(4,4,
                        PokemonRegionMapScene::SQUAREWIDTH,
                        PokemonRegionMapScene::SQUAREHEIGHT,Color.new(255,0,0))
                        encdata=load_data("Data/encounters.dat")
                        points=[]
                        mapwidth=1+PokemonRegionMapScene::RIGHT-PokemonRegionMapScene::LEFT
                        for enc in encdata.keys
                        enctypes=encdata[enc][1]
                        if pbFindEncounter(enctypes,@species)
                        mappos=pbGetMetadata(enc,MetadataMapPosition)
                        if mappos && mappos[0]==region
                        showpoint=true
                        for loc in @mapdata[region][2]
                        showpoint=false if loc[0]==mappos[1] && loc[1]==mappos[2] &&
                        loc[7] && !$game_switches[loc[7]]
                        end
                        if showpoint
                        mapsize=pbGetMetadata(enc,MetadataMapSize)
                        if mapsize && mapsize[0] && mapsize[0]>0
                        sqwidth=mapsize[0]
                        sqheight=(mapsize[1].length*1.0/mapsize[0]).ceil
                        for i in 0...sqwidth
                        for j in 0...sqheight
                        if mapsize[1][i+j*sqwidth,1].to_i>0
                        points[mappos[1]+i+(mappos[2]+j)*mapwidth]=true
                        end
                        end
                        end
                        else
                        points[mappos[1]+mappos[2]*mapwidth]=true
                        end
                        end
                        end
                        end
                        end
                        i=0
                        for j in 0...points.length
                        if points[j]
                        s=SpriteWrapper.new(@viewport)
                        s.x=(j%mapwidth)*PokemonRegionMapScene::SQUAREWIDTH-2
                        s.x+=([email protected]["map"].bitmap.width)/2
                        s.y=(j/mapwidth)*PokemonRegionMapScene::SQUAREHEIGHT-2
                        s.y+=([email protected]["map"].bitmap.height)/2
                        if j>=1 && points[j-1]
                        if j>=mapwidth && points[j-mapwidth]
                        [email protected]
                        else
                        [email protected]
                        end
                        else
                        if j>=mapwidth && points[j-mapwidth]
                        [email protected]
                        else
                        [email protected]
                        end
                        end
                        @sprites["point#{i}"]=s
                        i+=1
                        end
                        end
                        @numpoints=i
                        return true
                        end
                        #===============================================================================
                        # * Pokédex FORMS
                        #===============================================================================
                        def drawPageThree
                        [email protected]
                        @gender=$Trainer.formlastseen[species][0]
                        @form=$Trainer.formlastseen[species][1]
                        @available=pbGetAvailable # [name, gender, form]
                        @sprites["bg"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/bg3")
                        @sprites["formname_bg"]=IconSprite.new(130,6,@viewport)
                        @sprites["formname_bg"].setBitmap("Graphics/Pictures/Pokedex/Pages/formname")
                        @sprites["text"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                        @sprites["front"]=PokemonSprite.new(@viewport)
                        @sprites["back"]=PokemonSprite.new(@viewport)
                        if @spriteIsFrontSprite
                        @sprites["back"].visible=false
                        else
                        @sprites["front"].visible=false
                        end
                        @sprites["icon"]=PokemonSpeciesIconSprite.new(@species,@viewport)
                        @sprites["icon"][email protected]
                        @sprites["icon"][email protected]
                        @sprites["icon"].x=52
                        @sprites["icon"].y=290
                        @sprites["icon"].visible=false
                        @sprites["select"]=IconSprite.new(130,306,@viewport)
                        @sprites["select"].setBitmap("Graphics/Pictures/Pokedex/Pages/turn_sprite")
                        @sprites["start"]=IconSprite.new(258,306,@viewport)
                        @sprites["start"].setBitmap("Graphics/Pictures/Pokedex/Pages/start_sprite")

                        @sprites["leftarrow"]=IconSprite.new(8,0,@viewport)
                        @sprites["leftarrow"].setBitmap("Graphics/Pictures/Pokedex/Pages/arrow_left")

                        @sprites["rightarrow"]=IconSprite.new(484,0,@viewport)
                        @sprites["rightarrow"].setBitmap("Graphics/Pictures/Pokedex/Pages/arrow_right")
                        @frontSprite=nil; @backSprite=nil; @formNeedsRefresh=false
                        end

                        # Updating Page 3. Will be called every frame.
                        def updatePage3
                        @sprites["text"].bitmap.clear
                        pbSetSystemFont(@sprites["text"].bitmap)
                        name=""
                        for i in @available
                        if i[1][email protected] && i[2][email protected]
                        name=i[0]
                        break
                        end
                        end
                        text=[
                        [_INTL("{1}",name),
                        256,44,2,
                        Color.new(255,255,255),Color.new(165,165,173)],
                        ]
                        pbDrawTextPositions(@sprites["text"].bitmap,text)
                        frontBitmap=pbCheckPokemonBitmapFiles([@species,false,(@gender==1),false,@form,false])
                        if (frontBitmap && [email protected]) || @formNeedsRefresh
                        frontSprite=AnimatedBitmap.new(frontBitmap)
                        if USING_BITMAP_WRAPPER && defined?(AnimatedBitmapWrapper)
                        frontSprite=AnimatedBitmapWrapper.new(frontBitmap)
                        else
                        frontSprite=AnimatedBitmap.new(frontBitmap)
                        end
                        @sprites["front"].bitmap=frontSprite.bitmap
                        end
                        backBitmap=pbCheckPokemonBitmapFiles([@species,true,(@gender==1),false,@form,false])
                        if (backBitmap && [email protected]) || @formNeedsRefresh
                        if USING_BITMAP_WRAPPER && defined?(AnimatedBitmapWrapper)
                        backSprite=AnimatedBitmapWrapper.new(backBitmap)
                        else
                        backSprite=AnimatedBitmap.new(backBitmap)
                        end

                        @sprites["back"].bitmap=backSprite.bitmap
                        end
                        metrics=load_data("Data/metrics.dat")
                        backMetric=metrics[0][@species]
                        pbSetSpritePositionToMiddle(@sprites["front"])
                        pbSetSpritePositionToMiddle(@sprites["back"])
                        @sprites["icon"].update
                        if Input.trigger?(Input::C)
                        pbChooseForm
                        end
                        if ([email protected] || [email protected]) || @formNeedsRefresh
                        @frontSprite=frontSprite
                        @backSprite=backSprite
                        @formNeedsRefresh=false
                        end
                        animateSprite
                        end

                        # Checking for available forms.
                        def pbGetAvailable
                        available=[] # [name, gender, form]
                        dexdata=pbOpenDexData
                        pbDexDataOffset(dexdata,@species,18)
                        genderbyte=dexdata.fgetb
                        dexdata.close
                        formnames=pbGetMessage(MessageTypes::FormNames,@species)
                        if !formnames || formnames==""
                        formnames=[""]
                        else
                        formnames=strsplit(formnames,/,/)
                        end
                        @gender=0 if genderbyte==0 || genderbyte==255 # Always male or genderless
                        @gender=1 if genderbyte==254 # Always female
                        if formnames && formnames[0]!=""
                        for j in 0...2
                        if $Trainer.formseen[@species][j][0] || ALWAYSSHOWALLFORMS # That gender/form has been seen
                        if pbResolveBitmap(sprintf("Graphics/Battlers/%sf",getConstantName(PBSpecies,@species))) ||
                        pbResolveBitmap(sprintf("Graphics/Battlers/%03df",@species))
                        available.push([_INTL("{1} Male",formnames[0]),j,0]) if j==0
                        available.push([_INTL("{1} Female",formnames[0]),j,0]) if j==1
                        else
                        gendertopush=(genderbyte==254) ? 1 : 0
                        available.push([formnames[0],gendertopush,0])
                        break
                        end
                        end
                        end
                        else
                        if $Trainer.formseen[@species][0][0] || ALWAYSSHOWALLFORMS # Male/form 0 has been seen
                        if genderbyte!=254 && genderbyte!=255 # Not always female & not genderless
                        available.push([_INTL("Male"),0,0])
                        end
                        end
                        if $Trainer.formseen[@species][1][0] || ALWAYSSHOWALLFORMS # Female/form 0 has been seen
                        if genderbyte!=0 && genderbyte!=255 # Not always male & not genderless
                        available.push([_INTL("Female"),1,0])
                        end
                        end
                        if $Trainer.formseen[@species][0][0] || ALWAYSSHOWALLFORMS # Genderless/form 0 has been seen
                        if genderbyte==255 # Genderless
                        if formnames && formnames.length>1
                        available.push([_INTL("One Form"),0,0])
                        else
                        available.push([_INTL("Genderless"),0,0])
                        end
                        end
                        end
                        end
                        for i in 1...formnames.length
                        for j in 0...2
                        if $Trainer.formseen[@species][j][i] || ALWAYSSHOWALLFORMS # That gender/form has been seen
                        if pbResolveBitmap(sprintf("Graphics/Battlers/%sf_%d",getConstantName(PBSpecies,@species),i)) ||
                        pbResolveBitmap(sprintf("Graphics/Battlers/%03df_%d",@species,i))
                        available.push([_INTL("{1} Male",formnames[i]),j,i]) if j==0
                        available.push([_INTL("{1} Female",formnames[i]),j,i]) if j==1
                        else
                        available.push([formnames[i],j,i])
                        break
                        end
                        end
                        end
                        end
                        return available
                        end

                        # Checking for commands.
                        def pbGetCommands
                        commands=[]
                        for i in @available
                        commands.push(i[0])
                        end
                        return commands
                        end

                        # Animates the Sprite. Thanks Luka for his BitmapWrapper class.
                        def animateSprite
                        if !defined?(AnimatedBitmapWrapper)
                        p "Animation can only be played when using AnimatedBitmapWrapper." if $DEBUG
                        return
                        end
                        if @animSprite
                        if @frontSprite.finished?
                        @frontSprite.toFrame(0)
                        @backSprite.toFrame(0)
                        end
                        @frontSprite.play
                        @backSprite.play
                        @sprites["front"][email protected]
                        @sprites["back"][email protected]
                        end
                        end

                        # Switches the form to the left.
                        def switchFormToLeft
                        @sprites["leftarrow"].setBitmap("Graphics/Pictures/Pokedex/Pages/arrow_left2")
                        [email protected]["front"].x
                        10.times do
                        @sprites["front"].x-=([email protected]["front"].bitmap.width/2)/10
                        @sprites["back"][email protected]["front"].x
                        updateBackground
                        animateSprite
                        pbWait(1)
                        end
                        @sprites["leftarrow"].setBitmap("Graphics/Pictures/Pokedex/Pages/arrow_left")
                        minForm=0
                        for i in [email protected]
                        if @[email protected][i][1] && @[email protected][i][2]
                        currentForm=i
                        break
                        end
                        end
                        if currentForm==minForm
                        [email protected]
                        else
                        nextForm=currentForm-1
                        end
                        @[email protected]["icon"][email protected][nextForm][1]
                        @[email protected]["icon"][email protected][nextForm][2]
                        @formNeedsRefresh=true
                        updatePage3
                        @sprites["front"].x=512+(@sprites["front"].bitmap.width/2)
                        [email protected]["front"].x/2
                        10.times do
                        @sprites["front"].x-=([email protected]["front"].bitmap.width/2)/10
                        @sprites["back"][email protected]["front"].x
                        updateBackground
                        animateSprite
                        pbWait(1)
                        end
                        end

                        # Switches the form to the right.
                        def switchFormToRight
                        @sprites["rightarrow"].setBitmap("Graphics/Pictures/Pokedex/Pages/arrow_right2")
                        [email protected]["front"].x
                        10.times do
                        @sprites["front"].x+=([email protected]["front"].bitmap.width/2)/10
                        @sprites["back"][email protected]["front"].x
                        updateBackground
                        animateSprite
                        pbWait(1)
                        end
                        @sprites["rightarrow"].setBitmap("Graphics/Pictures/Pokedex/Pages/arrow_right")
                        [email protected]
                        for i in [email protected]
                        if @[email protected][i][1] && @[email protected][i][2]
                        currentForm=i
                        break
                        end
                        end
                        if currentForm==maxForm
                        nextForm=0
                        else
                        nextForm=currentForm+1
                        end
                        @[email protected]["icon"][email protected][nextForm][1]
                        @[email protected]["icon"][email protected][nextForm][2]
                        @formNeedsRefresh=true
                        updatePage3
                        @sprites["front"].x=0-(@sprites["front"].bitmap.width/2)
                        x=256-(@sprites["front"].bitmap.width/2)
                        10.times do
                        @sprites["front"].x+=([email protected]["front"].bitmap.width/2)/10
                        @sprites["back"][email protected]["front"].x
                        updateBackground
                        animateSprite
                        pbWait(1)
                        end
                        end

                        # Choosing the form manually by pressing enter.
                        def pbChooseForm
                        [email protected]
                        [email protected]
                        commands=pbGetCommands
                        using(cmdwindow=Window_CommandPokemon.new(commands)) {
                        cmdwindow.height=128 if cmdwindow.height>128
                        [email protected]+1
                        pbBottomRight(cmdwindow)
                        for i in [email protected]
                        if @available[i][1][email protected] && @available[i][2][email protected]
                        cmdwindow.index=i
                        break
                        end
                        end
                        loop do
                        updateBackground
                        oldindex=cmdwindow.index
                        Graphics.update
                        Input.update
                        cmdwindow.update
                        @sprites["icon"].update
                        if cmdwindow.index!=oldindex
                        @[email protected]["icon"][email protected][cmdwindow.index][1]
                        @[email protected]["icon"][email protected][cmdwindow.index][2]
                        @formNeedsRefresh=true
                        updatePage3
                        end
                        if Input.release?(Input::B)
                        pbPlayCancelSE()
                        @[email protected]["icon"].gender=oldgender
                        @[email protected]["icon"].form=oldform
                        break
                        end
                        if Input.trigger?(Input::C)
                        pbPlayDecisionSE()
                        break
                        end
                        end
                        }
                        end
                        end
                        #===============================================================================
                        # Pokédex Search
                        #===============================================================================
                        class PokedexSearch
                        def initialize
                        @options=["ORDER","NAME","TYPE","COLOR"]
                        @order=["NUMBER","A to Z","Heavy to Light","Light to Heavy",
                        "Tall to Short","Short to Tall"]
                        @name=["--","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P",
                        "Q","R","S","T","U","V","W","X","Y","Z"]
                        @type=["-","Normal","Fighting","Flying","Poison","Ground","Rock","Bug",
                        "Ghost","Steel","Fire","Water","Grass","Electric","Psychic",
                        "Ice","Dragon","Dark"]
                        @color=["-","Red","Blue","Yellow","Green","Black","Brown","Purple","Gray",
                        "White","Pink"]
                        @stuff=[@order,@name,@type,@color]
                        @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
                        @viewport.z=99999
                        @sprites={}
                        @sprites["bg"]=Sprite.new(@viewport)
                        @sprites["bg"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/bg")
                        for i in [email protected]
                        @sprites["index_panel#{i+1}"]=IconSprite.new(8,4+50*i,@viewport)
                        @sprites["index_panel#{i+1}"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/index_panel")
                        end
                        drawPanels
                        @sprites["check0"]=IconSprite.new(262,0,@viewport)
                        @sprites["check0"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/checked")
                        @sprites["check0"].visible=false
                        @sprites["check1"]=IconSprite.new(262,0,@viewport)
                        @sprites["check1"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/checked")
                        @sprites["check1"].visible=false
                        @sprites["down_bg"]=Sprite.new(@viewport)
                        @sprites["down_bg"].bitmap=Bitmap.new("Graphics/Pictures/Universal/down_bg")
                        @sprites["down_bg"][email protected]["down_bg"].bitmap.height
                        @sprites["functions"]=IconSprite.new(0,288,@viewport)
                        @sprites["functions"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/functions")
                        @sprites["exit"]=IconSprite.new(426,346,@viewport)
                        @sprites["exit"].setBitmap("Graphics/Pictures/Universal/exit")
                        @sprites["return"]=IconSprite.new(474,346,@viewport)
                        @sprites["return"].setBitmap("Graphics/Pictures/Universal/return")
                        @sprites["index_panel_sel"]=IconSprite.new(262,-5000,@viewport)
                        @sprites["index_panel_sel"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/index_panel_sel")
                        @sprites["panel_sel"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/panel_sel")
                        @sprites["panel_sel"].visible=false
                        @sprites["sort"]=IconSprite.new(8,124,@viewport)
                        @sprites["overlay"]=BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
                        @sprites["overlay2"]=BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
                        @sprites["scroll_bar"]=IconSprite.new(502,18,@viewport)
                        @sprites["scroll_bar"].setBitmap("Graphics/Pictures/Pokedex/scroll_bar")
                        @sprites["scroll_bar"].visible=false
                        @sprites["slider"]=IconSprite.new(500,16,@viewport)
                        @sprites["slider"].setBitmap("Graphics/Pictures/Pokedex/slider")
                        @sprites["slider"].visible=false
                        update
                        end

                        # Method for updating the background.
                        def updateBackground
                        return if [email protected]["bg"]
                        @sprites["bg"].x-=2
                        @sprites["bg"].x=0 if @sprites["bg"].x <= -512
                        end

                        # Method which is basically pbWait(x) but with a background update added.
                        def waitAndUpdate(frames)
                        frames.times do
                        updateBackground
                        pbWait(1)
                        end
                        end

                        # Method for ending the scene.
                        def pbEndScene
                        pbFadeOutAndHide(@sprites)
                        pbDisposeSpriteHash(@sprites)
                        @viewport.dispose
                        end

                        # Method for updating the Index panel.
                        def updateIndexPanel
                        @sprites["index_panel_sel"].y= 2+50*(@index-1)
                        end

                        # Method for the action which happens when pressing exit.
                        def exitPressed
                        @sprites["exit"].setBitmap("Graphics/Pictures/Universal/exit2")
                        waitAndUpdate(10)
                        @sprites["exit"].setBitmap("Graphics/Pictures/Universal/exit")
                        waitAndUpdate(5)
                        end

                        # Method for drawing the second page.
                        def drawPageTwo
                        @index2=0
                        @sprites["scroll_bar"].visible=true
                        @sprites["slider"].visible=true
                        @sprites["panel_sel"].y=2
                        @sprites["panel_sel"].visible=true
                        @sprites["panel_#{@index}"].visible=true
                        @sprites["overlay_#{@index}"].visible=true
                        @sprites["overlay2"].visible=true
                        @sprites["functions"].visible=false
                        @sprites["exit"].visible=false
                        @sprites["overlay"].visible=false
                        @sprites["check0"].visible=true if $searchSettings[@index][0]>(-1)
                        if ($searchSettings[2][1]>(-1)) && @index==2
                        @sprites["check1"].visible=true
                        end
                        updateCheckSprite
                        updateSliderPosition
                        index2Text
                        for i in [email protected]
                        @sprites["index_panel#{i+1}"].visible=false
                        end
                        @sprites["sort"].visible=true
                        @sprites["sort"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/sort")
                        @sprites["sort"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/sort2") if @index==2
                        end

                        # Method for drawing the first page.
                        def drawPageOne
                        @sprites["scroll_bar"].visible=false
                        @sprites["slider"].visible=false
                        @sprites["panel_sel"].visible=false
                        @sprites["panel_#{@index}"].visible=false
                        @sprites["overlay_#{@index}"].visible=false
                        @sprites["sort"].visible=false
                        @sprites["panel_#{@index}"].y=2
                        @sprites["panel_#{@index}"].visible=false
                        @sprites["overlay_#{@index}"][email protected]["panel_#{@index}"].y
                        @sprites["overlay_#{@index}"].visible=false
                        @sprites["overlay2"].visible=false
                        @sprites["check0"].visible=false
                        @sprites["check1"].visible=false
                        @sprites["functions"].visible=true
                        @sprites["exit"].visible=true
                        @sprites["overlay"].visible=true
                        @sprites["index_panel_sel"].visible=true
                        indexText
                        for i in [email protected]
                        @sprites["index_panel#{i+1}"].visible=true
                        end
                        @index+=1
                        end

                        # Method for drawing panels.
                        def drawPanels
                        @count=0 if [email protected]
                        @count+=1
                        panel=Sprite.new
                        panel.bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/panel")
                        baseColor = Color.new(255,255,255)
                        shadowColor = Color.new(165,165,173)
                        for i in [email protected]
                        @sprites["panel_#{i}"]=Sprite.new(@viewport)
                        @sprites["panel_#{i}"].bitmap=Bitmap.new(240,48*@stuff[i].length-1)
                        @sprites["panel_#{i}"].x=258
                        @sprites["panel_#{i}"].y=2
                        @sprites["panel_#{i}"].visible=false
                        end
                        @sprites["panel_sel"]=IconSprite.new(256,2,@viewport)
                        for i in [email protected]
                        @sprites["overlay_#{i}"]=BitmapSprite.new(240,48*@stuff[i].length-1,@viewport)
                        @sprites["overlay_#{i}"].visible=false
                        @sprites["overlay_#{i}"].x=258
                        @sprites["overlay_#{i}"].y=2
                        pbSetSystemFont(@sprites["overlay_#{i}"].bitmap)
                        textpos=[]
                        for u in [email protected][i].length
                        if u != @stuff[i].length
                        textpos.push([_INTL("#{@stuff[i][u+1]}"),120,8+48*u,2,baseColor,shadowColor])
                        end
                        @sprites["panel_#{i}"].bitmap.blt(0,u*48,panel.bitmap,Rect.new(
                        0,0,panel.bitmap.width,panel.bitmap.height))
                        end
                        pbDrawTextPositions(@sprites["overlay_#{i}"].bitmap,textpos)
                        end
                        panel.dispose
                        @sprites["panel_0"].src_rect.height-=48
                        end

                        # Method for drawing the text of the index Page.
                        def indexText
                        @sprites["overlay"].bitmap.clear
                        baseColor = Color.new(255,255,255)
                        shadowColor = Color.new(165,165,173)
                        pbSetSystemFont(@sprites["overlay"].bitmap)
                        textpos=[]
                        for i in [email protected]
                        textpos.push([_INTL("#{@options[i]}"),98,8+50*i,false,baseColor,shadowColor])
                        textpos.push([_INTL("#{@stuff[i][0]}"),385,8+50*i,2,baseColor,shadowColor]) if !$searchSettings
                        end
                        if $searchSettings
                        for i in [email protected]
                        if i ==2
                        if $searchSettings[2][0]>(-1) && $searchSettings[2][1]>(-1) # Two types are selected.
                        v=$searchSettings[2][0]+1; v2=$searchSettings[2][1]+1
                        txt="#{@stuff[2][v]}/#{@stuff[2][v2]}"
                        elsif $searchSettings[2][0]>(-1)
                        v=$searchSettings[2][0]+1
                        txt="#{@stuff[2][v]}"
                        elsif $searchSettings[2][1]>(-1)
                        v=$searchSettings[2][1]+1
                        txt="#{@stuff[2][v]}"
                        else
                        txt="#{@stuff[2][0]}"
                        end
                        elsif $searchSettings[i]>(-1)
                        v=$searchSettings[i]+1
                        txt="#{@stuff[i][v]}"
                        else
                        txt="#{@stuff[i][0]}"
                        end
                        textpos.push([_INTL("#{txt}"),385,8+50*i,2,baseColor,shadowColor])
                        end
                        end
                        pbDrawTextPositions(@sprites["overlay"].bitmap,textpos)
                        end

                        # Method for drawing the text of the second Page (does not include
                        # the text on the panels).
                        def index2Text
                        @sprites["overlay2"].bitmap.clear
                        baseColor = Color.new(255,255,255)
                        shadowColor = Color.new(165,165,173)
                        pbSetSystemFont(@sprites["overlay2"].bitmap)
                        textpos=[]
                        textpos.push([_INTL("#{@options[@index]}"),128,128,2,baseColor,shadowColor])
                        if @index==2
                        if $searchSettings[2][0]>(-1) && $searchSettings[2][1]>(-1) # Two types are selected.
                        v=$searchSettings[2][0]+1; v2=$searchSettings[2][1]+1
                        txt="#{@stuff[2][v]}"
                        txt2="#{@stuff[2][v2]}"
                        elsif $searchSettings[2][0]>(-1)
                        v=$searchSettings[2][0]+1
                        txt="#{@stuff[2][v]}"
                        txt2="#{@stuff[2][0]}"
                        elsif $searchSettings[2][1]>(-1)
                        v=$searchSettings[2][1]+1
                        txt2="#{@stuff[2][v]}"
                        txt="#{@stuff[2][0]}"
                        else
                        txt="#{@stuff[2][0]}"
                        txt2="#{@stuff[2][0]}"
                        end
                        elsif $searchSettings[@index]>(-1)
                        v=$searchSettings[@index]+1
                        txt="#{@stuff[@index][v]}"
                        else
                        txt="#{@stuff[@index][0]}"
                        end
                        textpos.push([_INTL("#{txt}"),128,176,2,baseColor,shadowColor])
                        if txt2
                        textpos.push([_INTL("#{txt2}"),128,224,2,baseColor,shadowColor])
                        end
                        pbDrawTextPositions(@sprites["overlay2"].bitmap,textpos)
                        end


                        # Method for scrolling down.
                        def scrollDownPanel
                        return if currentIndex<7
                        return if @sprites["panel_sel"].y<290
                        if ((maxIndex)>=currentIndex)
                        @sprites["panel_#{@index}"].y-=48
                        @sprites["overlay_#{@index}"].y-=48
                        end
                        updateSliderPosition
                        end

                        # Method for scrolling up.
                        def scrollUpPanel
                        @sprites["panel_#{@index}"].y+=48
                        @sprites["overlay_#{@index}"].y+=48
                        end

                        # Method which checks if you can scroll down.
                        def canScrollDown
                        return (@[email protected])>0
                        end

                        # Method which checks if you can scroll up.
                        def canScrollUp
                        return (@index2>0)
                        end

                        # Method which will return the current Index.
                        def currentIndex
                        return @index2
                        end

                        # Method which will current the maximum reachable Index.
                        def maxIndex
                        return (@stuff[@index].length-2)
                        end

                        # This method updates the position of the slider.
                        def updateSliderPosition
                        pos=16
                        pos+=300*currentIndex/maxIndex
                        @sprites["slider"].y=pos
                        end

                        # This method updates the little checked sprite in the second page
                        # when a panel was selected.
                        def updateCheckSprite
                        if @index==2
                        if $searchSettings[2][0]>(-1)
                        [email protected]["panel_#{@index}"].y+$searchSettings[2][0]*48
                        @sprites["check0"].y=y
                        @sprites["check0"].visible=true
                        else
                        @sprites["check0"].visible=false
                        end
                        if $searchSettings[2][1]>(-1)
                        [email protected]["panel_#{@index}"].y+$searchSettings[2][1]*48
                        @sprites["check1"].y=y
                        @sprites["check1"].visible=true
                        else
                        @sprites["check1"].visible=false
                        end
                        elsif $searchSettings[@index]>(-1)
                        [email protected]["panel_#{@index}"].y+$searchSettings[@index]*48
                        @sprites["check0"].y=y
                        @sprites["check0"].visible=true
                        else
                        @sprites["check0"].visible=false
                        end
                        end

                        # Will return true if it's the first side. the method is using the visibility
                        # of the object @sprites["exit"] to check.
                        def firstPage
                        return (@sprites["exit"].visible==true)
                        end

                        # Will return true if it's the second side. the method is using the visibility
                        # of the object @sprites["exit"] to check.
                        def secondPage
                        return (@sprites["exit"].visible==false)
                        end

                        # Function which will return the index.
                        def mousePanelClick
                        for i in 0..6
                        if $mouse.inAreaLeft?(256,2+i*48,240,44)
                        val=i
                        end
                        end
                        return if !val
                        val-= (@sprites["panel_#{@index}"].y-2)/48
                        return val
                        end

                        # Function for saving the setting when clicking on on a panel with the mouse.
                        def mousePanelClickUpdate
                        val=mousePanelClick
                        if val
                        # Lines which are handling the Types since you can select two types.
                        if @index==2
                        if $searchSettings[2][0]==val
                        $searchSettings[2][0]= -1
                        elsif $searchSettings[2][1]==val
                        $searchSettings[2][1]= -1
                        elsif $searchSettings[2][0]== -1
                        $searchSettings[2][0]=val
                        elsif $searchSettings[2][0]>(-1)
                        $searchSettings[2][1]=val
                        end
                        # Lines which are handling everything except the Types.
                        elsif $searchSettings[@index]==val
                        $searchSettings[@index]= -1
                        else
                        $searchSettings[@index]=val
                        end
                        end
                        updateCheckSprite
                        index2Text
                        end

                        # Function for using the mouse for the scrolling bar.
                        def mouseScrollBar
                        return if @sprites["exit"].visible
                        return if !$mouse.inAreaPress?(494,10,18,315)
                        # Updating slider.
                        if $mouse.y>316
                        @sprites["slider"].y=316
                        elsif $mouse.y<16
                        @sprites["slider"].y=16
                        else
                        @sprites["slider"].y=$mouse.y
                        end
                        # Updating index.
                        @index2= (@sprites["slider"].y-16)*maxIndex/300
                        @index2=0 if @index2<0
                        # Updating panel position.
                        [email protected]["panel_#{@index}"].y
                        @sprites["panel_#{@index}"].y= -48*(currentIndex-6)+2 if @sprites["panel_sel"].y>=290
                        @sprites["panel_#{@index}"].y= -48*currentIndex+2 if @sprites["panel_sel"].y<=2
                        if y_pos<@sprites["panel_#{@index}"].y && @sprites["panel_sel"].y>10
                        @sprites["panel_#{@index}"].y=y_pos
                        end
                        # Updating overlay.
                        @sprites["overlay_#{@index}"][email protected]["panel_#{@index}"].y
                        # Updating selected panel.
                        @sprites["panel_sel"].y=2+48*[email protected]["panel_#{@index}"].y
                        end

                        # Update Method
                        def update
                        index= -1 ; index2=0
                        @index=0 ; @index2=0;
                        @searchStarted=false; returnpressed=false
                        if !$searchSettings
                        $searchSettings=[]
                        @options.length.times do
                        $searchSettings.push(-1)
                        end
                        $searchSettings[2]=[-1,-1] # 2 Types can be choosen.
                        end
                        loop do
                        Graphics.update
                        Input.update
                        updateBackground
                        updateIndexPanel
                        if @newDex
                        if @newDex.empty?
                        @sprites["search"].dispose
                        @newDex=nil
                        else
                        break
                        end
                        end
                        if Input.trigger?(Input::B)
                        if firstPage
                        exitPressed
                        break
                        elsif secondPage
                        @sprites["return"].bitmap=Bitmap.new("Graphics/Pictures/Universal/return2")
                        waitAndUpdate(10)
                        @sprites["return"].bitmap=Bitmap.new("Graphics/Pictures/Universal/return")
                        waitAndUpdate(5)
                        drawPageOne
                        end
                        end
                        # Scrolling down.
                        if Input.trigger?(Input::DOWN) && @index<@options.length
                        if secondPage
                        if currentIndex<maxIndex
                        @index2+=1
                        scrollDownPanel if @sprites["panel_sel"].y>=290
                        @sprites["panel_sel"].y+=48 if @sprites["panel_sel"].y<290
                        updateSliderPosition
                        end
                        else
                        @index+=1
                        end
                        end
                        # Scrolling up.
                        if Input.trigger?(Input::UP) && @index>0
                        if secondPage
                        if currentIndex>0
                        @index2-=1
                        scrollUpPanel if @sprites["panel_sel"].y<10
                        @sprites["panel_sel"].y-=48 if @sprites["panel_sel"].y>5
                        updateSliderPosition
                        end
                        else
                        @index-=1
                        end
                        end
                        if Input.trigger?(Input::C)
                        if firstPage
                        waitAndUpdate(10)
                        @sprites["index_panel_sel"].visible=false
                        waitAndUpdate(5)
                        drawPageTwo
                        elsif secondPage
                        if ($searchSettings[3][0]>(-1)) && @index==2
                        $searchSettings[3][1][email protected]
                        else
                        $searchSettings[@index][email protected]
                        end
                        updateCheckSprite
                        index2Text
                        end
                        end
                        if defined?($mouse)
                        for i in [email protected]
                        if firstPage && $mouse.inAreaLeft?(262,4+50*i,
                        @sprites["index_panel#{i+1}"].bitmap.width,
                        @sprites["index_panel#{i+1}"].bitmap.height)
                        @index=i
                        @sprites["index_panel_sel"].y=2+50*i
                        waitAndUpdate(10)
                        @sprites["index_panel_sel"].visible=false
                        waitAndUpdate(5)
                        drawPageTwo
                        end
                        end
                        if firstPage && $mouse.leftClick?(@sprites["exit"])
                        exitPressed
                        break
                        end
                        if firstPage && $mouse.inAreaLeft?(4,299,98,36)
                        pbReset
                        end
                        if firstPage && $mouse.inAreaLeft?(226,294,286,46)
                        pbStartSearch
                        end
                        if secondPage && $mouse.leftClick?(@sprites["panel_#{@index}"])
                        mousePanelClickUpdate
                        end
                        if $mouse.leftPressed?(@sprites["return"])
                        @sprites["return"].bitmap=Bitmap.new("Graphics/Pictures/Universal/return2")
                        waitAndUpdate(10)
                        @sprites["return"].bitmap=Bitmap.new("Graphics/Pictures/Universal/return")
                        waitAndUpdate(5)
                        returnpressed=true if firstPage
                        break if firstPage
                        drawPageOne if secondPage
                        end
                        mouseScrollBar
                        end
                        # Index Index changes.
                        if @index != index
                        indexText
                        [email protected]
                        end
                        # if panel index changes.
                        if @index2 != index2
                        updateCheckSprite
                        [email protected]
                        end
                        end
                        pbEndScene
                        if @newDex
                        MainPokedex.new(0,0,-46,@newDex)
                        elsif !returnpressed
                        MainPokedex.new(0,0,-46,nil)
                        end
                        end

                        # Will return the pokedex without species which the trainer didn't see.
                        def convertDex(dex)
                        ret=[]
                        for i in 0...dex.length
                        ret.push(dex[i]) if $Trainer.seen[dex[i]]
                        end
                        return ret
                        end

                        # Method will return the number of total search criteria (created for the
                        # search bar).
                        def totalCriteria
                        ret=0
                        ret+=1 if $searchSettings[0]>(-1)
                        ret+=1 if $searchSettings[1]>(-1)
                        ret+=1 if $searchSettings[2][0]>(-1) || $searchSettings[2][1]>(-1)
                        ret+=1 if $searchSettings[3]>(-1)
                        return ret
                        end

                        # Method which will reset all the settings.
                        def pbReset
                        @sprites["reset2"]=IconSprite.new(4,300,@viewport)
                        @sprites["reset2"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/reset2")
                        waitAndUpdate(10)
                        @sprites["reset2"].dispose
                        $searchSettings=[]
                        @options.length.times do
                        $searchSettings.push(-1)
                        end
                        $searchSettings[2]=[-1,-1] # Creating a 2nd option for the Type.
                        indexText
                        end

                        # This method is basically the core of the class. It will sort out every
                        # Pokémon which has the choosen settings.
                        def pbStartSearch
                        @sprites["start2"]=IconSprite.new(226,294,@viewport)
                        @sprites["start2"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/start2")
                        waitAndUpdate(10)
                        @sprites["start2"].dispose
                        waitAndUpdate(5)
                        @sprites["search"]=Sprite.new(@viewport)
                        @sprites["search"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/pkmn_search")
                        @sprites["search"][email protected]["search"].bitmap.height
                        @sprites["search_bar"].dispose if @sprites["search_bar"]
                        @sprites["search_bar"]=Sprite.new(@viewport)
                        @sprites["search_bar"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/search_bar")
                        @sprites["search_bar"].x=18
                        [email protected]["search_bar"].bitmap.width
                        @sprites["search_bar"][email protected]["search"].y+58
                        @sprites["search_bar"].src_rect.width=0
                        wasNoScanBefore=true
                        criteria=totalCriteria
                        if !$pokedex2
                        $pokedex2=$pokedex
                        end
                        $pokedex=$pokedex2
                        newDex=[]
                        # Searching Pokémon by name.
                        if $searchSettings[1]>(-1)
                        alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                        letter=alphabet[$searchSettings[1],1]
                        letter2=letter.downcase
                        oldDex=$pokedex.clone
                        for i in 0...oldDex.length
                        pokemon=PokeBattle_Pokemon.new(oldDex[i],1)
                        if pokemon.name[0,1]==(letter || letter2)
                        newDex.push(oldDex[i])
                        end
                        end
                        wasNoScanBefore=false
                        end
                        # Searching Pokémon by type.
                        if $searchSettings[2][0]>(-1) || $searchSettings[2][1]>(-1) ||
                        ($searchSettings[2][0]>(-1) && $searchSettings[2][1]>(-1))
                        type=$searchSettings[2][0] if $searchSettings[2][0]>(-1)
                        type2=$searchSettings[2][1] if $searchSettings[2][1]>(-1)
                        # Since the 9th type is "???" we need to adapt the variable type.
                        if ($searchSettings[2][0])>8
                        type+=1
                        end
                        if ($searchSettings[2][1])>8
                        type2+=1
                        end
                        oldDex=newDex
                        oldDex=$pokedex.clone if wasNoScanBefore
                        newDex=[]
                        for i in 0...oldDex.length
                        pokemon=PokeBattle_Pokemon.new(oldDex[i],1)
                        if pokemon.hasType?(type) && !type2
                        newDex.push(oldDex[i])
                        elsif pokemon.hasType?(type2) && !type
                        newDex.push(oldDex[i])
                        elsif pokemon.hasType?(type) && pokemon.hasType?(type2)
                        newDex.push(oldDex[i])
                        end
                        end
                        wasNoScanBefore=false
                        end
                        # Searching Pokémon by color.
                        if $searchSettings[3]>(-1)
                        color=$searchSettings[3]
                        oldDex=newDex
                        oldDex=$pokedex.clone if wasNoScanBefore
                        newDex=[]
                        for i in 0...oldDex.length
                        pokemon=PokeBattle_Pokemon.new(oldDex[i],1)
                        if pokemon.hasColor?(color)
                        newDex.push(oldDex[i])
                        end
                        end
                        end
                        # Sorting Pokémon from A to Z.
                        if $searchSettings[0] == 0
                        wasAlreadyOneOption=true
                        oldDex=newDex
                        oldDex=$pokedex.clone if wasNoScanBefore
                        oldDex2=oldDex.clone
                        newDex=[]
                        for i in 0...oldDex2.length
                        pokemon=PokeBattle_Pokemon.new(oldDex2[i],1)
                        oldDex[i]=[pokemon.name,oldDex[i]]
                        oldDex2[i]=pokemon.name
                        end
                        oldDex2=oldDex2.sort
                        for i in 0...oldDex2.length
                        pokemon=oldDex2[i]
                        for i in 0...oldDex.length
                        if pokemon==oldDex[i][0]
                        newDex.push(oldDex[i][1])
                        break
                        end
                        end
                        end
                        wasNoScanBefore=false
                        end
                        # Sorting Pokémon from Heavy to Light and from Light to Heavy.
                        if $searchSettings[0]==1 || $searchSettings[0]==2
                        oldDex=newDex
                        oldDex=$pokedex.clone if wasNoScanBefore
                        oldDex2=oldDex.clone
                        newDex=[]
                        for i in 0...oldDex2.length
                        pokemon=PokeBattle_Pokemon.new(oldDex2[i],1)
                        oldDex[i]=[pokemon.weight,oldDex[i]]
                        oldDex2[i]=pokemon.weight
                        end
                        oldDex2=oldDex2.sort
                        oldDex2=oldDex2.reverse if $searchSettings[0]==1
                        for i in 0...oldDex2.length
                        weight=oldDex2[i]
                        for i in 0...oldDex.length
                        if weight==oldDex[i][0]
                        newDex.push(oldDex[i][1]) if oldDex[i][1] != newDex[newDex.length-1]
                        break
                        end
                        end
                        end
                        wasNoScanBefore=false
                        end
                        # Sorting Pokémon from Tall to Short and from Short to Tall.
                        if $searchSettings[0]==3 || $searchSettings[0]==4
                        wasAlreadyOneOption=true
                        oldDex=newDex
                        oldDex=$pokedex.clone if wasNoScanBefore
                        oldDex2=oldDex.clone
                        newDex=[]
                        for i in 0...oldDex2.length
                        dexdata=pbOpenDexData
                        pbDexDataOffset(dexdata,oldDex2[i],33)
                        height=dexdata.fgetb
                        dexdata.close
                        pokemon=PokeBattle_Pokemon.new(oldDex2[i],1)
                        oldDex[i]=[height,oldDex[i]]
                        oldDex2[i]=height
                        end
                        oldDex2=oldDex2.sort
                        oldDex2.reverse! if $searchSettings[0]==3
                        for a in 0...oldDex2.length
                        height=oldDex2[a]
                        for b in 0...oldDex.length
                        if height==oldDex[b][0]
                        check=true
                        if !newDex.empty?
                        for c in 0...newDex.length
                        check=false if newDex[c]==oldDex[b][1]
                        end
                        end
                        if check==true
                        newDex.push(oldDex[b][1])
                        break
                        end
                        end
                        end
                        @sprites["search_bar"].src_rect.width+=(bar_width/criteria)/oldDex2.length
                        end
                        end
                        # Finished search.
                        frames=40
                        frame=0
                        frames.times do
                        frame+=1
                        waitAndUpdate(1)
                        @sprites["search_bar"].src_rect.width=(bar_width*frame)/frames
                        end
                        waitAndUpdate(20)
                        @sprites["search_bar"].dispose
                        newDex=convertDex(newDex)
                        newDex=$pokedex if totalCriteria==0
                        if newDex.empty?
                        @sprites["search"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/no_pkmn_found")
                        else
                        @sprites["search"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/pkmn_found")
                        end
                        loop do
                        waitAndUpdate(1)
                        break if Input.trigger?(Input::C)
                        if defined?($mouse)
                        if $mouse.inAreaLeft?(0,0,Graphics.width,Graphics.height)
                        break
                        end
                        end
                        end
                        @searchStarted=true
                        @newDex=newDex
                        end
                        end
                        Reply With Quote
                          #837    
                        Old August 6th, 2017 (4:54 AM).
                        Marin's Avatar
                        Marin Marin is offline
                        Not Bored
                           
                          Join Date: Nov 2016
                          Gender: Other
                          Posts: 624
                          Quote:
                          Originally Posted by JackRoland View Post
                          Hello Luka, I have a problem with your battle system. I tried to change pokedex script but an error occurred in EliteBattle_BitmapWrapper
                          here-->
                          Spoiler:
                          ---------------------------
                          Pokemon Essentials
                          ---------------------------
                          Script 'EliteBattle_BitmapWrapper' line 341: NameError occurred.

                          undefined method `pbStartScene' for class `PokedexFormScene'
                          ---------------------------
                          OK
                          ---------------------------

                          Here is pokedex's script
                          Spoiler:
                          #===============================================================================
                          # * BW2 Pokédex by shiney570 made from scratch.
                          #===============================================================================


                          # Generel Settings.

                          # Whether to use the new Pokedex or not.
                          USE_ADVANCED_BW2_POKEDEX = true

                          # Change to false if you don't use Luka S.J's Elite Battle 2015.
                          USING_BITMAP_WRAPPER = false
                          # Whether you want to see all forms on the form page no matter whether
                          # the player saw them or not.
                          ALWAYSSHOWALLFORMS = false
                          #===============================================================================
                          # * SET UP YOUR REGIONAL DEXES HERE
                          #===============================================================================

                          # - Choose between: Kanto ("Kanto")
                          # Johto ("Johto")
                          # Hoenn ("Hoenn")
                          # Sinnoh ("Sinnoh")
                          # Sinnoh2 ("Sinnoh2")
                          # Unova ("Unova")
                          # Unova2 ("Unova2")
                          # Custom ("Custom")
                          # None ("")

                          REGIONAL_DEX = "Unova2"
                          REGIONAL_DEX2= "Sinnoh2"

                          # This is just a quick example of a Custom Pokédex. Just add and edit values
                          # of the array and change REGIONAL_DEX or REGIONAL_DEX2 to "Custom" to use
                          # your selfmade Pokédex.
                          CUSTOM_DEX = [151,152,153,154,155,156,157,158,159,10,11,12,13,14]


                          # Change to false if you don't use Luka S.J's Elite Battle 2015.
                          USING_BITMAP_WRAPPER = true

                          # Dex Names which will appear in the Pokédex.
                          def pbDexNames
                          return ["UNOVA","SINNOH","NATIONAL"]
                          end
                          #==============================================================================#
                          # * Regional Dex'es of already existing Pokémon Editions. #
                          #==============================================================================#
                          $regional_dex_1=[]
                          $regional_dex_2=[]

                          # Gen 1 Dex.
                          if REGIONAL_DEX=="Kanto" || REGIONAL_DEX2=="Kanto"
                          kanto_dex=[]
                          for dex_num in 1..151
                          kanto_dex.insert(kanto_dex.length,dex_num)
                          end
                          $regional_dex_1=kanto_dex if REGIONAL_DEX=="Kanto"
                          $regional_dex_2=kanto_dex if REGIONAL_DEX2=="Kanto"
                          end

                          # Gen 2 Dex.
                          if REGIONAL_DEX=="Johto" || REGIONAL_DEX2=="Johto"
                          johto_dex=[152,153,154,155,156,157,158,159,160,16,17,18,21,22,163,164,19,
                          20,161,162,172,25,26,10,11,12,13,14,15,165,166,167,168,74,75,76,41,42,169,173,
                          35,36,174,39,40,175,176,27,28,23,24,206,179,180,181,194,195,92,93,94,201,95,
                          208,69,70,71,187,188,189,46,47,60,61,62,186,129,130,118,119,79,80,199,43,44,
                          45,182,96,97,63,64,65,132,204,205,29,30,31,32,33,34,193,469,191,192,102,103,
                          185,202,48,49,123,212,127,214,109,110,88,89,81,82,100,101,190,424,209,210,37,
                          38,58,59,234,183,184,50,51,56,57,52,53,54,55,66,67,68,236,106,107,237,203,128,
                          241,240,126,238,124,239,125,122,83,177,178,211,72,73,98,99,213,120,121,90,91,
                          222,223,223,170,171,86,87,108,463,114,465,133,134,135,136,169,197,116,117,230,
                          207,225,220,221,473,216,217,231,232,226,227,84,85,77,78,104,105,115,111,112,
                          198,228,229,218,219,215,200,137,233,113,242,131,138,139,140,141,142,143,1,2,3,
                          4,5,6,7,8,9,144,145,146,243,244,245,147,148,149,246,247,248,249,250,150,151,251]
                          $regional_dex_1=johto_dex if REGIONAL_DEX=="Johto"
                          $regional_dex_2=johto_dex if REGIONAL_DEX2=="Johto"
                          end

                          # Gen 3 Dex.
                          if REGIONAL_DEX=="Hoenn" || REGIONAL_DEX2=="Hoenn"
                          hoenn_dex=[252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,
                          267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,
                          286,287,288,289,63,64,65,290,291,292,293,294,295,296,297,118,119,129,130,298,
                          183,184,74,75,76,299,300,301,41,42,169,72,73,302,303,304,305,306,66,67,68,307,
                          308,309,310,311,312,81,82,100,101,313,314,43,44,45,182,84,85,315,316,317,318,
                          319,320,321,322,323,218,219,324,88,89,109,110,325,326,27,28,327,227,328,329,
                          330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,
                          174,39,40,349,350,351,120,121,352,353,354,355,356,357,358,359,37,38,172,25,26,
                          54,55,360,202,177,178,203,231,232,127,214,111,112,361,362,363,364,365,366,367,
                          368,369,222,170,171,370,116,117,230,371,372,373,374,375,376,377,378,379,380,
                          381,382,383,384,385,386]
                          $regional_dex_1=hoenn_dex if REGIONAL_DEX=="Hoenn"
                          $regional_dex_2=hoenn_dex if REGIONAL_DEX2=="Hoenn"
                          end


                          # Gen 4 Dex.

                          # Gen 4 V2 Dex.
                          if REGIONAL_DEX=="Sinnoh" || REGIONAL_DEX2=="Sinnoh"
                          sinnoh2_dex=[387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,
                          403,404,405,63,64,65,129,130,406,315,407,41,42,169,74,75,76,95,208,408,409,410,
                          411,66,67,68,54,55,412,413,414,256,266,267,268,269,415,416,417,418,419,420,421,
                          422,423,214,190,424,425,426,427,428,92,93,94,200,429,198,430,431,432,118,119,
                          340,433,358,434,435,307,308,436,437,77,78,438,185,439,122,440,113,242,173,35,
                          36,441,172,25,26,163,164,442,443,444,445,446,143,201,447,448,194,195,278,279,
                          203,449,450,298,183,184,451,452,453,454,455,223,224,456,457,72,73,349,350,458,
                          226,459,460,215,461,480,481,482,483,484]
                          $regional_dex_1=sinnoh2_dex if REGIONAL_DEX=="Sinnoh"
                          $regional_dex_2=sinnoh2_dex if REGIONAL_DEX2=="Sinnoh"
                          end

                          # Gen 4 V2 Dex.
                          if REGIONAL_DEX=="Sinnoh2" || REGIONAL_DEX2=="Sinnoh2"
                          sinnoh2_dex=[387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,
                          403,404,405,63,64,65,129,130,406,315,407,41,42,169,74,75,76,95,208,408,409,410,
                          411,66,67,68,54,55,412,413,414,256,266,267,268,269,415,416,417,418,419,420,421,
                          422,423,214,190,424,425,426,427,428,92,93,94,200,429,198,430,431,432,118,119,
                          340,433,358,434,435,307,308,436,437,77,78,438,185,439,122,440,113,242,173,35,
                          36,441,172,25,26,163,164,442,443,444,445,446,143,201,447,448,194,195,278,279,
                          203,449,450,298,183,184,451,452,453,454,455,223,224,456,457,72,73,349,350,458,
                          226,459,460,215,461,480,481,482,483,484,490,479,207,472,299,476,280,281,282,
                          475,108,463,133,134,135,163,196,197,470,471,333,334,175,176,468,228,229,81,82,
                          462,114,465,193,469,357,111,112,464,355,356,477,137,233,474,123,212,239,125,
                          466,240,126,467,220,221,473,361,362,478,359,487]
                          $regional_dex_1=sinnoh2_dex if REGIONAL_DEX=="Sinnoh2"
                          $regional_dex_2=sinnoh2_dex if REGIONAL_DEX2=="Sinnoh2"
                          end

                          # Gen 5 Dex.
                          if REGIONAL_DEX=="Unova" || REGIONAL_DEX2=="Unova"
                          unova_dex=[]
                          for dex_num in 495..649
                          unova_dex.insert(unova_dex.length,dex_num)
                          end
                          $regional_dex_1=unova_dex if REGIONAL_DEX=="Unova"
                          $regional_dex_2=unova_dex if REGIONAL_DEX2=="Unova"
                          end

                          # Gen 5 V2 Dex.
                          if REGIONAL_DEX=="Unova2" || REGIONAL_DEX2=="Unova2"
                          unova2_dex=[495,496,497,498,499,500,501,502,503,504,505,509,
                          510,519,520,521,540,541,542,191,192,506,507,508,179,180,181,54,55,298,183,184,
                          447,448,206,531,511,512,513,514,515,516,543,544,545,109,110,81,82,462,58,59,
                          240,126,467,239,125,466,19,20,41,42,169,88,89,527,528,524,525,526,95,208,532,
                          533,534,529,530,300,301,427,428,546,547,548,549,517,518,173,35,36,133,134,135,
                          136,196,197,470,471,551,552,553,554,555,550,568,569,572,573,627,628,629,630,27,
                          28,557,558,559,560,556,561,328,329,330,562,563,564,565,566,567,599,600,601,406,
                          315,407,574,575,576,577,578,579,415,416,587,214,127,522,523,418,419,570,571,580,
                          581,588,589,616,617,585,586,590,591,351,299,476,304,305,306,343,344,636,637,595,
                          596,597,598,602,603,604,592,593,594,610,611,612,335,336,605,606,607,608,609,631,
                          632,613,614,615,641,642,645,451,452,227,322,323,325,326,425,426,353,354,278,279,
                          337,338,359,114,465,619,620,207,472,624,625,638,639,640,535,536,537,618,213,458,
                          226,223,224,222,120,121,320,321,131,363,364,365,333,334,37,38,436,437,215,461,
                          225,582,583,584,220,221,473,132,374,375,376,86,87,538,539,626,621,622,623,633,
                          634,635,287,288,289,341,342,174,39,40,108,463,193,469,357,455,453,454,246,247,
                          248,643,644,646,647,648,649]
                          $regional_dex_1=unova2_dex if REGIONAL_DEX=="Unova2"
                          $regional_dex_2=unova2_dex if REGIONAL_DEX2=="Unova2"
                          end

                          # Custom Dex.
                          if REGIONAL_DEX=="Custom" || REGIONAL_DEX2=="Custom"
                          $regional_dex_1=CUSTOM_DEX if REGIONAL_DEX=="Custom"
                          $regional_dex_2=CUSTOM_DEX if REGIONAL_DEX2=="Custom"
                          end

                          # Method which creates an array for the National Dex.
                          def pbNationalDex
                          national_dex=[]
                          for dex_num in 1..PBSpecies.maxValue
                          national_dex.insert(national_dex.length,dex_num)
                          end
                          return national_dex
                          end
                          #===============================================================================
                          # * Updating existing methods to work with the new way of Regional Dex'es.
                          #===============================================================================

                          class PokeBattle_Trainer

                          def pokedexSeen(region=-1) # Number of Pokémon seen
                          ret=0
                          if region==-1
                          for i in 0..PBSpecies.maxValue
                          ret+=1 if @seen[i]
                          end
                          else
                          if pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==0
                          regionlist=$regional_dex_1 # Region A
                          else
                          regionlist=$regional_dex_2 # Region B
                          end
                          regionlist=pbAllRegionalSpecies(region)
                          for i in regionlist
                          ret+=1 if @seen[i]
                          end
                          end
                          return ret
                          end

                          def pokedexOwned(region=-1) # Number of Pokémon owned
                          ret=0
                          if region==-1
                          for i in 0..PBSpecies.maxValue
                          ret+=1 if @owned[i]
                          end
                          else
                          if pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==0
                          regionlist=$regional_dex_1 # Region A
                          else
                          regionlist=$regional_dex_2 # Region B
                          end
                          for i in regionlist
                          ret+=1 if @owned[i]
                          end
                          return ret
                          end
                          end
                          end

                          def pbSetSpritePositionToMiddle(sprite)
                          sprite.x=Graphics.width/2-(sprite.bitmap.width/2)
                          sprite.y=Graphics.height/2-(sprite.bitmap.height/2)
                          end
                          #===============================================================================
                          # * Starting the Pokédex.
                          #===============================================================================
                          class StartPokedex

                          def initialize
                          if !$Trainer.pokedex
                          p "Pokédex isn't obtained yet. The game will return." if $DEBUG
                          return
                          end
                          @bg=Sprite.new
                          @bg.z=999999
                          if $Trainer.isFemale?
                          @bg.bitmap=Bitmap.new("Graphics/Pictures/Pokedex/StartPokedex/OpenDex_f")
                          else
                          @bg.bitmap=Bitmap.new("Graphics/Pictures/Pokedex/StartPokedex/OpenDex")
                          end
                          @load=Sprite.new
                          @load.bitmap=Bitmap.new("Graphics/Pictures/Pokedex/StartPokedex/load2")
                          @load.y= -384
                          @load.z=999999
                          @black_bitmap=Bitmap.new(512,384)
                          @black_sprite=Sprite.new
                          @[email protected]_bitmap
                          @black_sprite.z=999999
                          @black_sprite.opacity=0
                          @black_bitmap.fill_rect(0,0,512,384,Color.new(0,0,0))
                          update
                          end

                          def update(frame=0)
                          loop do
                          Graphics.update
                          Input.update
                          frame+=1
                          break if Input.trigger?(Input::B)
                          break if Input.trigger?(Input::C)
                          if defined?($mouse)
                          break if $mouse.inAreaLeft?(0,0,512,384)
                          end
                          break if frame>=120
                          end
                          startMainPokedex
                          end

                          def startMainPokedex
                          20.times do
                          @load.y+=384/20
                          Graphics.update
                          pbWait(1)
                          end
                          10.times do
                          @black_sprite.opacity+=255/10
                          @[email protected]/20
                          @[email protected]/20
                          @load.zoom_x+=0.1
                          @load.zoom_y+=0.1
                          Graphics.update
                          pbWait(1)
                          end
                          pbWait(25)
                          @bg.dispose
                          @load.dispose
                          @black_sprite.dispose
                          MainPokedex.new(0,0,-46,nil)
                          end
                          end
                          #===============================================================================
                          # * Main Pokédex Window.
                          #===============================================================================
                          class MainPokedex

                          def initialize(dex_index,panel_y,panel_sel_y,pokedex) # 0,0,-46
                          $pokedex=currentDex if panel_sel_y<0
                          $pokedex=pokedex if (pokedex != nil)# <--Only used because of search function.
                          @dex_index=dex_index
                          @index=0
                          @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
                          @viewport.z=99999
                          @sprites={}
                          @sprites["bg"]=Sprite.new(@viewport)
                          @sprites["bg"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/bg")
                          @main_bitmap=Bitmap.new(302,2+$pokedex.length*48)
                          @sprites["panels"]=Sprite.new(@viewport)
                          @sprites["panels"].x=192
                          @sprites["panels"].y=panel_y
                          @sprites["panel_sel"]=Sprite.new(@viewport)
                          @sprites["panel_sel"].y=panel_sel_y
                          drawDexPanels
                          drawPanels
                          @sprites["scroll_bar"]=IconSprite.new(502,18,@viewport)
                          @sprites["scroll_bar"].setBitmap("Graphics/Pictures/Pokedex/scroll_bar")
                          @sprites["slider"]=IconSprite.new(500,16,@viewport)
                          @sprites["slider"].setBitmap("Graphics/Pictures/Pokedex/slider")
                          @sprites["undiscovered"]=IconSprite.new(34,82,@viewport)
                          @sprites["undiscovered"].setBitmap("Graphics/Pictures/Pokedex/undiscovered")
                          @sprites["undiscovered"].visible=false
                          @sprites["pkmn_info"]=IconSprite.new(12,0,@viewport)
                          @sprites["pkmn_info"].setBitmap("Graphics/Pictures/Pokedex/pkmn_info")
                          @sprites["pkmn_info"].visible=false
                          @sprites["pkmn_info"].z+=1
                          @sprites["pkmn_sprite"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                          @sprites["pkmn_sprite"].x=96
                          @sprites["pkmn_sprite"].y=96
                          @sprites["down_bg"]=Sprite.new(@viewport)
                          @sprites["down_bg"].bitmap=Bitmap.new("Graphics/Pictures/Universal/down_bg")
                          @sprites["down_bg"].y=336
                          @sprites["select"]=IconSprite.new(10,340,@viewport)
                          @sprites["select"].setBitmap("Graphics/Pictures/Pokedex/select")
                          @sprites["start"]=IconSprite.new(142,340,@viewport)
                          @sprites["start"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/start")
                          @sprites["leftright"]=IconSprite.new(278,346,@viewport)
                          @sprites["leftright"].setBitmap("Graphics/Pictures/Pokedex/leftright")
                          @sprites["exit"]=IconSprite.new(426,346,@viewport)
                          @sprites["exit"].setBitmap("Graphics/Pictures/Universal/exit")
                          @sprites["return"]=IconSprite.new(474,346,@viewport)
                          @sprites["return"].setBitmap("Graphics/Pictures/Universal/return")
                          @sprites["leftright2"]=IconSprite.new(278,346,@viewport)
                          @sprites["leftright2"].setBitmap("Graphics/Pictures/Pokedex/leftright4")
                          updateLeftRight2Sprite
                          @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                          pbSetSystemFont(@sprites["overlay"].bitmap)
                          update
                          end

                          # Method which returns an array of the current dex.
                          def currentDex
                          if $PokemonGlobal.pokedexUnlocked[0] && pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==0
                          p "Your Regional Dex is empty. Please edit it in the Script-Editor." if REGIONAL_DEX.empty? && $DEBUG
                          return $regional_dex_1 if !REGIONAL_DEX.empty?
                          elsif $PokemonGlobal.pokedexUnlocked[1] && pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==1
                          p "Your Regional Dex is empty. Please edit it in the Script-Editor." if REGIONAL_DEX2.empty? && $DEBUG
                          return $regional_dex_2
                          elsif $PokemonGlobal.pokedexUnlocked[0] && !REGIONAL_DEX.empty?
                          return $regional_dex_1
                          elsif $PokemonGlobal.pokedexUnlocked[1] && !REGIONAL_DEX2.empty?
                          return $regional_dex_2
                          elsif $PokemonGlobal.pokedexUnlocked[-1]
                          return pbNationalDex
                          else
                          p "None of the Dex'es is unlocked yet." if $DEBUG
                          return nil
                          end
                          end

                          # Method for drawing the panels.
                          def drawPanels
                          @main_bitmap=Bitmap.new(302,2+$pokedex.length*48)
                          @main_bitmap.clear
                          @sprites["panels"][email protected]_bitmap
                          for i in 0..$pokedex.length-1
                          species=PokeBattle_Pokemon.new($pokedex[i],1)
                          # Drawing panels.
                          panel=Sprite.new
                          if $Trainer.seen[$pokedex[i]]
                          panel.bitmap=Bitmap.new("Graphics/Pictures/Pokedex/panel_pkmn")
                          @main_bitmap.blt(0,2+i*48,panel.bitmap,Rect.new(0,0,panel.bitmap.width,
                          panel.bitmap.height))
                          # Drawing little Pokémon icon.
                          icon=Sprite.new
                          icon.bitmap=Bitmap.new(sprintf("Graphics/Icons/icon%03d",$pokedex[i]))
                          # icon.src_rect.width=64
                          @main_bitmap.blt(2,i*48-18,icon.bitmap,Rect.new(0,0,
                          icon.bitmap.width/2,icon.bitmap.height))
                          icon.dispose
                          else
                          panel.bitmap=Bitmap.new("Graphics/Pictures/Pokedex/panel")
                          @main_bitmap.blt(64,2+i*48,panel.bitmap,Rect.new(0,0,panel.bitmap.width,
                          panel.bitmap.height))
                          end
                          panel.dispose
                          # Drawing little caught icon.
                          if $Trainer.owned[$pokedex[i]]
                          owned=Sprite.new(@viewport)
                          owned.bitmap=Bitmap.new("Graphics/Pictures/Pokedex/caught")
                          @main_bitmap.blt(82,10+i*48,owned.bitmap,Rect.new(0,0,owned.bitmap.width,
                          owned.bitmap.height))
                          owned.dispose
                          end
                          # Drawing text.
                          text=BitmapSprite.new(Graphics.width, Graphics.height)
                          pbSetSystemFont(text.bitmap)
                          dex_number=(i+1).to_s
                          if dex_number.length==1
                          dex_number.insert(0,"0")
                          end
                          if dex_number.length==2
                          dex_number.insert(0,"0")
                          end
                          textpos=[]
                          textpos.push([dex_number,0,0,0,Color.new(222,222,222),
                          Color.new(132,132,132)])
                          if $Trainer.seen[$pokedex[i]]
                          pkmn_name=species.name
                          else
                          pkmn_name="?????"
                          end
                          textpos.push([pkmn_name,56,0,0,Color.new(222,222,222),
                          Color.new(132,132,132)])
                          pbDrawTextPositions(text.bitmap,textpos)
                          @main_bitmap.blt(112,6+48*i,text.bitmap,Rect.new(0,0,190,32))
                          text.dispose
                          end
                          end

                          # Method for drawing the Dex Panels.
                          def drawDexPanels
                          num=0
                          num+=1 if $PokemonGlobal.pokedexUnlocked[0] # Regional Dex 1
                          num+=1 if $PokemonGlobal.pokedexUnlocked[1] # Regional Dex 2
                          num+=1 if $PokemonGlobal.pokedexUnlocked[-1]# National Dex
                          for i in 1..num
                          @sprites["dex_panel#{i}"]=IconSprite.new(0,290-46*i+46,@viewport)
                          @sprites["dex_panel#{i}"].setBitmap("Graphics/Pictures/Pokedex/leftpanel")
                          end
                          dexnames=pbDexNames
                          base=Color.new(255,255,255)
                          shadow=Color.new(165,165,173)
                          textos=[]
                          if num==3 && pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==0
                          @dexes=[2,1,0]
                          elsif num==3 && pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==1
                          @dexes=[2,0,1]
                          elsif num==3 && pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]>1
                          @dexes=[1,0,2]
                          elsif num==2
                          if pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==0 && $PokemonGlobal.pokedexUnlocked[0]
                          @dexes=[1,0] if $PokemonGlobal.pokedexUnlocked[1]
                          @dexes=[2,0] if $PokemonGlobal.pokedexUnlocked[-1]
                          elsif pbGetMetadata($game_map.map_id,MetadataMapPosition)[0]==1 && $PokemonGlobal.pokedexUnlocked[1]
                          @dexes=[0,1] if $PokemonGlobal.pokedexUnlocked[0]
                          @dexes=[2,1] if $PokemonGlobal.pokedexUnlocked[-1]
                          elsif $PokemonGlobal.pokedexUnlocked[0]
                          textos.push([_INTL("{1}", dexnames[0]),4,252,false,base,shadow])
                          @dexes=[1,0] if $PokemonGlobal.pokedexUnlocked[1]
                          @dexes=[2,0] if $PokemonGlobal.pokedexUnlocked[-1]
                          elsif $PokemonGlobal.pokedexUnlocked[1]
                          @dexes=[0,1] if $PokemonGlobal.pokedexUnlocked[0]
                          @dexes=[2,1] if $PokemonGlobal.pokedexUnlocked[-1]
                          end
                          elsif num==1
                          @dexes=[0] if $PokemonGlobal.pokedexUnlocked[0]
                          @dexes=[1] if $PokemonGlobal.pokedexUnlocked[1]
                          @dexes=[2] if $PokemonGlobal.pokedexUnlocked[-1]
                          end
                          textos.push([_INTL("{1}", dexnames[@dexes[0]]),4,298,false,base,shadow])
                          if num>=2
                          textos.push([_INTL("{1}", dexnames[@dexes[1]]),4,252,false,base,shadow])
                          end
                          if num==3
                          textos.push([_INTL("{1}", dexnames[@dexes[2]]),4,206,false,base,shadow])
                          end
                          normal_dexes=[$regional_dex_1,$regional_dex_2,pbNationalDex]
                          y=5000
                          y=290 if num==3 && $pokedex==normal_dexes[@dexes[0]]
                          y=244 if num==3 && $pokedex==normal_dexes[@dexes[1]]
                          y=198 if num==3 && $pokedex==normal_dexes[@dexes[2]]
                          y=290 if num==2 && $pokedex==normal_dexes[@dexes[0]]
                          y=244 if num==2 && $pokedex==normal_dexes[@dexes[1]]
                          y=290 if num==1
                          @sprites["dex_panel_sel"]=IconSprite.new(0,y,@viewport)
                          @sprites["dex_panel_sel"].setBitmap("Graphics/Pictures/Pokedex/leftpanel2")
                          @sprites["dexnames"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                          pbSetSystemFont(@sprites["dexnames"].bitmap)
                          pbDrawTextPositions(@sprites["dexnames"].bitmap,textos)
                          end

                          # Method for checking and updating if a species is in the dex and the
                          # dex has changed.
                          def updateDexIndexIfDexHasChanged(species)
                          return if @dex_index<1
                          #if @dex_index<1
                          # @sprites["panels"].y=0
                          # @sprites["panel_sel"].y= -46
                          # return
                          #end
                          for i in 0...$pokedex.length
                          if $pokedex[i]==species
                          @dex_index=i+1
                          if @dex_index<8
                          @sprites["panels"].y=0
                          @sprites["panel_sel"][email protected]_index*48-46
                          elsif @dex_index>$pokedex.length-8
                          @sprites["panels"].y= -48*($pokedex.length-7)
                          @sprites["panel_sel"].y=290-([email protected]_index)*48
                          else
                          @sprites["panels"].y= -48*(@dex_index-1)
                          @sprites["panel_sel"].y=2
                          end
                          return
                          end
                          end
                          @sprites["panels"].y=0
                          @sprites["panel_sel"].y=2
                          @dex_index=1
                          end

                          # Updates the leftright2 sprite.
                          def updateLeftRight2Sprite
                          @sprites["leftright2"].x=278
                          if @dex_index<8 && (@dex_index>($pokedex.length-7))
                          @sprites["leftright2"].src_rect.x=0
                          @sprites["leftright2"].src_rect.width=96
                          elsif @dex_index<8
                          @sprites["leftright2"].src_rect.x=0
                          @sprites["leftright2"].src_rect.width=48
                          elsif (@dex_index>($pokedex.length-7))
                          @sprites["leftright2"].src_rect.x=48
                          @sprites["leftright2"].src_rect.width=48
                          @sprites["leftright2"].x=278+50
                          else
                          @sprites["leftright2"].src_rect.x=0
                          @sprites["leftright2"].src_rect.width=0
                          end

                          end

                          # Method which checks whether you can scroll down or not.
                          def canScrollDown
                          return (@dex_index>7 && @sprites["panel_sel"].y==290 && ((@sprites["panels"][email protected]["panels"].y)>338))
                          end

                          # Method which checks whether you can scroll up or not.
                          def canScrollUp
                          return (@dex_index>0 && @sprites["panel_sel"].y==2 )
                          end

                          # This method updates the position of the slider.
                          def updateSliderPosition
                          pos=16
                          pos+=300*@dex_index/$pokedex.length
                          @sprites["slider"].y=pos
                          end

                          # Method returning the number of the current selected Pokémon.
                          def currentPokemon
                          return ($pokedex[@dex_index-1])
                          end

                          # Method for updating the background.
                          def updateBackground
                          return if [email protected]["bg"]
                          @sprites["bg"].x-=2
                          @sprites["bg"].x=0 if @sprites["bg"].x <= -512
                          end

                          # Method which is basically pbWait(x) but with a background update added.
                          def waitAndUpdate(x)
                          x.times do
                          updateBackground
                          pbWait(1)
                          end
                          end

                          # Method for scrolling 7 Pokémon up.
                          def scrollToLeft
                          return if @dex_index<8
                          @sprites["leftright"].setBitmap("Graphics/Pictures/Pokedex/leftright2")
                          7.times do
                          @dex_index-=1
                          if @sprites["panel_sel"].y>10
                          @sprites["panel_sel"].y-=48
                          else
                          @sprites["panels"].y+=48
                          end
                          updatePokemonSprite
                          updateSliderPosition
                          waitAndUpdate(1)
                          end
                          waitAndUpdate(3)
                          @sprites["leftright"].setBitmap("Graphics/Pictures/Pokedex/leftright")
                          end

                          # Method for scrolling 7 Pokémon down.
                          def scrollToRight
                          return if (@dex_index>($pokedex.length-7))
                          @sprites["leftright"].setBitmap("Graphics/Pictures/Pokedex/leftright3")
                          7.times do
                          @dex_index+=1
                          if @sprites["panel_sel"].y<280
                          @sprites["panel_sel"].y+=48
                          else
                          @sprites["panels"].y-=48
                          end
                          updatePokemonSprite
                          updateSliderPosition
                          waitAndUpdate(1)
                          end
                          waitAndUpdate(3)
                          @sprites["leftright"].setBitmap("Graphics/Pictures/Pokedex/leftright")
                          end

                          # updates the Pokemon Sprite when called.
                          def updatePokemonSprite
                          @sprites["pkmn_sprite"].bitmap.clear
                          if $Trainer.seen[currentPokemon]
                          @sprites["panel_sel"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/panel_sel_pkmn")
                          @sprites["panel_sel"].x=192
                          if USING_BITMAP_WRAPPER==true && defined?(AnimatedBitmapWrapper)
                          pkmnbitmap=AnimatedBitmapWrapper.new(pbPokemonBitmapFile(currentPokemon,false))
                          else
                          pkmnbitmap=AnimatedBitmap.new(pbPokemonBitmapFile(currentPokemon,false))
                          end
                          @sprites["pkmn_sprite"].bitmap.blt(0,0,
                          pkmnbitmap.bitmap,Rect.new(0,0,pkmnbitmap.bitmap.width,pkmnbitmap.bitmap.height))
                          @sprites["pkmn_sprite"].ox=pkmnbitmap.bitmap.width/2
                          @sprites["pkmn_sprite"].oy=pkmnbitmap.bitmap.height/2
                          @sprites["pkmn_info"].visible=true
                          @sprites["undiscovered"].visible=false
                          else
                          @sprites["panel_sel"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/panel_sel")
                          @sprites["panel_sel"].x=256
                          @pokemon_sprite.visible=false if @pokemon_sprite
                          @sprites["pkmn_info"].visible=false
                          @sprites["undiscovered"].visible=true
                          end
                          end

                          # Function for using the mouse for the scrolling bar.
                          def mouseScrollBar
                          if $mouse.inAreaPress?(494,10,18,315)#16, 300
                          if $mouse.y>316
                          @sprites["slider"].y=316
                          elsif $mouse.y<16
                          @sprites["slider"].y=16
                          else
                          @sprites["slider"].y=$mouse.y
                          end
                          @dex_index=(@sprites["slider"].y-16)*$pokedex.length/300
                          @dex_index=1 if @dex_index<1
                          if @sprites["slider"].y>16
                          @sprites["panels"].y= -48*($pokedex.length-7)
                          @sprites["panels"].y= -48*(@dex_index-1) if @dex_index<($pokedex.length-5)
                          @sprites["panels"].y=0 if ($pokedex.length<7)
                          @sprites["panel_sel"].y=48*(@dex_index-1)[email protected]["panels"].y+2
                          else
                          @sprites["panels"].y=0
                          end
                          end
                          end

                          # Method for updating the Dex Panels.
                          def mouseDexPanels
                          update=false
                          current= -1
                          if @nextDex
                          current=(@sprites["dex_panel_sel"].y-198)/48
                          max=0
                          for i in 0...3
                          max+=1 if @sprites["dex_panel#{i}"]
                          end
                          if max==current
                          current=4-max
                          else
                          current+=1
                          end
                          end
                          if $mouse.leftClick?(@sprites["dex_panel1"]) || current==1
                          return if @sprites["dex_panel_sel"][email protected]["dex_panel1"].y
                          pkmn=currentPokemon
                          if @dexes[0]==0
                          $pokedex=$regional_dex_1
                          elsif @dexes[0]==1
                          $pokedex=$regional_dex_2
                          else
                          $pokedex=pbNationalDex
                          end
                          @sprites["dex_panel_sel"][email protected]["dex_panel1"].y
                          update=true
                          end
                          if @sprites["dex_panel2"]
                          if $mouse.leftClick?(@sprites["dex_panel2"]) || current==2
                          return if @sprites["dex_panel_sel"][email protected]["dex_panel2"].y
                          pkmn=currentPokemon
                          if @dexes[1]==0
                          $pokedex=$regional_dex_1
                          elsif @dexes[1]==1
                          $pokedex=$regional_dex_2
                          else
                          $pokedex=pbNationalDex
                          end
                          @sprites["dex_panel_sel"][email protected]["dex_panel2"].y
                          update=true
                          end
                          end
                          if @sprites["dex_panel3"]
                          if $mouse.leftClick?(@sprites["dex_panel3"]) || current==3
                          return if @sprites["dex_panel_sel"][email protected]["dex_panel3"].y
                          pkmn=currentPokemon
                          if @dexes[2]==0
                          $pokedex=$regional_dex_1
                          elsif @dexes[2]==1
                          $pokedex=$regional_dex_2
                          else
                          $pokedex=pbNationalDex
                          end
                          @sprites["dex_panel_sel"][email protected]["dex_panel3"].y
                          update=true
                          end
                          end
                          return if !update
                          @black=Sprite.new(@viewport)
                          @black.z=9999999
                          black_bitmap=Bitmap.new(512,384)
                          black_bitmap.fill_rect(0,0,512,384,Color.new(0,0,0))
                          @black.bitmap=black_bitmap
                          @black.opacity=0
                          $pokedex2=$pokedex
                          10.times do
                          @black.opacity+=255/10
                          waitAndUpdate(1)
                          end
                          @sprites["dex_panel_sel"].visible=false
                          updateDexIndexIfDexHasChanged(pkmn)
                          drawPanels
                          updateSliderPosition
                          updatePokemonSprite if @dex_index>0
                          @sprites["dex_panel_sel"].visible=true
                          10.times do
                          @black.opacity-=255/10
                          waitAndUpdate(1)
                          end
                          @black.dispose
                          @nextDex=false
                          end

                          # If a Panel was being pressed this will return the current clicked Pokémon.
                          def mousePanelInput
                          return if !$mouse.leftPressed?(@sprites["panels"])
                          # when clicking on a panel and no panel is selected yet.
                          if @sprites["panel_sel"].y<0
                          for i in 0..6
                          if $mouse.inArea?(192,i*48+2,302,42) && Input.releaseex?(Input::Mouse_Left)
                          @sprites["panel_sel"].y+=48*(i+1)
                          @dex_index+=i+1
                          @sprites["panel_sel"].x=192
                          @sprites["panel_sel"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/panel_sel_pkmn")
                          updatePokemonSprite
                          waitAndUpdate(5)
                          @sprites["panel_sel"].visible=false
                          waitAndUpdate(5)
                          @sprites["panel_sel"].visible=true
                          @scene=2 if $Trainer.seen[currentPokemon]
                          return
                          end
                          end
                          end
                          # when clicking on the selected panel.
                          if $mouse.leftPressed?(@sprites["panel_sel"])
                          updatePokemonSprite
                          @sprites["panel_sel"].visible=true
                          waitAndUpdate(5)
                          @sprites["panel_sel"].visible=false
                          waitAndUpdate(5)
                          @sprites["panel_sel"].visible=true
                          @scene=2 if $Trainer.seen[currentPokemon]
                          return
                          end
                          # when clicking on a panel which is not the selected panel.
                          subtract=(@sprites["panel_sel"].y-2)/48
                          for i in 0..6
                          if $mouse.inArea?(192,i*48+2,302,42) && $mouse.leftPressed?(@sprites["panels"])
                          addition=i
                          end
                          end
                          return if !addition
                          species=currentPokemon+addition-subtract
                          @dex_index+=addition-subtract
                          graphic_change=(addition-subtract)*48
                          @sprites["panel_sel"].y+=graphic_change
                          @sprites["panel_sel"].visible=true
                          updatePokemonSprite
                          waitAndUpdate(5)
                          @sprites["panel_sel"].visible=false
                          waitAndUpdate(5)
                          @sprites["panel_sel"].visible=true
                          @scene=2 if $Trainer.seen[currentPokemon]
                          end

                          # Method for ending the scene.
                          def pbEndScene
                          pbFadeOutAndHide(@sprites)
                          pbDisposeSpriteHash(@sprites)
                          @viewport.dispose
                          end

                          def update(current_dex_index=0,current_index=0)
                          @scene= -1 # 0=exit , 1=Search Function , 2=Pokémon information
                          @nextDex=false
                          while @scene<0
                          Graphics.update
                          Input.update
                          # Animating background.
                          updateBackground
                          # Inputs
                          if Input.trigger?(Input::DOWN) && @index==0
                          if @dex_index<$pokedex.length
                          @dex_index+=1
                          if @sprites["panel_sel"].y<290
                          @sprites["panel_sel"].y+=48
                          else
                          @sprites["panels"].y-=48 if canScrollDown
                          end
                          end
                          end
                          if Input.trigger?(Input::UP) && @index==0
                          if @dex_index>1
                          @dex_index-=1
                          if @sprites["panel_sel"].y>2
                          @sprites["panel_sel"].y-=48
                          else
                          @sprites["panels"].y+=48 if canScrollUp
                          end
                          end
                          end
                          if Input.trigger?(Input::C)
                          case @index
                          when 0
                          @scene=2
                          end
                          end

                          if Input.trigger?(Input::B)
                          pbShowAnimation("exit")
                          @scene=0
                          end
                          if defined?($mouse)
                          mousePanelInput
                          mouseScrollBar
                          mouseDexPanels
                          if $mouse.inAreaLeft?(278,346,34,28)
                          scrollToLeft
                          end
                          if $mouse.inAreaLeft?(328,346,34,28)
                          scrollToRight
                          end
                          if $mouse.leftClick?(@sprites["exit"])
                          pbShowAnimation("exit")
                          @scene=0
                          end
                          if $mouse.leftClick?(@sprites["return"])
                          @sprites["return"].setBitmap("Graphics/Pictures/Universal/return2")
                          pbWait(10)
                          @sprites["return"].setBitmap("Graphics/Pictures/Universal/return")
                          pbWait(5)
                          @scene=0
                          $MenuClose=true
                          end
                          if $mouse.leftClick?(@sprites["start"])
                          @sprites["start"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/start2")
                          waitAndUpdate(10)
                          @sprites["start"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/start")
                          waitAndUpdate(5)
                          @scene=1
                          end
                          if $mouse.leftClick?(@sprites["select"])
                          @sprites["select"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/select2")
                          waitAndUpdate(10)
                          @sprites["select"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/select")
                          waitAndUpdate(5)
                          @nextDex=true
                          mouseDexPanels
                          end
                          end
                          # updating if index has changed.
                          if @index != current_index
                          if [email protected]["cursor_1"]
                          drawBW2Cursor(469,339,23,25) if @index==1
                          end
                          [email protected]
                          end
                          # updating if dex index has changed.
                          if @dex_index != current_dex_index
                          updatePokemonSprite
                          updateSliderPosition
                          [email protected]_index
                          updateLeftRight2Sprite
                          end


                          end
                          [email protected]["panels"].y if @scene==2
                          [email protected]["panel_sel"].y if @scene==2
                          pbEndScene
                          PokedexSearch.new if @scene==1
                          if a && b && @dex_index && currentPokemon
                          PokedexPages.new(@dex_index,a,b) if $Trainer.seen[currentPokemon] && @scene==2
                          end

                          end

                          end


                          #===============================================================================
                          # * Four Pokédex Pages
                          #===============================================================================
                          class PokedexPages
                          def initialize(dex_index,panel_y,panel_sel_y)
                          @dex_index=dex_index
                          @old_dex_index=dex_index
                          @species=$pokedex[@dex_index-1]
                          @panel_y=panel_y
                          @panel_sel_y=panel_sel_y
                          @pokemon=PokeBattle_Pokemon.new(@species,1)
                          @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
                          @viewport.z=99999
                          @sprites={}
                          @sprites["bg"]=Sprite.new(@viewport)
                          @sprites["bg"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/bg1")
                          @sprites["down_bg"]=IconSprite.new(0,336,@viewport)
                          @sprites["down_bg"].bitmap=Bitmap.new("Graphics/Pictures/Universal/down_bg")
                          @sprites["updown"]=IconSprite.new(10,342,@viewport)
                          @sprites["updown"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/updown")
                          @sprites["info"]=IconSprite.new(96,340,@viewport)
                          @sprites["info"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/info")
                          @sprites["area"]=IconSprite.new(160,340,@viewport)
                          @sprites["area"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/area")
                          @sprites["forms"]=IconSprite.new(224,340,@viewport)
                          @sprites["forms"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/forms")
                          @sprites["exit"]=IconSprite.new(426,346,@viewport)
                          @sprites["exit"].bitmap=Bitmap.new("Graphics/Pictures/Universal/exit")
                          @sprites["return"]=IconSprite.new(474,346,@viewport)
                          @sprites["return"].bitmap=Bitmap.new("Graphics/Pictures/Universal/return")
                          @page=1
                          @sel=0
                          update
                          end

                          # Method for updating the background.
                          def updateBackground
                          return if [email protected]["bg"]
                          @sprites["bg"].x-=2
                          @sprites["bg"].x=0 if @sprites["bg"].x <= -512
                          end

                          # Method which is basically pbWait(x) but with a background update added.
                          def waitAndUpdate(x)
                          x.times do
                          updateBackground
                          pbWait(1)
                          end
                          end

                          # Method for disposing all necessary sprites if the page changes.
                          def disposeSprites
                          # Page 1 Sprites
                          @sprites["overlay"].dispose if @sprites["overlay"]
                          @sprites["page1"].dispose if @sprites["page1"]
                          @sprites["owned"].dispose if @sprites["owned"]
                          @sprites["pokemon"].dispose if @sprites["pokemon"]
                          @sprites["dexentry"].dispose if @sprites["dexentry"]
                          # Page 2 Sprites
                          @sprites["map"].dispose if @sprites["map"]
                          @sprites["map2"].dispose if @sprites["map2"]
                          @sprites["mapbottom"].dispose if @sprites["mapbottom"]
                          # Page 3 Sprites
                          @sprites["formname_bg"].dispose if @sprites["formname_bg"]
                          @sprites["front"].dispose if @sprites["front"]
                          @sprites["back"].dispose if @sprites["back"]
                          @sprites["select"].dispose if @sprites["select"]
                          @sprites["start"].dispose if @sprites["start"]
                          @sprites["text"].dispose if @sprites["text"]
                          @sprites["leftarrow"].dispose if @sprites["leftarrow"]
                          @sprites["rightarrow"].dispose if @sprites["rightarrow"]
                          end

                          # Method which checks whether you can scroll down or not.
                          def canScrollDown
                          return (@dex_index != ($pokedex.length))
                          end

                          # Method which checks whether you can scroll up or not.
                          def canScrollUp
                          return (@dex_index != 1)
                          end

                          # Method for pressing exit.
                          def pressedExit
                          @sprites["exit"].bitmap=Bitmap.new("Graphics/Pictures/Universal/exit2")
                          waitAndUpdate(10)
                          @sprites["exit"].bitmap=Bitmap.new("Graphics/Pictures/Universal/exit")
                          waitAndUpdate(5)
                          end

                          # Method for ending the scene.
                          def pbEndScene
                          pbFadeOutAndHide(@sprites)
                          pbDisposeSpriteHash(@sprites)
                          @viewport.dispose
                          end


                          # Method for getting the next seen Pokémon in the dex. Will return 0
                          # if there if there is no next seen Pokémon.
                          def searchNextSeenPokemon(dir)
                          if dir==2 # DOWN
                          for i in @dex_index...$pokedex.length
                          return (i+1) if $Trainer.seen[$pokedex[i]]
                          end
                          return 0
                          elsif dir==8 # UP
                          [email protected]_index-2
                          while !$Trainer.seen[$pokedex[i]]
                          i-=1
                          return 0 if i==0
                          end
                          return (i+1)
                          end
                          end

                          def changePokemon(dir)
                          new_index=searchNextSeenPokemon(dir)
                          if dir==2 # DOWN
                          return if !canScrollDown
                          if new_index != @dex_index && new_index != 0 && new_index
                          @dex_index=new_index
                          else
                          return
                          end
                          @sprites["updown"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/updown3")
                          elsif dir==8 # UP
                          return if !canScrollUp
                          if new_index != @dex_index && new_index != 0 && new_index
                          @dex_index=new_index
                          else
                          return
                          end
                          @sprites["updown"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/updown2")
                          end
                          waitAndUpdate(10)
                          @sprites["updown"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/updown")
                          waitAndUpdate(5)
                          disposeSprites
                          @species=$pokedex[@dex_index-1]
                          @pokemon=PokeBattle_Pokemon.new(@species,1)
                          drawPageOne if @page==1
                          drawPageTwo if @page==2
                          @backSprite=nil if @page==3
                          @frontSprite=nil if @page==3
                          drawPageThree if @page==3
                          end

                          # Method for updating Page 2.
                          def updatePage2
                          @numpoints.times {|i|
                          @sprites["point#{i}"].opacity=[64,96,128,160,128,96][(Graphics.frame_count/4)%6] if @sprites["point#{i}"]
                          }
                          end

                          def update
                          @animSprite=false # For Page 3 whether the Pokémon sprite is animated or not.
                          page=0
                          @spriteIsFrontSprite=true
                          loop do
                          Graphics.update
                          Input.update
                          updateBackground
                          updatePage2 if @page==2
                          updatePage3 if @page==3
                          if [email protected]
                          break
                          end
                          # Inputs
                          if Input.trigger?(Input::DOWN)
                          if @sel==0
                          changePokemon(2)
                          end
                          end
                          if Input.trigger?(Input::UP)
                          if @sel==0
                          changePokemon(8)
                          end
                          end
                          if Input.trigger?(Input::RIGHT)
                          @page+=1 if @page<3
                          end
                          if Input.trigger?(Input::LEFT)
                          @page-=1 if @page>1
                          end
                          if Input.trigger?(Input::B)
                          pressedExit
                          break
                          end
                          if defined?($mouse)
                          if $mouse.inAreaLeft?(10,342,28,34) # up arrow
                          changePokemon(8)
                          end
                          if $mouse.inAreaLeft?(58,344,28,34) # down arrow
                          changePokemon(2)
                          end
                          if $mouse.leftClick?(@sprites["exit"])
                          pressedExit
                          break
                          end
                          if $mouse.leftClick?(@sprites["info"])
                          @page=1
                          end
                          if $mouse.leftClick?(@sprites["area"])
                          @page=2
                          end
                          if $mouse.leftClick?(@sprites["forms"])
                          @page=3
                          end
                          if @page==3
                          if @sprites["leftarrow"]
                          if [email protected]["leftarrow"].disposed?
                          if $mouse.leftClick?(@sprites["leftarrow"])
                          switchFormToLeft
                          end
                          end
                          end

                          if @sprites["rightarrow"]
                          if [email protected]["rightarrow"].disposed?
                          if $mouse.leftClick?(@sprites["rightarrow"])
                          switchFormToRight
                          end
                          end
                          end
                          if @sprites["select"]
                          if [email protected]["select"].disposed?
                          if $mouse.leftClick?(@sprites["select"])
                          @sprites["select"].setBitmap("Graphics/Pictures/Pokedex/Pages/turn_sprite2")
                          waitAndUpdate(10)
                          @sprites["front"][email protected]["back"].visible
                          @[email protected]["front"].visible
                          @sprites["back"].visible=(@sprites["front"].visible)? false : true
                          @sprites["select"].setBitmap("Graphics/Pictures/Pokedex/Pages/turn_sprite")
                          waitAndUpdate(5)
                          end
                          end
                          end

                          if @sprites["start"]
                          if [email protected]["start"].disposed?
                          if $mouse.leftClick?(@sprites["start"])
                          @sprites["start"].setBitmap("Graphics/Pictures/Pokedex/Pages/start_sprite2")
                          waitAndUpdate(10)
                          if @animSprite
                          @animSprite=false
                          else
                          @animSprite=true
                          end
                          @sprites["start"].setBitmap("Graphics/Pictures/Pokedex/Pages/start_sprite")
                          end
                          end
                          end
                          end
                          end
                          # If the page changes.
                          if @page != page
                          @sprites["info"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/info") if page==1
                          @sprites["area"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/area") if page==2
                          @sprites["forms"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/forms") if page==3
                          @sprites["info"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/info2") if @page==1
                          @sprites["area"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/area2") if @page==2
                          @sprites["forms"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/forms2") if @page==3
                          disposeSprites
                          drawPageOne if @page==1
                          drawPageTwo if @page==2
                          drawPageThree if @page==3
                          [email protected]
                          end
                          end
                          pbEndScene
                          if @dex_index<8
                          @panel_y=0
                          @[email protected]_index*48-46
                          elsif @dex_index>$pokedex.length-8
                          @panel_y= -48*($pokedex.length-7)
                          @panel_sel_y=290-([email protected]_index)*48
                          else
                          @panel_y= -48*(@dex_index-1)
                          @panel_sel_y=2
                          end
                          MainPokedex.new(@dex_index,@panel_y,@panel_sel_y,$pokedex)
                          end
                          #===============================================================================
                          # * Pokédex INFO
                          #===============================================================================
                          def drawPageOne
                          @sprites["bg"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/bg1")
                          @sprites["page1"]=Sprite.new(@viewport)
                          @sprites["page1"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/page1")
                          @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                          @sprites["dexentry"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                          pbSetSystemFont(@sprites["overlay"].bitmap)
                          pbSetSystemFont(@sprites["dexentry"].bitmap)
                          baseColor=Color.new(90,82,82)
                          baseColor2=Color.new(255,255,255)
                          shadowColor=Color.new(165,165,173)
                          textpos=[
                          [sprintf(_INTL("HT")),288,152,0,baseColor,shadowColor],
                          [sprintf(_INTL("WT")),288,184,0,baseColor,shadowColor]
                          ]
                          [email protected]_index.to_s
                          if dex_num.length==1
                          dex_num.insert(0,"0")
                          end
                          if dex_num.length==2
                          dex_num.insert(0,"0")
                          end
                          textpos.push([_INTL("#{dex_num}"),272,26,0,baseColor,shadowColor])
                          textpos.push([_INTL("#{@pokemon.name}"),352,26,0,baseColor,shadowColor])
                          if $Trainer.owned[@species]
                          @sprites["owned"]=IconSprite.new(204,16,@viewport)
                          @sprites["owned"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/owned")
                          dexdata=pbOpenDexData
                          pbDexDataOffset(dexdata,@species,8)
                          type1=dexdata.fgetb
                          type2=dexdata.fgetb
                          pbDexDataOffset(dexdata,@species,33)
                          height=dexdata.fgetw
                          weight=dexdata.fgetw
                          dexdata.close
                          kind=pbGetMessage(MessageTypes::Kinds,@species)
                          dexentry=pbGetMessage(MessageTypes::Entries,@species)
                          inches=(height/0.254).round
                          pounds=(weight/0.45359).round
                          textpos.push([_ISPRINTF("{1:s} Pokémon",kind),376,60,2,baseColor,shadowColor])
                          if pbGetCountry()==0xF4 # If the user is in the United States
                          textpos.push([_ISPRINTF("{1:d}'{2:02d}"",inches/12,inches%12),490,152,1,baseColor,shadowColor])
                          textpos.push([_ISPRINTF("{1:4.1f} lbs.",pounds/10.0),490,184,1,baseColor,shadowColor])
                          else
                          textpos.push([_ISPRINTF("{1:.1f} m",height/10.0),490,152,1,baseColor,shadowColor])
                          textpos.push([_ISPRINTF("{1:.1f} kg",weight/10.0),490,184,1,baseColor,shadowColor])
                          end
                          drawTextEx(@sprites["dexentry"].bitmap,
                          36,234,Graphics.width-36,3,dexentry,baseColor2,shadowColor)
                          footprintfile=pbPokemonFootprintFile(@species)
                          if footprintfile
                          footprint=BitmapCache.load_bitmap(footprintfile)
                          @sprites["overlay"].bitmap.blt(225,116,footprint,footprint.rect)
                          footprint.dispose
                          end
                          typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
                          type1rect=Rect.new(0,type1*24,64,24)
                          type2rect=Rect.new(0,type2*24,64,24)
                          @sprites["overlay"].bitmap.blt(304,108,typebitmap.bitmap,type1rect)
                          @sprites["overlay"].bitmap.blt(384,108,typebitmap.bitmap,type2rect) if type1!=type2
                          typebitmap.dispose
                          else
                          # if $Trainer.seen[@species]
                          # typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
                          # type1rect=Rect.new(0,type1*24,64,24)
                          # type2rect=Rect.new(0,type2*24,64,24)
                          # @sprites["overlay"].bitmap.blt(304,108,typebitmap.bitmap,type1rect)
                          # @sprites["overlay"].bitmap.blt(384,108,typebitmap.bitmap,type2rect) if type1!=type2
                          # typebitmap.dispose
                          # end

                          textpos.push([_INTL("????? Pokémon"),376,60,2,baseColor,shadowColor])
                          if pbGetCountry()==0xF4 # If the user is in the United States
                          textpos.push([_INTL("???'??""),490,152,1,baseColor,shadowColor])
                          textpos.push([_INTL("????.? lbs."),490,184,1,baseColor,shadowColor])
                          else
                          textpos.push([_INTL("????.? m"),490,152,1,baseColor,shadowColor])
                          textpos.push([_INTL("????.? kg"),490,184,1,baseColor,shadowColor])
                          end
                          end
                          pbDrawTextPositions(@sprites["overlay"].bitmap,textpos)
                          if USING_BITMAP_WRAPPER && defined?(AnimatedBitmapWrapper)
                          pkmnbitmap=AnimatedBitmapWrapper.new(pbPokemonBitmapFile(@species,false))
                          else
                          pkmnbitmap=AnimatedBitmap.new(pbPokemonBitmapFile(@species,false))
                          end
                          @sprites["pokemon"]=BitmapSprite.new(pkmnbitmap.bitmap.width,
                          pkmnbitmap.bitmap.height,@viewport)
                          @sprites["pokemon"].bitmap.blt(0,0,
                          pkmnbitmap.bitmap,pkmnbitmap.bitmap.rect)
                          @sprites["pokemon"].mirror=true
                          @sprites["pokemon"].ox=pkmnbitmap.width/2
                          @sprites["pokemon"].oy=pkmnbitmap.height/2
                          @sprites["pokemon"].x=96
                          @sprites["pokemon"].y=96
                          pkmnbitmap.dispose
                          pbPlayCry(@species)
                          end
                          #===============================================================================
                          # * Pokédex AREA
                          #===============================================================================
                          def drawPageTwo
                          regionmap= -1
                          pbRgssOpen("Data/townmap.dat","rb"){|f|
                          @mapdata=Marshal.load(f)
                          }
                          mappos=!$game_map ? nil : pbGetMetadata($game_map.map_id,MetadataMapPosition)
                          region=regionmap
                          if region<0 # Use player's current region
                          region=mappos ? mappos[0] : 0 # Region 0 default
                          end
                          @sprites["map"]=IconSprite.new(0,0,@viewport)
                          @sprites["map"].setBitmap("Graphics/Pictures/#{@mapdata[region][1]}")
                          @sprites["map"].x+=([email protected]["map"].bitmap.width)/2
                          for hidden in REGIONMAPEXTRAS
                          if hidden[0]==region && hidden[1]>0 && $game_switches[hidden[1]]
                          if [email protected]["map2"]
                          @sprites["map2"]=BitmapSprite.new(480,320,@viewport)
                          @sprites["map2"][email protected]["map"].x; @sprites["map2"][email protected]["map"].y
                          end
                          pbDrawImagePositions(@sprites["map2"].bitmap,[
                          ["Graphics/Pictures/#{hidden[4]}",
                          hidden[2]*PokemonRegionMapScene::SQUAREWIDTH,
                          hidden[3]*PokemonRegionMapScene::SQUAREHEIGHT,0,0,-1,-1]
                          ])
                          end
                          end
                          @point=BitmapWrapper.new(PokemonRegionMapScene::SQUAREWIDTH+4,
                          PokemonRegionMapScene::SQUAREHEIGHT+4)
                          @point.fill_rect(0,0,
                          PokemonRegionMapScene::SQUAREWIDTH+4,
                          PokemonRegionMapScene::SQUAREHEIGHT+4,Color.new(255,0,0))
                          @point2=BitmapWrapper.new(PokemonRegionMapScene::SQUAREWIDTH+4,
                          PokemonRegionMapScene::SQUAREHEIGHT+4)
                          @point2.fill_rect(4,0,
                          PokemonRegionMapScene::SQUAREWIDTH,
                          PokemonRegionMapScene::SQUAREHEIGHT+4,Color.new(255,0,0))
                          @point3=BitmapWrapper.new(PokemonRegionMapScene::SQUAREWIDTH+4,
                          PokemonRegionMapScene::SQUAREHEIGHT+4)
                          @point3.fill_rect(0,4,
                          PokemonRegionMapScene::SQUAREWIDTH+4,
                          PokemonRegionMapScene::SQUAREHEIGHT,Color.new(255,0,0))
                          @point4=BitmapWrapper.new(PokemonRegionMapScene::SQUAREWIDTH+4,
                          PokemonRegionMapScene::SQUAREHEIGHT+4)
                          @point4.fill_rect(4,4,
                          PokemonRegionMapScene::SQUAREWIDTH,
                          PokemonRegionMapScene::SQUAREHEIGHT,Color.new(255,0,0))
                          encdata=load_data("Data/encounters.dat")
                          points=[]
                          mapwidth=1+PokemonRegionMapScene::RIGHT-PokemonRegionMapScene::LEFT
                          for enc in encdata.keys
                          enctypes=encdata[enc][1]
                          if pbFindEncounter(enctypes,@species)
                          mappos=pbGetMetadata(enc,MetadataMapPosition)
                          if mappos && mappos[0]==region
                          showpoint=true
                          for loc in @mapdata[region][2]
                          showpoint=false if loc[0]==mappos[1] && loc[1]==mappos[2] &&
                          loc[7] && !$game_switches[loc[7]]
                          end
                          if showpoint
                          mapsize=pbGetMetadata(enc,MetadataMapSize)
                          if mapsize && mapsize[0] && mapsize[0]>0
                          sqwidth=mapsize[0]
                          sqheight=(mapsize[1].length*1.0/mapsize[0]).ceil
                          for i in 0...sqwidth
                          for j in 0...sqheight
                          if mapsize[1][i+j*sqwidth,1].to_i>0
                          points[mappos[1]+i+(mappos[2]+j)*mapwidth]=true
                          end
                          end
                          end
                          else
                          points[mappos[1]+mappos[2]*mapwidth]=true
                          end
                          end
                          end
                          end
                          end
                          i=0
                          for j in 0...points.length
                          if points[j]
                          s=SpriteWrapper.new(@viewport)
                          s.x=(j%mapwidth)*PokemonRegionMapScene::SQUAREWIDTH-2
                          s.x+=([email protected]["map"].bitmap.width)/2
                          s.y=(j/mapwidth)*PokemonRegionMapScene::SQUAREHEIGHT-2
                          s.y+=([email protected]["map"].bitmap.height)/2
                          if j>=1 && points[j-1]
                          if j>=mapwidth && points[j-mapwidth]
                          [email protected]
                          else
                          [email protected]
                          end
                          else
                          if j>=mapwidth && points[j-mapwidth]
                          [email protected]
                          else
                          [email protected]
                          end
                          end
                          @sprites["point#{i}"]=s
                          i+=1
                          end
                          end
                          @numpoints=i
                          return true
                          end
                          #===============================================================================
                          # * Pokédex FORMS
                          #===============================================================================
                          def drawPageThree
                          [email protected]
                          @gender=$Trainer.formlastseen[species][0]
                          @form=$Trainer.formlastseen[species][1]
                          @available=pbGetAvailable # [name, gender, form]
                          @sprites["bg"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Pages/bg3")
                          @sprites["formname_bg"]=IconSprite.new(130,6,@viewport)
                          @sprites["formname_bg"].setBitmap("Graphics/Pictures/Pokedex/Pages/formname")
                          @sprites["text"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                          @sprites["front"]=PokemonSprite.new(@viewport)
                          @sprites["back"]=PokemonSprite.new(@viewport)
                          if @spriteIsFrontSprite
                          @sprites["back"].visible=false
                          else
                          @sprites["front"].visible=false
                          end
                          @sprites["icon"]=PokemonSpeciesIconSprite.new(@species,@viewport)
                          @sprites["icon"][email protected]
                          @sprites["icon"][email protected]
                          @sprites["icon"].x=52
                          @sprites["icon"].y=290
                          @sprites["icon"].visible=false
                          @sprites["select"]=IconSprite.new(130,306,@viewport)
                          @sprites["select"].setBitmap("Graphics/Pictures/Pokedex/Pages/turn_sprite")
                          @sprites["start"]=IconSprite.new(258,306,@viewport)
                          @sprites["start"].setBitmap("Graphics/Pictures/Pokedex/Pages/start_sprite")

                          @sprites["leftarrow"]=IconSprite.new(8,0,@viewport)
                          @sprites["leftarrow"].setBitmap("Graphics/Pictures/Pokedex/Pages/arrow_left")

                          @sprites["rightarrow"]=IconSprite.new(484,0,@viewport)
                          @sprites["rightarrow"].setBitmap("Graphics/Pictures/Pokedex/Pages/arrow_right")
                          @frontSprite=nil; @backSprite=nil; @formNeedsRefresh=false
                          end

                          # Updating Page 3. Will be called every frame.
                          def updatePage3
                          @sprites["text"].bitmap.clear
                          pbSetSystemFont(@sprites["text"].bitmap)
                          name=""
                          for i in @available
                          if i[1][email protected] && i[2][email protected]
                          name=i[0]
                          break
                          end
                          end
                          text=[
                          [_INTL("{1}",name),
                          256,44,2,
                          Color.new(255,255,255),Color.new(165,165,173)],
                          ]
                          pbDrawTextPositions(@sprites["text"].bitmap,text)
                          frontBitmap=pbCheckPokemonBitmapFiles([@species,false,(@gender==1),false,@form,false])
                          if (frontBitmap && [email protected]) || @formNeedsRefresh
                          frontSprite=AnimatedBitmap.new(frontBitmap)
                          if USING_BITMAP_WRAPPER && defined?(AnimatedBitmapWrapper)
                          frontSprite=AnimatedBitmapWrapper.new(frontBitmap)
                          else
                          frontSprite=AnimatedBitmap.new(frontBitmap)
                          end
                          @sprites["front"].bitmap=frontSprite.bitmap
                          end
                          backBitmap=pbCheckPokemonBitmapFiles([@species,true,(@gender==1),false,@form,false])
                          if (backBitmap && [email protected]) || @formNeedsRefresh
                          if USING_BITMAP_WRAPPER && defined?(AnimatedBitmapWrapper)
                          backSprite=AnimatedBitmapWrapper.new(backBitmap)
                          else
                          backSprite=AnimatedBitmap.new(backBitmap)
                          end

                          @sprites["back"].bitmap=backSprite.bitmap
                          end
                          metrics=load_data("Data/metrics.dat")
                          backMetric=metrics[0][@species]
                          pbSetSpritePositionToMiddle(@sprites["front"])
                          pbSetSpritePositionToMiddle(@sprites["back"])
                          @sprites["icon"].update
                          if Input.trigger?(Input::C)
                          pbChooseForm
                          end
                          if ([email protected] || [email protected]) || @formNeedsRefresh
                          @frontSprite=frontSprite
                          @backSprite=backSprite
                          @formNeedsRefresh=false
                          end
                          animateSprite
                          end

                          # Checking for available forms.
                          def pbGetAvailable
                          available=[] # [name, gender, form]
                          dexdata=pbOpenDexData
                          pbDexDataOffset(dexdata,@species,18)
                          genderbyte=dexdata.fgetb
                          dexdata.close
                          formnames=pbGetMessage(MessageTypes::FormNames,@species)
                          if !formnames || formnames==""
                          formnames=[""]
                          else
                          formnames=strsplit(formnames,/,/)
                          end
                          @gender=0 if genderbyte==0 || genderbyte==255 # Always male or genderless
                          @gender=1 if genderbyte==254 # Always female
                          if formnames && formnames[0]!=""
                          for j in 0...2
                          if $Trainer.formseen[@species][j][0] || ALWAYSSHOWALLFORMS # That gender/form has been seen
                          if pbResolveBitmap(sprintf("Graphics/Battlers/%sf",getConstantName(PBSpecies,@species))) ||
                          pbResolveBitmap(sprintf("Graphics/Battlers/%03df",@species))
                          available.push([_INTL("{1} Male",formnames[0]),j,0]) if j==0
                          available.push([_INTL("{1} Female",formnames[0]),j,0]) if j==1
                          else
                          gendertopush=(genderbyte==254) ? 1 : 0
                          available.push([formnames[0],gendertopush,0])
                          break
                          end
                          end
                          end
                          else
                          if $Trainer.formseen[@species][0][0] || ALWAYSSHOWALLFORMS # Male/form 0 has been seen
                          if genderbyte!=254 && genderbyte!=255 # Not always female & not genderless
                          available.push([_INTL("Male"),0,0])
                          end
                          end
                          if $Trainer.formseen[@species][1][0] || ALWAYSSHOWALLFORMS # Female/form 0 has been seen
                          if genderbyte!=0 && genderbyte!=255 # Not always male & not genderless
                          available.push([_INTL("Female"),1,0])
                          end
                          end
                          if $Trainer.formseen[@species][0][0] || ALWAYSSHOWALLFORMS # Genderless/form 0 has been seen
                          if genderbyte==255 # Genderless
                          if formnames && formnames.length>1
                          available.push([_INTL("One Form"),0,0])
                          else
                          available.push([_INTL("Genderless"),0,0])
                          end
                          end
                          end
                          end
                          for i in 1...formnames.length
                          for j in 0...2
                          if $Trainer.formseen[@species][j][i] || ALWAYSSHOWALLFORMS # That gender/form has been seen
                          if pbResolveBitmap(sprintf("Graphics/Battlers/%sf_%d",getConstantName(PBSpecies,@species),i)) ||
                          pbResolveBitmap(sprintf("Graphics/Battlers/%03df_%d",@species,i))
                          available.push([_INTL("{1} Male",formnames[i]),j,i]) if j==0
                          available.push([_INTL("{1} Female",formnames[i]),j,i]) if j==1
                          else
                          available.push([formnames[i],j,i])
                          break
                          end
                          end
                          end
                          end
                          return available
                          end

                          # Checking for commands.
                          def pbGetCommands
                          commands=[]
                          for i in @available
                          commands.push(i[0])
                          end
                          return commands
                          end

                          # Animates the Sprite. Thanks Luka for his BitmapWrapper class.
                          def animateSprite
                          if !defined?(AnimatedBitmapWrapper)
                          p "Animation can only be played when using AnimatedBitmapWrapper." if $DEBUG
                          return
                          end
                          if @animSprite
                          if @frontSprite.finished?
                          @frontSprite.toFrame(0)
                          @backSprite.toFrame(0)
                          end
                          @frontSprite.play
                          @backSprite.play
                          @sprites["front"][email protected]
                          @sprites["back"][email protected]
                          end
                          end

                          # Switches the form to the left.
                          def switchFormToLeft
                          @sprites["leftarrow"].setBitmap("Graphics/Pictures/Pokedex/Pages/arrow_left2")
                          [email protected]["front"].x
                          10.times do
                          @sprites["front"].x-=([email protected]["front"].bitmap.width/2)/10
                          @sprites["back"][email protected]["front"].x
                          updateBackground
                          animateSprite
                          pbWait(1)
                          end
                          @sprites["leftarrow"].setBitmap("Graphics/Pictures/Pokedex/Pages/arrow_left")
                          minForm=0
                          for i in [email protected]
                          if @[email protected][i][1] && @[email protected][i][2]
                          currentForm=i
                          break
                          end
                          end
                          if currentForm==minForm
                          [email protected]
                          else
                          nextForm=currentForm-1
                          end
                          @[email protected]["icon"][email protected][nextForm][1]
                          @[email protected]["icon"][email protected][nextForm][2]
                          @formNeedsRefresh=true
                          updatePage3
                          @sprites["front"].x=512+(@sprites["front"].bitmap.width/2)
                          [email protected]["front"].x/2
                          10.times do
                          @sprites["front"].x-=([email protected]["front"].bitmap.width/2)/10
                          @sprites["back"][email protected]["front"].x
                          updateBackground
                          animateSprite
                          pbWait(1)
                          end
                          end

                          # Switches the form to the right.
                          def switchFormToRight
                          @sprites["rightarrow"].setBitmap("Graphics/Pictures/Pokedex/Pages/arrow_right2")
                          [email protected]["front"].x
                          10.times do
                          @sprites["front"].x+=([email protected]["front"].bitmap.width/2)/10
                          @sprites["back"][email protected]["front"].x
                          updateBackground
                          animateSprite
                          pbWait(1)
                          end
                          @sprites["rightarrow"].setBitmap("Graphics/Pictures/Pokedex/Pages/arrow_right")
                          [email protected]
                          for i in [email protected]
                          if @[email protected][i][1] && @[email protected][i][2]
                          currentForm=i
                          break
                          end
                          end
                          if currentForm==maxForm
                          nextForm=0
                          else
                          nextForm=currentForm+1
                          end
                          @[email protected]["icon"][email protected][nextForm][1]
                          @[email protected]["icon"][email protected][nextForm][2]
                          @formNeedsRefresh=true
                          updatePage3
                          @sprites["front"].x=0-(@sprites["front"].bitmap.width/2)
                          x=256-(@sprites["front"].bitmap.width/2)
                          10.times do
                          @sprites["front"].x+=([email protected]["front"].bitmap.width/2)/10
                          @sprites["back"][email protected]["front"].x
                          updateBackground
                          animateSprite
                          pbWait(1)
                          end
                          end

                          # Choosing the form manually by pressing enter.
                          def pbChooseForm
                          [email protected]
                          [email protected]
                          commands=pbGetCommands
                          using(cmdwindow=Window_CommandPokemon.new(commands)) {
                          cmdwindow.height=128 if cmdwindow.height>128
                          [email protected]+1
                          pbBottomRight(cmdwindow)
                          for i in [email protected]
                          if @available[i][1][email protected] && @available[i][2][email protected]
                          cmdwindow.index=i
                          break
                          end
                          end
                          loop do
                          updateBackground
                          oldindex=cmdwindow.index
                          Graphics.update
                          Input.update
                          cmdwindow.update
                          @sprites["icon"].update
                          if cmdwindow.index!=oldindex
                          @[email protected]["icon"][email protected][cmdwindow.index][1]
                          @[email protected]["icon"][email protected][cmdwindow.index][2]
                          @formNeedsRefresh=true
                          updatePage3
                          end
                          if Input.release?(Input::B)
                          pbPlayCancelSE()
                          @[email protected]["icon"].gender=oldgender
                          @[email protected]["icon"].form=oldform
                          break
                          end
                          if Input.trigger?(Input::C)
                          pbPlayDecisionSE()
                          break
                          end
                          end
                          }
                          end
                          end
                          #===============================================================================
                          # Pokédex Search
                          #===============================================================================
                          class PokedexSearch
                          def initialize
                          @options=["ORDER","NAME","TYPE","COLOR"]
                          @order=["NUMBER","A to Z","Heavy to Light","Light to Heavy",
                          "Tall to Short","Short to Tall"]
                          @name=["--","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P",
                          "Q","R","S","T","U","V","W","X","Y","Z"]
                          @type=["-","Normal","Fighting","Flying","Poison","Ground","Rock","Bug",
                          "Ghost","Steel","Fire","Water","Grass","Electric","Psychic",
                          "Ice","Dragon","Dark"]
                          @color=["-","Red","Blue","Yellow","Green","Black","Brown","Purple","Gray",
                          "White","Pink"]
                          @stuff=[@order,@name,@type,@color]
                          @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
                          @viewport.z=99999
                          @sprites={}
                          @sprites["bg"]=Sprite.new(@viewport)
                          @sprites["bg"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/bg")
                          for i in [email protected]
                          @sprites["index_panel#{i+1}"]=IconSprite.new(8,4+50*i,@viewport)
                          @sprites["index_panel#{i+1}"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/index_panel")
                          end
                          drawPanels
                          @sprites["check0"]=IconSprite.new(262,0,@viewport)
                          @sprites["check0"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/checked")
                          @sprites["check0"].visible=false
                          @sprites["check1"]=IconSprite.new(262,0,@viewport)
                          @sprites["check1"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/checked")
                          @sprites["check1"].visible=false
                          @sprites["down_bg"]=Sprite.new(@viewport)
                          @sprites["down_bg"].bitmap=Bitmap.new("Graphics/Pictures/Universal/down_bg")
                          @sprites["down_bg"][email protected]["down_bg"].bitmap.height
                          @sprites["functions"]=IconSprite.new(0,288,@viewport)
                          @sprites["functions"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/functions")
                          @sprites["exit"]=IconSprite.new(426,346,@viewport)
                          @sprites["exit"].setBitmap("Graphics/Pictures/Universal/exit")
                          @sprites["return"]=IconSprite.new(474,346,@viewport)
                          @sprites["return"].setBitmap("Graphics/Pictures/Universal/return")
                          @sprites["index_panel_sel"]=IconSprite.new(262,-5000,@viewport)
                          @sprites["index_panel_sel"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/index_panel_sel")
                          @sprites["panel_sel"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/panel_sel")
                          @sprites["panel_sel"].visible=false
                          @sprites["sort"]=IconSprite.new(8,124,@viewport)
                          @sprites["overlay"]=BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
                          @sprites["overlay2"]=BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
                          @sprites["scroll_bar"]=IconSprite.new(502,18,@viewport)
                          @sprites["scroll_bar"].setBitmap("Graphics/Pictures/Pokedex/scroll_bar")
                          @sprites["scroll_bar"].visible=false
                          @sprites["slider"]=IconSprite.new(500,16,@viewport)
                          @sprites["slider"].setBitmap("Graphics/Pictures/Pokedex/slider")
                          @sprites["slider"].visible=false
                          update
                          end

                          # Method for updating the background.
                          def updateBackground
                          return if [email protected]["bg"]
                          @sprites["bg"].x-=2
                          @sprites["bg"].x=0 if @sprites["bg"].x <= -512
                          end

                          # Method which is basically pbWait(x) but with a background update added.
                          def waitAndUpdate(frames)
                          frames.times do
                          updateBackground
                          pbWait(1)
                          end
                          end

                          # Method for ending the scene.
                          def pbEndScene
                          pbFadeOutAndHide(@sprites)
                          pbDisposeSpriteHash(@sprites)
                          @viewport.dispose
                          end

                          # Method for updating the Index panel.
                          def updateIndexPanel
                          @sprites["index_panel_sel"].y= 2+50*(@index-1)
                          end

                          # Method for the action which happens when pressing exit.
                          def exitPressed
                          @sprites["exit"].setBitmap("Graphics/Pictures/Universal/exit2")
                          waitAndUpdate(10)
                          @sprites["exit"].setBitmap("Graphics/Pictures/Universal/exit")
                          waitAndUpdate(5)
                          end

                          # Method for drawing the second page.
                          def drawPageTwo
                          @index2=0
                          @sprites["scroll_bar"].visible=true
                          @sprites["slider"].visible=true
                          @sprites["panel_sel"].y=2
                          @sprites["panel_sel"].visible=true
                          @sprites["panel_#{@index}"].visible=true
                          @sprites["overlay_#{@index}"].visible=true
                          @sprites["overlay2"].visible=true
                          @sprites["functions"].visible=false
                          @sprites["exit"].visible=false
                          @sprites["overlay"].visible=false
                          @sprites["check0"].visible=true if $searchSettings[@index][0]>(-1)
                          if ($searchSettings[2][1]>(-1)) && @index==2
                          @sprites["check1"].visible=true
                          end
                          updateCheckSprite
                          updateSliderPosition
                          index2Text
                          for i in [email protected]
                          @sprites["index_panel#{i+1}"].visible=false
                          end
                          @sprites["sort"].visible=true
                          @sprites["sort"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/sort")
                          @sprites["sort"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/sort2") if @index==2
                          end

                          # Method for drawing the first page.
                          def drawPageOne
                          @sprites["scroll_bar"].visible=false
                          @sprites["slider"].visible=false
                          @sprites["panel_sel"].visible=false
                          @sprites["panel_#{@index}"].visible=false
                          @sprites["overlay_#{@index}"].visible=false
                          @sprites["sort"].visible=false
                          @sprites["panel_#{@index}"].y=2
                          @sprites["panel_#{@index}"].visible=false
                          @sprites["overlay_#{@index}"][email protected]["panel_#{@index}"].y
                          @sprites["overlay_#{@index}"].visible=false
                          @sprites["overlay2"].visible=false
                          @sprites["check0"].visible=false
                          @sprites["check1"].visible=false
                          @sprites["functions"].visible=true
                          @sprites["exit"].visible=true
                          @sprites["overlay"].visible=true
                          @sprites["index_panel_sel"].visible=true
                          indexText
                          for i in [email protected]
                          @sprites["index_panel#{i+1}"].visible=true
                          end
                          @index+=1
                          end

                          # Method for drawing panels.
                          def drawPanels
                          @count=0 if [email protected]
                          @count+=1
                          panel=Sprite.new
                          panel.bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/panel")
                          baseColor = Color.new(255,255,255)
                          shadowColor = Color.new(165,165,173)
                          for i in [email protected]
                          @sprites["panel_#{i}"]=Sprite.new(@viewport)
                          @sprites["panel_#{i}"].bitmap=Bitmap.new(240,48*@stuff[i].length-1)
                          @sprites["panel_#{i}"].x=258
                          @sprites["panel_#{i}"].y=2
                          @sprites["panel_#{i}"].visible=false
                          end
                          @sprites["panel_sel"]=IconSprite.new(256,2,@viewport)
                          for i in [email protected]
                          @sprites["overlay_#{i}"]=BitmapSprite.new(240,48*@stuff[i].length-1,@viewport)
                          @sprites["overlay_#{i}"].visible=false
                          @sprites["overlay_#{i}"].x=258
                          @sprites["overlay_#{i}"].y=2
                          pbSetSystemFont(@sprites["overlay_#{i}"].bitmap)
                          textpos=[]
                          for u in [email protected][i].length
                          if u != @stuff[i].length
                          textpos.push([_INTL("#{@stuff[i][u+1]}"),120,8+48*u,2,baseColor,shadowColor])
                          end
                          @sprites["panel_#{i}"].bitmap.blt(0,u*48,panel.bitmap,Rect.new(
                          0,0,panel.bitmap.width,panel.bitmap.height))
                          end
                          pbDrawTextPositions(@sprites["overlay_#{i}"].bitmap,textpos)
                          end
                          panel.dispose
                          @sprites["panel_0"].src_rect.height-=48
                          end

                          # Method for drawing the text of the index Page.
                          def indexText
                          @sprites["overlay"].bitmap.clear
                          baseColor = Color.new(255,255,255)
                          shadowColor = Color.new(165,165,173)
                          pbSetSystemFont(@sprites["overlay"].bitmap)
                          textpos=[]
                          for i in [email protected]
                          textpos.push([_INTL("#{@options[i]}"),98,8+50*i,false,baseColor,shadowColor])
                          textpos.push([_INTL("#{@stuff[i][0]}"),385,8+50*i,2,baseColor,shadowColor]) if !$searchSettings
                          end
                          if $searchSettings
                          for i in [email protected]
                          if i ==2
                          if $searchSettings[2][0]>(-1) && $searchSettings[2][1]>(-1) # Two types are selected.
                          v=$searchSettings[2][0]+1; v2=$searchSettings[2][1]+1
                          txt="#{@stuff[2][v]}/#{@stuff[2][v2]}"
                          elsif $searchSettings[2][0]>(-1)
                          v=$searchSettings[2][0]+1
                          txt="#{@stuff[2][v]}"
                          elsif $searchSettings[2][1]>(-1)
                          v=$searchSettings[2][1]+1
                          txt="#{@stuff[2][v]}"
                          else
                          txt="#{@stuff[2][0]}"
                          end
                          elsif $searchSettings[i]>(-1)
                          v=$searchSettings[i]+1
                          txt="#{@stuff[i][v]}"
                          else
                          txt="#{@stuff[i][0]}"
                          end
                          textpos.push([_INTL("#{txt}"),385,8+50*i,2,baseColor,shadowColor])
                          end
                          end
                          pbDrawTextPositions(@sprites["overlay"].bitmap,textpos)
                          end

                          # Method for drawing the text of the second Page (does not include
                          # the text on the panels).
                          def index2Text
                          @sprites["overlay2"].bitmap.clear
                          baseColor = Color.new(255,255,255)
                          shadowColor = Color.new(165,165,173)
                          pbSetSystemFont(@sprites["overlay2"].bitmap)
                          textpos=[]
                          textpos.push([_INTL("#{@options[@index]}"),128,128,2,baseColor,shadowColor])
                          if @index==2
                          if $searchSettings[2][0]>(-1) && $searchSettings[2][1]>(-1) # Two types are selected.
                          v=$searchSettings[2][0]+1; v2=$searchSettings[2][1]+1
                          txt="#{@stuff[2][v]}"
                          txt2="#{@stuff[2][v2]}"
                          elsif $searchSettings[2][0]>(-1)
                          v=$searchSettings[2][0]+1
                          txt="#{@stuff[2][v]}"
                          txt2="#{@stuff[2][0]}"
                          elsif $searchSettings[2][1]>(-1)
                          v=$searchSettings[2][1]+1
                          txt2="#{@stuff[2][v]}"
                          txt="#{@stuff[2][0]}"
                          else
                          txt="#{@stuff[2][0]}"
                          txt2="#{@stuff[2][0]}"
                          end
                          elsif $searchSettings[@index]>(-1)
                          v=$searchSettings[@index]+1
                          txt="#{@stuff[@index][v]}"
                          else
                          txt="#{@stuff[@index][0]}"
                          end
                          textpos.push([_INTL("#{txt}"),128,176,2,baseColor,shadowColor])
                          if txt2
                          textpos.push([_INTL("#{txt2}"),128,224,2,baseColor,shadowColor])
                          end
                          pbDrawTextPositions(@sprites["overlay2"].bitmap,textpos)
                          end


                          # Method for scrolling down.
                          def scrollDownPanel
                          return if currentIndex<7
                          return if @sprites["panel_sel"].y<290
                          if ((maxIndex)>=currentIndex)
                          @sprites["panel_#{@index}"].y-=48
                          @sprites["overlay_#{@index}"].y-=48
                          end
                          updateSliderPosition
                          end

                          # Method for scrolling up.
                          def scrollUpPanel
                          @sprites["panel_#{@index}"].y+=48
                          @sprites["overlay_#{@index}"].y+=48
                          end

                          # Method which checks if you can scroll down.
                          def canScrollDown
                          return (@[email protected])>0
                          end

                          # Method which checks if you can scroll up.
                          def canScrollUp
                          return (@index2>0)
                          end

                          # Method which will return the current Index.
                          def currentIndex
                          return @index2
                          end

                          # Method which will current the maximum reachable Index.
                          def maxIndex
                          return (@stuff[@index].length-2)
                          end

                          # This method updates the position of the slider.
                          def updateSliderPosition
                          pos=16
                          pos+=300*currentIndex/maxIndex
                          @sprites["slider"].y=pos
                          end

                          # This method updates the little checked sprite in the second page
                          # when a panel was selected.
                          def updateCheckSprite
                          if @index==2
                          if $searchSettings[2][0]>(-1)
                          [email protected]["panel_#{@index}"].y+$searchSettings[2][0]*48
                          @sprites["check0"].y=y
                          @sprites["check0"].visible=true
                          else
                          @sprites["check0"].visible=false
                          end
                          if $searchSettings[2][1]>(-1)
                          [email protected]["panel_#{@index}"].y+$searchSettings[2][1]*48
                          @sprites["check1"].y=y
                          @sprites["check1"].visible=true
                          else
                          @sprites["check1"].visible=false
                          end
                          elsif $searchSettings[@index]>(-1)
                          [email protected]["panel_#{@index}"].y+$searchSettings[@index]*48
                          @sprites["check0"].y=y
                          @sprites["check0"].visible=true
                          else
                          @sprites["check0"].visible=false
                          end
                          end

                          # Will return true if it's the first side. the method is using the visibility
                          # of the object @sprites["exit"] to check.
                          def firstPage
                          return (@sprites["exit"].visible==true)
                          end

                          # Will return true if it's the second side. the method is using the visibility
                          # of the object @sprites["exit"] to check.
                          def secondPage
                          return (@sprites["exit"].visible==false)
                          end

                          # Function which will return the index.
                          def mousePanelClick
                          for i in 0..6
                          if $mouse.inAreaLeft?(256,2+i*48,240,44)
                          val=i
                          end
                          end
                          return if !val
                          val-= (@sprites["panel_#{@index}"].y-2)/48
                          return val
                          end

                          # Function for saving the setting when clicking on on a panel with the mouse.
                          def mousePanelClickUpdate
                          val=mousePanelClick
                          if val
                          # Lines which are handling the Types since you can select two types.
                          if @index==2
                          if $searchSettings[2][0]==val
                          $searchSettings[2][0]= -1
                          elsif $searchSettings[2][1]==val
                          $searchSettings[2][1]= -1
                          elsif $searchSettings[2][0]== -1
                          $searchSettings[2][0]=val
                          elsif $searchSettings[2][0]>(-1)
                          $searchSettings[2][1]=val
                          end
                          # Lines which are handling everything except the Types.
                          elsif $searchSettings[@index]==val
                          $searchSettings[@index]= -1
                          else
                          $searchSettings[@index]=val
                          end
                          end
                          updateCheckSprite
                          index2Text
                          end

                          # Function for using the mouse for the scrolling bar.
                          def mouseScrollBar
                          return if @sprites["exit"].visible
                          return if !$mouse.inAreaPress?(494,10,18,315)
                          # Updating slider.
                          if $mouse.y>316
                          @sprites["slider"].y=316
                          elsif $mouse.y<16
                          @sprites["slider"].y=16
                          else
                          @sprites["slider"].y=$mouse.y
                          end
                          # Updating index.
                          @index2= (@sprites["slider"].y-16)*maxIndex/300
                          @index2=0 if @index2<0
                          # Updating panel position.
                          [email protected]["panel_#{@index}"].y
                          @sprites["panel_#{@index}"].y= -48*(currentIndex-6)+2 if @sprites["panel_sel"].y>=290
                          @sprites["panel_#{@index}"].y= -48*currentIndex+2 if @sprites["panel_sel"].y<=2
                          if y_pos<@sprites["panel_#{@index}"].y && @sprites["panel_sel"].y>10
                          @sprites["panel_#{@index}"].y=y_pos
                          end
                          # Updating overlay.
                          @sprites["overlay_#{@index}"][email protected]["panel_#{@index}"].y
                          # Updating selected panel.
                          @sprites["panel_sel"].y=2+48*[email protected]["panel_#{@index}"].y
                          end

                          # Update Method
                          def update
                          index= -1 ; index2=0
                          @index=0 ; @index2=0;
                          @searchStarted=false; returnpressed=false
                          if !$searchSettings
                          $searchSettings=[]
                          @options.length.times do
                          $searchSettings.push(-1)
                          end
                          $searchSettings[2]=[-1,-1] # 2 Types can be choosen.
                          end
                          loop do
                          Graphics.update
                          Input.update
                          updateBackground
                          updateIndexPanel
                          if @newDex
                          if @newDex.empty?
                          @sprites["search"].dispose
                          @newDex=nil
                          else
                          break
                          end
                          end
                          if Input.trigger?(Input::B)
                          if firstPage
                          exitPressed
                          break
                          elsif secondPage
                          @sprites["return"].bitmap=Bitmap.new("Graphics/Pictures/Universal/return2")
                          waitAndUpdate(10)
                          @sprites["return"].bitmap=Bitmap.new("Graphics/Pictures/Universal/return")
                          waitAndUpdate(5)
                          drawPageOne
                          end
                          end
                          # Scrolling down.
                          if Input.trigger?(Input::DOWN) && @index<@options.length
                          if secondPage
                          if currentIndex<maxIndex
                          @index2+=1
                          scrollDownPanel if @sprites["panel_sel"].y>=290
                          @sprites["panel_sel"].y+=48 if @sprites["panel_sel"].y<290
                          updateSliderPosition
                          end
                          else
                          @index+=1
                          end
                          end
                          # Scrolling up.
                          if Input.trigger?(Input::UP) && @index>0
                          if secondPage
                          if currentIndex>0
                          @index2-=1
                          scrollUpPanel if @sprites["panel_sel"].y<10
                          @sprites["panel_sel"].y-=48 if @sprites["panel_sel"].y>5
                          updateSliderPosition
                          end
                          else
                          @index-=1
                          end
                          end
                          if Input.trigger?(Input::C)
                          if firstPage
                          waitAndUpdate(10)
                          @sprites["index_panel_sel"].visible=false
                          waitAndUpdate(5)
                          drawPageTwo
                          elsif secondPage
                          if ($searchSettings[3][0]>(-1)) && @index==2
                          $searchSettings[3][1][email protected]
                          else
                          $searchSettings[@index][email protected]
                          end
                          updateCheckSprite
                          index2Text
                          end
                          end
                          if defined?($mouse)
                          for i in [email protected]
                          if firstPage && $mouse.inAreaLeft?(262,4+50*i,
                          @sprites["index_panel#{i+1}"].bitmap.width,
                          @sprites["index_panel#{i+1}"].bitmap.height)
                          @index=i
                          @sprites["index_panel_sel"].y=2+50*i
                          waitAndUpdate(10)
                          @sprites["index_panel_sel"].visible=false
                          waitAndUpdate(5)
                          drawPageTwo
                          end
                          end
                          if firstPage && $mouse.leftClick?(@sprites["exit"])
                          exitPressed
                          break
                          end
                          if firstPage && $mouse.inAreaLeft?(4,299,98,36)
                          pbReset
                          end
                          if firstPage && $mouse.inAreaLeft?(226,294,286,46)
                          pbStartSearch
                          end
                          if secondPage && $mouse.leftClick?(@sprites["panel_#{@index}"])
                          mousePanelClickUpdate
                          end
                          if $mouse.leftPressed?(@sprites["return"])
                          @sprites["return"].bitmap=Bitmap.new("Graphics/Pictures/Universal/return2")
                          waitAndUpdate(10)
                          @sprites["return"].bitmap=Bitmap.new("Graphics/Pictures/Universal/return")
                          waitAndUpdate(5)
                          returnpressed=true if firstPage
                          break if firstPage
                          drawPageOne if secondPage
                          end
                          mouseScrollBar
                          end
                          # Index Index changes.
                          if @index != index
                          indexText
                          [email protected]
                          end
                          # if panel index changes.
                          if @index2 != index2
                          updateCheckSprite
                          [email protected]
                          end
                          end
                          pbEndScene
                          if @newDex
                          MainPokedex.new(0,0,-46,@newDex)
                          elsif !returnpressed
                          MainPokedex.new(0,0,-46,nil)
                          end
                          end

                          # Will return the pokedex without species which the trainer didn't see.
                          def convertDex(dex)
                          ret=[]
                          for i in 0...dex.length
                          ret.push(dex[i]) if $Trainer.seen[dex[i]]
                          end
                          return ret
                          end

                          # Method will return the number of total search criteria (created for the
                          # search bar).
                          def totalCriteria
                          ret=0
                          ret+=1 if $searchSettings[0]>(-1)
                          ret+=1 if $searchSettings[1]>(-1)
                          ret+=1 if $searchSettings[2][0]>(-1) || $searchSettings[2][1]>(-1)
                          ret+=1 if $searchSettings[3]>(-1)
                          return ret
                          end

                          # Method which will reset all the settings.
                          def pbReset
                          @sprites["reset2"]=IconSprite.new(4,300,@viewport)
                          @sprites["reset2"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/reset2")
                          waitAndUpdate(10)
                          @sprites["reset2"].dispose
                          $searchSettings=[]
                          @options.length.times do
                          $searchSettings.push(-1)
                          end
                          $searchSettings[2]=[-1,-1] # Creating a 2nd option for the Type.
                          indexText
                          end

                          # This method is basically the core of the class. It will sort out every
                          # Pokémon which has the choosen settings.
                          def pbStartSearch
                          @sprites["start2"]=IconSprite.new(226,294,@viewport)
                          @sprites["start2"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/start2")
                          waitAndUpdate(10)
                          @sprites["start2"].dispose
                          waitAndUpdate(5)
                          @sprites["search"]=Sprite.new(@viewport)
                          @sprites["search"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/pkmn_search")
                          @sprites["search"][email protected]["search"].bitmap.height
                          @sprites["search_bar"].dispose if @sprites["search_bar"]
                          @sprites["search_bar"]=Sprite.new(@viewport)
                          @sprites["search_bar"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/search_bar")
                          @sprites["search_bar"].x=18
                          [email protected]["search_bar"].bitmap.width
                          @sprites["search_bar"][email protected]["search"].y+58
                          @sprites["search_bar"].src_rect.width=0
                          wasNoScanBefore=true
                          criteria=totalCriteria
                          if !$pokedex2
                          $pokedex2=$pokedex
                          end
                          $pokedex=$pokedex2
                          newDex=[]
                          # Searching Pokémon by name.
                          if $searchSettings[1]>(-1)
                          alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                          letter=alphabet[$searchSettings[1],1]
                          letter2=letter.downcase
                          oldDex=$pokedex.clone
                          for i in 0...oldDex.length
                          pokemon=PokeBattle_Pokemon.new(oldDex[i],1)
                          if pokemon.name[0,1]==(letter || letter2)
                          newDex.push(oldDex[i])
                          end
                          end
                          wasNoScanBefore=false
                          end
                          # Searching Pokémon by type.
                          if $searchSettings[2][0]>(-1) || $searchSettings[2][1]>(-1) ||
                          ($searchSettings[2][0]>(-1) && $searchSettings[2][1]>(-1))
                          type=$searchSettings[2][0] if $searchSettings[2][0]>(-1)
                          type2=$searchSettings[2][1] if $searchSettings[2][1]>(-1)
                          # Since the 9th type is "???" we need to adapt the variable type.
                          if ($searchSettings[2][0])>8
                          type+=1
                          end
                          if ($searchSettings[2][1])>8
                          type2+=1
                          end
                          oldDex=newDex
                          oldDex=$pokedex.clone if wasNoScanBefore
                          newDex=[]
                          for i in 0...oldDex.length
                          pokemon=PokeBattle_Pokemon.new(oldDex[i],1)
                          if pokemon.hasType?(type) && !type2
                          newDex.push(oldDex[i])
                          elsif pokemon.hasType?(type2) && !type
                          newDex.push(oldDex[i])
                          elsif pokemon.hasType?(type) && pokemon.hasType?(type2)
                          newDex.push(oldDex[i])
                          end
                          end
                          wasNoScanBefore=false
                          end
                          # Searching Pokémon by color.
                          if $searchSettings[3]>(-1)
                          color=$searchSettings[3]
                          oldDex=newDex
                          oldDex=$pokedex.clone if wasNoScanBefore
                          newDex=[]
                          for i in 0...oldDex.length
                          pokemon=PokeBattle_Pokemon.new(oldDex[i],1)
                          if pokemon.hasColor?(color)
                          newDex.push(oldDex[i])
                          end
                          end
                          end
                          # Sorting Pokémon from A to Z.
                          if $searchSettings[0] == 0
                          wasAlreadyOneOption=true
                          oldDex=newDex
                          oldDex=$pokedex.clone if wasNoScanBefore
                          oldDex2=oldDex.clone
                          newDex=[]
                          for i in 0...oldDex2.length
                          pokemon=PokeBattle_Pokemon.new(oldDex2[i],1)
                          oldDex[i]=[pokemon.name,oldDex[i]]
                          oldDex2[i]=pokemon.name
                          end
                          oldDex2=oldDex2.sort
                          for i in 0...oldDex2.length
                          pokemon=oldDex2[i]
                          for i in 0...oldDex.length
                          if pokemon==oldDex[i][0]
                          newDex.push(oldDex[i][1])
                          break
                          end
                          end
                          end
                          wasNoScanBefore=false
                          end
                          # Sorting Pokémon from Heavy to Light and from Light to Heavy.
                          if $searchSettings[0]==1 || $searchSettings[0]==2
                          oldDex=newDex
                          oldDex=$pokedex.clone if wasNoScanBefore
                          oldDex2=oldDex.clone
                          newDex=[]
                          for i in 0...oldDex2.length
                          pokemon=PokeBattle_Pokemon.new(oldDex2[i],1)
                          oldDex[i]=[pokemon.weight,oldDex[i]]
                          oldDex2[i]=pokemon.weight
                          end
                          oldDex2=oldDex2.sort
                          oldDex2=oldDex2.reverse if $searchSettings[0]==1
                          for i in 0...oldDex2.length
                          weight=oldDex2[i]
                          for i in 0...oldDex.length
                          if weight==oldDex[i][0]
                          newDex.push(oldDex[i][1]) if oldDex[i][1] != newDex[newDex.length-1]
                          break
                          end
                          end
                          end
                          wasNoScanBefore=false
                          end
                          # Sorting Pokémon from Tall to Short and from Short to Tall.
                          if $searchSettings[0]==3 || $searchSettings[0]==4
                          wasAlreadyOneOption=true
                          oldDex=newDex
                          oldDex=$pokedex.clone if wasNoScanBefore
                          oldDex2=oldDex.clone
                          newDex=[]
                          for i in 0...oldDex2.length
                          dexdata=pbOpenDexData
                          pbDexDataOffset(dexdata,oldDex2[i],33)
                          height=dexdata.fgetb
                          dexdata.close
                          pokemon=PokeBattle_Pokemon.new(oldDex2[i],1)
                          oldDex[i]=[height,oldDex[i]]
                          oldDex2[i]=height
                          end
                          oldDex2=oldDex2.sort
                          oldDex2.reverse! if $searchSettings[0]==3
                          for a in 0...oldDex2.length
                          height=oldDex2[a]
                          for b in 0...oldDex.length
                          if height==oldDex[b][0]
                          check=true
                          if !newDex.empty?
                          for c in 0...newDex.length
                          check=false if newDex[c]==oldDex[b][1]
                          end
                          end
                          if check==true
                          newDex.push(oldDex[b][1])
                          break
                          end
                          end
                          end
                          @sprites["search_bar"].src_rect.width+=(bar_width/criteria)/oldDex2.length
                          end
                          end
                          # Finished search.
                          frames=40
                          frame=0
                          frames.times do
                          frame+=1
                          waitAndUpdate(1)
                          @sprites["search_bar"].src_rect.width=(bar_width*frame)/frames
                          end
                          waitAndUpdate(20)
                          @sprites["search_bar"].dispose
                          newDex=convertDex(newDex)
                          newDex=$pokedex if totalCriteria==0
                          if newDex.empty?
                          @sprites["search"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/no_pkmn_found")
                          else
                          @sprites["search"].bitmap=Bitmap.new("Graphics/Pictures/Pokedex/Search/pkmn_found")
                          end
                          loop do
                          waitAndUpdate(1)
                          break if Input.trigger?(Input::C)
                          if defined?($mouse)
                          if $mouse.inAreaLeft?(0,0,Graphics.width,Graphics.height)
                          break
                          end
                          end
                          end
                          @searchStarted=true
                          @newDex=newDex
                          end
                          end
                          # Change to false if you don't use Luka S.J's Elite Battle 2015.
                          USING_BITMAP_WRAPPER = false

                          Right at the top.
                          __________________
                          If you're looking for me, I'm on Safari Zone.
                          Reply With Quote
                            #838    
                          Old August 6th, 2017 (6:57 AM).
                          JackRoland JackRoland is offline
                             
                            Join Date: Jul 2017
                            Posts: 2
                            Quote:
                            Originally Posted by M3rein View Post
                            # Change to false if you don't use Luka S.J's Elite Battle 2015.
                            USING_BITMAP_WRAPPER = false

                            Right at the top.
                            I had already changed USING_BITMAP_WRAPPER but unfortunately I get the error I posted in the previous message. If you knew how to solve this problem I would be very grateful to you.
                            Reply With Quote
                              #839    
                            Old August 17th, 2017 (12:02 PM).
                            silver-wind's Avatar
                            silver-wind silver-wind is offline
                               
                              Join Date: Jun 2012
                              Gender: Female
                              Posts: 49
                              I need help installing this. I watched the youtube tutorial and the file I downloaed looks different. the zip contains a folder with _installer folder, and a .exe file which shows a bug when I run it. I can't find the EliteBattle scripts which the video says to add to the project. all I see are graphics and settings as text files. is my zip file broken? or am I supposed to unzip in my game folder and then run the .exe?
                              Reply With Quote
                                #840    
                              Old August 20th, 2017 (1:08 AM).
                              Marin's Avatar
                              Marin Marin is offline
                              Not Bored
                                 
                                Join Date: Nov 2016
                                Gender: Other
                                Posts: 624
                                Quote:
                                Originally Posted by silver-wind View Post
                                I need help installing this. I watched the youtube tutorial and the file I downloaed looks different. the zip contains a folder with _installer folder, and a .exe file which shows a bug when I run it. I can't find the EliteBattle scripts which the video says to add to the project. all I see are graphics and settings as text files. is my zip file broken? or am I supposed to unzip in my game folder and then run the .exe?
                                Yes, you can't properly run executables in zipped folders as far as I'm aware.
                                __________________
                                If you're looking for me, I'm on Safari Zone.
                                Reply With Quote
                                  #841    
                                Old August 22nd, 2017 (9:55 PM). Edited August 24th, 2017 by Telemetius.
                                Telemetius's Avatar
                                Telemetius Telemetius is offline
                                Tele*
                                   
                                  Join Date: Nov 2014
                                  Location: Italy
                                  Gender: Male
                                  Nature: Relaxed
                                  Posts: 267
                                  I took the liberty of compressing the sprites of Luka's plugin. This is the link. I can remove it immediately if it's against the rules.
                                  __________________

                                  That way!
                                  I thought..uhm, ok.
                                  -----------------------------------------------------------------------------------------------
                                  Beta 50%
                                  Reply With Quote
                                    #842    
                                  Old September 2nd, 2017 (7:28 PM).
                                  AngelsAdvent77's Avatar
                                  AngelsAdvent77 AngelsAdvent77 is offline
                                     
                                    Join Date: Apr 2016
                                    Gender: Other
                                    Posts: 128
                                    Will EBS support Z-Moves? If so, when? Thank you
                                    Reply With Quote
                                      #843    
                                    Old September 17th, 2017 (12:46 PM).
                                    AngelsAdvent77's Avatar
                                    AngelsAdvent77 AngelsAdvent77 is offline
                                       
                                      Join Date: Apr 2016
                                      Gender: Other
                                      Posts: 128
                                      Hello, the "EntryAnimations Script" from the "Elite Battle system by Luka S.J." states it can be used by itself . . . .
                                      Quote:
                                      If you'd like to use just the new transitions from EBS for your project,
                                      you'll also need to copy over the EliteBattle_Sprites section of the scripts
                                      to your project, as well as the configurations for the following constants:
                                      - VIEWPORT_HEIGHT
                                      - VIEWPORT_OFFSET
                                      However, what is meant by the "VIEWPORTs" step?
                                      Reply With Quote
                                        #844    
                                      Old September 22nd, 2017 (2:02 AM). Edited September 22nd, 2017 by Painkiller97.
                                      Painkiller97 Painkiller97 is offline
                                         
                                        Join Date: Jul 2017
                                        Posts: 2
                                        First of allI say that Im new on this page and my English isn´t very well, sorry :(

                                        When I try to launch game, it show me this error.

                                        Script SJPlugins_Settings line 153: NameError occurred.

                                        uninitialized constant PBSpecies.
                                        Reply With Quote
                                          #845    
                                        Old September 22nd, 2017 (10:07 AM). Edited September 26th, 2017 by sukoshijon.
                                        sukoshijon's Avatar
                                        sukoshijon sukoshijon is offline
                                        beyond the stars...
                                           
                                          Join Date: Apr 2016
                                          Location: A Digital Audio Workstation
                                          Gender: Male
                                          Nature: Relaxed
                                          Posts: 55
                                          First, you're asking in the wrong place. Second, the answer to this issue is in the EBS FAQ. To fix it, you need to compile your game data by holding CTRL when starting the game from RPG Maker XP. Like I said, it's in the FAQ. Please check it before asking questions, as chances are, the question has already been answered.
                                          __________________
                                          what's a signature?

                                          soundcloud
                                          youtube
                                          Reply With Quote
                                            #846    
                                          Old September 30th, 2017 (7:02 AM).
                                          pokemonequality pokemonequality is offline
                                             
                                            Join Date: Jan 2017
                                            Gender: Male
                                            Posts: 14
                                            Okay, so I ran into 2 bugs
                                            First one: When I click run in a Trainer Battle it says: \PN called *pokemonname* and it raises one of its stats instead of: No, there's no running from a Trainer Battle!
                                            How can I fix this? I am using Essentials V16.2 and I litteraly just re-installed EBS through the UPS provided on your website.
                                            The other bug has to do with the Sprite Positioner, whenever I load it up: I get this error:
                                            Spoiler:
                                            Exception: ArgumentError
                                            Message: The species number (no. 41 of 831) is invalid.
                                            PokeBattle_Pokemon:891:in `initialize'
                                            Pokemon_SpritePos **:129:in `new'
                                            Pokemon_SpritePos **:129:in `pbChangeSpecies'
                                            Pokemon_SpritePos **:164:in `pbSpecies'
                                            Pokemon_SpritePos **:158:in `loop'
                                            Pokemon_SpritePos **:178:in `pbSpecies'
                                            Pokemon_SpritePos **:310:in `pbStart'
                                            Pokemon_SpritePos **:309:in `loop'
                                            Pokemon_SpritePos **:317:in `pbStart'

                                            The only edits I have in my Pokemon.txt is the removal of all official Pokémon and simply only having my own Fakemon, so like the grass starter starts at No. 001 and the txt ends at No. 200
                                            Reply With Quote
                                              #847    
                                            Old September 30th, 2017 (6:58 PM).
                                            Diverscope's Avatar
                                            Diverscope Diverscope is offline
                                            Pardon me
                                               
                                              Join Date: Apr 2013
                                              Gender: Male
                                              Nature: Rash
                                              Posts: 81
                                              The first one isn't a bug. You have the shadow-type defined, thats why the run-button calls a pokémon. Check your types.txt

                                              The second one seems to be a problem of you changing the pokemon.txt and not properly recompiling the game and starting a new save file. The game still recognizes the old Pokémon (as it counts 831 different species, as the error log says). Hold CTRL while your game is starting and start a new save file (if not already done) and it should work.
                                              __________________
                                              Reply With Quote
                                                #848    
                                              Old September 30th, 2017 (11:26 PM).
                                              pokemonequality pokemonequality is offline
                                                 
                                                Join Date: Jan 2017
                                                Gender: Male
                                                Posts: 14
                                                Quote:
                                                Originally Posted by Diverscope View Post
                                                The first one isn't a bug. You have the shadow-type defined, thats why the run-button calls a pokémon. Check your types.txt

                                                The second one seems to be a problem of you changing the pokemon.txt and not properly recompiling the game and starting a new save file. The game still recognizes the old Pokémon (as it counts 831 different species, as the error log says). Hold CTRL while your game is starting and start a new save file (if not already done) and it should work.
                                                Hey, thanks for the Help! So, removing the Shadow Type worked for me so thank you for that, unfortunately compiling the game doesn't resolve the Positioner Crash, I deleted all Save Files I have from my project, opened up RPG XP, compiled the game, started a new Playthrough, saved and exited, I don't get what I am doing wrong here??
                                                Reply With Quote
                                                  #849    
                                                Old October 15th, 2017 (7:01 AM).
                                                Kurama_Times Kurama_Times is offline
                                                   
                                                  Join Date: Oct 2017
                                                  Posts: 1
                                                  hey I recently used EBS on the last version of essentials (17.2) and everything about EBS is working fine, but the text sound effect (the textbox sound) has been muted, Does anyone know why?
                                                  Reply With Quote
                                                    #850    
                                                  Old December 15th, 2017 (9:41 AM).
                                                  sharzin's Avatar
                                                  sharzin sharzin is offline
                                                  the biggest iranian pokemon fan
                                                     
                                                    Join Date: Oct 2015
                                                    Location: iran
                                                    Gender: Male
                                                    Posts: 135

                                                    why is this happening? what should i do?
                                                    __________________
                                                    check out my fangame:

                                                    pokemon re-imagined
                                                    and click here if you are interested in helping me for it.
                                                    my youtube= https://www.youtube.com/channel/UCzu7etRQgtNkCiZNLc3CLjA?view_as=subscriber
                                                    Reply With Quote
                                                    Reply

                                                    Quick Reply

                                                    Join the conversation!

                                                    Create an account to post a reply in this thread, participate in other discussions, and more!

                                                    Create a PokéCommunity Account

                                                    Sponsored Links
                                                    Thread Tools

                                                    Posting Rules
                                                    You may not post new threads
                                                    You may not post replies
                                                    You may not post attachments
                                                    You may not edit your posts

                                                    BB code is On
                                                    Smilies are On
                                                    [IMG] code is On
                                                    HTML code is Off

                                                    Forum Jump


                                                    All times are GMT -8. The time now is 2:25 AM.