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

Randomise Items Gained

Zeak6464

Zeak #3205 - Discord
1,101
Posts
11
Years
  • This will randomize items so any items gained will be randomized even key-items

    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]

    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 CustomItem is an item in items.txt
     
    Last edited:
    824
    Posts
    8
    Years
  • This one still needs some fine-tuning IMO, but I don't even know where to begin.

    Also, it randomizes ALL items gained, not just the ones written as a number. The one you wrote originally was the one that had that issue (the one that had elsif)
     

    Nickalooose

    --------------------
    1,309
    Posts
    16
    Years
    • Seen Dec 28, 2023
    I found something I used a long time ago, maybe you can make better use than I ever will.
    I added some comments in-case you'd like to understand it:
    Code:
    # Use this as a 'Conditional Branch' script.
    # Just call 'randomItemBall' or 'randomItemBall(5)' etc.
    def randomItemBall(qty=1) # qty = quantity, will always equal 1 unless told different
      ret=false
      item=rand(PBItems.maxValue) # random number within the items.txt
      # Now check if the item is:
      # 1. an item
      # 2. not a key item
      # 3. not a TM
      # 4. not a HM
      while (item==0 || pbIsKeyItem?(item) || 
              pbIsTechnicalMachine?(item) || pbIsHiddenMachine?(item))
        item=rand(PBItems.maxValue)
      end
      ret=Kernel.pbItemBall(item,qty) # Add the item
      return ret # return true or false
    end
    Edit accordingly, but remember, this will still return MasterBalls and other "non" key items.
     
    Back
    Top