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

Changing Shiny rate temporarily

34
Posts
10
Years
    • Seen Oct 1, 2014
    (Sorry, I'm a half tard. Please bear with my utter stupidity. Because as Einstein said. It is infinite)
    I've recently implemented FL's random egg generator into my game to give the player a random egg. But I wanted to make it sort of like the egg given in pokemon crystal with a significantly higher chance to be shiny. How would I go about changing the shiny rate to about 1/32 (Which I believe would be setting the value in settings to 2048) before the egg is handed over, and changing it back as soon as the egg is given?

    (I don't want this to be implemented into the Random egg generator code. As I want to be able to call upon it later, for instance if I wanted it to trigger when I entered a certain area. (So I could just set it as an invisible event that would trigger on touch)).
     
    1,224
    Posts
    10
    Years
  • You could add a conditional branch to the utility that generates the egg, that activates on a switch.

    Code:
    def pbGenerateEgg(species,text="")
      return false if $Trainer.party.length>=6
      if species.is_a?(String) || species.is_a?(Symbol)
        species=getID(PBSpecies,species)
      end
      # Get egg steps
      dexdata=pbOpenDexData
      pbDexDataOffset(dexdata,species,21)
      eggsteps=dexdata.fgetw
      dexdata.close
      # Generate egg
      egg=PokeBattle_Pokemon.new(species,EGGINITIALLEVEL,$Trainer)
      egg.calcStats
      egg.name=_INTL("Egg")
      egg.eggsteps=eggsteps
      egg.obtainText=text
      [COLOR="Red"]if $game_switches[XX]==true #XX is whatever switch number
       if rand(32)==1 #1 in 32 chance
       egg.makeShiny
       else
       egg.makeNotShiny
       end
      end[/COLOR]
      # Add egg to party
      $Trainer.party[$Trainer.party.length]=egg
      return true
    end

    This way, you can make this effect apply to egg generating other than just FL's, when you turn the switch on
     
    Back
    Top