• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • 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
    12
    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:
    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)
     
    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