• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Battle Points

SunakazeKun

SunakazeKun | Aurum
30
Posts
9
Years
  • 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))
     
    Last edited:

    ShadowFiendZX

    Gym Leader
    59
    Posts
    11
    Years
  • 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.
     

    ShadowFiendZX

    Gym Leader
    59
    Posts
    11
    Years
  • 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
        overlay=@sprites["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
     
    Last edited:

    Skystrike

    [i]As old as time itself.[/i]
    1,641
    Posts
    15
    Years
  • 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
     
    1,224
    Posts
    10
    Years
  • 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]|[COLOR="Red"][Bb][Pp]|[/COLOR][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.
     

    Skystrike

    [i]As old as time itself.[/i]
    1,641
    Posts
    15
    Years
  • 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]|[COLOR=Red][Bb][Pp]|[/COLOR][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.
     
    220
    Posts
    9
    Years
  • 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.
     

    FL

    Pokémon Island Creator
    2,449
    Posts
    13
    Years
    • Seen today
    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'.
     
    220
    Posts
    9
    Years
  • 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.
     
    220
    Posts
    9
    Years
  • 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:

    bp_err10.png


    How can i fix this?
     

    averyindahouse

    Creator of Pokemon Sigma (Coming Soon)
    41
    Posts
    9
    Years
  • 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
     
    971
    Posts
    7
    Years
    • Age 21
    • Seen Nov 28, 2022
    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
     
    Last edited:

    averyindahouse

    Creator of Pokemon Sigma (Coming Soon)
    41
    Posts
    9
    Years
  • 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 :)
     
    Back
    Top