• 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.

Creating a new Poké Ball

69
Posts
14
Years
    • Seen Nov 19, 2014
    I didn´t want to create a new topic for my question, so i guest i should post it here.

    How i can make a pokeball that only catches a certain pokemon? (more specifically, i want a pokeball that can catch only 3 determinated and the others pokeball can´t)
     
    1,224
    Posts
    10
    Years
  • I didn´t want to create a new topic for my question, so i guest i should post it here.

    How i can make a pokeball that only catches a certain pokemon? (more specifically, i want a pokeball that can catch only 3 determinated and the others pokeball can´t)

    Add to PokemonBalls

    Code:
    BallHandlers::IsUnconditional.add(:WHATEVERBALL,proc{|ball,battle,battler|
       next true if battler.pokemon && (isConst?(battler.species,PBSpecies,:DELCATTY) ||
          isConst?(battler.species,PBSpecies,:MUNNA) ||
          isConst?(battler.species,PBSpecies,:MUSHARNA))
       next false
    })

    Replace ball name and the species with what you like. Make sure to add the new ball as the next number in $BallTypes
     

    Maruno

    Lead Dev of Pokémon Essentials
    5,285
    Posts
    16
    Years
  • Do note that the code mej provided will have your new Poké Ball behave like a Master Ball for the named species (i.e. always capture). If you want it to only have a chance of capture, you'll have to use different code.

    You'll also need to add code to all the other Poké Balls to make them definitely fail against the named species.
     
    1,224
    Posts
    10
    Years
  • Do note that the code mej provided will have your new Poké Ball behave like a Master Ball for the named species (i.e. always capture). If you want it to only have a chance of capture, you'll have to use different code.

    You'll also need to add code to all the other Poké Balls to make them definitely fail against the named species.

    good call, I didn't fully understand what he wanted the first time.

    Replace PokemonBalls with this

    Code:
    module BallHandlers
      IsUnconditional=ItemHandlerHash.new
      ModifyCatchRate=ItemHandlerHash.new
      OnCatch=ItemHandlerHash.new
    
      def self.isUnconditional?(ball,battle,battler)
        if !IsUnconditional[ball]
          return false
        end
        return IsUnconditional.trigger(ball,battle,battler)
      end
    
      def self.modifyCatchRate(ball,catchRate,battle,battler)
        if !ModifyCatchRate[ball]
          return catchRate
        end
        return ModifyCatchRate.trigger(ball,catchRate,battle,battler)
      end
    
      def self.onCatch(ball,battle,pokemon)
        if OnCatch[ball]
          OnCatch.trigger(ball,battle,pokemon)
        end
      end
    end
    
    
    
    def pbBallTypeToBall(balltype)
      if $BallTypes[balltype]
        ret=getID(PBItems,$BallTypes[balltype])
        return ret if ret!=0
      end
      if $BallTypes[0]
        ret=getID(PBItems,$BallTypes[0])
        return ret if ret!=0
      end
      return getID(PBItems,:POKEBALL)
    end
    
    def pbGetBallType(ball)
      ball=getID(PBItems,ball)
      for key in $BallTypes.keys
        return key if isConst?(ball,PBItems,$BallTypes[key])
      end
      return 0
    end
    
    ################################
    
    $BallTypes={
       0=>:POKEBALL,
       1=>:GREATBALL,
       2=>:SAFARIBALL,
       3=>:ULTRABALL,
       4=>:MASTERBALL,
       5=>:NETBALL,
       6=>:DIVEBALL,
       7=>:NESTBALL,
       8=>:REPEATBALL,
       9=>:TIMERBALL,
       10=>:LUXURYBALL,
       11=>:PREMIERBALL,
       12=>:DUSKBALL,
       13=>:HEALBALL,
       14=>:QUICKBALL,
       15=>:CHERISHBALL,
       16=>:FASTBALL,
       17=>:LEVELBALL,
       18=>:LUREBALL,
       19=>:HEAVYBALL,
       20=>:LOVEBALL,
       21=>:FRIENDBALL,
       22=>:MOONBALL,
       23=>:SPORTBALL,
       24=>:SPECIESBALL
    }
    
    BallHandlers::ModifyCatchRate.add(:POKEBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
    next catchRate
    })
    
    BallHandlers::ModifyCatchRate.add(:GREATBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
    next (catchRate*3/2).floor
    })
    
    BallHandlers::ModifyCatchRate.add(:SAFARIBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       next (catchRate*3/2).floor
    })
    
    BallHandlers::ModifyCatchRate.add(:ULTRABALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       next (catchRate*2).floor
    })
    
    BallHandlers::IsUnconditional.add(:MASTERBALL,proc{|ball,battle,battler|
       next true
    })
    
    BallHandlers::ModifyCatchRate.add(:NETBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       catchRate*=3 if battler.pbHasType?(:BUG) || battler.pbHasType?(:WATER)
       next catchRate
    })
    
    BallHandlers::ModifyCatchRate.add(:DIVEBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       catchRate=(catchRate*7/2).floor if battle.environment==PBEnvironment::Underwater
       next catchRate
    })
    
    BallHandlers::ModifyCatchRate.add(:NESTBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       if battler.level<=30
         catchRate*=(40-battler.level)/10
       end
       next catchRate
    })
    
    BallHandlers::ModifyCatchRate.add(:REPEATBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       catchRate*=3 if battle.pbPlayer.owned[battler.species]
       next catchRate
    })
    
    BallHandlers::ModifyCatchRate.add(:TIMERBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       multiplier=[1+(0.3*battle.turncount),4].min
       catchRate*=multiplier
       next catchRate
    })
    
    BallHandlers::ModifyCatchRate.add(:DUSKBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       catchRate*=7/2 if PBDayNight.isNight?(pbGetTimeNow)
       next catchRate
    })
    
    BallHandlers::ModifyCatchRate.add(:HEALBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
    next catchRate
    })
    BallHandlers::OnCatch.add(:HEALBALL,proc{|ball,battle,pokemon|
       pokemon.heal
    })
    
    BallHandlers::ModifyCatchRate.add(:QUICKBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       catchRate*=4 if battle.turncount<=1
       next catchRate
    })
    
    BallHandlers::ModifyCatchRate.add(:FASTBALL,proc{|ball,catchRate,battle,battler|
       dexdata=pbOpenDexData
       pbDexDataOffset(dexdata,battler.species,13)
       basespeed=dexdata.fgetb
       dexdata.close
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       catchRate*=4 if basespeed>=100
       next catchRate
    })
    
    BallHandlers::ModifyCatchRate.add(:LEVELBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       pbattler=battle.battlers[0].level
       pbattler=battle.battlers[2].level if battle.battlers[2] &&
                                            battle.battlers[2].level>pbattler
       if pbattler>=battler.level*4
         catchRate*=8
       elsif pbattler>=battler.level*2
         catchRate*=4
       elsif pbattler>battler.level
         catchRate*=2
       end
       next catchRate
    })
    
    BallHandlers::ModifyCatchRate.add(:LUREBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       catchRate*=3 if $PokemonTemp.encounterType==EncounterTypes::OldRod ||
                       $PokemonTemp.encounterType==EncounterTypes::GoodRod ||
                       $PokemonTemp.encounterType==EncounterTypes::SuperRod
       next catchRate
    })
    
    BallHandlers::ModifyCatchRate.add(:HEAVYBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       weight=battler.weight
       if weight>4000
         catchRate+=40
       elsif weight>3000
         catchRate+=30
       elsif weight>=2050
         catchRate+=20
       else
         catchRate-=20
       end
       catchRate=[catchRate,1].max
       next catchRate
    })
    
    BallHandlers::ModifyCatchRate.add(:LOVEBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       pbattler=battle.battlers[0]
       pbattler2=battle.battlers[2] if battle.battlers[2]
       if pbattler.species==battler.species &&
          ((battler.gender==0 && pbattler.gender==1) ||
          (battler.gender==1 && pbattler.gender==0))
         catchRate*=8
       elsif pbattler2 && pbattler2.species==battler.species &&
          ((battler.gender==0 && pbattler2.gender==1) ||
           (battler.gender==1 && pbattler2.gender==0))
         catchRate*=8
       end
       next catchRate
    })
    
    BallHandlers::ModifyCatchRate.add(:FRIENDBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
    next catchRate
    })
    
    BallHandlers::OnCatch.add(:FRIENDBALL,proc{|ball,battle,pokemon|
       pokemon.happiness=200
    })
    
    BallHandlers::ModifyCatchRate.add(:MOONBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       if isConst?(battler.species,PBSpecies,:NIDORANfE) ||
          isConst?(battler.species,PBSpecies,:NIDORINA) ||
          isConst?(battler.species,PBSpecies,:NIDOQUEEN) ||
          isConst?(battler.species,PBSpecies,:NIDORANmA) ||
          isConst?(battler.species,PBSpecies,:NIDORINO) ||
          isConst?(battler.species,PBSpecies,:NIDOKING) ||
          isConst?(battler.species,PBSpecies,:CLEFFA) ||
          isConst?(battler.species,PBSpecies,:CLEFAIRY) ||
          isConst?(battler.species,PBSpecies,:CLEFABLE) ||
          isConst?(battler.species,PBSpecies,:IGGLYBUFF) ||
          isConst?(battler.species,PBSpecies,:JIGGLYPUFF) ||
          isConst?(battler.species,PBSpecies,:WIGGLYTUFF) ||
          isConst?(battler.species,PBSpecies,:SKITTY) ||
          isConst?(battler.species,PBSpecies,:DELCATTY) ||
          isConst?(battler.species,PBSpecies,:MUNNA) ||
          isConst?(battler.species,PBSpecies,:MUSHARNA)
         catchRate*=4
       end
       next catchRate
    })
    
    BallHandlers::ModifyCatchRate.add(:SPORTBALL,proc{|ball,catchRate,battle,battler|
     catchRate*=0 if  (isConst?(battler.species,PBSpecies,:Species1) || isConst?(battler.species,PBSpecies,:Species2) || isConst?(battler.species,PBSpecies,:Species3))
       next (catchRate*3/2).floor
    })
    BallHandlers::ModifyCatchRate.add(:SPECIESBALL,proc{|ball,battle,battler|
     catchRate*=0 if  (!isConst?(battler.species,PBSpecies,:Species1) || !isConst?(battler.species,PBSpecies,:Species2) || !isConst?(battler.species,PBSpecies,:Species3))    
    next catchRate
    })

    And change all instances of "Species1", "Species2", and "Species3" to your desired species.
    Note that I left masterball unchanged, you can change that if you wish.

    Edit: Also note that the SPECIESBALL I put has the catch rate of a Pokeball if the species condition is met. This code is not guaranteed to work as I am not completely sure of the effect of catchRate being 0,since there aren't previous examples and I've never tried it.
     
    Last edited:
    69
    Posts
    14
    Years
    • Seen Nov 19, 2014
    Thanks for the code, by now i can´t test it, but when i can i will edit this message to say if it worked or not.
     
    69
    Posts
    14
    Years
    • Seen Nov 19, 2014
    Well not completely, the pokeballs don´t catch the pokémon i choose, but the species can´t be catched either with the masterball or speciesball :/

    However i still trying to get the rigth code.
     
    6
    Posts
    2
    Years
    • Seen Dec 17, 2023
    this code actually still works in 20.1, but it needs a tiny tweak.
    Code:
    Battle::PokeBallEffects::IsUnconditional.add(:SHINEBALL,proc{|ball,battle,battler|
       next true if battler.pokemon && battler.pokemon.shiny?
       next false
    })
    is the code that I used. also, no longer need to define the Ball Type, as that's done automatically.
    hope this helps someone out there ^^
     
    Back
    Top