The PokéCommunity Forums Fan Games Game Development Scripts & Tutorials
Engine Pokémon Essentials DS

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.


Closed Thread
 
Thread Tools
  #1    
Old December 24th, 2010 (11:44 AM). Edited May 16th, 2011 by venom12.
venom12's Avatar
venom12 venom12 is offline
Pokemon Crystal Rain Relased
     
    Join Date: Sep 2006
    Age: 27
    Gender: Male
    Nature: Adamant
    Posts: 529


    Welcome here is my gift for christmas :D so its a dual screen, edited from pokemon essentials,
    its first version so it can have some bugs.
    Pokegear is not finished, stortage system almost done need to fix some things.

    First version have:
    Changed Resolution
    Pokedex, bag, Pokemon Screen, Summary Screen, vs sequence, Menu on map finished.
    Animated pokemons, animated trainers.
    Two registered items.
    Mouse support

    Not Finished:
    Pokegear.


    Next Relase WIll have:
    Possibly Pokegear will be finished
    Fixed Bugs
    And some other features

    if anyone want can add his edits or new systems to this kit so post scripts or link here.

    Link:Pokemon Essentials DS v0.3.8


    Credits
    Poccil and Flameguru - For Pokemon Essentials
    Luka Sj - For vs sequence, help, and mouse modules and modyfications. And for the Logo.
    Cybersam & Astro_Mech - Mouse module
    Alexandre
    Mad.array for pedapp
    zingzags
    CNG - Battle moves select menu.
    Help-14 - Pokemon Following and Pokedex
    CollosalPokemon
    Wichu - Sprites
    FL - Egg Types Script and Unova pokemons
    KitsuneKouta
    venom12 - for Pokemon Essentials DS

    Relevant Advertising!

      #2    
    Old December 24th, 2010 (11:53 AM).
    me2hack's Avatar
    me2hack me2hack is offline
    Graphics Artist
       
      Join Date: Jul 2009
      Gender: Female
      Nature: Quiet
      Posts: 292
      Isn't this a project Luka is working on? o_O
      __________________



        #3    
      Old December 24th, 2010 (11:54 AM).
      venom12's Avatar
      venom12 venom12 is offline
      Pokemon Crystal Rain Relased
         
        Join Date: Sep 2006
        Age: 27
        Gender: Male
        Nature: Adamant
        Posts: 529
        Nope i doing it myself, some things are from peoples which i credited.
          #4    
        Old December 24th, 2010 (12:00 PM).
        me2hack's Avatar
        me2hack me2hack is offline
        Graphics Artist
           
          Join Date: Jul 2009
          Gender: Female
          Nature: Quiet
          Posts: 292
          Hmm.. Because Luka, was working on something like this with the exact same name and same goal like dual screen and all.
          __________________



            #5    
          Old December 24th, 2010 (12:04 PM).
          venom12's Avatar
          venom12 venom12 is offline
          Pokemon Crystal Rain Relased
             
            Join Date: Sep 2006
            Age: 27
            Gender: Male
            Nature: Adamant
            Posts: 529
            Yeah right, but i wanted to do this and i asked luka if its ok and he told yes so i started working on this few days ago.
              #6    
            Old December 24th, 2010 (12:06 PM).
            me2hack's Avatar
            me2hack me2hack is offline
            Graphics Artist
               
              Join Date: Jul 2009
              Gender: Female
              Nature: Quiet
              Posts: 292
              The system is still a bit buggy though. But yea it's still v0.1. Good luck on this project.
              __________________



                #7    
              Old December 24th, 2010 (12:54 PM).
              carmaniac's Avatar
              carmaniac carmaniac is offline
              Where the pickle surprise at?
                 
                Join Date: Apr 2009
                Location: England
                Age: 23
                Nature: Relaxed
                Posts: 682
                I've tried the kit but I've noticed a slight mistake you've done when coding the hg/ss menu. You did it entirely in scene_map giving it horrendous amount of lag compared to coding it outside the map code and having the map call and refresh the code. That way would reduce the lag alot. Other than that I say cudos to you on the effort of getting the code done.
                __________________
                This signature has been disabled.
                Spoilers are not allowed in signatures.
                Please review and fix the issues by reading the signature rules.

                You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

                Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
                  #8    
                Old December 24th, 2010 (1:10 PM).
                venom12's Avatar
                venom12 venom12 is offline
                Pokemon Crystal Rain Relased
                   
                  Join Date: Sep 2006
                  Age: 27
                  Gender: Male
                  Nature: Adamant
                  Posts: 529
                  Yeah carmaniac but menu like you have been done wasnt updating like i want this wokrs perfectly and luka sj told me what is better to update graphics.

                  Btw updated version fixed few bugs.
                    #9    
                  Old December 24th, 2010 (1:21 PM).
                  me2hack's Avatar
                  me2hack me2hack is offline
                  Graphics Artist
                     
                    Join Date: Jul 2009
                    Gender: Female
                    Nature: Quiet
                    Posts: 292
                    Just calling the window reducing a lot of lag. And it's easier too.
                    __________________



                      #10    
                    Old December 24th, 2010 (1:23 PM).
                    venom12's Avatar
                    venom12 venom12 is offline
                    Pokemon Crystal Rain Relased
                       
                      Join Date: Sep 2006
                      Age: 27
                      Gender: Male
                      Nature: Adamant
                      Posts: 529
                      if anyone want can add his edits or new systems to this kit post scripts or links here.

                      One thing please dont change the mouse module.
                        #11    
                      Old December 24th, 2010 (1:27 PM).
                      carmaniac's Avatar
                      carmaniac carmaniac is offline
                      Where the pickle surprise at?
                         
                        Join Date: Apr 2009
                        Location: England
                        Age: 23
                        Nature: Relaxed
                        Posts: 682
                        Quote:
                        Originally Posted by venom12 View Post
                        if anyone want can add his edits or new systems to this kit post scripts or links here.

                        One thing please dont change the mouse module.
                        I'll try add in the window style method to reduce lag for you if you need. It updates perfectly fine with the map when done correctly :P.
                        __________________
                        This signature has been disabled.
                        Spoilers are not allowed in signatures.
                        Please review and fix the issues by reading the signature rules.

                        You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

                        Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
                          #12    
                        Old December 24th, 2010 (3:03 PM). Edited December 24th, 2010 by zingzags.
                        zingzags's Avatar
                        zingzags zingzags is offline
                        PokemonGDX creator
                           
                          Join Date: Jan 2009
                          Location: Boston
                          Age: 24
                          Nature: Adamant
                          Posts: 562
                          Hmm nice kit. Yea noticed bugs tooo!
                          But still good. Noticed the Mouse is not updated when text boxes are displayed.
                          __________________
                          Check out the Pokemon Game Engine I am working on:
                          https://github.com/sjosegarcia/Pokemon
                            #13    
                          Old December 24th, 2010 (3:04 PM).
                          Luka S.J.'s Avatar
                          Luka S.J. Luka S.J. is offline
                          Jealous Croatian
                             
                            Join Date: Dec 2008
                            Location: Croatia
                            Age: 25
                            Gender: Male
                            Nature: Adamant
                            Posts: 1,118
                            I think what you're doing when updating the bottom screen on the map is refreshing the full def, which is where the lag comes from. It is a good idea to use the bottom screen on the scene_map, since the menu is always available, but make sure just to update the bitmaps instead of refreshing the full def, which creates a whole new set of sprites and commands, causing the lag. If coded properly it works perfect :)
                            __________________

                              #14    
                            Old December 24th, 2010 (8:43 PM).
                            help-14's Avatar
                            help-14 help-14 is offline
                               
                              Join Date: Jul 2007
                              Location: Viet Nam
                              Age: 25
                              Gender: Male
                              Nature: Adamant
                              Posts: 282
                              It is using Pokemon following character v2.1, i think you should update to v3.1 :)
                                #15    
                              Old December 26th, 2010 (6:34 AM).
                              Geeked's Avatar
                              Geeked Geeked is offline
                              Pokemon Crimson Version
                                 
                                Join Date: Jun 2007
                                Age: 24
                                Gender: Male
                                Nature: Adamant
                                Posts: 363
                                Whats up with this? I would really like to use it, but there's so much lag. Help!!
                                __________________
                                Coming soon I guess?
                                  #16    
                                Old December 26th, 2010 (12:00 PM).
                                IceGod64's Avatar
                                IceGod64 IceGod64 is offline
                                In the Lost & Found bin!
                                   
                                  Join Date: Oct 2008
                                  Location: Castelia City
                                  Age: 30
                                  Gender: Male
                                  Nature: Naive
                                  Posts: 627
                                  Quote:
                                  Originally Posted by Geeked View Post
                                  Whats up with this? I would really like to use it, but there's so much lag. Help!!
                                  There can be a huge number of different reasons for that, including something as expensive as needing a new computer altogether, or something as simple as closing other programs.
                                  __________________

                                    #17    
                                  Old December 26th, 2010 (12:15 PM).
                                  Geeked's Avatar
                                  Geeked Geeked is offline
                                  Pokemon Crimson Version
                                     
                                    Join Date: Jun 2007
                                    Age: 24
                                    Gender: Male
                                    Nature: Adamant
                                    Posts: 363
                                    No, it's due to this system. As stated above.
                                    __________________
                                    Coming soon I guess?
                                      #18    
                                    Old December 26th, 2010 (12:31 PM).
                                    me2hack's Avatar
                                    me2hack me2hack is offline
                                    Graphics Artist
                                       
                                      Join Date: Jul 2009
                                      Gender: Female
                                      Nature: Quiet
                                      Posts: 292
                                      Yep, it's how he made it.
                                      __________________



                                        #19    
                                      Old December 26th, 2010 (1:05 PM).
                                      zingzags's Avatar
                                      zingzags zingzags is offline
                                      PokemonGDX creator
                                         
                                        Join Date: Jan 2009
                                        Location: Boston
                                        Age: 24
                                        Nature: Adamant
                                        Posts: 562
                                        use this for now if you dont want to lag, I removed the menu from it


                                        Spoiler:

                                        =begin

                                        Modified Scene_Map class for Pokemon.

                                        =end
                                        class Scene_Map
                                        def spriteset
                                        for i in @spritesets.values
                                        return i if i.map==$game_map
                                        end
                                        return @spritesets.values[0]
                                        end
                                        def disposeSpritesets
                                        return if [email protected]
                                        for i in @spritesets.keys
                                        if @spritesets[i]
                                        @spritesets[i].dispose
                                        @spritesets[i]=nil
                                        end
                                        end
                                        @spritesets.clear
                                        @spritesets={}
                                        end
                                        def createSpritesets
                                        @spritesets={}
                                        for map in $MapFactory.maps
                                        @spritesets[map.map_id]=Spriteset_Map.new(map)
                                        end
                                        $MapFactory.setSceneStarted(self)
                                        updateSpritesets
                                        end
                                        def updateMaps
                                        for map in $MapFactory.maps
                                        map.update
                                        end
                                        $MapFactory.updateMaps(self)
                                        end
                                        def updateSpritesets
                                        @spritesets={} if [email protected]
                                        [email protected]
                                        for i in keys
                                        if !$MapFactory.hasMap?(i)
                                        @spritesets[i].dispose if @spritesets[i]
                                        @spritesets[i]=nil
                                        @spritesets.delete(i)
                                        else
                                        @spritesets[i].update
                                        end
                                        end
                                        for map in $MapFactory.maps
                                        if [email protected][map.map_id]
                                        @spritesets[map.map_id]=Spriteset_Map.new(map)
                                        end
                                        end
                                        Events.onMapUpdate.trigger(self)
                                        end
                                        def main

                                        createSpritesets
                                        Graphics.transition
                                        loop do
                                        Graphics.update
                                        Input.update
                                        update
                                        # self.dualscreen
                                        $mouse.update
                                        if $scene != self
                                        break
                                        end
                                        end
                                        Graphics.freeze
                                        disposeSpritesets
                                        if $game_temp.to_title
                                        Graphics.transition
                                        Graphics.freeze
                                        end
                                        end
                                        def miniupdate
                                        $PokemonTemp.miniupdate=true if $PokemonTemp
                                        loop do
                                        updateMaps
                                        $game_player.update
                                        $game_system.update
                                        $game_screen.update
                                        unless $game_temp.player_transferring
                                        break
                                        end
                                        transfer_player
                                        if $game_temp.transition_processing
                                        break
                                        end
                                        end
                                        updateSpritesets
                                        $PokemonTemp.miniupdate=false if $PokemonTemp
                                        end
                                        def update
                                        loop do
                                        updateMaps
                                        pbMapInterpreter.update
                                        $game_player.update
                                        $game_system.update
                                        $game_screen.update
                                        unless $game_temp.player_transferring
                                        break
                                        end
                                        transfer_player
                                        if $game_temp.transition_processing
                                        break
                                        end
                                        end
                                        updateSpritesets
                                        if $game_temp.to_title
                                        $scene = pbCallTitle
                                        return
                                        end
                                        if $game_temp.transition_processing
                                        $game_temp.transition_processing = false
                                        if $game_temp.transition_name == ""
                                        Graphics.transition(20)
                                        else
                                        Graphics.transition(40, "Graphics/Transitions/" +
                                        $game_temp.transition_name)
                                        end
                                        end
                                        if $game_temp.message_window_showing
                                        return
                                        end
                                        if Input.trigger?(Input::C)
                                        unless pbMapInterpreterRunning?
                                        $PokemonTemp.hiddenMoveEventCalling=true
                                        end
                                        end
                                        if Input.trigger?(Input::B)
                                        unless pbMapInterpreterRunning? or
                                        $game_system.menu_disabled
                                        $game_temp.menu_calling = true
                                        $game_temp.menu_beep = true
                                        end
                                        end
                                        if Input.trigger?(Input::F5)
                                        unless pbMapInterpreterRunning?
                                        $PokemonTemp.keyItemCalling = true if $PokemonTemp
                                        end
                                        end
                                        if $DEBUG and Input.press?(Input::F9)
                                        $game_temp.debug_calling = true
                                        end
                                        unless $game_player.moving?
                                        if $game_temp.battle_calling
                                        call_battle
                                        elsif $game_temp.shop_calling
                                        call_shop
                                        elsif $game_temp.name_calling
                                        call_name
                                        elsif $game_temp.menu_calling
                                        call_menu
                                        elsif $game_temp.save_calling
                                        call_save
                                        elsif $game_temp.debug_calling
                                        call_debug
                                        elsif $PokemonTemp && $PokemonTemp.keyItemCalling
                                        $PokemonTemp.keyItemCalling=false
                                        $game_player.straighten
                                        Kernel.pbUseKeyItem
                                        elsif $PokemonTemp && $PokemonTemp.keyItemCalling2
                                        $PokemonTemp.keyItemCalling2=false
                                        $game_player.straighten
                                        pbUseKeyItem2
                                        elsif $PokemonTemp && $PokemonTemp.hiddenMoveEventCalling
                                        $PokemonTemp.hiddenMoveEventCalling=false
                                        $game_player.straighten
                                        Kernel.pbHiddenMoveEvent
                                        end
                                        end
                                        end
                                        def call_name
                                        $game_temp.name_calling = false
                                        $game_player.straighten
                                        $game_map.update
                                        end
                                        def call_menu
                                        $game_temp.menu_calling = false
                                        $game_player.straighten
                                        $game_map.update
                                        # sscene=PokemonMenu_Scene.new
                                        # sscreen=PokemonMenu.new(sscene)
                                        # sscreen.pbStartPokemonMenu
                                        end
                                        def call_debug
                                        $game_temp.debug_calling = false
                                        pbPlayDecisionSE()
                                        $game_player.straighten
                                        $scene = Scene_Debug.new
                                        end
                                        def autofade(mapid)
                                        playingBGM=$game_system.playing_bgm
                                        playingBGS=$game_system.playing_bgs
                                        return if !playingBGM && !playingBGS
                                        map=pbLoadRxData(sprintf("Data/Map%03d", mapid))
                                        if playingBGM && map.autoplay_bgm
                                        if playingBGM.name!=map.bgm.name
                                        pbBGMFade(0.8)
                                        end
                                        end
                                        if playingBGS && map.autoplay_bgs
                                        if playingBGS.name!=map.bgs.name
                                        pbBGMFade(0.8)
                                        end
                                        end
                                        Graphics.frame_reset
                                        end
                                        def transfer_player(cancelVehicles=true)
                                        $game_temp.player_transferring = false
                                        if cancelVehicles
                                        Kernel.pbCancelVehicles($game_temp.player_new_map_id)
                                        end
                                        autofade($game_temp.player_new_map_id)
                                        if $game_map.map_id != $game_temp.player_new_map_id
                                        $MapFactory.setup($game_temp.player_new_map_id)
                                        end
                                        $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
                                        case $game_temp.player_new_direction
                                        when 2
                                        $game_player.turn_down
                                        when 4
                                        $game_player.turn_left
                                        when 6
                                        $game_player.turn_right
                                        when 8
                                        $game_player.turn_up
                                        end
                                        $game_player.straighten
                                        $game_map.update
                                        disposeSpritesets
                                        GC.start
                                        createSpritesets
                                        if $game_temp.transition_processing
                                        $game_temp.transition_processing = false
                                        Graphics.transition(20)
                                        end
                                        $game_map.autoplay
                                        Graphics.frame_reset
                                        Input.update
                                        end
                                        end

                                        class PokemonGlobalMetadata
                                        attr_accessor :menubitmap
                                        attr_accessor :menudexbitmap
                                        attr_accessor :menupokbitmap
                                        attr_accessor :menugearbitmap
                                        end


                                        __________________
                                        Check out the Pokemon Game Engine I am working on:
                                        https://github.com/sjosegarcia/Pokemon
                                          #20    
                                        Old December 26th, 2010 (1:06 PM).
                                        POKEMONMASTER260 POKEMONMASTER260 is offline
                                           
                                          Join Date: Jun 2009
                                          Posts: 139
                                          This is great! I realize it might be hard, but 1 feature I'd personally suggest is BW compatibility...
                                            #21    
                                          Old December 26th, 2010 (1:22 PM). Edited December 30th, 2010 by zingzags.
                                          zingzags's Avatar
                                          zingzags zingzags is offline
                                          PokemonGDX creator
                                             
                                            Join Date: Jan 2009
                                            Location: Boston
                                            Age: 24
                                            Nature: Adamant
                                            Posts: 562
                                            Quote:
                                            Originally Posted by POKEMONMASTER260 View Post
                                            This is great! I realize it might be hard, but 1 feature I'd personally suggest is BW compatibility...
                                            You are lucky enough to get PE remotely close to HG/SS. Just try to get it black and white style yourself.


                                            Replace PokemonMessages with this

                                            Spoiler:

                                            Code:
                                            #########
                                            
                                            class Game_Temp
                                              attr_writer :message_window_showing
                                              attr_writer :player_transferring
                                              attr_writer :transition_processing
                                              def message_window_showing
                                                @message_window_showing=false if [email protected]_window_showing
                                                return @message_window_showing
                                              end
                                              def player_transferring
                                                @player_transferring=false if [email protected]_transferring
                                                return @player_transferring
                                              end
                                              def transition_processing
                                                @transition_processing=false if [email protected]_processing
                                                return @transition_processing
                                              end
                                            end
                                            
                                            class Game_Message
                                             attr_writer :background, :visible
                                             def visible; return @visible ? @visible : false; end
                                             def background; return @background ? @background : 0; end
                                            end
                                            
                                            class Game_System
                                              attr_writer :message_position
                                              def message_position
                                                @message_position=2 if [email protected]_position
                                                return @message_position
                                              end
                                            end
                                            
                                            
                                            #########
                                            
                                            class Scene_Map
                                              def updatemini
                                                oldmws=$game_temp.message_window_showing
                                                oldvis=$game_message ? $game_message.visible : false
                                                $game_temp.message_window_showing=true
                                                $game_message.visible=true if $game_message
                                                loop do
                                                  $game_map.update
                                                  $game_player.update
                                                  $game_system.update
                                                  if $game_screen
                                                    $game_screen.update
                                                  else
                                                    $game_map.screen.update
                                                  end
                                                  unless $game_temp.player_transferring
                                                    break
                                                  end
                                                  transfer_player
                                                  if $game_temp.transition_processing
                                                    break
                                                  end
                                                end
                                                $game_temp.message_window_showing=oldmws
                                                $game_message.visible=oldvis if $game_message
                                                @spriteset.update if @spriteset
                                                @message_window.update if @message_window
                                              end
                                            end
                                            
                                            class Scene_Battle
                                              def updatemini
                                                if self.respond_to?("update_basic")
                                                  update_basic(true)
                                                  update_info_viewport                  # Update information viewport
                                                  if $game_message && $game_message.visible
                                                    @info_viewport.visible = false
                                                    @message_window.visible = true
                                                  end
                                                else
                                                  oldmws=$game_temp.message_window_showing
                                                  $game_temp.message_window_showing=true
                                                  # Update system (timer) and screen
                                                  $game_system.update
                                                  if $game_screen
                                                    $game_screen.update
                                                  else
                                                    $game_map.screen.update
                                                  end    
                                                  # If timer has reached 0
                                                  if $game_system.timer_working and $game_system.timer == 0
                                                    # Abort battle
                                                    $game_temp.battle_abort = true
                                                  end
                                                  # Update windows
                                                  @help_window.update if @help_window
                                                  @party_command_window.update if @party_command_window
                                                  @actor_command_window.update if @actor_command_window
                                                  @status_window.update if @status_window
                                                  $game_temp.message_window_showing=oldmws
                                                  @message_window.update if @message_window
                                                  # Update sprite set
                                                  @spriteset.update if @spriteset
                                                end
                                              end
                                            end
                                            
                                            def pbMapInterpreterRunning?
                                             interp=pbMapInterpreter
                                             return interp && interp.running?
                                            end
                                            
                                            def pbMapInterpreter
                                             if $game_map && $game_map.respond_to?("interpreter")
                                              return $game_map.interpreter
                                             elsif $game_system
                                              return $game_system.map_interpreter
                                             end
                                             return nil
                                            end
                                            
                                            def pbRefreshSceneMap
                                             if $scene && $scene.is_a?(Scene_Map)
                                              if $scene.respond_to?("miniupdate")
                                               $scene.miniupdate
                                              else
                                               $scene.updatemini
                                              end
                                             elsif $scene && $scene.is_a?(Scene_Battle)
                                               $scene.updatemini
                                             end
                                            end
                                            
                                            def pbUpdateSceneMap
                                             if $scene && $scene.is_a?(Scene_Map) && !pbIsFaded?
                                              if $scene.respond_to?("miniupdate")
                                               $scene.miniupdate
                                              else
                                               $scene.updatemini
                                              end
                                             elsif $scene && $scene.is_a?(Scene_Battle)
                                               $scene.updatemini
                                             end
                                            end
                                            #########
                                            
                                            
                                            module PokemonSkins
                                             @defaultTextSkin=nil
                                             def self.getDefaultTextSkin
                                              textSkin=MessageConfig::TextSkinName
                                              if textSkin==nil
                                                if [email protected]
                                                  skin=load_data("Data/System.rxdata").windowskin_name rescue nil
                                                  skin="../System/Window" if !skin
                                                  @defaultTextSkin=skin
                                                end
                                                return @defaultTextSkin
                                              end
                                             end
                                            end
                                            
                                            
                                            def pbCsvField!(str)
                                              ret=""
                                              str.sub!(/^\s*/,"")
                                              if str[0,1]=="\""
                                               str[0,1]=""
                                               escaped=false
                                               fieldbytes=0
                                               str.scan(/./) do |s|
                                                fieldbytes+=s.length
                                                break if s=="\"" && !escaped
                                                if s=="\\" && !escaped
                                                 escaped=true
                                                else
                                                 ret+=s
                                                 escaped=false
                                                end
                                               end
                                               str[0,fieldbytes]=""
                                               if !str[/^\s*,/] && !str[/^\s*$/] 
                                                raise _INTL("Invalid quoted field (in: {1})",ret)
                                               end
                                               str[0,str.length]=$~.post_match
                                              else
                                               if str[/,/]
                                                str[0,str.length]=$~.post_match
                                                ret=$~.pre_match
                                               else
                                                ret=str.clone
                                                str[0,str.length]=""
                                               end
                                               ret.gsub!(/\s+$/,"")
                                              end
                                              return ret
                                            end
                                            
                                            def pbCsvPosInt!(str)
                                             ret=pbCsvField!(str)
                                             if !ret[/^\d+$/]
                                              raise _INTL("Field {1} is not a positive integer",ret)
                                             end
                                             return ret.to_i
                                            end
                                            
                                            def pbEventCommentInput(*args)
                                                parameters = []
                                                list = *args[0].list # Event or event page
                                                elements = *args[1] # Number of elements
                                                trigger = *args[2] # Trigger
                                                return nil if list == nil
                                                return nil unless list.is_a?(Array)
                                                for item in list
                                                  next unless item.code == 108 || item.code == 408
                                                  if item.parameters[0] == trigger
                                                    start = list.index(item) + 1
                                                    finish = start + elements
                                                    for id in start...finish
                                                      next if !list[id]
                                                      parameters.push(list[id].parameters[0])
                                                    end
                                                    return parameters
                                                  end
                                                end
                                                return nil
                                            end
                                            
                                            # Gets the value of a variable.
                                            def pbGet(id)
                                              return 0 if !id || !$game_variables
                                              return $game_variables[id]
                                            end
                                            # Sets the value of a variable.
                                            def pbSet(id,value)
                                              if id && id>=0
                                               $game_variables[id]=value if $game_variables
                                               $game_map.need_refresh = true if $game_map
                                              end
                                            end
                                            
                                            def pbCurrentEventCommentInput(elements,trigger)
                                             return nil if !pbMapInterpreterRunning?
                                             event=pbMapInterpreter.get_character(0)
                                             return nil if !event
                                             return pbEventCommentInput(event,elements,trigger)
                                            end
                                            
                                            module InterpreterMixin
                                             def pbGlobalLock # Freezes all events on the map (for use at the beginning of common events)
                                              for event in $game_map.events.values
                                               event.minilock
                                              end
                                             end
                                             def pbGlobalUnlock # Unfreezes all events on the map (for use at the end of common events)
                                              for event in $game_map.events.values
                                               event.unlock
                                              end
                                             end
                                             def pbRepeatAbove(index)
                                              [email protected][index].indent
                                              loop do
                                               index-=1
                                               if @list[index].indent==indent
                                                return index+1
                                               end
                                              end
                                             end
                                             def pbBreakLoop(index)
                                              indent = @list[index].indent
                                              temp_index=index
                                              # Copy index to temporary variables
                                              loop do
                                               # Advance index
                                               temp_index += 1
                                               # If a fitting loop was not found
                                               if temp_index >= @list.size-1
                                                return index+1
                                               end
                                               if @list[temp_index].code == 413 and @list[temp_index].indent < indent
                                                return temp_index+1
                                               end
                                              end
                                             end
                                             def pbJumpToLabel(index,label_name)
                                                temp_index = 0
                                                loop do
                                                  if temp_index >= @list.size-1
                                                    return index+1
                                                  end
                                                  if @list[temp_index].code == 118 and
                                                     @list[temp_index].parameters[0] == label_name
                                                    return temp_index+1
                                                  end
                                                  temp_index += 1
                                                end
                                             end
                                             # Gets the next index in the interpreter, ignoring
                                             # certain events between messages
                                             def pbNextIndex(index)
                                              return -1 if [email protected] || @list.length==0
                                              i=index+1
                                              loop do
                                               if i>[email protected]
                                                return i
                                               end
                                               [email protected][i].code
                                               case code
                                                when 118, 108, 408 # Label, Comment
                                                 i+=1
                                                when 413 # Repeat Above
                                                 i=pbRepeatAbove(i)
                                                when 113 # Break Loop
                                                 i=pbBreakLoop(i)
                                                when 119 # Jump to Label
                                                 newI=pbJumpToLabel(i,@list[i].parameters[0])
                                                 if newI>i
                                                  i=newI
                                                 else
                                                  i+=1
                                                 end
                                                else
                                                 return i
                                               end     
                                              end
                                             end
                                             # Helper function that shows a picture in a script.  To be used in
                                             # a script event command.
                                             def pbShowPicture(number,name,origin,x,y,zoomX=100,zoomY=100,opacity=255,blendType=0)
                                                number = number + ($game_temp.in_battle ? 50 : 0)
                                                $game_screen.pictures[number].show(name,origin,
                                                  x, y, zoomX,zoomY,opacity,blendType)
                                             end
                                             # Erases an event and adds it to the list of erased events so that
                                             # it can stay erased when the game is saved then loaded again.  To be used in
                                             # a script event command.
                                             def pbEraseThisEvent
                                               if $game_map.events[@event_id]
                                                $game_map.events[@event_id].erase
                                                $PokemonMap.addErasedEvent(@event_id) if $PokemonMap
                                               end
                                               @index+=1
                                               return true
                                             end
                                             # Runs a common event.  To be used in
                                             # a script event command.
                                             def pbCommonEvent(id)
                                              if $game_temp.in_battle
                                               $game_temp.common_event_id = id
                                              else
                                               commonEvent = $data_common_events[id]
                                               $game_system.battle_interpreter.setup(commonEvent.list, 0)
                                              end
                                             end
                                             # Sets another event's self switch (eg. pbSetSelfSwitch(20,"A",true)).  To be used in
                                             # a script event command.
                                             def pbSetSelfSwitch(event,swtch,value)
                                              $game_self_switches[[@map_id,event,swtch]]=value
                                              $game_map.need_refresh = true
                                             end
                                             # Must use this approach to share the methods
                                             # because the methods already defined in a class
                                             # override those defined in an included module
                                             CustomEventCommands=<<_END_
                                            def command_242
                                             pbBGMFade(pbParams[0])
                                             return true
                                            end
                                            def command_246
                                             pbBGSFade(pbParams[0])
                                             return true
                                            end
                                            def command_251
                                             pbSEStop()
                                             return true
                                            end
                                              def command_241
                                                pbBGMPlay(pbParams[0])
                                                return true
                                              end
                                              def command_245
                                                pbBGSPlay(pbParams[0])
                                                return true
                                              end
                                              def command_249
                                                pbMEPlay(pbParams[0])
                                                return true
                                              end
                                              def command_250
                                                pbSEPlay(pbParams[0])
                                                return true
                                              end
                                            _END_
                                            end
                                            
                                            def pbButtonInputProcessing(variableNumber=0,timeoutFrames=0)
                                             ret=0
                                             loop do
                                               Graphics.update
                                               Input.update
                                               pbUpdateSceneMap
                                               n = 0
                                               for i in 1..18
                                                  if Input.trigger?(i)
                                                    n = i
                                                    ret=n
                                                  end
                                               end
                                               break if ret!=0
                                               if timeoutFrames && timeoutFrames>0
                                                i+=1
                                                break if i>=timeoutFrames
                                               end
                                             end
                                             Input.update
                                             if variableNumber && variableNumber>0
                                              $game_variables[variableNumber]=ret
                                              $game_map.need_refresh = true if $game_map
                                             end
                                             return ret
                                            end
                                            
                                            class Game_Temp
                                              attr_accessor :background
                                            end
                                            
                                            class Game_Interpreter
                                             include InterpreterMixin
                                             eval(InterpreterMixin::CustomEventCommands)
                                             @@immediateDisplayAfterWait=false
                                             @buttonInput=false
                                             def command_105
                                              return false if @buttonInput
                                              @buttonInput=true
                                              pbButtonInputProcessing(@list[@index].parameters[0])
                                              @buttonInput=false
                                              @index+=1
                                              return true
                                             end
                                             def command_101
                                              if $game_temp.message_window_showing
                                               return false
                                              end
                                              $game_message=Game_Message.new if !$game_message
                                              message=""
                                              commands=nil
                                              numInputVar=nil
                                              numInputDigitsMax=nil
                                              text=""
                                              [email protected][@index].parameters[0]
                                              [email protected][@index].parameters[1]
                                              if facename && facename!=""
                                               text+="\\ff[#{facename},#{faceindex}]"
                                              end
                                              if $game_message
                                               [email protected][@index].parameters[2]
                                              end
                                              [email protected][@index].parameters[3]
                                              message+=text
                                              messageend=""
                                              loop do
                                               nextIndex=pbNextIndex(@index)
                                               [email protected][nextIndex].code
                                               if code == 401
                                                [email protected][nextIndex].parameters[0]
                                                text+=" " if text!="" && text[text.length-1,1]!=" "
                                                message+=text
                                                @index=nextIndex
                                               else
                                                if code == 102
                                                 [email protected][nextIndex].parameters
                                                 @index=nextIndex
                                                elsif code == 106 && @@immediateDisplayAfterWait
                                                 [email protected][nextIndex].parameters
                                                 if params[0]<=10
                                                  [email protected][nextIndex+1].code
                                                  if nextcode==101||nextcode==102||nextcode==103
                                                   @index=nextIndex
                                                  else
                                                   break
                                                  end
                                                 else
                                                  break
                                                 end
                                                elsif code == 103
                                                 [email protected][nextIndex].parameters[0]
                                                 [email protected][nextIndex].parameters[1]
                                                 @index=nextIndex
                                                elsif code == 101
                                                 messageend="\1"
                                                end
                                                break
                                               end
                                              end
                                              message=_MAPINTL($game_map.map_id,message)
                                              @message_waiting=true
                                              if commands
                                               cmdlist=[]
                                               for cmd in commands[0]
                                                cmdlist.push(_MAPINTL($game_map.map_id,cmd))
                                               end
                                               command=Kernel.pbMessage(message+messageend,cmdlist,commands[1])
                                               @branch[@list[@index].indent] = command
                                              elsif numInputVar
                                               params=ChooseNumberParams.new
                                               params.setMaxDigits(numInputDigitsMax)
                                               params.setDefaultValue($game_variables[numInputVar])
                                               $game_variables[numInputVar]=Kernel.pbMessageChooseNumber(message+messageend,params)
                                               $game_map.need_refresh = true if $game_map
                                              else
                                               Kernel.pbMessage(message+messageend)
                                              end
                                              @message_waiting=false
                                              return true
                                             end
                                             def command_102
                                              @message_waiting=true
                                              command=Kernel.pbShowCommands(nil,@list[@index].parameters[0],@list[@index].parameters[1])
                                              @message_waiting=false
                                              @branch[@list[@index].indent] = command
                                              Input.update # Must call Input.update again to avoid extra triggers
                                              return true
                                             end
                                             def command_103
                                              [email protected][@index].parameters[0]
                                              @message_waiting=true
                                               params=ChooseNumberParams.new
                                               params.setMaxDigits(@list[@index].parameters[1])
                                               params.setDefaultValue($game_variables[varnumber])
                                               $game_variables[varnumber]=Kernel.pbChooseNumber(nil,params)
                                               $game_map.need_refresh = true if $game_map
                                              @message_waiting=false
                                              return true
                                             end
                                            end
                                            
                                            class Interpreter
                                             include InterpreterMixin
                                             eval(InterpreterMixin::CustomEventCommands)
                                             @@immediateDisplayAfterWait=false
                                             @buttonInput=false
                                             def command_105
                                              return false if @buttonInput
                                              @buttonInput=true
                                              pbButtonInputProcessing(@list[@index].parameters[0])
                                              @buttonInput=false
                                              @index+=1
                                              return true
                                             end
                                             def command_101
                                              if $game_temp.message_window_showing
                                               return false
                                              end
                                              message=""
                                              commands=nil
                                              numInputVar=nil
                                              numInputDigitsMax=nil
                                              text=""
                                              firstText=nil
                                              if @list[@index].parameters.length==1
                                               [email protected][@index].parameters[0]
                                               [email protected][@index].parameters[0]
                                               text+=" " if text[text.length-1,1]!=" "
                                               message+=text
                                              else
                                               [email protected][@index].parameters[0]
                                               [email protected][@index].parameters[1]
                                               if facename && facename!=""
                                                text+="\\ff[#{facename},#{faceindex}]"
                                                message+=text
                                               end
                                              end
                                              messageend=""
                                              loop do
                                               nextIndex=pbNextIndex(@index)
                                               [email protected][nextIndex].code
                                               if code == 401
                                                [email protected][nextIndex].parameters[0]
                                                text+=" " if text[text.length-1,1]!=" "
                                                message+=text
                                                @index=nextIndex
                                               else
                                                if code == 102
                                                 [email protected][nextIndex].parameters
                                                 @index=nextIndex
                                                elsif code == 106 && @@immediateDisplayAfterWait
                                                 [email protected][nextIndex].parameters
                                                 if params[0]<=10
                                                  [email protected][nextIndex+1].code
                                                  if nextcode==101||nextcode==102||nextcode==103
                                                   @index=nextIndex
                                                  else
                                                   break
                                                  end
                                                 else
                                                  break
                                                 end
                                                elsif code == 103
                                                 [email protected][nextIndex].parameters[0]
                                                 [email protected][nextIndex].parameters[1]
                                                 @index=nextIndex
                                                elsif code == 101
                                                 if @list[@index].parameters.length==1
                                                   [email protected][@index].parameters[0]
                                                   if text[/^\\ignr/] && text==firstText
                                                     text+=" " if text[text.length-1,1]!=" "
                                                     message+=text
                                                     @index=nextIndex
                                                     continue
                                                   end
                                                 end
                                                 messageend="\1"
                                                end
                                                break
                                               end
                                              end
                                              @message_waiting=true # needed to allow parallel process events to work while
                                                                    # a message is displayed
                                              message=_MAPINTL($game_map.map_id,message)
                                              if commands
                                               cmdlist=[]
                                               for cmd in commands[0]
                                                cmdlist.push(_MAPINTL($game_map.map_id,cmd))
                                               end
                                               command=Kernel.pbMessage(message+messageend,cmdlist,commands[1])
                                               @branch[@list[@index].indent] = command
                                              elsif numInputVar
                                               params=ChooseNumberParams.new
                                               params.setMaxDigits(numInputDigitsMax)
                                               params.setDefaultValue($game_variables[numInputVar])
                                               $game_variables[numInputVar]=Kernel.pbMessageChooseNumber(message+messageend,params)
                                               $game_map.need_refresh = true if $game_map
                                              else
                                               Kernel.pbMessage(message+messageend,nil)
                                              end
                                              @message_waiting=false
                                              return true
                                             end
                                             def command_102
                                               @message_waiting=true
                                               command=Kernel.pbShowCommands(nil,@list[@index].parameters[0],@list[@index].parameters[1])
                                               @message_waiting=false
                                               @branch[@list[@index].indent] = command
                                               Input.update # Must call Input.update again to avoid extra triggers
                                              return true
                                             end
                                             def command_103
                                              [email protected][@index].parameters[0]
                                              @message_waiting=true
                                               params=ChooseNumberParams.new
                                               params.setMaxDigits(@list[@index].parameters[1])
                                               params.setDefaultValue($game_variables[varnumber])
                                               $game_variables[varnumber]=Kernel.pbChooseNumber(nil,params)
                                               $game_map.need_refresh = true if $game_map
                                              @message_waiting=false
                                              return true
                                             end
                                            end
                                            
                                            
                                            def pbEventFacesPlayer?(event,player,distance)
                                               return false if distance<=0
                                               # Event can't reach player if no coordinates coincide
                                               return false if event.x!=player.x && event.y!=player.y
                                               deltaX = (event.direction == 6 ? 1 : event.direction == 4 ? -1 : 0)
                                               deltaY =  (event.direction == 2 ? 1 : event.direction == 8 ? -1 : 0)
                                               # Check for existence of player
                                               curx=event.x
                                               cury=event.y
                                               found=false
                                               for i in 0...distance
                                                curx+=deltaX
                                                cury+=deltaY
                                                if player.x==curx && player.y==cury
                                                 found=true
                                                 break
                                                end
                                               end
                                               return found
                                            end
                                            def pbEventCanReachPlayer?(event,player,distance)
                                               return false if distance<=0
                                               # Event can't reach player if no coordinates coincide
                                               return false if event.x!=player.x && event.y!=player.y
                                               deltaX = (event.direction == 6 ? 1 : event.direction == 4 ? -1 : 0)
                                               deltaY =  (event.direction == 2 ? 1 : event.direction == 8 ? -1 : 0)
                                               # Check for existence of player
                                               curx=event.x
                                               cury=event.y
                                               found=false
                                               realdist=0
                                               for i in 0...distance
                                                curx+=deltaX
                                                cury+=deltaY
                                                if player.x==curx && player.y==cury
                                                 found=true
                                                 break
                                                end
                                                realdist+=1
                                               end
                                               return false if !found
                                               # Check passibility
                                               curx=event.x
                                               cury=event.y
                                               for i in 0...realdist
                                                if !event.passable?(curx,cury,event.direction)
                                                 return false
                                                end
                                                curx+=deltaX
                                                cury+=deltaY
                                               end
                                               return true
                                            end
                                            
                                            class ChooseNumberParams
                                             def initialize
                                              @maxDigits=0
                                              @minNumber=0
                                              @maxNumber=0
                                              @skin=nil
                                              @messageSkin=nil
                                              @negativesAllowed=false
                                              @initialNumber=0
                                              @cancelNumber=nil
                                             end
                                             def setMessageSkin(value)
                                              @messageSkin=value
                                             end
                                             def messageSkin
                                              @messageSkin
                                             end
                                             def setSkin(value)
                                              @skin=value
                                             end
                                             def skin
                                              @skin
                                             end
                                             def setNegativesAllowed(value)
                                              @negativeAllowed=value
                                             end
                                             def negativesAllowed
                                              @negativeAllowed ? true : false
                                             end
                                             def setRange(minNumber,maxNumber)
                                              maxNumber=minNumber if minNumber>maxNumber
                                              @maxDigits=0
                                              @minNumber=minNumber
                                              @maxNumber=maxNumber
                                             end
                                             def setDefaultValue(number)
                                              @initialNumber=number
                                              @cancelNumber=nil
                                             end
                                             def setInitialValue(number)
                                              @initialNumber=number
                                             end
                                             def setCancelValue(number)
                                              @cancelNumber=number
                                             end
                                             def initialNumber
                                              return clamp(@initialNumber,self.minNumber,self.maxNumber)
                                             end
                                             def cancelNumber
                                              return @cancelNumber ? @cancelNumber : self.initialNumber
                                             end
                                             def minNumber
                                              ret=0
                                              if @maxDigits>0
                                               ret=-((10**@maxDigits)-1)
                                              elsif
                                               [email protected]
                                              end
                                              ret=0 if [email protected] && ret<0
                                              return ret
                                             end
                                             def maxNumber
                                              ret=0
                                              if @maxDigits>0
                                               ret=((10**@maxDigits)-1)
                                              elsif
                                               [email protected]
                                              end
                                              ret=0 if [email protected] && ret<0
                                              return ret
                                             end
                                             def setMaxDigits(value)
                                              @maxDigits=[1,value].max
                                             end
                                             def maxDigits
                                              if @maxDigits>0
                                               return @maxDigits
                                              else
                                               return [numDigits(self.minNumber),numDigits(self.maxNumber)].max
                                              end
                                             end
                                             private
                                             def clamp(v,mn,mx)
                                              return v<mn ? mn : (v>mx ? mx : v)
                                             end
                                             def numDigits(number)
                                                ans = 1
                                                number=number.abs
                                                while number >= 10
                                                    ans+=1
                                                    number/=10;
                                                end
                                                return ans
                                             end
                                            end
                                            
                                            def pbChooseNumber(msgwindow,params)
                                              return 0 if !params
                                              ret=0
                                              maximum=params.maxNumber
                                              minimum=params.minNumber
                                              defaultNumber=params.initialNumber
                                              cancelNumber=params.cancelNumber
                                              cmdwindow=Window_InputNumberPokemon.new(params.maxDigits)
                                              cmdwindow.z=99999
                                              cmdwindow.visible=true
                                              cmdwindow.setSkin(params.skin) if params.skin
                                              cmdwindow.sign=params.negativesAllowed # must be set before number
                                              cmdwindow.number=defaultNumber
                                              curnumber=defaultNumber
                                              pbPositionNearMsgWindow(cmdwindow,msgwindow,:right)
                                              command=0
                                              loop do
                                               Graphics.update
                                               Input.update
                                               pbUpdateSceneMap
                                               cmdwindow.update
                                               msgwindow.update if msgwindow
                                               yield if block_given?
                                               if Input.trigger?(Input::C)
                                                  ret=cmdwindow.number
                                                  if ret>maximum
                                                    pbPlayBuzzerSE()
                                                  elsif ret<minimum
                                                    pbPlayBuzzerSE()
                                                  else
                                                    pbPlayDecisionSE()
                                                    break
                                                  end
                                               elsif Input.trigger?(Input::B)
                                                  pbPlayCancelSE()
                                                  ret=cancelNumber
                                                  break
                                               end
                                              end
                                              cmdwindow.dispose
                                              Input.update
                                              return ret 
                                            end
                                            
                                            def Kernel.pbShowCommandsWithHelp(msgwindow,commands,help,cmdIfCancel=0,defaultCmd=0)
                                             msgwin=msgwindow
                                             if !msgwindow
                                              msgwin=Kernel.pbCreateMessageWindow(nil)
                                             end
                                             oldlbl=msgwin.letterbyletter
                                             msgwin.letterbyletter=false
                                             if commands
                                               cmdwindow=Window_CommandPokemonEx.new(commands)
                                               cmdwindow.z=99999
                                               cmdwindow.visible=true
                                               cmdwindow.resizeToFit(cmdwindow.commands)
                                               cmdwindow.height=msgwin.y if cmdwindow.height>msgwin.y
                                               cmdwindow.index=defaultCmd
                                               command=0
                                               msgwin.text=help[cmdwindow.index]
                                               loop do
                                                Graphics.update
                                                Input.update
                                                oldindex=cmdwindow.index
                                                cmdwindow.update
                                                if oldindex!=cmdwindow.index
                                                 msgwin.text=help[cmdwindow.index]
                                                end
                                                msgwin.update
                                                yield if block_given?
                                                if Input.trigger?(Input::B)
                                                  if cmdIfCancel>0
                                                   command=cmdIfCancel-1
                                                   break
                                                  elsif cmdIfCancel<0
                                                   command=cmdIfCancel
                                                   break
                                                  end
                                                end
                                                if Input.trigger?(Input::C)
                                                  command=cmdwindow.index
                                                  break
                                                end
                                                pbUpdateSceneMap
                                               end
                                               ret=command
                                               cmdwindow.dispose
                                               Input.update
                                             end
                                             msgwin.letterbyletter=oldlbl
                                             if !msgwindow
                                              msgwin.dispose
                                             end
                                             return ret
                                            end
                                            
                                            def Kernel.pbShowCommands(msgwindow,commands=nil,cmdIfCancel=0,defaultCmd=0)
                                              ret=0
                                              if commands
                                               cmdwindow=Window_CommandPokemonEx.new(commands)
                                               cmdwindow.z=99999
                                               cmdwindow.visible=true
                                               cmdwindow.resizeToFit(cmdwindow.commands)
                                               pbPositionNearMsgWindow(cmdwindow,msgwindow,:right)
                                               cmdwindow.index=defaultCmd
                                               command=0
                                               loop do
                                                Graphics.update
                                                Input.update
                                                cmdwindow.update
                                                msgwindow.update if msgwindow
                                                yield if block_given?
                                                if Input.trigger?(Input::B)
                                                  if cmdIfCancel>0
                                                   command=cmdIfCancel-1
                                                   break
                                                  elsif cmdIfCancel<0
                                                   command=cmdIfCancel
                                                   break
                                                  end
                                                end
                                                if Input.trigger?(Input::C)
                                                  command=cmdwindow.index
                                                  break
                                                end
                                                pbUpdateSceneMap
                                               end
                                               ret=command
                                               cmdwindow.dispose
                                               Input.update
                                              end
                                              return ret
                                            end
                                            
                                            def pbPositionFaceWindow(facewindow,msgwindow)
                                               return if !facewindow
                                               if msgwindow
                                                if facewindow.height<=msgwindow.height
                                                 facewindow.y=msgwindow.y
                                                else
                                                 facewindow.y=msgwindow.y+msgwindow.height-facewindow.height
                                                end
                                                facewindow.x=Graphics.width-facewindow.width
                                                msgwindow.x=0
                                                msgwindow.width=Graphics.width-facewindow.width
                                               else
                                                facewindow.height=$Graphics_height if facewindow.height>$Graphics_height
                                                facewindow.x=0
                                                facewindow.y=0
                                               end
                                            end
                                            
                                            def pbPositionNearMsgWindow(cmdwindow,msgwindow,side)
                                               return if !cmdwindow
                                               if msgwindow
                                                height=[cmdwindow.height,$Graphics_height-msgwindow.height].min
                                                if cmdwindow.height!=height
                                                 cmdwindow.height=height
                                                end
                                                cmdwindow.y=msgwindow.y-cmdwindow.height
                                                if cmdwindow.y<0
                                                 cmdwindow.y=msgwindow.y+msgwindow.height
                                                 if cmdwindow.y+cmdwindow.height>$Graphics_height
                                                  cmdwindow.y=msgwindow.y-cmdwindow.height
                                                 end
                                                end
                                                case side
                                                 when :left
                                                  cmdwindow.x=msgwindow.x
                                                 when :right
                                                  cmdwindow.x=msgwindow.x+msgwindow.width-cmdwindow.width
                                                 else
                                                  cmdwindow.x=msgwindow.x+msgwindow.width-cmdwindow.width
                                                end
                                               else
                                                cmdwindow.height=$Graphics_height if cmdwindow.height>$Graphics_height
                                                cmdwindow.x=0
                                                cmdwindow.y=0
                                               end
                                            end
                                            
                                            def pbGetMapNameFromId(id)
                                              begin
                                                map = pbLoadRxData("Data/MapInfos")
                                                return "" if !map
                                                return map[id].name
                                              rescue
                                                return ""
                                              end
                                            end
                                            
                                            def Kernel.pbMessage(message,commands=nil,cmdIfCancel=0,skin=nil,defaultCmd=0,&block)
                                              ret=0
                                              msgwindow=Kernel.pbCreateMessageWindow(nil,skin)
                                              if commands
                                               ret=Kernel.pbMessageDisplay(msgwindow,message,true,
                                                 proc {|msgwindow|
                                                   next Kernel.pbShowCommands(msgwindow,commands,cmdIfCancel,defaultCmd,&block)
                                                 },&block)
                                              else
                                               Kernel.pbMessageDisplay(msgwindow,message,&block)
                                              end
                                              Kernel.pbDisposeMessageWindow(msgwindow)
                                              Input.update
                                              return ret
                                            end
                                            
                                            def Kernel.pbMessageChooseNumber(message,params,&block)
                                              msgwindow=Kernel.pbCreateMessageWindow(nil,params.messageSkin)
                                              ret=Kernel.pbMessageDisplay(msgwindow,message,true,
                                                  proc {|msgwindow|
                                                    next Kernel.pbChooseNumber(msgwindow,params,&block)
                                                  },&block)
                                              Kernel.pbDisposeMessageWindow(msgwindow)
                                              return ret
                                            end
                                            
                                            def Kernel.pbConfirmMessage(message,&block)
                                             return (Kernel.pbMessage(message,[_INTL("YES"),_INTL("NO")],2,&block)==0)
                                            end
                                            
                                            def Kernel.pbConfirmMessageSerious(message,&block)
                                             return (Kernel.pbMessage(message,[_INTL("NO"),_INTL("YES")],1,&block)==1)
                                            end
                                            
                                            
                                            def Kernel.pbCreateStatusWindow(viewport=nil)
                                              msgwindow=Window_AdvancedTextPokemon.new("")
                                              if !viewport
                                               msgwindow.z=99999
                                              else
                                               msgwindow.viewport=viewport
                                              end
                                              msgwindow.visible=false
                                              msgwindow.letterbyletter=false
                                              pbBottomLeftLines(msgwindow,2)
                                              skinfile=PokemonSkins.getDefaultTextSkin
                                              msgwindow.setSkin("Graphics/Windowskins/#{skinfile}")
                                              return msgwindow
                                            end
                                            
                                            def Kernel.pbCreateMessageWindow(viewport=nil,skin=nil)
                                              msgwindow=Window_AdvancedTextPokemon.new("")
                                              if !viewport
                                               msgwindow.z=99999
                                              else
                                               msgwindow.viewport=viewport
                                              end
                                              msgwindow.visible=true
                                              msgwindow.letterbyletter=true
                                              msgwindow.back_opacity=MessageConfig::WindowOpacity
                                              pbBottomLeftLines(msgwindow,2)
                                              $game_temp.message_window_showing=true if $game_temp
                                              $game_message.visible=true if $game_message
                                              skin=PokemonSkins.getDefaultTextSkin if !skin
                                              msgwindow.setSkin("Graphics/Windowskins/#{skin}")
                                              return msgwindow
                                            end
                                            
                                            def Kernel.pbDisposeMessageWindow(msgwindow)
                                              $game_temp.message_window_showing=false if $game_temp
                                              $game_message.visible=false if $game_message
                                              msgwindow.dispose
                                            end
                                            
                                            def isDarkBackground(background,rect=nil)
                                              if !background || background.disposed?
                                               return true
                                              end
                                              rect=background.rect if !rect
                                              if rect.width<=0 || rect.height<=0
                                               return true
                                              end
                                              xSeg=(rect.width/16)
                                              xLoop=(xSeg==0) ? 1 : 16
                                              xStart=(xSeg==0) ? rect.x+(rect.width/2) : rect.x+xSeg/2
                                              ySeg=(rect.height/16)
                                              yLoop=(ySeg==0) ? 1 : 16
                                              yStart=(ySeg==0) ? rect.y+(rect.height/2) : rect.y+ySeg/2
                                              count=0
                                              y=yStart
                                              r=0; g=0; b=0
                                              yLoop.times {
                                               x=xStart
                                               xLoop.times {
                                                clr=background.get_pixel(x,y)
                                                if clr.alpha!=0
                                                 r+=clr.red; g+=clr.green; b+=clr.blue
                                                 count+=1
                                                end
                                                x+=xSeg
                                               }
                                               y+=ySeg
                                              }
                                              return true if count==0
                                              r/=count
                                              g/=count
                                              b/=count
                                              return (r*0.299+g*0.587+b*0.114)<128
                                            end
                                            
                                            def isDarkWindowskin(windowskin)
                                             if !windowskin || windowskin.disposed?
                                              return true
                                             end
                                             if windowskin.width==192 && windowskin.height==128
                                              return isDarkBackground(windowskin,Rect.new(0,0,128,128))
                                             elsif windowskin.width==128 && windowskin.height==128
                                              return isDarkBackground(windowskin,Rect.new(0,0,64,64))
                                             else
                                              clr=windowskin.get_pixel(windowskin.width/2, windowskin.height/2)
                                              return (clr.red*0.299+clr.green*0.587+clr.blue*0.114)<128
                                             end
                                            end
                                            
                                            class FaceWindowVX < SpriteWindow_Base 
                                             def initialize(face)
                                              super(0,0,128,128)
                                              faceinfo=face.split(",")
                                              facefile=pbResolveBitmap("Graphics/Faces/"+faceinfo[0])
                                              facefile=pbResolveBitmap("Graphics/Pictures/"+faceinfo[0]) if !facefile
                                              self.contents.dispose if self.contents
                                              @faceIndex=faceinfo[1].to_i
                                              @facebitmaptmp=AnimatedBitmap.new(facefile)
                                              @facebitmap=BitmapWrapper.new(96,96)
                                              @facebitmap.blt(0,0,@facebitmaptmp.bitmap,Rect.new(
                                                (@faceIndex % 4) * 96,
                                                (@faceIndex / 4) * 96, 96, 96
                                              ))
                                              [email protected]
                                             end
                                             def update
                                              super
                                              if @facebitmaptmp.totalFrames>1
                                               @facebitmaptmp.update
                                               @facebitmap.blt(0,0,@facebitmaptmp.bitmap,Rect.new(
                                                (@faceIndex % 4) * 96,
                                                (@faceIndex / 4) * 96, 96, 96
                                               ))
                                              end
                                             end
                                             def dispose
                                              @facebitmaptmp.dispose
                                              @facebitmap.dispose if @facebitmap
                                              super
                                             end
                                            end
                                            
                                            def itemIconTag(item)
                                              return "" if !item
                                              if item.respond_to?("icon_name")
                                               return sprintf("<icon=%s>",item.icon_name)
                                              else
                                               ix=item.icon_index % 16 * 24
                                               iy=item.icon_index / 16 * 24
                                               return sprintf("<img=Graphics/System/Iconset|%d|%d|24|24>",ix,iy)
                                              end
                                            end
                                            
                                            def getSkinColor(windowskin,color,isDarkSkin)
                                             if !windowskin || windowskin.disposed? || 
                                                windowskin.width!=128 || windowskin.height!=128
                                              textcolors=[
                                                isDarkSkin ? "<c2=7FFF5EF7>" : "<c2=318c675a>",
                                                "<c2=7E105D08>",
                                                "<c2=421F2117>",
                                                "<c2=43F022E8>",
                                                "<c2=7FF05EE8>",
                                                "<c2=7E1F5D17>",
                                                "<c2=43FF22F7>",
                                                "<c2=63184210>",
                                                "<c2=7FFF5EF7>"
                                              ]
                                              color=0 if color>textcolors.length
                                              return textcolors[color]
                                             else # VX windowskin
                                              color=0 if color>=32
                                              x = 64 + (color % 8) * 8
                                              y = 96 + (color / 8) * 8
                                              pixel=windowskin.get_pixel(x, y)
                                              return shadowctagFromColor(pixel)
                                             end
                                            end
                                            
                                            # internal function
                                            def pbRepositionMessageWindow(msgwindow, linecount=2)
                                              msgwindow.height=32*linecount+msgwindow.borderY
                                              msgwindow.y=($Graphics_height)-(msgwindow.height)
                                              if $game_temp && $game_temp.in_battle && 
                                                 !$scene.respond_to?("update_basic")
                                               msgwindow.y=0
                                              elsif $game_system && $game_system.respond_to?("message_position")
                                               case $game_system.message_position
                                                when 0  # up
                                                 msgwindow.y=0
                                                when 1  # middle
                                                 msgwindow.y=($Graphics_height/2)-(msgwindow.height/2)
                                                when 2
                                                 msgwindow.y=($Graphics_height)-(msgwindow.height)
                                               end
                                              end
                                              if $game_system && $game_system.respond_to?("message_frame")
                                               if $game_system.message_frame != 0
                                                msgwindow.opacity = 0
                                               end
                                              end
                                              if $game_message
                                               case $game_message.background
                                                when 1  # dim
                                                 msgwindow.opacity=0
                                                when 2  # transparent
                                                 msgwindow.opacity=0
                                               end 
                                              end
                                            end
                                            
                                            # internal function
                                            def pbUpdateMsgWindowPos(msgwindow,event,eventChanged=false)
                                               if event
                                                if eventChanged
                                                 msgwindow.resizeToFit2(msgwindow.text,
                                                   Graphics.width*2/3,msgwindow.height)
                                                end
                                                msgwindow.y=event.screen_y-48-msgwindow.height  
                                                if msgwindow.y<0
                                                 msgwindow.y=event.screen_y+24
                                                end
                                                msgwindow.x=event.screen_x-(msgwindow.width/2)
                                                msgwindow.x=0 if msgwindow.x<0
                                                if msgwindow.x>Graphics.width-msgwindow.width
                                                 msgwindow.x=Graphics.width-msgwindow.width
                                                end
                                               else
                                                curwidth=msgwindow.width
                                                if curwidth!=Graphics.width
                                                 msgwindow.width=Graphics.width
                                                 msgwindow.width=Graphics.width     
                                                end
                                               end
                                            end
                                            
                                            # internal function
                                            
                                            
                                            def pbGetGoldString
                                            moneyString=""
                                                  if $Trainer
                                                   moneyString=_INTL("${1}",$Trainer.money)
                                                 else
                                                   if $data_system.respond_to?("words")
                                                     moneyString=_INTL("{1} {2}",$game_party.gold,$data_system.words.gold)
                                                   else
                                                     moneyString=_INTL("{1} {2}",$game_party.gold,Vocab.gold)         
                                                   end
                                                  end
                                             return moneyString
                                            end
                                            
                                            def pbDisplayGoldWindow(msgwindow)
                                                  moneyString=pbGetGoldString()
                                                  goldwindow=Window_UnformattedTextPokemon.newWithSize(
                                                    _INTL("MONEY:\n{1}",moneyString),0,0,32,32,msgwindow.viewport)
                                                  goldwindow.resizeToFit(goldwindow.text,Graphics.width)
                                                  if msgwindow.y==0
                                                   goldwindow.y=$Graphics_height-goldwindow.height
                                                  else
                                                   goldwindow.y=0
                                                  end
                                                  goldwindow.viewport=msgwindow.viewport
                                                  goldwindow.z=msgwindow.z
                                                  return goldwindow
                                            end
                                            
                                            
                                            
                                            def pbRecord(arg); end
                                            def pbMessageWaitForInput(msgwindow,frames,showPause=false)
                                              return if !frames || frames<=0
                                              if msgwindow && showPause
                                                msgwindow.startPause
                                              end
                                              frames.times do
                                                  Graphics.update
                                                  Input.update
                                                  msgwindow.update if msgwindow
                                                  pbUpdateSceneMap
                                                  if Input.trigger?(Input::C) || Input.trigger?(Input::B)
                                                     break
                                                  end
                                              end
                                              if msgwindow && showPause
                                                msgwindow.stopPause
                                              end
                                            end
                                            
                                            def Kernel.pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
                                              return if !msgwindow
                                              oldletterbyletter=msgwindow.letterbyletter
                                              msgwindow.letterbyletter=(letterbyletter ? true : false)
                                              ret=nil
                                              count=0
                                              commands=nil
                                              facewindow=nil
                                              goldwindow=nil
                                              cmdvariable=0
                                              cmdIfCancel=0
                                              msgwindow.waitcount=0
                                              autoresume=false
                                              text=message.clone
                                              msgback=nil
                                              linecount=($Graphics_height>400) ? 3 : 2
                                              ### Text replacement
                                              text.gsub!(/\\\\/,"\5")
                                              if $game_actors
                                               text.gsub!(/\\[Nn]\[([1-8])\]/){ 
                                                m=$1.to_i
                                                next $game_actors[m].name
                                               }
                                              end
                                              text.gsub!(/\\[Ss][Ii][Gg][Nn]\[([^\]]*)\]/){ 
                                                next "\\op\\cl\\ts[]\\w["+$1+"]"
                                              }
                                              text.gsub!(/\\[Pp][Nn]/,$Trainer.name) if $Trainer
                                              text.gsub!(/\\[Pp][Mm]/,_INTL("${1}",$Trainer.money)) if $Trainer
                                              text.gsub!(/\\[Nn]/,"\n")
                                              text.gsub!(/\\\[([0-9A-Fa-f]{8,8})\]/){ "<c2="+$1+">" }
                                              text.gsub!(/\\[Bb]/,"<c2=6546675A>")
                                              text.gsub!(/\\[Rr]/,"<c2=043C675A>")
                                              text.gsub!(/\\1/,"\1")
                                              colortag=""
                                              isDarkSkin=isDarkWindowskin(msgwindow.windowskin)
                                              if ($game_message && $game_message.background>0) ||
                                                 ($game_system && $game_system.respond_to?("message_frame") &&
                                                  $game_system.message_frame != 0)
                                               colortag=getSkinColor(msgwindow.windowskin,0,true)
                                              else
                                               colortag=getSkinColor(msgwindow.windowskin,0,isDarkSkin)
                                              end
                                              text.gsub!(/\\[Cc]\[([0-9]+)\]/){ 
                                                m=$1.to_i
                                                next getSkinColor(msgwindow.windowskin,m,isDarkSkin)
                                              }
                                              begin
                                               last_text = text.clone
                                               text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
                                              end until text == last_text
                                              begin
                                               last_text = text.clone
                                               text.gsub!(/\\[Ll]\[([0-9]+)\]/) { 
                                                  linecount=[1,$1.to_i].max;
                                                  next "" 
                                               }
                                              end until text == last_text
                                              text=colortag+text
                                              ### Controls
                                              textchunks=[]
                                              controls=[]
                                              while text[/(?:\\([WwFf]|[Ff][Ff]|[Tt][Ss]|[Cc][Ll]|[Mm][Ee]|[Ss][Ee]|[Ww][Tt]|[Ww][Tt][Nn][Pp]|[Cc][Hh])\[([^\]]*)\]|\\([Gg]|[Ww][Dd]|[Ww][Mm]|[Oo][Pp]|[Cc][Ll]|[Ww][Uu]|[\.]|[\|]|[\!]|[\x5E])())/i]
                                               textchunks.push($~.pre_match)
                                               if $~[1]
                                                controls.push([$~[1].downcase,$~[2],-1])
                                               else
                                                controls.push([$~[3].downcase,"",-1])
                                               end
                                               text=$~.post_match
                                              end
                                              textchunks.push(text)
                                              for chunk in textchunks
                                               chunk.gsub!(/\005/,"\\")
                                              end
                                              textlen=0
                                              for i in 0...controls.length
                                               control=controls[i][0]
                                               if control=="wt" || control=="wtnp" || control=="." || control=="|"
                                                textchunks[i]+="\2"
                                               elsif control=="!"
                                                textchunks[i]+="\1"
                                               end
                                               textlen+=toUnformattedText(textchunks[i]).scan(/./m).length
                                               controls[i][2]=textlen
                                              end
                                              text=textchunks.join("")
                                              unformattedText=toUnformattedText(text)
                                              signWaitCount=0
                                              haveSpecialClose=false
                                              specialCloseSE=""
                                              for i in 0...controls.length
                                               control=controls[i][0]
                                               param=controls[i][1]
                                               if control=="f"
                                                facewindow.dispose if facewindow
                                                facewindow=PictureWindow.new("Graphics/Pictures/#{param}")
                                               elsif control=="op"
                                                signWaitCount=21
                                               elsif control=="cl"
                                                text=text.sub(/\001$/,"")
                                                haveSpecialClose=true
                                                specialCloseSE=param
                                               elsif control=="se" && controls[i][2]==0
                                                startSE=param
                                                controls[i]=nil
                                               elsif control=="ff"
                                                facewindow.dispose if facewindow
                                                facewindow=FaceWindowVX.new(param)
                                               elsif control=="ch"
                                                cmds=param.clone
                                                cmdvariable=pbCsvPosInt!(cmds)
                                                cmdIfCancel=pbCsvField!(cmds).to_i
                                                commands=[]
                                                while cmds.length>0
                                                 commands.push(pbCsvField!(cmds))
                                                end
                                               elsif control=="wtnp" || control=="^"
                                                text=text.sub(/\001$/,"")
                                               end
                                              end
                                              if startSE!=nil
                                               pbSEPlay(pbStringToAudioFile(startSE))
                                              elsif signWaitCount==0 && letterbyletter
                                               pbPlayDecisionSE()
                                              end
                                              ########## Position message window  ##############
                                              pbRepositionMessageWindow(msgwindow,linecount)
                                              if $game_message && $game_message.background==1
                                                msgback=IconSprite.new(0,msgwindow.y,msgwindow.viewport)
                                                msgback.z=msgwindow.z-1
                                                msgback.setBitmap("Graphics/System/MessageBack")
                                              end
                                              if facewindow
                                                pbPositionNearMsgWindow(facewindow,msgwindow,:left)
                                                facewindow.viewport=msgwindow.viewport
                                                facewindow.z=msgwindow.z
                                              end
                                              atTop=(msgwindow.y==0)
                                              ########## Show text #############################
                                              msgwindow.text=text
                                              Graphics.frame_reset if Graphics.frame_rate>40
                                              begin
                                               if signWaitCount>0
                                                signWaitCount-=1
                                                if atTop
                                                 msgwindow.y=-(msgwindow.height*(signWaitCount)/20)
                                                else
                                                 msgwindow.y=$Graphics_height-(msgwindow.height*(20-signWaitCount)/20)
                                                end
                                               end
                                               for i in 0...controls.length
                                                if controls[i] && controls[i][2]<=msgwindow.position && msgwindow.waitcount==0
                                                 control=controls[i][0]
                                                 param=controls[i][1]
                                                 if control=="f"
                                                  facewindow.dispose if facewindow
                                                  facewindow=PictureWindow.new("Graphics/Pictures/#{param}")
                                                  pbPositionNearMsgWindow(facewindow,msgwindow,:left)
                                                  facewindow.viewport=msgwindow.viewport
                                                  facewindow.z=msgwindow.z
                                                 elsif control=="ts"
                                                  if param==""
                                                   msgwindow.textspeed=-999
                                                  else
                                                   msgwindow.textspeed=param.to_i
                                                  end
                                                 elsif control=="ff"
                                                  facewindow.dispose if facewindow
                                                  facewindow=FaceWindowVX.new(param)
                                                  pbPositionNearMsgWindow(facewindow,msgwindow,:left)
                                                  facewindow.viewport=msgwindow.viewport
                                                  facewindow.z=msgwindow.z
                                                 elsif control=="g" # Display gold window
                                                  goldwindow.dispose if goldwindow
                                                  goldwindow=pbDisplayGoldWindow(msgwindow)
                                                 elsif control=="wu"
                                                  msgwindow.y=0
                                                  atTop=true
                                                  msgback.y=msgwindow.y if msgback
                                                  pbPositionNearMsgWindow(facewindow,msgwindow,:left)
                                                  msgwindow.y=-(msgwindow.height*(signWaitCount)/20)
                                                 elsif control=="wm"
                                                  atTop=false
                                                  msgwindow.y=($Graphics_height/2)-(msgwindow.height/2)
                                                  msgback.y=msgwindow.y if msgback
                                                  pbPositionNearMsgWindow(facewindow,msgwindow,:left)
                                                 elsif control=="wd"
                                                  atTop=false
                                                  msgwindow.y=($Graphics_height)-(msgwindow.height)
                                                  msgback.y=msgwindow.y if msgback
                                                  pbPositionNearMsgWindow(facewindow,msgwindow,:left)
                                                  msgwindow.y=$Graphics_height-(msgwindow.height*(20-signWaitCount)/20)
                                                 elsif control=="."
                                                  msgwindow.waitcount+=Graphics.frame_rate/4
                                                 elsif control=="|"
                                                  msgwindow.waitcount+=Graphics.frame_rate
                                                 elsif control=="wt" # Wait
                                                  param=param.sub(/^\s+/,"").sub(/\s+$/,"")
                                                  msgwindow.waitcount+=param.to_i*2
                                                 elsif control=="w" # Windowskin
                                                  if param==""
                                                   msgwindow.windowskin=nil
                                                  else
                                                   msgwindow.setSkin("Graphics/Windowskins/#{param}")
                                                  end
                                                 elsif control=="^" # Wait, no pause
                                                  autoresume=true
                                                 elsif control=="wtnp" # Wait, no pause
                                                  param=param.sub(/^\s+/,"").sub(/\s+$/,"")
                                                  msgwindow.waitcount=param.to_i*2
                                                  autoresume=true
                                                 elsif control=="se" # Play SE
                                                  pbSEPlay(pbStringToAudioFile(param))
                                                 elsif control=="me" # Play ME
                                                  pbMEPlay(pbStringToAudioFile(param))
                                                 end
                                                 controls[i]=nil
                                                end
                                               end
                                               break if !letterbyletter
                                               Graphics.update
                                               Input.update
                                               facewindow.update if facewindow
                                               if $DEBUG && Input.trigger?(Input::F6)
                                                  pbRecord(unformattedText)
                                               end
                                               if autoresume && msgwindow.waitcount==0
                                                 msgwindow.resume if msgwindow.busy?
                                                 break if !msgwindow.busy?
                                               end
                                               if (Input.trigger?(Input::C) || Input.trigger?(Input::B))
                                                 if msgwindow.busy?
                                                  pbPlayDecisionSE() if msgwindow.pausing?
                                                  msgwindow.resume
                                                 else
                                                  break if signWaitCount==0
                                                 end
                                               end
                                               pbUpdateSceneMap
                                               msgwindow.update
                                               yield if block_given?
                                              end until (!letterbyletter || commandProc || commands) && !msgwindow.busy?
                                              Input.update # Must call Input.update again to avoid extra triggers
                                              msgwindow.letterbyletter=oldletterbyletter
                                              if commands
                                               $game_variables[cmdvariable]=Kernel.pbShowCommands(
                                                 msgwindow,commands,cmdIfCancel)
                                               $game_map.need_refresh = true if $game_map
                                              end
                                              if commandProc
                                                ret=commandProc.call(msgwindow)
                                              end
                                              msgback.dispose if msgback
                                              goldwindow.dispose if goldwindow
                                              facewindow.dispose if facewindow
                                              if haveSpecialClose
                                               pbSEPlay(pbStringToAudioFile(specialCloseSE))
                                               atTop=(msgwindow.y==0)
                                               for i in 0..20
                                                if atTop
                                                 msgwindow.y=-(msgwindow.height*(i)/20)
                                                else
                                                 msgwindow.y=$Graphics_height-(msgwindow.height*(20-i)/20)
                                                end
                                                Graphics.update
                                                Input.update
                                                pbUpdateSceneMap
                                                msgwindow.update
                                               end
                                              end
                                              return ret
                                            end
                                            
                                            def pbFacingTileRegular(direction=nil,event=nil)
                                              event=$game_player if !event
                                              return [0,0,0] if !event
                                              x=event.x
                                              y=event.y
                                              direction=event.direction if !direction
                                              case direction
                                               when 1; y+=1; x-=1
                                               when 2; y+=1
                                               when 3; y+=1; x+=1
                                               when 4; x-=1
                                               when 6; x+=1
                                               when 7; y-=1; x-=1
                                               when 8; y-=1
                                               when 9; y-=1; x+=1
                                              end
                                              return [$game_map ? $game_map.map_id : 0,x,y]
                                            end
                                            
                                            def pbFacingTile(direction=nil,event=nil)
                                             if $MapFactory
                                              return $MapFactory.getFacingTerrainTag(direction,event)
                                             else
                                              return pbFacingTileRegular(direction,event)
                                             end
                                            end
                                            
                                            
                                            
                                            def pbFacingEachOther(event1,event2)
                                             return false if !event1 || !event2
                                             if $MapFactory
                                              tile1=$MapFactory.getFacingTile(nil,event1)
                                              tile2=$MapFactory.getFacingTile(nil,event2)
                                              return false if !tile1 || !tile2
                                              if tile1[0]==event2.map.map_id &&
                                                 tile1[1]==event2.x && tile1[2]==event2.y &&
                                                 tile2[0]==event1.map.map_id &&
                                                 tile2[1]==event1.x && tile2[2]==event1.y
                                               return true
                                              else
                                               return false
                                              end
                                             else
                                              tile1=Kernel.pbFacingTile(nil,event1)
                                              tile2=Kernel.pbFacingTile(nil,event2)
                                              return false if !tile1 || !tile2
                                              if tile1[1]==event2.x && tile1[2]==event2.y &&
                                                 tile2[1]==event1.x && tile2[2]==event1.y
                                               return true
                                              else
                                               return false
                                              end
                                             end
                                            end
                                            
                                            def pbGetTerrainTag(event=nil)
                                             event=$game_player if !event
                                             return 0 if !event
                                             if $MapFactory
                                              return $MapFactory.getTerrainTag(event.map.map_id,event.x,event.y)
                                             else
                                              $game_map.terrain_tag(event.x,event.y)
                                             end
                                            end
                                            
                                            def Kernel.pbFacingTerrainTag
                                             if $MapFactory
                                              return $MapFactory.getFacingTerrainTag
                                             else
                                              return 0 if !$game_player
                                              facing=pbFacingTile()
                                              return $game_map.terrain_tag(facing[1],facing[2])
                                             end
                                            end
                                            
                                            def pbTurnTowardEvent(event,otherEvent)
                                             sx=0
                                             sy=0
                                             if $MapFactory
                                              relativePos=$MapFactory.getThisAndOtherEventRelativePos(otherEvent,event)
                                              sx = relativePos[0]
                                              sy = relativePos[1]
                                             else
                                              sx = event.x - otherEvent.x
                                              sy = event.y - otherEvent.y
                                             end
                                             if sx == 0 and sy == 0
                                               return
                                             end
                                             if sx.abs > sy.abs
                                               sx > 0 ? event.turn_left : event.turn_right
                                             else
                                               sy > 0 ? event.turn_up : event.turn_down
                                             end
                                            end
                                            
                                            def Kernel.pbMoveTowardPlayer(event)
                                              maxsize=[$game_map.width,$game_map.height].max
                                              return if !pbEventCanReachPlayer?(event,$game_player,maxsize)
                                              loop do
                                               x=event.x
                                               y=event.y
                                               event.move_toward_player
                                               break if event.x==x && event.y==y
                                               while event.moving?
                                                Graphics.update
                                                Input.update
                                                pbUpdateSceneMap
                                               end
                                              end
                                              $PokemonMap.addMovedEvent(event.id) if $PokemonMap
                                            end
                                            
                                            def Kernel.pbJumpToward(dist=1,playSound=false)
                                              x=$game_player.x
                                              y=$game_player.y
                                             case $game_player.direction
                                               when 2 # down
                                                  $game_player.jump(0,dist)
                                               when 4 # left
                                                  $game_player.jump(-dist,0)
                                               when 6 # right
                                                  $game_player.jump(dist,0)
                                               when 8 # up
                                                  $game_player.jump(0,-dist)
                                             end
                                             if $game_player.x!=x || $game_player.y!=y
                                              if playSound
                                               pbSEPlay("jump")
                                              end
                                              while $game_player.jumping?
                                               Graphics.update
                                               Input.update
                                               pbUpdateSceneMap
                                              end
                                              return true
                                             end
                                             return false
                                            end
                                            
                                            def pbWait(numframes)
                                             numframes.times do
                                              Graphics.update
                                              Input.update
                                              pbUpdateSceneMap
                                             end
                                            end
                                            
                                            
                                            module PBMoveRoute
                                            Down=1
                                            Left=2
                                            Right=3
                                            Up=4
                                            LowerLeft=5
                                            LowerRight=6
                                            UpperLeft=7
                                            UpperRight=8
                                            Random=9
                                            TowardPlayer=10
                                            AwayFromPlayer=11
                                            Forward=12
                                            Backward=13
                                            Jump=14 # xoffset, yoffset
                                            Wait=15 # frames
                                            TurnDown=16
                                            TurnLeft=17
                                            TurnRight=18
                                            TurnUp=19
                                            TurnRight90=20
                                            TurnLeft90=21
                                            Turn180=22
                                            TurnRightOrLeft90=23
                                            TurnRandom=24
                                            TurnTowardPlayer=25
                                            TurnAwayFromPlayer=26
                                            SwitchOn=27 # 1 param
                                            SwitchOff=28 # 1 param
                                            ChangeSpeed=29 # 1 param
                                            ChangeFreq=30 # 1 param
                                            WalkAnimeOn=31
                                            WalkAnimeOff=32
                                            StepAnimeOn=33
                                            StepAnimeOff=34
                                            DirectionFixOn=35
                                            DirectionFixOff=36
                                            ThroughOn=37
                                            ThroughOff=38
                                            AlwaysOnTopOn=39
                                            AlwaysOnTopOff=40
                                            Graphic=41 # Name, hue, direction, pattern
                                            Opacity=42 # 1 param
                                            Blending=43 # 1 param
                                            PlaySE=44 # 1 param
                                            Script=45 # 1 param
                                            ScriptAsync=101 # 1 param
                                            end
                                            
                                            class Game_Character
                                             def jumpForward
                                              case self.direction
                                              when 2 # down
                                               jump(0,1)
                                              when 4 # left
                                               jump(-1,0)
                                              when 6 # right
                                               jump(1,0)
                                              when 8 # up
                                               jump(0,-1)
                                              end
                                             end
                                             def jumpBackward
                                              case self.direction
                                              when 2 # down
                                               jump(0,-1)
                                              when 4 # left
                                               jump(1,0)
                                              when 6 # right
                                               jump(-1,0)
                                              when 8 # up
                                               jump(0,1)
                                              end
                                             end
                                             def moveLeft90
                                              case self.direction
                                              when 2 # down
                                               move_right
                                              when 4 # left
                                               move_down
                                              when 6 # right
                                               move_up
                                              when 8 # up
                                               move_left
                                              end
                                             end
                                             def moveRight90
                                              case self.direction
                                              when 2 # down
                                               move_left
                                              when 4 # left
                                               move_up
                                              when 6 # right
                                               move_down
                                              when 8 # up
                                               move_right
                                              end
                                             end
                                             def minilock
                                               @[email protected]
                                               @locked=true
                                             end
                                            end
                                            
                                            def pbMoveRoute(event,commands,waitComplete=false)
                                             route=RPG::MoveRoute.new
                                             route.repeat=false
                                             route.skippable=true
                                             route.list.clear
                                             route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOn))
                                             i=0;while i<commands.length
                                              case commands[i]
                                              when PBMoveRoute::Wait, PBMoveRoute::SwitchOn,
                                                PBMoveRoute::SwitchOff, PBMoveRoute::ChangeSpeed,
                                                PBMoveRoute::ChangeFreq, PBMoveRoute::Opacity,
                                                PBMoveRoute::Blending, PBMoveRoute::PlaySE,
                                                PBMoveRoute::Script
                                               route.list.push(RPG::MoveCommand.new(commands[i],
                                                [commands[i+1]]))
                                               i+=1
                                              when PBMoveRoute::ScriptAsync
                                               route.list.push(RPG::MoveCommand.new(PBMoveRoute::Script,
                                                [commands[i+1]]))
                                               route.list.push(RPG::MoveCommand.new(PBMoveRoute::Wait,[0]))
                                               i+=1
                                              when PBMoveRoute::Jump
                                               route.list.push(RPG::MoveCommand.new(commands[i],
                                                [commands[i+1],commands[i+2]]))
                                               i+=2
                                              when PBMoveRoute::Graphic
                                               route.list.push(RPG::MoveCommand.new(commands[i],
                                                [commands[i+1],commands[i+2],commands[i+3],commands[i+4]]))
                                               i+=4
                                              else
                                               route.list.push(RPG::MoveCommand.new(commands[i]))
                                              end
                                              i+=1
                                             end
                                             route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOff))
                                             route.list.push(RPG::MoveCommand.new(0))
                                             if event
                                              event.force_move_route(route)
                                             end
                                             return route
                                            end
                                            
                                            def pbToneChangeAll(tone, duration)
                                                $game_screen.start_tone_change(tone,duration * 2)
                                                for picture in $game_screen.pictures
                                                  picture.start_tone_change(tone,duration * 2) if picture
                                                end
                                            end
                                            
                                            def pbShake(power,speed,frames)
                                             $game_screen.start_shake(power,speed,frames * 2)
                                            end
                                            
                                            def pbFlash(color,frames)
                                             $game_screen.start_flash(color,frames * 2)
                                            end
                                            
                                            def pbScrollMap(direction, distance, speed)
                                             return if !$game_map
                                             if speed==0
                                              case direction
                                               when 2
                                                $game_map.scroll_down(distance * 128)
                                               when 4
                                                $game_map.scroll_left(distance * 128)
                                               when 6
                                                $game_map.scroll_right(distance * 128)
                                               when 8
                                                $game_map.scroll_up(distance * 128)
                                              end
                                             else
                                               $game_map.start_scroll(direction, distance, speed);
                                               oldx=$game_map.display_x
                                               oldy=$game_map.display_y
                                               loop do
                                                Graphics.update
                                                Input.update
                                                if !$game_map.scrolling?
                                                  break
                                                end
                                                pbUpdateSceneMap
                                                if $game_map.display_x==oldx &&
                                                   $game_map.display_y==oldy
                                                  break
                                                end
                                                oldx=$game_map.display_x
                                                oldy=$game_map.display_y 
                                               end
                                             end
                                            end



                                            and make a new script file and just put this in there:

                                            $Graphics_height= 384
                                            __________________
                                            Check out the Pokemon Game Engine I am working on:
                                            https://github.com/sjosegarcia/Pokemon
                                              #22    
                                            Old December 26th, 2010 (2:05 PM). Edited December 26th, 2010 by IceGod64.
                                            IceGod64's Avatar
                                            IceGod64 IceGod64 is offline
                                            In the Lost & Found bin!
                                               
                                              Join Date: Oct 2008
                                              Location: Castelia City
                                              Age: 30
                                              Gender: Male
                                              Nature: Naive
                                              Posts: 627
                                              Quote:
                                              Originally Posted by zingzags View Post
                                              $Graphics_height= 384
                                              Single-screen?
                                              Ice God approves.

                                              However, you mad want to use CODE instead of SPOILER, as the emoticons seem to mess up the copy + paste process.
                                              __________________

                                                #23    
                                              Old December 26th, 2010 (2:09 PM).
                                              venom12's Avatar
                                              venom12 venom12 is offline
                                              Pokemon Crystal Rain Relased
                                                 
                                                Join Date: Sep 2006
                                                Age: 27
                                                Gender: Male
                                                Nature: Adamant
                                                Posts: 529
                                                Tommorow i will work on some updates so check for that, i will try to fix menu.
                                                  #24    
                                                Old December 26th, 2010 (7:03 PM).
                                                Geeked's Avatar
                                                Geeked Geeked is offline
                                                Pokemon Crimson Version
                                                   
                                                  Join Date: Jun 2007
                                                  Age: 24
                                                  Gender: Male
                                                  Nature: Adamant
                                                  Posts: 363
                                                  I'll look for those updates, I really want to use this.
                                                  __________________
                                                  Coming soon I guess?
                                                    #25    
                                                  Old December 27th, 2010 (4:03 PM). Edited December 29th, 2010 by PietroMaker96.
                                                  PietroMaker96's Avatar
                                                  PietroMaker96 PietroMaker96 is offline
                                                  Pokémon: Il Portale del Tempo
                                                     
                                                    Join Date: Aug 2010
                                                    Gender: Male
                                                    Posts: 22
                                                    -resolved-

                                                    pokedex lacking in the balance

                                                    sorry for my English but I am Italian =3
                                                    Closed Thread

                                                    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 1:47 PM.