#===============================================================================
# * Triple Triad Booster Pack - by FL (Credits will be apreciated)
#===============================================================================
#
# This script is for Pokémon Essentials. It's a booster pack item for
# Triple Triad minigame.
#
#===============================================================================
#
# To this script works, put it above main. Put an item into item.txt like:
#
# 712,BOOSTERPACK,Booster Pack,1,500,An booster pack for Triple Triad game. Contains 3 cards ,2,0,0,
#
# You can set a max/min value for the biggest attribute in a card. So, you can
# create several types of packs, an example where 3 is the number of cards,
# 5 is the minimum level and 9 is the maximum level:
#
# ItemHandlers::UseFromBag.add(:SUPERPACK,proc{|item|
# giveBoosterPack(item,3,5,9)
# })
#
# This script generates random cards, but generate some cards in order to a
# player won't reset the game trying to get other cards. The variable
# MIN_BOOSTER_STOCK defines how many cards are stocked in save. If the number
# in this variable is 5, by example, and the values are initialized. Even if
# the player saves and keep opening the packs and resetting, he gets the same
# first 5 cards, since these cards are randomized only the 5 cards ahead. To
# disable this feature, just make the variable value as 0.
#
# I suggest you to initialize this list after the professor lecture, for all
# packs. If, in your game, you have packs from min/max levels from 2/4, 3/6
# and 5/9, after professor lecture add the script commands:
#
# $PokemonGlobal.fillBoosterStock(2,4)
# $PokemonGlobal.fillBoosterStock(3,6)
# $PokemonGlobal.fillBoosterStock(5,9)
#
#===============================================================================
MIN_BOOSTER_STOCK=30
if MIN_BOOSTER_STOCK>0
class PokemonGlobalMetadata
def fillBoosterStock(minLevel,maxLevel)
@boosterStock=[] if !@boosterStock
@boosterStock[minLevel]=[] if @boosterStock.size<=minLevel
if @boosterStock[minLevel].size<=maxLevel
@boosterStock[minLevel][maxLevel]=[]
end
while @boosterStock[minLevel][maxLevel].size<MIN_BOOSTER_STOCK
randomCard = getRandomTriadCard(minLevel,maxLevel)
@boosterStock[minLevel][maxLevel].push(randomCard)
end
end
def getFirstBoosterAtStock(minLevel,maxLevel)
# Called twice since the variable maybe isn't initialized
fillBoosterStock(minLevel,maxLevel)
newCard = @boosterStock[minLevel][maxLevel].shift
fillBoosterStock(minLevel,maxLevel)
return newCard
end
end
end
def getRandomTriadCard(minLevel,maxLevel)
overflowCount=0
loop do
overflowCount+=1
raise "Can't draw a random card!" if overflowCount>10000
randomPokemon = rand(PBSpecies.maxValue)+1
cname=getConstantName(PBSpecies,randomPokemon) rescue nil
next if !cname
triad=TriadCard.new(randomPokemon)
level=[triad.north,triad.south,triad.east,triad.west].max
next if level<minLevel || level>maxLevel
return randomPokemon
end
end
def giveBoosterPack(item,numberOfCards,minLevel=0,maxLevel=20)
Kernel.pbMessage(_INTL("{1} opened the {2}.",
$Trainer.name,PBItems.getName(item)))
cardEarned = 0
overflowCount = 0
for i in 0...numberOfCards
card=-1
if MIN_BOOSTER_STOCK>0
card = $PokemonGlobal.getFirstBoosterAtStock(minLevel,maxLevel)
else
card = getRandomTriadCard(minLevel,maxLevel)
end
pbGiveTriadCard(card,1)
Kernel.pbMessage(_INTL("{1} draws {2} card!",
$Trainer.name,getConstantName(PBSpecies,card)))
end
return 3
end
ItemHandlers::UseFromBag.add(:BOOSTERPACK,proc{|item|
giveBoosterPack(item,3)
})
Really thank you for this FL, but i have not understand how to create a specific card type. Can you give me an exemple?I updated the old code to a more broad approach, that you can define the entire card set.
Spoiler:Code:#=============================================================================== # * Triple Triad Booster Pack - by FL (Credits will be apreciated) #=============================================================================== # # This script is for Pokémon Essentials. It's a booster pack item for # Triple Triad minigame. # #=============================================================================== # # To this script works, put it above main. Put an item into item.txt like: # # 712,BOOSTERPACK,Booster Pack,1,500,An booster pack for Triple Triad game. Contains 3 cards ,2,0,0, # # You can set a max/min value for the biggest attribute in a card. So, you can # create several types of packs, an example where 3 is the number of cards, # 5 is the minimum level and 9 is the maximum level: # # ItemHandlers::UseFromBag.add(:SUPERPACK,proc{|item| # giveBoosterPack(item,3,5,9) # }) # # This script generates random cards, but generate some cards in order to a # player won't reset the game trying to get other cards. The variable # MIN_BOOSTER_STOCK defines how many cards are stocked in save. If the number # in this variable is 5, by example, and the values are initialized. Even if # the player saves and keep opening the packs and resetting, he gets the same # first 5 cards, since these cards are randomized only the 5 cards ahead. To # disable this feature, just make the variable value as 0. # # I suggest you to initialize this list after the professor lecture, for all # packs. If, in your game, you have packs from min/max levels from 2/4, 3/6 # and 5/9, after professor lecture add the script commands: # # $PokemonGlobal.fillBoosterStock(2,4) # $PokemonGlobal.fillBoosterStock(3,6) # $PokemonGlobal.fillBoosterStock(5,9) # #=============================================================================== MIN_BOOSTER_STOCK=30 if MIN_BOOSTER_STOCK>0 class PokemonGlobalMetadata def fillBoosterStock(minLevel,maxLevel) @boosterStock=[] if !@boosterStock @boosterStock[minLevel]=[] if @boosterStock.size<=minLevel if @boosterStock[minLevel].size<=maxLevel @boosterStock[minLevel][maxLevel]=[] end while @boosterStock[minLevel][maxLevel].size<MIN_BOOSTER_STOCK randomCard = getRandomTriadCard(minLevel,maxLevel) @boosterStock[minLevel][maxLevel].push(randomCard) end end def getFirstBoosterAtStock(minLevel,maxLevel) # Called twice since the variable maybe isn't initialized fillBoosterStock(minLevel,maxLevel) newCard = @boosterStock[minLevel][maxLevel].shift fillBoosterStock(minLevel,maxLevel) return newCard end end end def getRandomTriadCard(minLevel,maxLevel) overflowCount=0 loop do overflowCount+=1 raise "Can't draw a random card!" if overflowCount>10000 randomPokemon = rand(PBSpecies.maxValue)+1 cname=getConstantName(PBSpecies,randomPokemon) rescue nil next if !cname triad=TriadCard.new(randomPokemon) level=[triad.north,triad.south,triad.east,triad.west].max next if level<minLevel || level>maxLevel return randomPokemon end end def giveBoosterPack(item,numberOfCards,minLevel=0,maxLevel=20) Kernel.pbMessage(_INTL("{1} opened the {2}.", $Trainer.name,PBItems.getName(item))) cardEarned = 0 overflowCount = 0 for i in 0...numberOfCards card=-1 if MIN_BOOSTER_STOCK>0 card = $PokemonGlobal.getFirstBoosterAtStock(minLevel,maxLevel) else card = getRandomTriadCard(minLevel,maxLevel) end pbGiveTriadCard(card,1) Kernel.pbMessage(_INTL("{1} draws {2} card!", $Trainer.name,getConstantName(PBSpecies,card))) end return 3 end ItemHandlers::UseFromBag.add(:BOOSTERPACK,proc{|item| giveBoosterPack(item,3) })
First, use the main thread script (I edited the post to make it more clear). At script event command, use 'p getSpeciesOfType(PBTypes::DRAGON)', by example, and copy/past the result in the third array in BOOSTER_LIST (the one that starts with '[16'). After that, just copy the example DRAGONPACK.Really thank you for this FL, but i have not understand how to create a specific card type. Can you give me an exemple?
Thank you FL finally i've created my special packs. Thank you again :)First, use the main thread script (I edited the post to make it more clear). At script event command, use 'p getSpeciesOfType(PBTypes::DRAGON)', by example, and copy/past the result in the third array in BOOSTER_LIST (the one that starts with '[16'). After that, just copy the example DRAGONPACK.
Say the species available on a pack and I make one for you.@dydd90 can you please post a copy of the script having hard time understanding but if i saw your modification to the script im sure i would understand. Thanks in advance also if your modification had multiple custom packs that would be great.
115, 128, 132, 133, 137, 143],
# Ghost Pack. Index 3
[92, 93, 94, 200, 292, 302, 353, 354, 355, 356, 425, 426, 429, 442, 477, 478,
479, 487, 562, 563, 592, 593, 607, 608, 609, 622, 623],
# Brushfire Pack. Index 4
[4, 5, 6, 37, 38, 58, 59, 77, 78, 126, 136, 146, 155, 156, 157, 218, 219, 228,
229, 240, 244, 250, 255, 256, 257, 322, 323, 324, 390, 391, 392, 467, 485,
494, 498, 499, 500, 513, 514, 554, 555, 607, 608, 609, 631, 636, 637, 643,
1, 2, 3, 43, 44, 45, 46, 47, 69, 70, 71, 102, 103, 114, 152, 153, 154, 182,
187, 188, 189, 191, 192, 251, 252, 253, 254, 270, 271, 272, 273, 274, 275,
285, 286, 315, 331, 332, 345, 346, 357, 387, 388, 389, 406, 407, 413, 420,
421, 455, 459, 460, 465, 470, 492, 495, 496, 497, 511, 512, 540, 541, 542,
546, 547, 548, 549, 556, 585, 586, 590, 591, 597, 598, 640]
ItemHandlers::UseFromBag.add(:GHOSTPACK,proc{|item|
giveBoosterPack(item,3,3)
})
ItemHandlers::UseFromBag.add(:BRUSHFIREPACK,proc{|item|
giveBoosterPack(item,3,4)
})
801,GHOSTPACK,Ghost Pack,Ghost Packs,1,500,Description goes here,2,0,0,
802,BRUSHFIREPACK,Brushfire Pack,Brushfire Pack,1,500,Description goes here,2,0,0,
So, you pasted in the wrong place, since line 44 reads "MIN_BOOSTER_STOCK=30". Paste here the lines between the script comment reader and 'if MIN_BOOSTER_STOCK>0'.its given me a syntax error line 66 the line reads MIN_BOOSTER_STOCK=30 any idea whats going on i pasted the code in all the right places and it all makes sense to me
#===============================================================================
# * Triple Triad Booster Pack - by FL (Credits will be apreciated)
#===============================================================================
#
# This script is for Pokémon Essentials. It's a booster pack item for
# Triple Triad minigame.
#
#===============================================================================
#
# To this script works, put it above main. Put an item into item.txt like:
#
# 712,BOOSTERPACK,Booster Pack,1,500,An booster pack for Triple Triad game. Contains 3 cards ,2,0,0,
#
# You can set a max/min value for the biggest attribute in a card. So, you can
# create several types of packs, an example where 3 is the number of cards,
# 5 is the minimum level and 9 is the maximum level:
#
# ItemHandlers::UseFromBag.add(:SUPERPACK,proc{|item|
# giveBoosterPack(item,3,5,9)
# })
#
# This script generates random cards, but generate some cards in order to a
# player won't reset the game trying to get other cards. The variable
# MIN_BOOSTER_STOCK defines how many cards are stocked in save. If the number
# in this variable is 5, by example, and the values are initialized. Even if
# the player saves and keep opening the packs and resetting, he gets the same
# first 5 cards, since these cards are randomized only the 5 cards ahead. To
# disable this feature, just make the variable value as 0.
#
# I suggest you to initialize this list after the professor lecture, for all
# packs. If, in your game, you have packs from min/max levels from 2/4, 3/6
# and 5/9, after professor lecture add the script commands:
#
# $PokemonGlobal.fillBoosterStock(2,4)
# $PokemonGlobal.fillBoosterStock(3,6)
# $PokemonGlobal.fillBoosterStock(5,9)
#
#===============================================================================
MIN_BOOSTER_STOCK=30
BOOSTER_LIST=[
nil,
# The below line is the booster of index 1
[1,4,9,152,155,158,252,255,258,387,390,393,495,498,501],
[16, 17, 18, 19, 20, 21, 22, 35, 36, 39, 40, 52, 53, 83, 84, 85, 108, 113,
115, 128, 132, 133, 137, 143],
# Ghost Pack. Index 3
[92, 93, 94, 200, 292, 302, 353, 354, 355, 356, 425, 426, 429, 442, 477, 478,
479, 487, 562, 563, 592, 593, 607, 608, 609, 622, 623],
# Brushfire Pack. Index 4
[4, 5, 6, 37, 38, 58, 59, 77, 78, 126, 136, 146, 155, 156, 157, 218, 219, 228,
229, 240, 244, 250, 255, 256, 257, 322, 323, 324, 390, 391, 392, 467, 485,
494, 498, 499, 500, 513, 514, 554, 555, 607, 608, 609, 631, 636, 637, 643,
1, 2, 3, 43, 44, 45, 46, 47, 69, 70, 71, 102, 103, 114, 152, 153, 154, 182,
187, 188, 189, 191, 192, 251, 252, 253, 254, 270, 271, 272, 273, 274, 275,
285, 286, 315, 331, 332, 345, 346, 357, 387, 388, 389, 406, 407, 413, 420,
421, 455, 459, 460, 465, 470, 492, 495, 496, 497, 511, 512, 540, 541, 542,
546, 547, 548, 549, 556, 585, 586, 590, 591, 597, 598, 640]
if MIN_BOOSTER_STOCK>0
class PokemonGlobalMetadata
def fillBoosterStock(minLevel,maxLevel)
@boosterStock=[] if !@boosterStock
@boosterStock[minLevel]=[] if @boosterStock.size<=minLevel
if @boosterStock[minLevel].size<=maxLevel
@boosterStock[minLevel][maxLevel]=[]
end
while @boosterStock[minLevel][maxLevel].size<MIN_BOOSTER_STOCK
randomCard = getRandomTriadCard(minLevel,maxLevel)
@boosterStock[minLevel][maxLevel].push(randomCard)
end
end
def getFirstBoosterAtStock(minLevel,maxLevel)
# Called twice since the variable maybe isn't initialized
fillBoosterStock(minLevel,maxLevel)
newCard = @boosterStock[minLevel][maxLevel].shift
fillBoosterStock(minLevel,maxLevel)
return newCard
end
end
end
def getRandomTriadCard(minLevel,maxLevel)
overflowCount=0
loop do
overflowCount+=1
raise "Can't draw a random card!" if overflowCount>10000
randomPokemon = rand(PBSpecies.maxValue)+1
cname=getConstantName(PBSpecies,randomPokemon) rescue nil
next if !cname
triad=TriadCard.new(randomPokemon)
level=[triad.north,triad.south,triad.east,triad.west].max
next if level<minLevel || level>maxLevel
return randomPokemon
end
end
def giveBoosterPack(item,numberOfCards,minLevel=0,maxLevel=20)
Kernel.pbMessage(_INTL("{1} opened the {2}.",
$Trainer.name,PBItems.getName(item)))
cardEarned = 0
overflowCount = 0
for i in 0...numberOfCards
card=-1
if MIN_BOOSTER_STOCK>0
card = $PokemonGlobal.getFirstBoosterAtStock(minLevel,maxLevel)
else
card = getRandomTriadCard(minLevel,maxLevel)
end
pbGiveTriadCard(card,1)
Kernel.pbMessage(_INTL("{1} draws {2} card!",
$Trainer.name,getConstantName(PBSpecies,card)))
end
return 3
end
ItemHandlers::UseFromBag.add(:BOOSTERPACK,proc{|item|
giveBoosterPack(item,3)
})
ItemHandlers::UseFromBag.add(:GHOSTPACK,proc{|item|
giveBoosterPack(item,3,3)
})
ItemHandlers::UseFromBag.add(:BRUSHFIREPACK,proc{|item|
giveBoosterPack(item,3,4)
})
I tried the code but for some reason it keeps giving me this error:
---------------------------
Pokemon
---------------------------
Exception: RuntimeError
Message: Field is not a positive integer
File PBS/items.txt, line 526
Compiler:417:in `csvPosInt!'
Compiler:494:in `pbGetCsvRecord'
Compiler:490:in `each'
Compiler:490:in `pbGetCsvRecord'
Compiler:1612:in `pbCompileItems'
Compiler:1611:in `pbCompilerEachCommentedLine'
Compiler:271:in `each_line'
Compiler:271:in `pbCompilerEachCommentedLine'
Compiler:268:in `open'
Compiler:268:in `pbCompilerEachCommentedLine'
How do I fix it?
You forgot about the last three numbers...526,BOOSTERPACK,Booster Pack,Booster Packs,1,500,"A booster pack for Triple Triad game."
After line `class TriadStorage` addHello! Great script, FL. I have included it and made my own packs, but I would like to ask you something. Do you know if it is possible for the cards to be sorted by Pokémon ID when calling "pbTriadList"?
I would like players to collect all cards, and sorting them by ID would make things so much more comfortable for them.
Thank you in advance! :D
def sort
@items= @items.sort_by { |item| item[0]}
end