The PokéCommunity Forums Fan Games Game Development Scripts & Tutorials
Essentials Script Battle Points

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 January 2nd, 2015 (10:21 AM). Edited January 3rd, 2015 by SunakazeKun.
SunakazeKun's Avatar
SunakazeKun SunakazeKun is offline
SunakazeKun | Aurum
     
    Join Date: Dec 2014
    Location: Germany
    Gender: Male
    Posts: 18
    This works like Coins used for Slot machines. Currently I'm working on the Message Box that shows the amount of Battle Points while talking to an NPC. The amount is stored in $PokemonGlobal.bpoints. Don't forget to credit me!

    New Script:
    Code:
    #===============================================================================
    # * Battle Points by Aurum / SunakazeKun
    #===============================================================================
    # * Global Metadata
    #===============================================================================
    class PokemonGlobalMetadata
      attr_accessor :bpoints
      def initialize
        @bpoints = 0
      end
    end
    
    #===============================================================================
    # * Point Card Item
    #===============================================================================
    ItemHandlers::UseFromBag.add(:POINTCARD,proc{|item|
       Kernel.pbMessage(_INTL("Battle Points:\n{1}",$PokemonGlobal.bpoints))
       next 1 # Continue
    })
    
    ItemHandlers::UseInField.add(:POINTCARD,proc{|item|
       Kernel.pbMessage(_INTL("Battle Points:\n{1}",$PokemonGlobal.bpoints))
       next 1 # Continue
    })
    Settings
    Put this under the line MAXCOINS = 99999.
    Code:
    MAXBPOINTS   = 99999
    PokemonDebug
    Put this under the line commands.add("setcoins",_INTL("Set Coins")).
    Code:
      commands.add("setbpoints",_INTL("Set Battle Points"))
    Put this under the line Kernel.pbMessage(_INTL("You now have {1} Coins.",$PokemonGlobal.coins)).
    Code:
        elsif cmd=="setbpoints"
          params=ChooseNumberParams.new
          params.setRange(0,MAXBPOINTS)
          params.setDefaultValue($PokemonGlobal.bpoints)
          $PokemonGlobal.bpoints=Kernel.pbMessageChooseNumber(
             _INTL("Set the player's Battle Point amount."),params)
          Kernel.pbMessage(_INTL("You now have {1} Battle Points.",$PokemonGlobal.bpoints))
    Reply With Quote

    Relevant Advertising!

      #2    
    Old January 7th, 2015 (9:43 AM).
    ShadowFiendZX's Avatar
    ShadowFiendZX ShadowFiendZX is offline
    Gym Leader
       
      Join Date: Jan 2013
      Location: Hamden Connecticut
      Age: 21
      Gender: Male
      Nature: Serious
      Posts: 59
      Nice script. By "message box" do you mean you want the NPC to tell you how many points you have?
      If so, you can go in the event and input a script that says

      Code:
      pbSet(1,$PokemonGlobal.bpoints)
      Then the NPC can say
      "You have \v[1] Battle Points."

      Unless you meant that you were going to create a gui that shows it, which is a bit more complicated but shouldn't be too difficult since it'll just show the amount of points. I could lead you in the right direction for that if you'd like a bit of help. Or rather, once I get home from school anyway.
      __________________
      BEHOLD THE FLOPPY MAGIKARP IN ALL ITS GLORY AND WISDOM

      Reply With Quote
        #3    
      Old January 7th, 2015 (11:03 AM).
      SunakazeKun's Avatar
      SunakazeKun SunakazeKun is offline
      SunakazeKun | Aurum
         
        Join Date: Dec 2014
        Location: Germany
        Gender: Male
        Posts: 18
        Yeah, I was talking about the GUI thing.
        __________________
        I'm from Germany, so please excuse my bad English ;)
        Reply With Quote
          #4    
        Old January 9th, 2015 (11:24 AM). Edited January 9th, 2015 by ShadowFiendZX.
        ShadowFiendZX's Avatar
        ShadowFiendZX ShadowFiendZX is offline
        Gym Leader
           
          Join Date: Jan 2013
          Location: Hamden Connecticut
          Age: 21
          Gender: Male
          Nature: Serious
          Posts: 59
          Quote:
          Originally Posted by SunakazeKun View Post
          Yeah, I was talking about the GUI thing.
          This should work, I haven't tested it, so there might be an error or two.

          Code:
          class BattlePointCardScene
            def update
              pbUpdateSpriteHash(@sprites)
            end
          
            def pbStartScene
              @sprites={}
              @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
              @viewport.z=99999
              background=pbResolveBitmap(sprintf("Graphics/Pictures/trainercardbgf"))
              if $Trainer.gender==1 && background
                addBackgroundPlane(@sprites,"bg","trainercardbgf",@viewport)
              else
                addBackgroundPlane(@sprites,"bg","trainercardbg",@viewport)
              end
              cardexists=pbResolveBitmap(sprintf("Graphics/Pictures/BPcardf"))
              @sprites["card"]=IconSprite.new(0,0,@viewport)
              if $Trainer.gender==1 && cardexists
                @sprites["card"].setBitmap("Graphics/Pictures/BPcardf")
              else
                @sprites["card"].setBitmap("Graphics/Pictures/BPcard")
              end
              @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
             
              pbSetSystemFont(@sprites["overlay"].bitmap)
              pbDrawBattlePointCardFront
              pbFadeInAndShow(@sprites) { update }
            end
          
            def pbDrawBattlePointCardFront
              [email protected]["overlay"].bitmap
              overlay.clear
              points=$PokemonGlobal.bpoints
              pointtext=_ISPRINTF("{1}",points)
              baseColor=Color.new(72,72,72)
              shadowColor=Color.new(160,160,160)
              textPositions=[
                 [_INTL("Battle Points"),34,64,0,baseColor,shadowColor],
                 [pointtext,302,64,1,baseColor,shadowColor]
              ]
              pbDrawTextPositions(overlay,textPositions)
            end
          
            def pbBattlePointCard
              loop do
                Graphics.update
                Input.update
                self.update
                   if Input.trigger?(Input::B)
                    pbEndScene
                    break
                    end
              end 
            end
          
            
            def pbEndScene
              pbFadeOutAndHide(@sprites) { update }
              pbDisposeSpriteHash(@sprites)
              @viewport.dispose
            end
          end
          
          
          
          class PokemonBattlePointCard
            def initialize(scene)
              @scene=scene
            end
          
            def pbStartScreen
              @scene.pbStartScene
              @scene.pbBattlePointCard
              @scene.pbEndScene
            end
          end
          Just insert that into a new script above main

          I'm pretty sure you call it like this

          Code:
           scene=BattlePointCardScene.new
                     screen=BattlePointCardScene.new(scene)
                     pbFadeOutIn(99999) { 
                        screen.pbStartScreen
                     }
          And put these images into the pictures folder
          Attached Thumbnails
          BPcard.png‎   BPcardf.png‎  
          __________________
          BEHOLD THE FLOPPY MAGIKARP IN ALL ITS GLORY AND WISDOM

          Reply With Quote
            #5    
          Old January 13th, 2015 (5:01 PM).
          Skystrike's Avatar
          Skystrike Skystrike is online now
          If I recall it was you, you wished for me to stay
           
          Join Date: Sep 2008
          Location: Beyond the Sky
          Gender: Male
          Nature: Quiet
          Posts: 1,548
          In PokemonMessages, under line 1484, copy paste this:

          Code:
          elsif control=="bp" # Display BP Windw
          bpwindow.dispose if bpwindow
          bpwindow=pbDisplayBPWindow(msgwindow,goldwindow)
          PokemonMessages, after the def "pbShowCoinsWindow"

          Code:
          def pbDisplayBPWindow(msgwindow,goldwindow) #EDIT
            bpString=($PokemonGlobal) ? $PokemonGlobal.bpoints : "0"
            bpwindow=Window_AdvancedTextPokemon.new(_INTL("Battle Points:\n<ar>{1}</ar>",bpString))
            bpwindow.setSkin("Graphics/Windowskins/goldskin")
            bpwindow.resizeToFit(bpwindow.text,Graphics.width)
            bpwindow.width=160 if bpwindow.width<=160
            if msgwindow.y==0
              bpwindow.y=(goldwindow) ? goldwindow.y-bpwindow.height : Graphics.height-bpwindow.height
            else
              bpwindow.y=(goldwindow) ? goldwindow.height : 0
            end
            bpwindow.viewport=msgwindow.viewport
            bpwindow.z=msgwindow.z
            return coinwindow
          end
          now you can show BP like you would show coins by using /BP
          __________________

          Garchomp, the Mach Pokémon
          Reply With Quote
            #6    
          Old January 13th, 2015 (5:10 PM).
          mej71's Avatar
          mej71 mej71 is offline
             
            Join Date: Mar 2014
            Location: Omnipresence
            Gender: Male
            Posts: 1,226
            Quote:
            Originally Posted by Air Lock View Post
            In PokemonMessages, under line 1484, copy paste this:

            Code:
            elsif control=="bp" # Display BP Windw
            bpwindow.dispose if bpwindow
            bpwindow=pbDisplayBPWindow(msgwindow,goldwindow)
            PokemonMessages, after the def "pbShowCoinsWindow"

            Code:
            def pbDisplayBPWindow(msgwindow,goldwindow) #EDIT
              bpString=($PokemonGlobal) ? $PokemonGlobal.bpoints : "0"
              bpwindow=Window_AdvancedTextPokemon.new(_INTL("Battle Points:\n<ar>{1}</ar>",bpString))
              bpwindow.setSkin("Graphics/Windowskins/goldskin")
              bpwindow.resizeToFit(bpwindow.text,Graphics.width)
              bpwindow.width=160 if bpwindow.width<=160
              if msgwindow.y==0
                bpwindow.y=(goldwindow) ? goldwindow.y-bpwindow.height : Graphics.height-bpwindow.height
              else
                bpwindow.y=(goldwindow) ? goldwindow.height : 0
              end
              bpwindow.viewport=msgwindow.viewport
              bpwindow.z=msgwindow.z
              return coinwindow
            end
            now you can show BP like you would show coins by using /BP
            Code:
            elsif control=="bp" # Display BP Windw
            this won't do anything by itself, you have to add it to this
            Code:
              while text[/(?:\\([WwFf]|[Ff][Ff]|[Tt][Ss]|[Cc][Ll]|[Mm][Ee]|[Ss][Ee]|[Ww][Tt]|[Ww][Tt][Nn][Pp]|[Cc][Hh])\[([^\]]*)\]|\\([Gg]|[Cc][Nn]|[Ww][Dd]|[Ww][Mm]|[Oo][Pp]|[Cc][Ll]|[Bb][Pp]|[Ww][Uu]|[\.]|[\|]|[\!]|[\x5E])())/i]
            though I already PM'd SunakazeKun how to do this a bit ago, I'm surprised there hasn't been an update.
            Reply With Quote
              #7    
            Old January 13th, 2015 (5:19 PM).
            Skystrike's Avatar
            Skystrike Skystrike is online now
            If I recall it was you, you wished for me to stay
             
            Join Date: Sep 2008
            Location: Beyond the Sky
            Gender: Male
            Nature: Quiet
            Posts: 1,548
            Quote:
            Originally Posted by mej71 View Post
            Code:
            elsif control=="bp" # Display BP Windw
            this won't do anything by itself, you have to add it to this
            Code:
              while text[/(?:\\([WwFf]|[Ff][Ff]|[Tt][Ss]|[Cc][Ll]|[Mm][Ee]|[Ss][Ee]|[Ww][Tt]|[Ww][Tt][Nn][Pp]|[Cc][Hh])\[([^\]]*)\]|\\([Gg]|[Cc][Nn]|[Ww][Dd]|[Ww][Mm]|[Oo][Pp]|[Cc][Ll]|[Bb][Pp]|[Ww][Uu]|[\.]|[\|]|[\!]|[\x5E])())/i]
            though I already PM'd SunakazeKun how to do this a bit ago, I'm surprised there hasn't been an update.
            oops haha, I thought I was missing something.
            __________________

            Garchomp, the Mach Pokémon
            Reply With Quote
              #8    
            Old March 21st, 2015 (4:59 AM).
            Richard PT's Avatar
            Richard PT Richard PT is online now
               
              Join Date: Aug 2014
              Location: Portugal
              Gender: Male
              Nature: Calm
              Posts: 106
              I have a question? How can make an npc to give you bpoints? And How to spent bpoints to buy things? I copy the npc coins events and turned into bpoints but i have errors, so how can i make this.
              __________________
              Reply With Quote
                #9    
              Old March 22nd, 2015 (3:40 AM).
              FL's Avatar
              FL FL is offline
              Pokémon Island Creator
                 
                Join Date: Sep 2010
                Gender: Male
                Posts: 1,750
                Quote:
                Originally Posted by Richard PT View Post
                I have a question? How can make an npc to give you bpoints? And How to spent bpoints to buy things? I copy the npc coins events and turned into bpoints but i have errors, so how can i make this.
                'points' is the point number. You probably check the existence of POINTCARD. Call one of these scripts:

                Adding points clamping: '$PokemonGlobal.bpoints=[$PokemonGlobal.bpoints+points,MAXBPOINTS].min'.
                Adding points without clamping: '$PokemonGlobal.bpoints+=points'.
                Removing points clamping: '$PokemonGlobal.bpoints=[$PokemonGlobal.bpoints-points,0].max'.
                Removing points without clamping: '$PokemonGlobal.bpoints-=points'.
                __________________
                Reply With Quote
                  #10    
                Old June 17th, 2015 (10:18 AM).
                Richard PT's Avatar
                Richard PT Richard PT is online now
                   
                  Join Date: Aug 2014
                  Location: Portugal
                  Gender: Male
                  Nature: Calm
                  Posts: 106
                  Can you post here all pieces of code of COINs? Because bpoints are causing some odd errors, and i think its something missing, i follow all the steps and i've got this issues:

                  1- when using point card it shows this text - "Battle points: " I can't see if i get bpoints when i receive them. note: im using the FL pieces of code for an event, like coins.

                  2- Same prizes man from essentials but with bpoints.
                  example: the npc must detect if you have enough bpoints to buy an item and if not you can't buy it.

                  My game has events with coins and it works all fine but with bpoints not. So, please post here all pieces of code using by COINS, so i can copy that pieces of code and change that for bpoints to see what happens. Or post all the script coins.
                  Reply With Quote
                    #11    
                  Old September 6th, 2015 (5:33 AM).
                  Richard PT's Avatar
                  Richard PT Richard PT is online now
                     
                    Join Date: Aug 2014
                    Location: Portugal
                    Gender: Male
                    Nature: Calm
                    Posts: 106
                    After a few tests i found this error:

                    The code in Debug always makes game to crash.

                    And when a npc gives bpoints to player, i have this error:



                    How can i fix this?
                    Reply With Quote
                      #12    
                    Old January 25th, 2018 (5:25 PM).
                    averyindahouse's Avatar
                    averyindahouse averyindahouse is offline
                    Creator of Pokemon Sigma (Coming Soon)
                       
                      Join Date: Jan 2015
                      Location: Somewhere in California I think...
                      Gender: Male
                      Posts: 41
                      Sorry for bumping a three year old thread... but I REALLY want to use this custom script in my game. However, I am under the impression that this code is severely out of date considering it is now 2018, and I can see that the areas where this code is implemented have been modified.

                      Is there an updated version of these scripts that currently work with Essentials 17.2. Because upon adding Battle Points to the player's total using the command $PokemonGlobal.bpoints+= xxx, (xxx is a number), the game crashes and I get this:
                      https://gyazo.com/5446bbbebc27be046914164b0e05d9c0https://gyazo.com/5446bbbebc27be046914164b0e05d9c0
                      Reply With Quote
                        #13    
                      Old January 25th, 2018 (10:42 PM). Edited January 26th, 2018 by Marin.
                      Marin's Avatar
                      Marin Marin is online now
                      Not Bored
                       
                      Join Date: Nov 2016
                      Age: 15
                      Gender: Other
                      Posts: 648
                      Quote:
                      Originally Posted by averyindahouse View Post
                      Sorry for bumping a three year old thread... but I REALLY want to use this custom script in my game. However, I am under the impression that this code is severely out of date considering it is now 2018, and I can see that the areas where this code is implemented have been modified.

                      Is there an updated version of these scripts that currently work with Essentials 17.2. Because upon adding Battle Points to the player's total using the command $PokemonGlobal.bpoints+= xxx, (xxx is a number), the game crashes and I get this:
                      https://gyazo.com/5446bbbebc27be046914164b0e05d9c0https://gyazo.com/5446bbbebc27be046914164b0e05d9c0
                      You’re using an existing save file, which isn’t compatible. You could either restart or do the following:

                      1.) Take out the PokemonGlobalMetadata part (his first step)
                      2.) Add the following:
                      Code:
                      class PokemonGlobalMetadata
                        attr_writer :bpoints
                      
                        def bpoints
                          @bpoints ||= 0
                          return @bpoints
                        end
                      end
                      Reply With Quote
                        #14    
                      Old January 26th, 2018 (7:56 PM).
                      averyindahouse's Avatar
                      averyindahouse averyindahouse is offline
                      Creator of Pokemon Sigma (Coming Soon)
                         
                        Join Date: Jan 2015
                        Location: Somewhere in California I think...
                        Gender: Male
                        Posts: 41
                        Quote:
                        Originally Posted by Marin View Post
                        You’re using an existing save file, which isn’t compatible. You could either restart or do the following:

                        1.) Take out the PokemonGlobalMetadata part (his first step)
                        2.) Add the following:
                        Code:
                        class PokemonGlobalMetadata
                          attr_writer :bpoints
                        
                          def bpoints
                            @bpoints ||= 0
                            return @bpoints
                          end
                        end
                        This worked perfectly! Thank you :)
                        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 3:26 AM.