The PokéCommunity Forums Fan Games Game Development Scripts & Tutorials
Essentials Script How to set up O Powers

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 3 Weeks Ago (1:30 PM). Edited 2 Weeks Ago by samukomini.
samukomini samukomini is offline
     
    Join Date: Sep 2018
    Location: Spain
    Gender: Male
    Nature: Calm
    Posts: 7
    Hi! I'm learning programming and I joined this community because I wanted to share some scripts I did (and I think they are pretty well).

    I'm gonna give you some instructions to set up the 6th generation powers that you have. They have several functions: boost your team in battles, increase the gained money, speed up your egg hatching and pokemon growth... In the original games, using this consumes some "energy", which is restored when you close your DS and start walking.

    Obviously, it's difficult to walk if you are playing your fan game in your desktop XD, so I created this code adapted to the Essentials scripts. This is how the O Powers works with this script:
    • The O Power menu is in a button of Pokegear, and it is visible when you receive your first O Power level.
    • The O Power data is stored in the global variable $PokemonGlobal (object of PokemonGlobalMetadata)
    • The power energy is shown like a bar and fills up each 6400 steps (5% each 128)
    • The effect of O Power dissapear in the specified minutes (3 by default) and a message is shown to let you know.

    Here is the script you need. Put it above main to make it work.
    Spoiler:
    Code:
    #=======================================
    #     O-Powers. Created by Samukomini
    #     Credit wanted but not required.
    #=======================================
    
    module OPowers
      ATTACK    = 0
      DEFENSE   = 1
      CATCH     = 2
      HP_HEAL   = 3
      PP_HEAL   = 4
      REWARD    = 5
      CRITICAL  = 6
      HAPPINESS = 7
      DISCOUNT  = 8
      ENCOUNTER = 9
      REPEL     = 10
      INCUBATION = 11
      EXP_GAIN  = 12
      IV        = 13
      
      def self.names
        return ["Attack","Defense","Capture","HP Restore","PP Restore",
                "Reward","Critical","Happiness","Discount","Encounter",
                "Repel","Incubation","Experience Points","Individual Values"]
      end
    
      def self.descriptions
        return [
          "Boost the attack of your leading Pokémon in the next battle.",
          "Boost the attack of your leading Pokémon in the next battle.",
          "Raise the probability of catching a Pokémon.",
          "Restore your team health.",
          "Restore your team moves PPs.",
          "Raise the money you steal the trainers you win.",
          "Raise the critical hit ratio in battle.",
          "Boost the happiness your Pokémon win.",
          "Cut the prices on products in Pokémon Mart.",
          "Raise the probability of encountering a wild Pokémon.",
          "Reduce the probability of encountering a wild Pokémon.",
          "Speed up your egg hatching.",
          "Boost the experience points earned by your Pokémon.",
          "Wild Pokémon will boost their Individual Values."
        ]
      end
    
      def self.costs(level) # Over 100
        case level
        when 1
          return [10,10,20,10,20,15,15,15,20,10,15,20,25,25]
        when 2
          return [20,20,30,20,30,30,25,25,40,20,30,30,35,35]
        when 3
          return [30,30,40,30,40,45,40,35,60,30,40,40,50,50]
        end
        raise ArgumentError.new("Undefined cost for level: #{level}")
      end
    
      def self.instant?(power)
        return [ATTACK,DEFENSE,HP_HEAL,PP_HEAL].include?(getID(self,power))
      end
              
      def self.length; self.constants.length; end
    
      def self.getByName(name)
        for i in 0...length
          return i if names[i] == name
        end
        return -1
      end
    end
    
    class PokemonGlobalMetadata
      attr_reader   :oplevels
      attr_accessor :opower_data
      attr_reader   :openergy
      
      alias old_initialize initialize
      
      def initialize
        old_initialize
        @oplevels = []
        @opower_data = Array.new(OPowers.length) { nil }
        @openergy = 100
      end
    
      def opLevelUp(op,level=nil)
        if @oplevels.empty?
          @oplevels = Array.new(OPowers.length) {0}
        end
        op = getID(OPowers,op)
        if level
          @oplevels[op] = level
        else
          @oplevels[op] += 1
        end
      end
    
      def openergy=(val)
        @openergy = val
        @openergy = 0 if @openergy < 0
        @openergy = 100 if @openergy > 100
      end
    end
    
    class Scene_Map
      alias op_update update
    
      def update
        op_update
        update_opower
      end
    
      def update_opower
        for i in 0...$PokemonGlobal.opower_data.length
          data = $PokemonGlobal.opower_data[i]
          next if OPowers.instant?(i) || !data
          if Time.now.to_i > data[1].to_i + data[2] # Time expired
            Kernel.pbMessage(_INTL("The effect of  {1} O-Power finished.",OPowers.names[i]))
            $PokemonGlobal.opower_data[i] = nil
          end
        end
      end
    end
    
    ## Launch a power. Return if it has been succesfully launched.
    def pbLaunchOPower(opower,level,consume=true,time=3,showmessage=true,effects=true)
      opower = getID(OPowers,opower)
      if consume || ($DEBUG && Input.press?(Input::CTRL))
        if OPowers.costs(level)[opower] > $PokemonGlobal.openergy # Not enough energy
          Kernel.pbMessage("There isn't enough energy to launch this power.") if showmessage
          return false
        end
        $PokemonGlobal.openergy -= OPowers.costs(level)[opower]
      end
      if effects
        pbSEPlay("o_power")
        pbFadeOutIn2(255,255,255) {yield if block_given?}
      end
      Kernel.pbMessage(_INTL("You have activated {1} O-Power - Level {2}.",
          OPowers.names[opower],level.to_s)) if showmessage
      $PokemonGlobal.opower_data[opower] = [level,Time.now,(time*60).floor] # Time not needed for instant O-Powers
      ## Repel replaces Encounter and vice versa
      if isConst?(opower,OPowers,:ENCOUNTER)
        $PokemonGlobal.opower_data[OPowers::REPEL] = nil
      elsif isConst?(opower,OPowers,:REPEL)
        $PokemonGlobal.opower_data[OPowers::ENCOUNTER] = nil
      end
      if OPowers.instant?(opower)
        if isConst?(opower,OPowers,:HP_HEAL)
          case level
          when 1; prop = 1.0/3.0
          when 2; prop = 0.5
          when 3; prop = 2.0/3.0
          else; prop = 1
          end
          for i in $Trainer.party
            pbItemRestoreHP(i,(i.totalhp*prop).round)
          end
          $PokemonGlobal.opower_data[opower] = nil
        elsif isConst?(opower,OPowers,:PP_HEAL)
          case level
          when 1; restore = 5
          when 2; restore = 10
          when 3; restore = 15
          else; restore = 40
          end
          for i in $Trainer.party
            for j in 0...i.moves.length
              pbRestorePP(i,j,restore)
            end
          end
          $PokemonGlobal.opower_data[opower] = nil
        end
      end
    end
    
    Events.onStepTaken += proc {
      if $PokemonGlobal.happinessSteps==0
        # Done each 128 steps. See this Event in PField_Field section.
        $PokemonGlobal.openergy += 5
        # O Power energy would be full restored in 6400 steps
      end
    }
    
    Events.onWildPokemonCreate += proc {|s,e|
      pokemon = e[0]
      o = $PokemonGlobal.opower_data[OPowers::IV]
      if o
        case o[0]
        when 1; mod = rand(2) + 1
        when 2; mod = rand(3) + 2
        when 3; mod = rand(4) + 3
        else; mod = 6
        end
        ivs = randomAry(mod,pokemon.iv.length) # Random indexes of modifying ivs
        for i in ivs
          pokemon.iv[i] = 31
        end
        pokemon.calcStats
      end
    }
    
    class Scene_OPowers
      def start
        # => Prepare
        @sprites = {}
        @levels = $PokemonGlobal.oplevels.clone
        # Indexes of the own O Powers (non-leveled 0)
        @ownops = Array.new(OPowers.length) { |i| next i }
        for i in [email protected]
          if @levels[i] == 0
            @ownops[i] = nil
          end
        end
        @levels.delete(0); @ownops.compact!
        # => # SPRITES
        @viewport=Viewport.new(0,0,Graphics.width,Graphics.height); @viewport.z=99999
        @sprites[:list] = Window_CommandPokemon.newEmpty(169,46,330,276,@viewport)#
        #@sprites[:list].windowskin = nil
        @sprites[:list].index = 0
        @sprites[:list].z = 255
        @sprites[:list].windowskin = nil
        ##
        @sprites[:header] = Window_UnformattedTextPokemon.newWithSize(
          _INTL("Poderes O"),0,0,216,28,@viewport)
        @sprites[:header].baseColor = Color.new(248,248,248) ##TODO
        @sprites[:header].shadowColor = Color.new(0,0,0)
        ##
        @sprites[:info] = Window_AdvancedTextPokemon.newWithSize("",
           0,240,158,128,@viewport)
        ##
        barpower = ($PokemonGlobal.openergy * 0.01 * 318).floor
        @sprites[:bar] = IconSprite.new(178,336,@viewport)
        @sprites[:bar].setBitmap("Graphics/Pictures/O Power/bar")
        @sprites[:bar].src_rect = Rect.new(0,0,barpower,32)
        @sprites[:bar].z = 255
        ##
        @sprites[:textwindow] = Window_UnformattedTextPokemon.new("")
        @sprites[:textwindow].x = 0
        @sprites[:textwindow].y = 116
        @sprites[:textwindow].width = 158
        @sprites[:textwindow].height = 252
        @sprites[:textwindow].viewport = @viewport
        @sprites[:textwindow].windowskin = nil
        ## LISTA ##
        commands = []
        for i in [email protected]
          commands.push(_INTL("{1} - Lvl {2}",OPowers.names[@ownops[i]],@levels[i]))
        end
        commands.push("Exit")
        addBackgroundPlane(@sprites,:bg,"O Power/bg",@viewport)
        @sprites[:list].commands = commands
        pbFadeInAndShow(@sprites)
        Graphics.transition
        loop do # Update loop
          Graphics.update
          Input.update
          update
          update_text
          pbUpdateSpriteHash(@sprites)
          break if @break
        end
        pbFadeOutAndHide(@sprites)
        # Disposes the windows
        pbDisposeSpriteHash(@sprites)
        @viewport.dispose
      end
    
      def update
        if Input.trigger?(Input::B) # Back
          pbPlayCancelSE()
          @break = true
          return
        elsif Input.trigger?(Input::C)
          index = @sprites[:list].index
          if index == @ownops.length # Index of exit (last command)
            pbPlayCancelSE()
            @break = true
            return
          end
          selected = @ownops[index] # O Power id selected
          if $PokemonGlobal.oplevels[selected] == 1
            if Kernel.pbConfirmMessage(_INTL("Activate {1} O-Power?",@sprites[:list].commands[index]))
              pbLaunchOPower(selected,1)
            end
          else
            commands = []
            for i in 1..$PokemonGlobal.oplevels[selected]
              commands.push(_INTL("Level {1} ({2}%)",i.to_s,OPowers.costs(i)[selected].to_s))
            end
            commands.push("Exit")
            cmd = Kernel.pbMessage(_INTL("Choose a level."),commands,commands.length)
            if cmd < commands.length-1 # Not back command
              if Kernel.pbConfirmMessage(_INTL("Activate {1} O-Power - level {2}?",
                OPowers.names[selected],cmd+1))
                # Se lanza el poder O
                pbLaunchOPower(selected,cmd+1) {update_bar}
              end
            end
            #$scene = Scene_ConfirmOPower.new(selected)
          end
        end
      end
    
      def update_text
        selected = getID(OPowers,@ownops[@sprites[:list].index]) # O Power id selected
        if !selected
          # Back tag
          @sprites[:textwindow].text = _INTL("Back to the main menu.")
        else
          # O Power descriptions
          @sprites[:textwindow].text = OPowers.descriptions[selected] # Put descriptions
        end
      end
    
      def update_bar
        barpower = ($PokemonGlobal.openergy * 0.01 * 318).floor
        @sprites[:bar].src_rect.set(0,0,barpower,32)
      end
    
    end
    
    def pbFadeOutIn2(red,green,blue)
      col = Color.new(red,green,blue)
      viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
      viewport.z = 99999
      for j in 0..17
        col.set(red,green,blue,j*15)
        viewport.color = col
        Graphics.update
        Input.update
      end
      pbPushFade
      begin
        yield if block_given?
      ensure
        pbPopFade
        for j in 0..17
          col.set(red,green,blue,(17-j)*15)
          viewport.color=col
          Graphics.update
          Input.update
        end
        viewport.dispose
      end
    end

    This is the basis to set up O Power. In this thread you have a ZIP with pictures that this code need. You can modify them, but make sure you also modify the coordinates in the Scene_OPowers class.
    Now you need to make some changes in your scripts. I recommend you to put comment to point out that you have modified the script, if there was any error.

    Attack and defense
    I have modified this O Power: Attack makes the leading Pokémon raise its attack and special attack when it is called out. Defense does it for defense and special defense. To set up this, find in PokeBattle_Battle, in def pbStartBattleCore (line 2515) pbOnActiveAll and put this below it:
    Spoiler:
    Code:
        #pbOnActiveAll
        o = $PokemonGlobal.opower_data[OPowers::ATTACK]
        if o && @internalbattle #!#OPOWER ATTACK
          for i in [email protected]
            if pbOwnedByPlayer?(i)
              @battlers[i].pbIncreaseStatWithCause(
              PBStats::ATTACK,o[0]*2,@battlers[i],"O-Power #{OPowers.names[OPowers::ATTACK]}")
              @battlers[i].pbIncreaseStatWithCause(
              PBStats::SPATK,o[0]*2,@battlers[i],"O-Power #{OPowers.names[OPowers::ATTACK]}")
            end
          end
          $PokemonGlobal.opower_data[OPowers::ATTACK] = nil
        end
        o = $PokemonGlobal.opower_data[OPowers::DEFENSE]
        if o && @internalbattle #!#OPOWER DEFENSE
          for i in [email protected]
            if pbOwnedByPlayer?(i)
              @battlers[i].pbIncreaseStatWithCause(
              PBStats::DEFENSE,o[0]*2,@battlers[i],"O-Power #{OPowers.names[OPowers::DEFENSE]}")
              @battlers[i].pbIncreaseStatWithCause(
              PBStats::SPDEF,o[0]*2,@battlers[i],"O-Power #{OPowers.names[OPowers::DEFENSE]}")
            end
          end
          $PokemonGlobal.opower_data[OPowers::DEFENSE] = nil
        end
        #@turncount=0

    Catch
    Again, find in PokeBattle_Battle, def pbThrowPokeball and put this above shakes=0 (line 124).
    Spoiler:
    Code:
            #end
            o = $PokemonGlobal.opower_data[OPowers::CATCH]
            if o && @internalbattle #!#OPOWER CATCH
              case o[0]
              when 1; c = (c*1.25).floor
              when 2; c = (c*4.0/3).floor
              when 3; c = (c*1.5).floor
              else; c *= 2
              end
            end
            #shakes=0; critical=false

    Reward
    In the same class, find in def pbEndOfBattle (line 3939) and put this below tmoney*=2 if @doublemoney.
    Spoiler:
    Code:
    #          tmoney*=2 if @doublemoney
              if o = $PokemonGlobal.opower_data[OPowers::REWARD] #!#OPOWER REWARD
                case o[0] #!# Level
                when 1; tmoney = (tmoney*1.5).floor
                when 2; tmoney *= 2
                when 3; tmoney *= 3
                else; tmoney *= 5
                end
              end

    Critical
    Now, in PokeBattle_Move, in def pbIsCritical? find c+=1 if attacker.hasWorkingItem(...) (line 582) and put this below it:
    Spoiler:
    Code:
    #    c+=1 if attacker.hasWorkingItem(:SCOPELENS)
        o = $PokemonGlobal.opower_data[OPowers::CRITICAL] #!#OPOWER
        if o && @battle.internalbattle && #!# IF not an organized battle.
          @battle.pbOwnedByPlayer?(attacker.index) #!# If user is the player.
          c += o[0]>3 ? 3 : o[0] # Un aumento de críticos por cada nivel de Poder O
        end
    #    c=4 if c>4

    Happiness
    Go to PokeBattle_Pokemon to def changeHappiness and before @happiness+=gain (line 837) put this:
    Spoiler:
    Code:
    #    end
        o = $PokemonGlobal.opower_data[OPowers::HAPPINESS] #!#OPOWER HAPPINESS
        if o
          case o[0]
          when 1; gain *= 1.5
          when 2; gain *= 2
          when 3; gain *= 2.5
          else; gain *= 3
          end
          gain = gain.round
        end
    #    @happiness+=gain
    This will make the gaining happiness multiplies, even giving the Pokémon an object.
    Discount
    Go to PScreen_Mart, def pbPokemonMart (line 792). Replace everything that is before stock.compact! and put this (make sure you also change your own methods!):
    Spoiler:
    Code:
      o = $PokemonGlobal.opower_data[OPowers::DISCOUNT] #!#OPOWER DISCOUNT
      for i in 0...stock.length
        stock[i]=getID(PBItems,stock[i]) if !stock[i].is_a?(Integer)
        if !stock[i] || stock[i]==0 ||
           (pbIsImportantItem?(stock[i]) && $PokemonBag.pbQuantity(stock[i])>0)
          stock[i]=nil
        end
        if o #!#
          case o[0] #Level
          when 1; prop = 0.9
          when 2; prop = 0.75
          else; prop = 0.5
          end
          $game_temp.mart_prices[stock[i]]=[-1,-1] if !$game_temp.mart_prices[stock[i]]
          $game_temp.mart_prices[stock[i]][0]=($ItemData[stock][ITEMPRICE]*prop).round
        end
      end
    #  stock.compact!
    

    Encounter and Repel
    Go to PField_Encounters, def pbGenerateEncounter, line 321. Put above return nil if rand ...:
    Spoiler:
    Code:
        o = $PokemonGlobal.opower_data[OPowers::ENCOUNTER] #!#OPOWERS ENCOUNTER REPEL
        r = $PokemonGlobal.opower_data[OPowers::REPEL]
        if o || r
          mod = nil
          case o ? o[0] : r[0]
          when 1; mod = 0.9
          when 2; mod = 0.75
          when 3; mod = 0.5
          end
          if mod
            if o
              encount/=mod
            else
              encount*=mod
            end
          else
            encount = o ? -1 : 180*16 + 1
          end
        end
    #    return nil if rand(180*16)>=encount

    Incubation
    I have change this proc because it was inadaptable to these scripts. The effect is exactly the same, but more flexible to changes. In PScreen_EggHatching, line 205, comment by putting a =begin ... =end block (like commenting with '#') starting in the method Events.onStepTaken+=proc {|sender,e and add out of the block this:
    Spoiler:
    Code:
    Events.onStepTaken += proc {
    	next if !$Trainer
    	minus = 1 # The number that the Egg Steps will be taken
    	for i in $Trainer.party
    		if isConst?(i.ability,PBAbilities,:FLAMEBODY) ||
    			isConst?(i.ability,PBAbilities,:MAGMAARMOR)
    			minus += 1
    			break
    		end
    	end
      o = $PokemonGlobal.opower_data[OPowers::INCUBATION] rescue nil #!#OPOWERS
      if o
        case o[0] # Level
        when 1; minus = 1.25
        when 2; minus = 1.5
        when 3; minus = 2
        else; minus = 3
        end
      end
      for egg in $Trainer.party
      	next if egg.eggsteps <= 0 # Not an egg
      	egg.eggsteps -= minus
      	if egg.eggsteps <= 0
                    egg.eggsteps = 0
      		pbHatch(egg)
      	end
      end
    }
    Warning! Using this method may convert eggsteps (Integer) into Float, so be aware if you are checking an exact number of eggsteps anywhere.
    Experience gain
    Go back to PokeBattle_Battle section in def pbGainExpOne. Below isConst?(thispoke.itemInitial,PBItems,:LUCKYEGG) (line 1930) put this code:
    Spoiler:
    Code:
        #exp=(exp*3/2).floor if isConst?(thispoke.item,PBItems,:LUCKYEGG) ||
    #                           isConst?(thispoke.itemInitial,PBItems,:LUCKYEGG)
        o = $PokemonGlobal.opower_data[OPowers::EXP_GAIN] #!# OPOWER EXP
        if o
          case o[0] # Level
          when 1; exp *= 1.2
          when 2; exp *= 1.5
          when 3; exp *= 2
          else; exp *= 3
          end
          exp = exp.floor
        end
    #    growthrate=thispoke.growthrate

    I also added a Power that makes wild pokemon have 31 IVs according to the given level.

    Now you have to put the button in the PokéGear.
    Add this line in the section PScreen_Pokegear (def pbStartScreen, line 120) below [[email protected]=-1

    Code:
    cmdOPower=-1 #!#OP
    Then a few lines below, above commands[cmdJukebox=commands.length]=_INTL("Jukebox") put this line:
    Code:
    commands[cmdOPowers = commands.length] = ["o-powers",_INTL("O-Powers")] if !$PokemonGlobal.oplevels.empty? #!#OP
    Now, in the loop, (line 149) add this condition:
    Code:
          elsif cmdOPowers>=0 && cmd==cmdOPowers #!#OPOWERS
            pbPlayDecisionSE()
            Scene_OPowers.new.start
    #      end
    And Now the code is set! All you have to do is activate O-Powers in the adventure by using this code:n
    Code:
    $PokemonGlobal.opLevelUp(OPowers::X,level)
    Being X the internal name of the O-Power (defined in module OPowers) and level the number to sum to the current level (if you don't specify, by default is 1). This will allow the player to find the menu in the PokeGear and update that O Power.

    The attribute $PokemonGlobal.oplevels is an Array of the current level of each O Power id. If it is empty, the PokeGear won't show the O Power button. $PokemonGlobal.opower_data Array stores the current working O Power wich also relates each O Power id with the launched O Power ([level,launch time,duration] or nil if none). $PokemonGlobal.openergy is the energy in % of the power bar shown in the O Power scene. It can be between 0 and 100 inclusive.

    What can you add in?
    You can program a way to have the "most powerful O-Power". Each activation of powers checks its level, and if it has an unknown level (i.e. not 1, 2 nor 3), the power is more beneficial than other. If you want to add a new O-Power, all you have to do is define an id in module OPowers as well as a name, description and cost, and modify the code.

    I hope this is worth for you, and I would thank if you mention me in the credits. :D
    Attached Files
    File Type: zip O Power.zip‎ (3.2 KB, 7 views) (Save to Dropbox)
    Reply With Quote
      #2    
    Old 2 Weeks Ago (6:01 PM). Edited 2 Weeks Ago by WolfPP.
    WolfPP's Avatar
    WolfPP WolfPP is online now
       
      Join Date: Aug 2018
      Location: Brazil
      Gender: Male
      Nature: Jolly
      Posts: 113
      My god, so nice! I will put into my game. Ty ty!

      So, i dont get it how put 'Incubation'. Sorry to ask but can you teach more about that?

      My line 178:
      Spoiler:
      Code:
      def pbHatch(pokemon)
        speciesname = PBSpecies.getName(pokemon.species)
        pokemon.name           = speciesname
        pokemon.trainerID      = $Trainer.id
        pokemon.ot             = $Trainer.name
        pokemon.happiness      = 120
        pokemon.timeEggHatched = pbGetTimeNow
        pokemon.obtainMode     = 1   # hatched from egg
        pokemon.hatchedMap     = $game_map.map_id
        $Trainer.seen[pokemon.species]  = true
        $Trainer.owned[pokemon.species] = true
        pbSeenForm(pokemon)
        pokemon.pbRecordFirstMoves
        if !pbHatchAnimation(pokemon)
          Kernel.pbMessage(_INTL("Huh?\1"))
          Kernel.pbMessage(_INTL("...\1"))
          Kernel.pbMessage(_INTL("... .... .....\1"))
          Kernel.pbMessage(_INTL("{1} hatched from the Egg!",speciesname))
          if Kernel.pbConfirmMessage(_INTL("Would you like to nickname the newly hatched {1}?",speciesname))
            species=PBSpecies.getName(pokemon.species)
            nickname=pbEnterPokemonName(_INTL("{1}'s nickname?",speciesname),
               0,PokeBattle_Pokemon::NAMELIMIT,"",pokemon)
            pokemon.name=nickname if nickname!=""
          end #line 201
        end
      end

      Im usin v17.2 and EBS.

      Ty ty!


      EDIT:

      And i get this error:

      Spoiler:
      Code:
      ---------------------------
      Pokemon Essentials
      ---------------------------
      [Pokémon Essentials version 17.2]
      
      Exception: NoMethodError
      
      Message: undefined method `[]' for nil:NilClass
      
      PScreen_Pokegear:188:in `pbStartScreen'
      
      PScreen_Pokegear:154:in `loop'
      
      PScreen_Pokegear:194:in `pbStartScreen'
      
      Neo Pause Menu:405
      
      Neo Pause Menu:404:in `pbFadeOutIn'
      
      Neo Pause Menu:404
      
      Neo Pause Menu:401:in `call'
      
      Neo Pause Menu:48:in `runAction'
      
      Neo Pause Menu:319:in `pbStartPokemonMenu'
      
      Neo Pause Menu:303:in `loop'


      I see than your start screen is different to the others

      This is mine (the last add to pokegear, custom:
      Code:
            elsif cmdWallClockTimer>=0 && cmd==cmdWallClockTimer
              pbPlayDecisionSE
              pbFadeOutIn(99999){
                scene = WallClockScene.new
                screen = WallClockScreen.new(scene)
                screen.pbStartScreen($Trainer.gender==0)
              }
            end
          end
          @scene.pbEndScene
        end
      end
      How could be?

      Thanks!
      Reply With Quote
        #3    
      Old 2 Weeks Ago (7:04 AM). Edited 2 Weeks Ago by samukomini.
      samukomini samukomini is offline
         
        Join Date: Sep 2018
        Location: Spain
        Gender: Male
        Nature: Calm
        Posts: 7
        Quote:
        Originally Posted by WolfPP View Post
        My god, so nice! I will put into my game. Ty ty!

        So, i dont get it how put 'Incubation'. Sorry to ask but can you teach more about that?

        My line 178:
        Spoiler:
        Code:
        def pbHatch(pokemon)
          speciesname = PBSpecies.getName(pokemon.species)
          pokemon.name           = speciesname
          pokemon.trainerID      = $Trainer.id
          pokemon.ot             = $Trainer.name
          pokemon.happiness      = 120
          pokemon.timeEggHatched = pbGetTimeNow
          pokemon.obtainMode     = 1   # hatched from egg
          pokemon.hatchedMap     = $game_map.map_id
          $Trainer.seen[pokemon.species]  = true
          $Trainer.owned[pokemon.species] = true
          pbSeenForm(pokemon)
          pokemon.pbRecordFirstMoves
          if !pbHatchAnimation(pokemon)
            Kernel.pbMessage(_INTL("Huh?\1"))
            Kernel.pbMessage(_INTL("...\1"))
            Kernel.pbMessage(_INTL("... .... .....\1"))
            Kernel.pbMessage(_INTL("{1} hatched from the Egg!",speciesname))
            if Kernel.pbConfirmMessage(_INTL("Would you like to nickname the newly hatched {1}?",speciesname))
              species=PBSpecies.getName(pokemon.species)
              nickname=pbEnterPokemonName(_INTL("{1}'s nickname?",speciesname),
                 0,PokeBattle_Pokemon::NAMELIMIT,"",pokemon)
              pokemon.name=nickname if nickname!=""
            end #line 201
          end
        end

        Im usin v17.2 and EBS.

        Ty ty!


        EDIT:

        And i get this error:

        Spoiler:
        Code:
        ---------------------------
        Pokemon Essentials
        ---------------------------
        [Pokémon Essentials version 17.2]
        
        Exception: NoMethodError
        
        Message: undefined method `[]' for nil:NilClass
        
        PScreen_Pokegear:188:in `pbStartScreen'
        
        PScreen_Pokegear:154:in `loop'
        
        PScreen_Pokegear:194:in `pbStartScreen'
        
        Neo Pause Menu:405
        
        Neo Pause Menu:404:in `pbFadeOutIn'
        
        Neo Pause Menu:404
        
        Neo Pause Menu:401:in `call'
        
        Neo Pause Menu:48:in `runAction'
        
        Neo Pause Menu:319:in `pbStartPokemonMenu'
        
        Neo Pause Menu:303:in `loop'


        I see than your start screen is different to the others

        This is mine (the last add to pokegear, custom:
        Code:
              elsif cmdWallClockTimer>=0 && cmd==cmdWallClockTimer
                pbPlayDecisionSE
                pbFadeOutIn(99999){
                  scene = WallClockScene.new
                  screen = WallClockScreen.new(scene)
                  screen.pbStartScreen($Trainer.gender==0)
                }
              end
            end
            @scene.pbEndScene
          end
        end
        How could be?

        Thanks!
        Oh, I see, I'm sorry, my version was 16, this is why the starting script is so different. I will update this script, so by the moment, you only need to adapt it to the v17. So, in the PScreen_Pokegear, in the def pbStartScreen add what I told to set the Pokégear but removing the '@' of cmdOPower and instead the update_command (which doesn't exist in v17), put this after the several conditional branches:
        Spoiler:
        Code:
        if cmdOPower>=0 && cmd==cmdOPower #!#OPOWERS
                pbPlayDecisionSE()
                Scene_OPowers.new.start
              end

        Then replace the script I'd given by this:
        Spoiler:
        Code:
        #=======================================
        #     O-Powers. Created by Samukomini
        #     Credit wanted but not required.
        #=======================================
        
        module OPowers
          ATTACK    = 0
          DEFENSE   = 1
          CATCH     = 2
          HP_HEAL   = 3
          PP_HEAL   = 4
          REWARD    = 5
          CRITICAL  = 6
          HAPPINESS = 7
          DISCOUNT  = 8
          ENCOUNTER = 9
          REPEL     = 10
          INCUBATION = 11
          EXP_GAIN  = 12
          IV        = 13
          
          def self.names
            return ["Attack","Defense","Capture","HP Restore","PP Restore",
                    "Reward","Critical","Happiness","Discount","Encounter",
                    "Repel","Incubation","Experience Points","Individual Values"]
          end
        
          def self.descriptions
            return [
              "Boost the attack of your leading Pokémon in the next battle.",
              "Boost the attack of your leading Pokémon in the next battle.",
              "Raise the probability of catching a Pokémon.",
              "Restore your team health.",
              "Restore your team moves PPs.",
              "Raise the money you steal the trainers you win.",
              "Raise the critical hit ratio in battle.",
              "Boost the happiness your Pokémon win.",
              "Cut the prices on products in Pokémon Mart.",
              "Raise the probability of encountering a wild Pokémon.",
              "Reduce the probability of encountering a wild Pokémon.",
              "Speed up your egg hatching.",
              "Boost the experience points earned by your Pokémon.",
              "Wild Pokémon will boost their Individual Values."
            ]
          end
        
          def self.costs(level) # Over 100
            case level
            when 1
              return [10,10,20,10,20,15,15,15,20,10,15,20,25,25]
            when 2
              return [20,20,30,20,30,30,25,25,40,20,30,30,35,35]
            when 3
              return [30,30,40,30,40,45,40,35,60,30,40,40,50,50]
            end
            raise ArgumentError.new("Undefined cost for level: #{level}")
          end
        
          def self.instant?(power)
            return [ATTACK,DEFENSE,HP_HEAL,PP_HEAL].include?(getID(self,power))
          end
                  
          def self.length; self.constants.length; end
        
          def self.getByName(name)
            for i in 0...length
              return i if names[i] == name
            end
            return -1
          end
        end
        
        class PokemonGlobalMetadata
          attr_reader   :oplevels
          attr_accessor :opower_data
          attr_reader   :openergy
          
          alias old_initialize initialize
          
          def initialize
            old_initialize
            @oplevels = []
            @opower_data = Array.new(OPowers.length) { nil }
            @openergy = 100
          end
        
          def opLevelUp(op,level=nil)
            if @oplevels.empty?
              @oplevels = Array.new(OPowers.length) {0}
            end
            op = getID(OPowers,op)
            if level
              @oplevels[op] = level
            else
              @oplevels[op] += 1
            end
          end
        
          def openergy=(val)
            @openergy = val
            @openergy = 0 if @openergy < 0
            @openergy = 100 if @openergy > 100
          end
        end
        
        class Scene_Map
          alias op_update update
        
          def update
            op_update
            update_opower
          end
        
          def update_opower
            for i in 0...$PokemonGlobal.opower_data.length
              data = $PokemonGlobal.opower_data[i]
              next if OPowers.instant?(i) || !data
              if Time.now.to_i > data[1].to_i + data[2] # Time expired
                Kernel.pbMessage(_INTL("The effect of  {1} O-Power finished.",OPowers.names[i]))
                $PokemonGlobal.opower_data[i] = nil
              end
            end
          end
        end
        
        ## Launch a power. Return if it has been succesfully launched.
        def pbLaunchOPower(opower,level,consume=true,time=3,showmessage=true,effects=true)
          opower = getID(OPowers,opower)
          if consume || ($DEBUG && Input.press?(Input::CTRL))
            if OPowers.costs(level)[opower] > $PokemonGlobal.openergy # Not enough energy
              Kernel.pbMessage("There isn't enough energy to launch this power.") if showmessage
              return false
            end
            $PokemonGlobal.openergy -= OPowers.costs(level)[opower]
          end
          if effects
            pbSEPlay("o_power")
            pbFadeOutIn2(255,255,255) {yield if block_given?}
          end
          Kernel.pbMessage(_INTL("You have activated {1} O-Power - Level {2}.",
              OPowers.names[opower],level.to_s)) if showmessage
          $PokemonGlobal.opower_data[opower] = [level,Time.now,(time*60).floor] # Time not needed for instant O-Powers
          ## Repel replaces Encounter and vice versa
          if isConst?(opower,OPowers,:ENCOUNTER)
            $PokemonGlobal.opower_data[OPowers::REPEL] = nil
          elsif isConst?(opower,OPowers,:REPEL)
            $PokemonGlobal.opower_data[OPowers::ENCOUNTER] = nil
          end
          if OPowers.instant?(opower)
            if isConst?(opower,OPowers,:HP_HEAL)
              case level
              when 1; prop = 1.0/3.0
              when 2; prop = 0.5
              when 3; prop = 2.0/3.0
              else; prop = 1
              end
              for i in $Trainer.party
                pbItemRestoreHP(i,(i.totalhp*prop).round)
              end
              $PokemonGlobal.opower_data[opower] = nil
            elsif isConst?(opower,OPowers,:PP_HEAL)
              case level
              when 1; restore = 5
              when 2; restore = 10
              when 3; restore = 15
              else; restore = 40
              end
              for i in $Trainer.party
                for j in 0...i.moves.length
                  pbRestorePP(i,j,restore)
                end
              end
              $PokemonGlobal.opower_data[opower] = nil
            end
          end
        end
        
        Events.onStepTaken += proc {
          if $PokemonGlobal.happinessSteps==0
            # Done each 128 steps. See this Event in PField_Field section.
            $PokemonGlobal.openergy += 5
            # O Power energy would be full restored in 6400 steps
          end
        }
        
        Events.onWildPokemonCreate += proc {|s,e|
          pokemon = e[0]
          o = $PokemonGlobal.opower_data[OPowers::IV]
          if o
            case o[0]
            when 1; mod = rand(2) + 1
            when 2; mod = rand(3) + 2
            when 3; mod = rand(4) + 3
            else; mod = 6
            end
            ivs = randomAry(mod,pokemon.iv.length) # Random indexes of modifying ivs
            for i in ivs
              pokemon.iv[i] = 31
            end
            pokemon.calcStats
          end
        }
        
        class Scene_OPowers
          def start
            # => Prepare
            @sprites = {}
            @levels = $PokemonGlobal.oplevels.clone
            # Indexes of the own O Powers (non-leveled 0)
            @ownops = Array.new(OPowers.length) { |i| next i }
            for i in [email protected]
              if @levels[i] == 0
                @ownops[i] = nil
              end
            end
            @levels.delete(0); @ownops.compact!
            # => # SPRITES
            @viewport=Viewport.new(0,0,Graphics.width,Graphics.height); @viewport.z=99999
            @sprites[:list] = Window_CommandPokemon.newEmpty(169,46,330,276,@viewport)#
            #@sprites[:list].windowskin = nil
            @sprites[:list].index = 0
            @sprites[:list].z = 255
            @sprites[:list].windowskin = nil
            ##
            @sprites[:header] = Window_UnformattedTextPokemon.newWithSize(
              _INTL("Poderes O"),0,0,216,28,@viewport)
            @sprites[:header].baseColor = Color.new(248,248,248) ##TODO
            @sprites[:header].shadowColor = Color.new(0,0,0)
            ##
            @sprites[:info] = Window_AdvancedTextPokemon.newWithSize("",
               0,240,158,128,@viewport)
            ##
            barpower = ($PokemonGlobal.openergy * 0.01 * 318).floor
            @sprites[:bar] = IconSprite.new(178,336,@viewport)
            @sprites[:bar].setBitmap("Graphics/Pictures/O Power/bar")
            @sprites[:bar].src_rect = Rect.new(0,0,barpower,32)
            @sprites[:bar].z = 255
            ##
            @sprites[:textwindow] = Window_UnformattedTextPokemon.new("")
            @sprites[:textwindow].x = 0
            @sprites[:textwindow].y = 116
            @sprites[:textwindow].width = 158
            @sprites[:textwindow].height = 252
            @sprites[:textwindow].viewport = @viewport
            @sprites[:textwindow].windowskin = nil
            ## LISTA ##
            commands = []
            for i in [email protected]
              commands.push(_INTL("{1} - Lvl {2}",OPowers.names[@ownops[i]],@levels[i]))
            end
            commands.push("Exit")
            addBackgroundPlane(@sprites,:bg,"O Power/bg",@viewport)
            @sprites[:list].commands = commands
            Graphics.transition
            #pbFadeInAndShow(@sprites)
            #pbActivateWindow(@sprites,:list) {
              loop do # Update loop
                Graphics.update
                Input.update
                update
                update_text
                pbUpdateSpriteHash(@sprites)
                break if @break
              end
            #}
            Graphics.freeze
            # Disposes the windows
            pbDisposeSpriteHash(@sprites)
            @viewport.dispose
          end
        
          def update
            if Input.trigger?(Input::B) # Back
              pbPlayCancelSE()
              @break = true
              return
            elsif Input.trigger?(Input::C)
              index = @sprites[:list].index
              if index == @ownops.length # Index of exit (last command)
                pbPlayCancelSE()
                @break = true
                return
              end
              selected = @ownops[index] # O Power id selected
              if $PokemonGlobal.oplevels[selected] == 1
                if Kernel.pbConfirmMessage(_INTL("Activate {1} O-Power?",@sprites[:list].commands[index]))
                  pbLaunchOPower(selected,1)
                end
              else
                commands = []
                for i in 1..$PokemonGlobal.oplevels[selected]
                  commands.push(_INTL("Level {1} ({2}%)",i.to_s,OPowers.costs(i)[selected].to_s))
                end
                commands.push("Exit")
                cmd = Kernel.pbMessage(_INTL("Choose a level."),commands,commands.length)
                if cmd < commands.length-1 # Not back command
                  if Kernel.pbConfirmMessage(_INTL("Activate {1} O-Power - level {2}?",
                    OPowers.names[selected],cmd+1))
                    # Se lanza el poder O
                    pbLaunchOPower(selected,cmd+1) {update_bar}
                  end
                end
                #$scene = Scene_ConfirmOPower.new(selected)
              end
            end
          end
        
          def update_text
            selected = getID(OPowers,@ownops[@sprites[:list].index]) # O Power id selected
            if !selected
              # Back tag
              @sprites[:textwindow].text = _INTL("Back to the main menu.")
            else
              # O Power descriptions
              @sprites[:textwindow].text = OPowers.descriptions[selected] # Put descriptions
            end
          end
        
          def update_bar
            barpower = ($PokemonGlobal.openergy * 0.01 * 318).floor
            @sprites[:bar].src_rect.set(0,0,barpower,32)
          end
        
        end
        
        def pbFadeOutIn2(red,green,blue)
          col = Color.new(red,green,blue)
          viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
          viewport.z = 99999
          for j in 0..17
            col.set(red,green,blue,j*15)
            viewport.color = col
            Graphics.update
            Input.update
          end
          pbPushFade
          begin
            yield if block_given?
          ensure
            pbPopFade
            for j in 0..17
              col.set(red,green,blue,(17-j)*15)
              viewport.color=col
              Graphics.update
              Input.update
            end
            viewport.dispose
          end
        end


        By the way, the problem that you had trying to set the Incubation power is because of the version too. You just need to do what I specified in the last section's proc (line 205).

        I'm sorry for this all, I'm going to change the script and update the thread. This is the temporal solution, please tell me if you notice another error. Thanks for using the script!! :D
        Reply With Quote
          #4    
        Old 2 Weeks Ago (7:57 AM).
        WolfPP's Avatar
        WolfPP WolfPP is online now
           
          Join Date: Aug 2018
          Location: Brazil
          Gender: Male
          Nature: Jolly
          Posts: 113
          Hmmm, give me that issue:

          Code:
          ---------------------------
          Pokemon Essentials
          ---------------------------
          [Pokémon Essentials version 17.2]
          
          [Pokétch v1.1]
          
          Exception: NoMethodError
          
          Message: undefined method `start' for #<Scene_OPowers:0xd0e73a0>
          
          PScreen_Pokegear:193:in `pbStartScreen'
          
          PScreen_Pokegear:192:in `pbFadeOutIn'
          
          PScreen_Pokegear:192:in `pbStartScreen'
          
          PScreen_Pokegear:155:in `loop'
          
          PScreen_Pokegear:196:in `pbStartScreen'
          
          Neo Pause Menu:405
          
          Neo Pause Menu:404:in `pbFadeOutIn'
          
          Neo Pause Menu:404
          
          Neo Pause Menu:401:in `call'
          
          Neo Pause Menu:48:in `runAction'
          i think its your startscreen. You havent a pbStartScreen. And idk how to make one (to sad).
          Look:
          Code:
                elsif cmdJukebox>=0 && cmd==cmdJukebox
                  pbPlayDecisionSE
                  pbFadeOutIn(99999){
                    scene = PokemonJukebox_Scene.new
                    screen = PokemonJukeboxScreen.new(scene)
                    screen.pbStartScreen
                  }
          And "i" thank you lol :D
          Reply With Quote
            #5    
          Old 2 Weeks Ago (8:13 AM).
          samukomini samukomini is offline
             
            Join Date: Sep 2018
            Location: Spain
            Gender: Male
            Nature: Calm
            Posts: 7
            Ok, I'm stupid, I forgot to change the most important thing. I have edited the previous post with a 'start' method, try again copying that script. If it still doesn't work, you can PM me.
            Reply With Quote
              #6    
            Old 2 Weeks Ago (9:54 AM). Edited 2 Weeks Ago by WolfPP.
            WolfPP's Avatar
            WolfPP WolfPP is online now
               
              Join Date: Aug 2018
              Location: Brazil
              Gender: Male
              Nature: Jolly
              Posts: 113
              Quote:
              Originally Posted by samukomini View Post
              Ok, I'm stupid, I forgot to change the most important thing. I have edited the previous post with a 'start' method, try again copying that script. If it still doesn't work, you can PM me.
              Ok. I did :D

              EDIT:

              DONE!

              How?

              in ' def pbStartScreen' add:
              Code:
              cmdOPower         = -1
              above '@scene.pbStartScene(commands)' add:
              Code:
               commands[cmdOPower = commands.length] = ["opower",_INTL("O Powers")] if !$PokemonGlobal.oplevels.empty? #!#OP
              Then, below this:
              Code:
                  loop do
                    cmd = @scene.pbScene
                    if cmd<0
                      pbPlayCancelSE
                      break
              add this:
              Code:
                    elsif cmdOPower>=0 && cmd==cmdOPower
                      pbPlayDecisionSE
                      pbFadeOutIn(99999){
                        Scene_OPowers.new.start
                      }
              Ty ty! <3

              EDIT2: Now when i try to exit to overworld, i dont get it cuz keep the O Power screen.
              Reply With Quote
                #7    
              Old 2 Weeks Ago (3:00 PM).
              samukomini samukomini is offline
                 
                Join Date: Sep 2018
                Location: Spain
                Gender: Male
                Nature: Calm
                Posts: 7
                Okay, the thread is now updated to v17. I've tried it and it seems to work okay.
                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
                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 7:06 AM.