• 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?".
  • Staff applications for our PokéCommunity Daily and Social Media team are now open! Interested in joining staff? Then click here for more info!
  • 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.

Randomise Moves/Types/Items

Zeak6464

Zeak #3205 - Discord
  • 1,101
    Posts
    11
    Years
    Is there a way to randomize; Moves learned / Items Picked Up / Market / Move Types / Pokemon Types ?
     
    end [/QUOTE]
    And if you want randomize battle , here
    ################################################################################
    # Randomized Pokemon Script
    # By Umbreon
    ################################################################################
    # Used for a randomized pokemon challenge mainly.
    #
    # By randomized, I mean EVERY pokemon will be random, even interacted pokemon
    # like legendaries. (You may easily disable the randomizer for certain
    # situations like legendary battles and starter selecting.)
    #
    # To use: simply activate Switch Number X
    # (X = the number listed After "Switch = ", default is switch number 36.)
    #
    # If you want certain pokemon to NEVER appear, add them inside the black list.
    # (This does not take into effect if the switch stated above is off.)
    #
    # If you want ONLY certain pokemon to appear, add them to the whitelist. This
    # is only recommended when the amount of random pokemon available is around
    # 32 or less.(This does not take into effect if the switch stated above is off.)
    #
    ################################################################################

    ########################## You may edit any settings below this freely.
    module RandomizedChallenge
    Switch = 36 # switch ID to randomize a pokemon, if it's on then ALL
    # pokemon will be randomized. No exceptions.

    BlackListedPokemon = [PBSpecies::MEW, PBSpecies::ARCEUS]
    # Pokemon to Black List. Any pokemon in here will NEVER appear.

    WhiteListedPokemon = []
    # Leave this empty if all pokemon are allowed, otherwise only pokemon listed
    # above will be selected.
    end

    ######################### Do not edit anything below here.
    class PokeBattle_Pokemon

    alias randomized_init initialize

    def initialize(species,level,player=nil,withMoves=true)

    species = RandomizedChallenge::WhiteListedPokemon.shuffle[0]

    if $game_switches && $game_switches[RandomizedChallenge::Switch]
    if RandomizedChallenge::WhiteListedPokemon.length == 0
    species = rand(PBSpecies.maxValue - 1) + 1
    while RandomizedChallenge::BlackListedPokemon.include?(species)
    species = rand(PBSpecies.maxValue - 1) + 1
    end
    end
    end

    randomized_init(species, level, player, withMoves)
    end
    end
    You should give Umbreon credit.
     
    Randomizing the moves learned by Pokemon by way of Level Up:
    PokeBattle_Pokemon, search for "def getMoveList". Add the red stuff. You will have to go into your games moves.txt file (in the folder marked PBS) and find out what move is at the very bottom of the file. Replace the blue words with that move's internal name (Maruno likely knows a way to just grab the total number of moves legitimately rather than the workaround I came up with when I discovered that "PBMoves.maxvalue" didn't work like it does with "PBSpecies.maxvalue").
    Code:
      def getMoveList
        movelist=[]
        atkdata=pbRgssOpen("Data/attacksRS.dat","rb")
        offset=atkdata.getOffset(@species-1)
        length=atkdata.getLength(@species-1)>>1
        atkdata.pos=offset
        for k in 0..length-1
          level=atkdata.fgetw
          move=atkdata.fgetw[COLOR="red"]
          if move != nil
            move=rand(PBMoves::[COLOR="Navy"]CUSTOMMOVE[/COLOR])+1 if $game_switches[RANDOMIZER][/COLOR]
            movelist.push([level,move])[COLOR="Red"] if !(isConst?(move,PBMoves,:CHATTER) && !isConst?(self.species,PBSpecies,:CHATOT))
          end[/COLOR]
        end
        atkdata.close
        return movelist
      end
    Notes:
    1.) In the official games, Smearlge cannot Sketch Chatot's Chatter move because it would cause a glitch if used by any Pokemon other than Chatot. This limitation is coded into Essentials even though the glitch doesn't occur (no recording sounds in Essentials, so Chatter runs off the generic Chatot cry always), and as such I coded in the limitation that Chatter cannot be learned by any Pokemon except Chatot.
    2.) This code spits up a random learnset every time it is called. This means that you could level up your Glalie to level 37, have it learn Grass Whistle, then quit your game without saving and restart, level it up to 37 again, and have it learn Fire Blast instead.
    3.) The Pokemon still learns moves at the levels it normally would learn moves at.
    4.) You need some way of preventing the Move Relearner from working when Randomizer is on. Otherwise, players could stand next to him and ask him to tutor their Pokemon until the list contains some "press this move to win" move (to quote a video I once saw, "Ice-type, Glaciate-boosted STAB Hyper Beam!")

    Randomizing the types of Pokemon would run into an issue because it would be random every time the game checks what types the Pokemon is. That means your Pokemon might be Fairy/Dark when the game checks for type effectiveness, but then half a millisecond later it's Electric/Grass when checking if STAB applies. Randomizing the moves' types runs into a similar issue.

    I am unsure what bit of code allows for items picked up from item balls, or rather, how to ally this code in such a way that you get a random item. You'd have to have some way of preventing certain items from being chosen (i.e., Key Items), without creating the possibility of opening an item ball with nothing inside.
     
    Last edited:
    Randomizing the moves learned by Pokemon by way of Level Up:
    PokeBattle_Pokemon, search for "def getMoveList". Add the red stuff. You will have to go into your games moves.txt file (in the folder marked PBS) and find out what move is at the very bottom of the file. Replace the blue words with that move's internal name (Maruno likely knows a way to just grab the total number of moves legitimately rather than the workaround I came up with when I discovered that "PBMoves.maxvalue" didn't work like it does with "PBSpecies.maxvalue").
    Code:
      def getMoveList
        movelist=[]
        atkdata=pbRgssOpen("Data/attacksRS.dat","rb")
        offset=atkdata.getOffset(@species-1)
        length=atkdata.getLength(@species-1)>>1
        atkdata.pos=offset
        for k in 0..length-1
          level=atkdata.fgetw
          move=atkdata.fgetw[COLOR="red"]
          if move != nil
            move=rand(PBMoves::[COLOR="Navy"]CUSTOMMOVE[/COLOR])+1 if $game_switches[RANDOMIZER][/COLOR]
            movelist.push([level,move])[COLOR="Red"] if !(isConst?(move,PBMoves,:CHATTER) && !isConst?(self.species,PBSpecies,:CHATOT))
          end[/COLOR]
        end
        atkdata.close
        return movelist
      end
    Notes:
    1.) In the official games, Smearlge cannot Sketch Chatot's Chatter move because it would cause a glitch if used by any Pokemon other than Chatot. This limitation is coded into Essentials even though the glitch doesn't occur (no recording sounds in Essentials, so Chatter runs off the generic Chatot cry always), and as such I coded in the limitation that Chatter cannot be learned by any Pokemon except Chatot.
    2.) This code spits up a random learnset every time it is called. This means that you could level up your Glalie to level 37, have it learn Grass Whistle, then quit your game without saving and restart, level it up to 37 again, and have it learn Fire Blast instead.
    3.) The Pokemon still learns moves at the levels it normally would learn moves at.
    4.) You need some way of preventing the Move Relearner from working when Randomizer is on. Otherwise, players could stand next to him and ask him to tutor their Pokemon until the list contains some "press this move to win" move (to quote a video I once saw, "Ice-type, Glaciate-boosted STAB Hyper Beam!")

    Randomizing the types of Pokemon would run into an issue because it would be random every time the game checks what types the Pokemon is. That means your Pokemon might be Fairy/Dark when the game checks for type effectiveness, but then half a millisecond later it's Electric/Grass when checking if STAB applies. Randomizing the moves' types runs into a similar issue.

    I am unsure what bit of code allows for items picked up from item balls, or rather, how to ally this code in such a way that you get a random item. You'd have to have some way of preventing certain items from being chosen (i.e., Key Items), without creating the possibility of opening an item ball with nothing inside.

    thanks but now im trying to figure out items gained are randomized , and thank you for clearing up some issues i was having.

    Code:
    def Kernel.pbReceiveItem(item,quantity=1,plural=nil)
      if item.is_a?(String) || item.is_a?(Symbol)
        item=getID(PBItems,item)
      [COLOR="Red"]elsif item !=nil
        item=rand(PBItems::CUSTOMITEM)+1 if $game_switches[RANDOMIZER][/COLOR]
      end
     
    Last edited:
    thanks but now im trying to figure out items gained are randomized , and thank you for clearing up some issues i was having.

    Code:
    def Kernel.pbReceiveItem(item,quantity=1,plural=nil)
      if item.is_a?(String) || item.is_a?(Symbol)
        item=getID(PBItems,item)
      end
    [COLOR="Red"]  item=rand(PBItems::CUSTOMITEM)+1 if $game_switches[RANDOMIZER][/COLOR]

    You don't need the check to see if item is nil - the function itself does that (if item was nil, an error message will pop up.) The original way you had it also only would randomize items if the item was written as a number (pbRecieveItem(2) instead of pbRecieveItem(:SUPERPOTION) )

    Notes:
    1.) I'm fairly certain that pbRecieveItem is used by a lot more than item balls. NPCs and possibly even the item shop. Which means the player would think they're buying a potion and instead get a Cherish Ball. Maybe you can play off that and make shops sell "???" in Randomizer?
    2.) This still includes every single item, even Key Items. Considering some items are needed in order to progress, you need a way to say "this item get isn't randomized ever"
    3.) This code will only work if Custom Item is an item in items.txt
     
    Last edited:
    You don't need the check to see if item is nil - the function itself does that (if item was nil, an error message will pop up.) The original way you had it also only would randomize items if the item was written as a number (pbRecieveItem(2) instead of pbRecieveItem(:SUPERPOTION) )

    Notes:
    1.) I'm fairly certain that pbRecieveItem is used by a lot more than item balls. NPCs and possibly even the item shop. Which means the player would think they're buying a potion and instead get a Cherish Ball. Maybe you can play off that and make shops sell "???" in Randomizer?
    2.) This still includes every single item, even Key Items. Considering some items are needed in order to progress, you need a way to say "this item get isn't randomized ever"
    3.) This code will only work if Custom Item is an item in items.txt

    Thanks and i was more like making it for a Daily Item Event or Lottery
     
    (Maruno likely knows a way to just grab the total number of moves legitimately rather than the workaround I came up with when I discovered that "PBMoves.maxvalue" didn't work like it does with "PBSpecies.maxvalue").
    PBMoves.maxValue should work. It's used by Metronome's effect, for one. Note the camelCase.

    I think I would approach this topic by considering how the game knows which moves/items/whatever to come up with normally, i.e. without a randomiser. All this information (except Mart inventories and item balls which are map events) is stored in data files, which are compiled from the PBS files.

    My solution would be to generate alternate data files, separate from the original ones, by copying the original ones and randomising the appropriate values in them before writing them. Then edit the scripts to use these alternate data files instead if they exist and you're playing a randomised game. When you start a new game with the randomised feature, you generate these new data files. This results in consistent alternate moves/items/whatever, so Pokémon would remain the same type(s) and so forth. Generating them upon starting a new game would allow different randomisations each time the player starts over, increasing replayability, but the downside is that old save files would become irreparably altered due to the new data.

    When you generate the alternate data files, you will of course be able to prevent some things (e.g. Key Items) from being randomised.
     
    Back
    Top