• 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!
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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.

Random Market

Zeak6464

Zeak #3205 - Discord
  • 1,099
    Posts
    12
    Years
    This scrip make it so that shops can have random items for sell.
    $game_switches[799]==true is the switch it checks - Can be changed to any switch number
    This will also check the price of items as well now pbGetPrice(item)<=100


    credit : Mej71 - https://www.pokecommunity.com/threads/360904
    editor: Zeak6464 - made the script plug-play

    Code:
    class PokemonGlobalMetadata
      attr_accessor :itemHash
      
      def initialize
        @itemHash=nil
      end
    end
    
    def createItemHash
      itemHash={}
      itemArr=[]
      for i in 1..PBItems.maxValue
        itemArr.push(i)
      end
      itemArr.shuffle!
      itemArr.insert(0,nil)
      for i in 1...itemArr.length
        itemHash[i]=itemArr[i]
      end
      $PokemonGlobal.itemHash=itemHash
    end
    
    #Randomize items in mart
    alias random_pbPokemonMart pbPokemonMart
    def pbPokemonMart(stock,speech=nil,cantsell=false)
      createItemHash
      if $game_switches[799]==true
        for i in 0...stock.length
          item=getID(PBItems, stock[i])
          if !pbIsKeyItem?(item) && !pbIsHiddenMachine?(item) && !pbIsMail?(item) && !pbIsImportantItem?(item)
            item=$PokemonGlobal.itemHash[item]
            while (pbIsKeyItem?(item) || pbIsHiddenMachine?(item) || pbIsMail?(item) || pbIsImportantItem?(item) || pbGetPrice(item)<=100)
              item=0 if item+1>=($PokemonGlobal.itemHash.length)
              item=$PokemonGlobal.itemHash[item+1]
            end
            stock[i]=item
          end
        end
      end
      return random_pbPokemonMart(stock,speech,cantsell)
    end
     
    Last edited:
    i would make a suggestion of not allowing certain items to be sold for example key items
    if pbIsKeyItem?(item)
    next
    end
    putting this line after "#Last Item it randomizes from" will make it skip key items
    and you can add more if you so wish?
     
    Back
    Top