• 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?".
  • 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
    4
    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:
  • 22
    Posts
    10
    Years
    • Seen Nov 24, 2023
    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:

    #Not Important

    All hail the wishmaker
  • 910
    Posts
    4
    Years
    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...
     
  • 23
    Posts
    9
    Years
    • Seen Apr 10, 2024
    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.
     

    #Not Important

    All hail the wishmaker
  • 910
    Posts
    4
    Years
    Yes it will be in the next version but if u want to do it now replace the
    Code:
    (rand(PBItems::ROWAPBERRY)+1)
    to
    Code:
    (rand(391...445)+1)
     
  • 23
    Posts
    9
    Years
    • Seen Apr 10, 2024
    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.
     
  • 1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    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.
     

    #Not Important

    All hail the wishmaker
  • 910
    Posts
    4
    Years
    That is closer than what I had (in terms of defining the berries) but it's not finished
    Pls don't add more scripts here
    But I might use the pickup berry thing
     
    Last edited:

    #Not Important

    All hail the wishmaker
  • 910
    Posts
    4
    Years
    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 😅
     

    #Not Important

    All hail the wishmaker
  • 910
    Posts
    4
    Years
    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:
  • 23
    Posts
    9
    Years
    • Seen Apr 10, 2024
    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:
  • 1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    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])
     

    #Not Important

    All hail the wishmaker
  • 910
    Posts
    4
    Years
    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
     
  • 1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    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.
     

    #Not Important

    All hail the wishmaker
  • 910
    Posts
    4
    Years
    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:
  • 23
    Posts
    9
    Years
    • Seen Apr 10, 2024
    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:

    #Not Important

    All hail the wishmaker
  • 910
    Posts
    4
    Years
    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
     
  • 54
    Posts
    4
    Years
    I keep getting the error message when trying to run the game:

    Script 'PField_BerryTree' line 58: SyntaxError ocurred.


    I reinstalled the Script some times to see if it solved the problem, but there doesn't seem to have anything wrong with the modified scripts at all.
     
    Back
    Top