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
$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: