• 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?".
  • Staff applications for our PokéCommunity Daily and Social Media team are now open! Interested in joining staff? Then click here for more info!
  • 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.

Triple Triad Booster Pack

FL

Pokémon Island Creator
  • 2,505
    Posts
    14
    Years
    • Seen yesterday
    [PokeCommunity.com] Triple Triad Booster Pack

    Booster pack item with predefined sets for Triple Triad minigame.

    Link

    Tested on Essentials v13, v20.1 and v21.1. If this script isn't working on latest Essentials version, please inform on this thread.
     
    Last edited:
    I updated the main thread to a more broad approach, that you can define the entire card set. Old code:
    Spoiler:
     
    Last edited:
    I updated the old code to a more broad approach, that you can define the entire card set.
    Spoiler:
    Really thank you for this FL, but i have not understand how to create a specific card type. Can you give me an exemple?
     
    Really thank you for this FL, but i have not understand how to create a specific card type. Can you give me an exemple?
    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.
     
    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.
    Thank you FL finally i've created my special packs. Thank you again :)
     
    @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.
     
    @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.
    Say the species available on a pack and I make one for you.
     
    Ghost and if possible a booster that contains fire + grass (to emulate the brushfire theme deck) if not all 3 of these separately will do thank you again in advance im attempting to learn code by reverse engineering scripts like this so your help would be most valued.
     
    Change line '115, 128, 132, 133, 137, 143]' into

    Code:
        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]

    After the script, add

    Code:
    ItemHandlers::UseFromBag.add(:GHOSTPACK,proc{|item|
      giveBoosterPack(item,3,3)
    })
    
    ItemHandlers::UseFromBag.add(:BRUSHFIREPACK,proc{|item|
      giveBoosterPack(item,3,4)
    })

    Add, on items.txt PBS:

    Code:
    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,

    And done!

    I got the species numbers using the script line 'p ("ghost",getSpeciesOfType(PBTypes::GHOST),"fire",getSpeciesOfType(PBTypes::FIRE),"grass",getSpeciesOfType(PBTypes::GRASS))'.
     
    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
     
    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
    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'.
     
    I corrected that problem still giving me a syntax error on the line reading if MIN_BOOSTER_STOCK>30

    this is the script including the modifications

    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
    
    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)
    })
     
    After line '546, 547, 548, 549, 556, 585, 586, 590, 591, 597, 598, 640]' you removed a line with only a ']' character, add it again.
     
    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?
     
    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?

    Show us what your items.txt looks like on line 526 or we can't help you.
     
    Last edited:
    Hello! 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
     
    Last edited:
    Hello! 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
    After line `class TriadStorage` add
    Code:
    def sort
      @items= @items.sort_by { |item| item[0]}
    end
    And call '$PokemonGlobal.triads.sort' on pbTriadList start or each time that a card is added.
     
    Back
    Top