• 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 Conquest 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.

[Essentials Tutorial] Berry Tree From Galar

#Not Important

All hail the wishmaker
  • 910
    Posts
    5
    Years
    Hi everyone!
    I've been writing this script for a berry tree from Galar
    Change Log:
    Spoiler:

    But here be the tutorial:
    Change in PField_Encounters:
    Spoiler:
    To:
    Spoiler:
    Now here is the big part of the tutorial:
    Add a new script above main and below compiler that is:
    Spoiler:
    Also here:

    Now, we have created an encounter type and a script that calls it, Now to set the encounters:
    In Pokemon Game/PBS/encounters.txt add "BerryTree" encounters in format 20%,20%,10%,10%,10%,10%,5%,5%,4%,4%,1%,1%.
    e.g.:
    Spoiler:
    Will be improved...
     
    Last edited:
    wonderfull script, love it!!!
    I got an error trying to select "No" and when I put "x" to quit, the game crashes
    imgur(dot)com/WHG4jtq
     
    Last edited:
    wonderfull script, love it!!!
    I got an error trying to select "No" and when I put "x" to quit, the game crashes
    imgur(dot)com/WHG4jtq

    Yeah... fixing that and also making "No" actually work😅
     
    MAJOR UPDATE
    "No" Works now!
    Working on fully random results, and also now there are 52 More berries in the script, if you copy the Items.txt file (up to the shiny charm)
    Replace the main script
    Yeah...
    Thats it...
     
    Is there a way to implement the script without changing the numbers in items.txt, this would be a great function but if i have to dig through and rename every item in graphic/icons its really not worth it over regular berries.
     
    When I set it up with your fix i get an error that says rand can't turn a range into an integer. Going to attempt to break the range out into a list. Will update once i try.
     
    When I set it up with your fix i get an error that says rand can't turn a range into an integer. Going to attempt to break the range out into a list. Will update once i try.

    I think range support is implemented in Marin's Utils, or something. rand(a...b) is equivalent to... a + rand(b-a+1), IIRC.
     
    When I set it up with your fix i get an error that says rand can't turn a range into an integer. Going to attempt to break the range out into a list. Will update once i try.

    Nononononononononononononononononononononononononononononononono
    I'll do it, Don't worry 😅
     
    MAJOR UPDATE
    V1.2.0
    No items.txt editing needed
    Fixed the range randomization
    Made script shorter
    FOR THOSE WHO HAD THE SCRIPT:
    Change the script to this:
    Spoiler:
    [/code]
    Also here: https://pastebin.com/raw/L0BtuQ4W
    And revert the items.txt file up to the shiny charm to this:
    Spoiler:
     
    Last edited:
    I did run into another problem. I can get a random berry now but i can't trigger a random battle from the pbBerryTree. I did set up the encounter and pbBerryTreeTest works fine but pbBerryTree gave me over 50 berries with no encounter. Unless i am extremely lucky that shouldn't be working like that. After some testing I have found that no matter what numbers are after this line:if $game_variables[101]=1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9. it returns a berry. I replaced that line with if $game_variables[101]=44 and i still got a berry every time.
     
    Last edited:
    I did run into another problem. I can get a random berry now but i can't trigger a random battle from the pbBerryTree. I did set up the encounter and pbBerryTreeTest works fine but pbBerryTree gave me over 50 berries with no encounter. Unless i am extremely lucky that shouldn't be working like that. After some testing I have found that no matter what numbers are after this line:if $game_variables[101]=1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9. it returns a berry. I replaced that line with if $game_variables[101]=44 and i still got a berry every time.

    if $game_variables[101]=1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 this is equivalent to
    Code:
    $game_variables[101]=1
    if true
    You want something like
    [1,2,3,4,5,6,7,8,9].include?($game_variables[101])
     
    Maybe make a different event for each of them
    Like:
    Code:
    if $game_variables[101]=1
      Kernel.pbItemBall(rand(389...453))
    end
    if $game_variables[101]=2
      Kernel.pbItemBall(rand(389...453))
    end
    And so on...
    That should work
     
    Maybe make a different event for each of them
    Like:
    Code:
    if $game_variables[101]=1
      Kernel.pbItemBall(rand(389...453))
    end
    if $game_variables[101]=2
      Kernel.pbItemBall(rand(389...453))
    end
    And so on...
    That should work

    This will execute all the ifs. You mean == not =.

    EDIT: At which point include just makes more sense. Or $game_variables[101]==1 || $game_variables[101]==2 || $game_variables[101]==3 (etc) if you really like typing.
     
    if you really like typing.
    Actually, it would be like this:
    Code:
    day=pbGetTimeNow.day
    if LikesTyping? || (user==#Not Important && day==Friday)
      pbFixScript
    end
    for those who didn't understand:
    Spoiler:

    nice to see people using the block apart from me!
     
    Last edited:
    I updated the script and it works as intended now. I did want to point out one other thing that i had to change so that it ran proper, so anyone else who uses it knows and you can update your main script. rand(10) generates a number from 0-9 not 1-10, so i just set the if statement accordingly.

    My functioning script:
    Code:
    if Kernel.pbConfirmMessage("It's a berry tree would you like to shake it?")
            $game_variables[101]=rand(10)  #Encounters 2/10 of the time
            if $game_variables[101]==0 || $game_variables[101]==1 || $game_variables[101]==2 || $game_variables[101]==3 || $game_variables[101]==4 || $game_variables[101]==5 || $game_variables[101]==6 || $game_variables[101]==7 
              Kernel.pbItemBall(rand(389...453))
            elsif $game_variables[101]==8 || $game_variables[101]==9 
               pbEncounter(EncounterTypes::BerryTree)
               Kernel.pbMessage("Other pokemon took the berries left on the tree away...")
               exit=1#Exits
               break
     
    Last edited:
    I updated the script and it works as intended now. I did want to point out one other thing that i had to change so that it ran proper, so anyone else who uses it knows and you can update your main script. rand(10) generates a number from 0-9 not 1-10, so i just set the if statement accordingly.

    My functioning script:
    Code:
    if Kernel.pbConfirmMessage("It's a berry tree would you like to shake it?")
            $game_variables[101]=rand(10)  #Encounters 2/10 of the time
            if $game_variables[101]==0 || $game_variables[101]==1 || $game_variables[101]==2 || $game_variables[101]==3 || $game_variables[101]==4 || $game_variables[101]==5 || $game_variables[101]==6 || $game_variables[101]==7 
              Kernel.pbItemBall(rand(389...453))
            elsif $game_variables[101]==8 || $game_variables[101]==9 
               pbEncounter(EncounterTypes::BerryTree)
               Kernel.pbMessage("Other pokemon took the berries left on the tree away...")
               exit=1#Exits
               break

    Cool! Also thanks mgriffin
     
    Back
    Top