The PokéCommunity Forums Fan Games Game Development Scripts & Tutorials
Essentials Script PokéCenter Monitor Icons

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


Reply
 
Thread Tools
  #1    
Old April 8th, 2018 (3:10 PM). Edited 3 Weeks Ago by Ulithium_Dragon.
Ulithium_Dragon's Avatar
Ulithium_Dragon Ulithium_Dragon is offline
     
    Join Date: Jul 2015
    Gender: Male
    Nature: Timid
    Posts: 69
    PokéCenter Monitor Icons
    Current Version: v1.2


    *This is fully compatible with mej71's Improved PokeCenters!
    **This script will work with both PE v16.2 and v17+!



    -------
    This script shows your Party Pokemon's icons on the monitor when healing at a PokeCenter. It requires some manual setup, though.

    See the notes at the top of the script for installation and usage instructions!

    [Changelog]:
    Spoiler:

    v1.2:
    - Fixed alt forms not working.
    - Further compatibility checks for both PE v16 and v17+.
    - Some script optimizations.

    v1.1:
    - Fixed compatibility with PE v17+ (sound file name changes).
    - Overhauled the description, instructions, and examples.
    - Documented the code a bit more with relevant comments.

    v1.0:
    - Initial release.


    Script Download (.txt file)

    Script:
    Code:
    #==============================================================================#
    #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#
    #==============================================================================#
    #                           PokeCenter Monitor Icons                           #
    #                                    v1.2                                      #
    #                             By Ulithium_Dragon                               #
    #                                                                              #
    #==============================================================================#
    #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#
    #==============================================================================#
    # Shows your Party Pokemon's icons on the monitor when healing at a PokeCenter.#
    #                                                                              #
    #------------------------------------------------------------------------------#
    #        :::::This script is compatible with both PE v16 and v17:::::          #
    #==============================================================================#
    #                                                                              #
    #------------------------------------------------------------------------------#
    # **Place this script somewhere above Main and below Compiler.                 #
    #------------------------------------------------------------------------------#
    #                                                                              #
    # You will need to set the x and y coordinates to line up with your PokeCenter #
    #  screen manually. Unfortunately the best way to do this is "guess and check".#
    # Example: pbPokemonCenterIcons(240,48)                                        #
    #                                                                              #
    # The third parameter controls the icon's scale. By default, this is 0.45      #
    # because that is the largest I could make them to line up with the stock FrLg #
    # PokeCenter monitor. If your monitors are larger or you'd rather have minor   #
    # clipping instead of icon warping[1], set the scale to 0.5 or anything else.  #
    #                                                                              #
    # Example: pbPokemonCenterIcons(240,48,0.45)                                   #
    #  ^^These values are designed to fit the FrLg screens on PE's example maps.   #
    #                                                                              #
    # [1]The icons will warp a bit if you don't use whole numbers (or 0.5) to scale#
    #    them. I.e. 0.5, 1, 2, 3, etc. should be fine, but 1.25 or 0.75 will warp. #
    #                                                                              #
    #==============================================================================#
    # To use this script in a Pokemon Center, replace is script command in         #
    # the Nurse event with the new pbPokemonCenterIcons function:                  #
    #------------------------------------------------------------------------------#
    #                                                                              #
    #   count=$Trainer.pokemonCount                                                #
    #   for i in 1..count                                                          #
    #     pbSet(6,i)                                                               #
    #     pbSEPlay("ballshake")                                                    #
    #     pbWait(16)                                                               #
    #   end                                                                        #
    #                                                                              #
    # ...Then delete the "Play ME" in the event (this script takes care of that).  #
    # ____________________________________________                                 #
    #                                                                              #
    # Here's an image of how the event would look:                                 #
    #    https://i.imgur.com/F8GKC0v.png                                           #
    # ____________________________________________                                 #
    #                                                                              #
    #==============================================================================#
    # *NOTE: Depending on what version of Pokemon Essentials used, the sound file  #
    #        names may be slightly different (this won't matter, just replace it). #
    #                                                                              #
    #------------------------------------------------------------------------------#
    # *NOTE: If you are using mej71's Improved PokeCenters, there will be two      #
    #        script commands in the Nurse Event, so replace them both!             #
    #                                                                              #
    #------------------------------------------------------------------------------#
    #==============================================================================#
    #//////////////////////////////////////////////////////////////////////////////#
    #==============================================================================#
    
    
    # If you are using mej71's Improved PokeCenters, set this to "true".
    # *NOTE: By default, Improved PokeCenters is included with the Gen 6 Project!
    USING_NEWBALLSYSTEM = false  #Defaut: false
    
    
    
    
    #pbPokemonCenterIcons(240,48,0.45)
    def pbPokemonCenterIcons(xcoord=nil,ycoord=nil,scale=nil)
      height = 0  #The vertical screen coord to display the icons at.
      width = 0   #The horizontal screen coord to display the icons at.
      scale = 0.45 if !scale #Sets the icon size. Default is used if undefined.
      currentIndex = 0
      arrayindex = 0
      totalpkmn = $Trainer.pokemonCount  #Gets and stores the party size.
      pbSet(1,28347)  #Sets temp var 1 to a random number to use in messagebox checks.
      $pkmncentermonitor_soundchecktype = 0  #Global used in sound name checking.
    
    
      # Throws an error if the player has no pokemon yet and escapes to not crash.
      if !defined?($Trainer.party)
        return false
      end
      # Cycles through the party pokemon in order (eggs are skipped).
      # Uses gender, shiny, alt-form, and/or shadow pokemon sprites (if they exist).
      while arrayindex < totalpkmn
        species=$Trainer.party[arrayindex].species
        bitmapFileName=pbPokemonIconFile($Trainer.party[arrayindex])
        bitmap=pbResolveBitmap(bitmapFileName)
        bitmapFileName=BitmapCache.load_bitmap(bitmap)
          # Initializes full Pokemon icon bitmap.
        bitmap=Bitmap.new(bitmapFileName.width,bitmapFileName.height)
        bitmap.blt(0,0,bitmapFileName,Rect.new(0,0,bitmapFileName.width,bitmapFileName.height))
        width=bitmap.height*scale
        height=bitmap.height*scale
        bitmap=Bitmap.new(width,height)
        bitmap.stretch_blt(Rect.new(0,0,width,height),bitmapFileName,Rect.new((width/scale),0,width/scale,height/scale))
        if bitmap
          iconwindow = PictureWindow.new(bitmap)
          # Checks if the coordinates were defined.
          if !xcoord && !ycoord  #If undefined, use the center of the screen instead.
            iconwindow.x=(Graphics.width/2)-(iconwindow.width/2)
            iconwindow.y=((Graphics.height-96)/2)-(iconwindow.height/2)
          else
            iconwindow.x=xcoord
            iconwindow.y=ycoord
          end
          # Safeguard checks. Makes sure neither of the coordinates are undefined.
          if !xcoord
            iconwindow.x=(Graphics.width/2)-(iconwindow.width/2)
          elsif !ycoord
            iconwindow.y=((Graphics.height-96)/2)-(iconwindow.height/2)
          end
          $pkmncentermonitor_soundchecktype = 1
          if USING_NEWBALLSYSTEM  #New Ball System
            pbSet(6,pbGet(6)+1)
            pbPCMIGetSoundTypes
            if arrayindex < totalpkmn-1
              pbWait(16)
              iconwindow.dispose
            else
              pbWait(6)
            end
          else #Original Ball System
            pbSet(6,pbGet(6)+1)
            pbPCMIGetSoundTypes
            pbWait(16)
            iconwindow.dispose
          end
        end
        arrayindex = arrayindex+1
      end
      $pkmncentermonitor_soundchecktype = 2
      pbPCMIGetSoundTypes
      pbWait(4)
      iconwindow.dispose
      pbSet(1,false)
    end
    
    
    
    
    def pbPCMIGetSoundTypes
      # Since PE v17 changed a lot of the sound effect names, I use
      #  the "Sprite_SurfBase" added in v17 as a version check.
      if $pkmncentermonitor_soundchecktype == 1
        if defined?(Sprite_SurfBase)  #PE v17
          pbSEPlay("Battle ball shake")
        else    #PE v16
          pbSEPlay("ballshake")
        end
        $pkmncentermonitor_soundchecktype = 0
      elsif $pkmncentermonitor_soundchecktype == 2
        if defined?(Sprite_SurfBase)  #PE v17
          pbMEPlay("Pkmn healing",100,100)
        else    #PE v16
          pbMEPlay("Pokemon Healing",100,100)
        end
        $pkmncentermonitor_soundchecktype = 0
      end
      $pkmncentermonitor_soundchecktype = 0 #Redundancy catch.
    end
    
    
    #==============================================================================#
    #     Utilities                                                                #
    #==============================================================================#
    # *Overwrites the base function to removes the windowbox bg for this script.
    class SpriteWindow_Base < SpriteWindow
      TEXTPADDING=4 # In pixels
    
    
      def initialize(x, y, width, height)
        super()
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.z = 100
        @curframe=MessageConfig.pbGetSystemFrame()
        @curfont=MessageConfig.pbGetSystemFontName()
        @sysframe=AnimatedBitmap.new(@curframe)
        @customskin=nil
        __setWindowskin(@sysframe.bitmap)
        __resolveSystemFrame()
        pbSetSystemFont(self.contents) if self.contents
      end
    
    
      def __setWindowskin(skin)
        if pbGet(1) != 28347  #Random number so it can't be in use by something else.
          if skin && (skin.width==192 && skin.height==128) ||  # RPGXP Windowskin
                     (skin.width==128 && skin.height==128)     # RPGVX Windowskin
            self.skinformat=0
          else
            self.skinformat=1
          end
          self.windowskin=skin
        end
      end
    
    
      def __resolveSystemFrame
        if self.skinformat==1
          if [email protected]
            @resolvedFrame=MessageConfig.pbGetSystemFrame()
            @resolvedFrame.sub!(/\.[^\.\/\\]+$/,"")
          end
          self.loadSkinFile("#{@resolvedFrame}.txt") if @resolvedFrame!=""
        end
      end
    
    
      def setSkin(skin) # Filename of windowskin to apply. Supports XP, VX, and animated skins.
        @customskin.dispose if @customskin
        @customskin=nil
        resolvedName=pbResolveBitmap(skin)
        return if !resolvedName || resolvedName==""
        @customskin=AnimatedBitmap.new(resolvedName)
        __setWindowskin(@customskin.bitmap)
        if self.skinformat==1
          skinbase=resolvedName.sub(/\.[^\.\/\\]+$/,"")
          self.loadSkinFile("#{skinbase}.txt")
        end
      end
    
    
      def setSystemFrame
        @customskin.dispose if @customskin
        @customskin=nil
        __setWindowskin(@sysframe.bitmap)
        __resolveSystemFrame()
      end
    
    
      def update
        super
        if self.windowskin
          if @customskin
            if @customskin.totalFrames>1
              @customskin.update
              __setWindowskin(@customskin.bitmap)
            end
          elsif @sysframe
            if @sysframe.totalFrames>1
              @sysframe.update
              __setWindowskin(@sysframe.bitmap)
            end
          end
        end
        if @curframe!=MessageConfig.pbGetSystemFrame()
          @curframe=MessageConfig.pbGetSystemFrame()
          if @sysframe && [email protected]
            @sysframe.dispose if @sysframe
            @sysframe=AnimatedBitmap.new(@curframe)
            @resolvedFrame=nil
            __setWindowskin(@sysframe.bitmap)
            __resolveSystemFrame()   
          end
          begin
            refresh
          rescue NoMethodError
          end
        end
        if @curfont!=MessageConfig.pbGetSystemFontName()
          @curfont=MessageConfig.pbGetSystemFontName()
          if self.contents && !self.contents.disposed?
            pbSetSystemFont(self.contents)
          end
          begin
            refresh
          rescue NoMethodError
          end
        end
      end
    
    
      def dispose
        self.contents.dispose if self.contents
        @sysframe.dispose
        @customskin.dispose if @customskin
        super
      end
    end
    #==============================================================================#
    #//////////////////////////////////////////////////////////////////////////////#
    #==============================================================================#
    __________________
    PokéMounts Warp Tile Animation Tutorial Fall Down Hole Animation Tutorial
    Reply With Quote

    Relevant Advertising!

      #2    
    Old April 8th, 2018 (8:15 PM).
    Diegou18 Diegou18 is offline
       
      Join Date: Mar 2018
      Posts: 14
      Excuse me, but can you send a image with this script in the Nurse Event? I tried to do by myself, but I don't know what I did wrong.
      Reply With Quote
        #3    
      Old April 8th, 2018 (8:17 PM).
      Ulithium_Dragon's Avatar
      Ulithium_Dragon Ulithium_Dragon is offline
         
        Join Date: Jul 2015
        Gender: Male
        Nature: Timid
        Posts: 69
        Quote:
        Originally Posted by Diegou18 View Post
        Excuse me, but can you send a image with this script in the Nurse Event? I tried to do by myself, but I don't know what I did wrong.
        Sure:
        Spoiler:


        __________________
        PokéMounts Warp Tile Animation Tutorial Fall Down Hole Animation Tutorial
        Reply With Quote
          #4    
        Old April 8th, 2018 (8:38 PM).
        Diegou18 Diegou18 is offline
           
          Join Date: Mar 2018
          Posts: 14
          Thank you so much. I only have one question: how can I "activate" the light in the screen? I can see that you put a Switch (525). Where I can configure it?
          Sorry for my english.
          Reply With Quote
            #5    
          Old April 8th, 2018 (8:44 PM). Edited 2 Weeks Ago by Ulithium_Dragon.
          Ulithium_Dragon's Avatar
          Ulithium_Dragon Ulithium_Dragon is offline
             
            Join Date: Jul 2015
            Gender: Male
            Nature: Timid
            Posts: 69
            Quote:
            Originally Posted by Diegou18 View Post
            Thank you so much. I only have one question: how can I "activate" the light in the screen? I can see that you put a Switch (525). Where I can configure it?
            Sorry for my english.
            The light on the screen was not something covered by this resource. It's something I added myself using events and custom graphics.

            Spoiler:



            Spoiler:



            EDIT: Forgot to say, I created a global switch and enable/disable it in the Nurse Joy event where I want the screen to flash.
            __________________
            PokéMounts Warp Tile Animation Tutorial Fall Down Hole Animation Tutorial
            Reply With Quote
              #6    
            Old April 8th, 2018 (9:09 PM).
            Diegou18 Diegou18 is offline
               
              Join Date: Mar 2018
              Posts: 14
              Wow, it really improved my game. I think that details can make the difference, and your icon's script with the light on the screen did it. You're awesome. Thanks.
              Reply With Quote
                #7    
              Old 3 Weeks Ago (9:36 AM).
              Ulithium_Dragon's Avatar
              Ulithium_Dragon Ulithium_Dragon is offline
                 
                Join Date: Jul 2015
                Gender: Male
                Nature: Timid
                Posts: 69
                Update posted:

                v1.1:
                - Fixed compatibility with PE v17+ (sound file name changes).
                - Overhauled the description, instructions, and examples.
                - Documented the code a bit more with relevant comments.
                __________________
                PokéMounts Warp Tile Animation Tutorial Fall Down Hole Animation Tutorial
                Reply With Quote
                  #8    
                Old 3 Weeks Ago (3:28 PM).
                Ulithium_Dragon's Avatar
                Ulithium_Dragon Ulithium_Dragon is offline
                   
                  Join Date: Jul 2015
                  Gender: Male
                  Nature: Timid
                  Posts: 69
                  Update posted:

                  v1.2:
                  - Fixed alt forms not working.
                  - Further compatibility checks for both PE v16 and v17+.
                  - Some script optimizations.
                  __________________
                  PokéMounts Warp Tile Animation Tutorial Fall Down Hole Animation Tutorial
                  Reply With Quote
                  Reply

                  Quick Reply

                  Join the conversation!

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

                  Create a PokéCommunity Account

                  Sponsored Links
                  Thread Tools

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

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

                  Forum Jump


                  All times are GMT -8. The time now is 4:20 PM.