• 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] Dark Grass with Custom Wild Battle BGM

1,805
Posts
7
Years
  • ##################################################################
    # Dark Grass like in BW/B2W2 (can be extended to Flabebe/Oricorio grass) #
    # by Juliorain and (big shout out to Vendily!) #
    # Please credit us....took ages to figure out the details #
    # Special thanks for Riviera for debugging #
    ##################################################################

    Because fangames vary across possible encounters this assumes you have several things:

    - 2 Grass Sprites in your tileset and you have your alt wild battle theme
    - Assuming you just have the default encounters and/or terrain tags, if you have multiple custom ones, it is good to know that they are compatible. Just the module numbers might vary.
    - This guide is for v17.2 as the scripts needed are most likely not available in earlier versions...the code is there, but it is up to you dig for that

    This has three sections:

    1) Terrain Tag
    2) Encounter
    3) Music Code

    1) This is perhaps the most straightforward code:

    Add:

    Code:
      DarkGrass       = 16


    in the module in PBTerrain. If you have other terrains installed, use the lowest unused number.

    after that find the methods PBTerrain.isGrass? and PBTerrain.isJustGrass?

    replace with:

    Code:
       def PBTerrain.isGrass?(tag)
        return tag==PBTerrain::Grass ||
               tag==PBTerrain::TallGrass ||
               tag==PBTerrain::UnderwaterGrass ||
               tag==PBTerrain::SootGrass ||
               tag==PBTerrain::DarkGrass
      end
    
      def PBTerrain.isDarkGrass?(tag)
        return tag==PBTerrain::DarkGrass
      end
      
      def PBTerrain.isJustGrass?(tag)   # The Poké Radar only works in these tiles
        return tag==PBTerrain::Grass ||
               tag==PBTerrain::SootGrass ||
               tag==PBTerrain::DarkGrass
             end
        
      def PBTerrain.isJustDarkGrass?(tag)
        return tag==PBTerrain::DarkGrass
        end

    Part 2: In PBEncounters
    add
    Code:
      DarkGrass    = 13
      DarkGrassMorn = 14
      DarkGrassDay = 15
      DarkGrassNite = 16

    into Module EncounterTypes

    followed by:

    Code:
           "DarkGrass",
         "DarkGrassMorn",
         "DarkGrassDay",
         "DarkGrassNite"

    within the module. Remember to watch for your commas!

    In the string EncounterTypes add (while paying attention to formatting!):

    Code:
         [20,20,10,10,10,10,5,5,4,4,1,1],

    or whichever encounter percentages you wish for *each* new encounter!

    Finally in EnctypeDensities

    add four 25's and 1's to each respective string. Your game will crash if you skip this step. If you have a differing number of new encounters, enter the information for however many new encounters you have.

    then under method def isGrass?

    add the following method:

    Code:
      def isDarkGrass?
        return false if @density==nil
        return (@enctypes[EncounterTypes::DarkGrass] ||
                @enctypes[EncounterTypes::DarkGrassMorn] ||
                @enctypes[EncounterTypes::DarkGrassDay] ||
                @enctypes[EncounterTypes::DarkGrassNite]) ? true : false
              end

    Then under the method def pbEncounterType directly under:

    Code:
        elsif self.isCave?
          return EncounterTypes::Cave

    Code:
         elsif self.isDarkGrass? && PBTerrain.isDarkGrass?($game_map.terrain_tag($game_player.x,$game_player.y))
          time = pbGetTimeNow
          enctype = EncounterTypes::DarkGrass
          enctype = EncounterTypes::DarkGrassNite if self.hasEncounter?(EncounterTypes::DarkGrassNite) && PBDayNight.isNight?(time)
          enctype = EncounterTypes::DarkGrassDay if self.hasEncounter?(EncounterTypes::DarkGrassDay) && PBDayNight.isDay?(time)
          enctype = EncounterTypes::DarkGrassMorn if self.hasEncounter?(EncounterTypes::DarkGrassMorn) && PBDayNight.isMorning?(time)
          return enctype

    here is where it gets tricky.

    replace the method def isEncounterPossibleHere? with:

    Code:
      def isEncounterPossibleHere?
        if $PokemonGlobal && $PokemonGlobal.surfing
          return true
        elsif PBTerrain.isIce?(pbGetTerrainTag($game_player))
          return false
        elsif self.isCave?
          return true
        elsif self.isGrass? || self.isDarkGrass?
          return PBTerrain.isGrass?($game_map.terrain_tag($game_player.x,$game_player.y)) || PBTerrain.isDarkGrass?($game_map.terrain_tag($game_player.x,$game_player.y))
        end
        return false
      end

    Since your encounter is dependent on terrain tag, pokemon essentials seems to only want to draw your in-game location once. If you have multiple calls for your terrain tag, the game will take only the first one. However, including the checks on the same line means that they are getting all your data at once. With this in mind you can actually extend it an infinite number of grass tiles so long as you do the above for each new type of terrain-dependent encounter (and your game can handle it!)

    If you have custom encounters, check to see if you can add your code to that method. For instance if you have sludge water, a special type of water encounters, then you might want to add that code back into the above method.

    and there you have it! you have dark grass encounters for all times of the day.

    Part 3: The music

    This took a little time but when I figured it out it was three lines of code.

    In PSystem_File Utilities

    ctrl+f for def pbGetWildBattleBGM(species) and under:

    Code:
      if $PokemonGlobal.nextBattleBGM
        return $PokemonGlobal.nextBattleBGM.clone
      end
    ret=nil

    add the three lines of code:

    Code:
       if !ret && $game_map && PBTerrain.isDarkGrass?($game_map.terrain_tag($game_player.x,$game_player.y))
       ret = pbStringToAudioFile("30 Wild Battle 02")
          end

    And voila! remember to specify the file name! It doesn't need the path to the BGM folder as it has been preloaded in another Utilities script. Just make sure it is in the BGM subfolder of your Audio folder, and spelled correctly.
     
    Last edited:
    2
    Posts
    7
    Years
    • Seen May 23, 2019
    This is great! Been searching for a clean and simple way to do this for ages.
     

    Juno and Ice

    Developer of Pokémon Floral Tempus
    150
    Posts
    5
    Years
    • Seen Apr 30, 2024
    Does this do double battles like it did in B2W2 or will we still have to use tall grass for that like Essentials already has?

    Edit: Also is there a way to make Tall Grass not have double wild battles, but make your dark grass have double wild battles?
     
    Last edited:
    1,805
    Posts
    7
    Years
  • Does this do double battles like it did in B2W2 or will we still have to use tall grass for that like Essentials already has?

    Edit: Also is there a way to make Tall Grass not have double wild battles, but make your dark grass have double wild battles?

    while this tutorial does not specifically add double wild battles, they are possible!

    in PBTerrain find the method def PBTerrain.isDoubleWildBattle?(tag)

    your default 17.2 version should look like that:
    Code:
      def PBTerrain.isDoubleWildBattle?(tag)
        return tag==PBTerrain::TallGrass
      end
    end

    simply add

    Code:
     || tag==PBTerrain::DarkGrass
    before the first end!


    Currently essentials has a 30% chance to make the encounter double... if you want to change it to a guaranteed chance,

    open PBField_Field and find the method def pbBattleOnStepTaken(repel=false)

    and find the line

    Code:
     ($Trainer.ablePokemonCount>1 && PBTerrain.isDoubleWildBattle?(pbGetTerrainTag) && rand(100)<30))

    and replace with

    Code:
     ($Trainer.ablePokemonCount>1 && PBTerrain.isDoubleWildBattle?(pbGetTerrainTag)))
     
    Last edited:
    1,805
    Posts
    7
    Years
  • Hey so if anyone was curious how to do Flabebe or Oricorio grass, apply the same trick but instead for

    RedFlower, YellowFlower, BlueFlower, and PinkFlower

    then for each flower type make a new PBTerrain.isYellowFlower?(tag) method for each. Remember to sneak the tags in the PBTerrain.isGrass? and PBTerrain.isJustGrass? to get the PokeRadar to work in them and display the rustling animation when walking on them!

    If you want them as separate encounters, repeat section 2 of the tutorial for each color of flower!

    Then in Pokemon_Forms:

    replace Flabebe's default block with:

    Code:
    MultipleForms.register(:ORICORIO,{
    "getFormOnCreation"=>proc{|pokemon|
       next 3 if $game_map && PBTerrain.isBlueFlower?($game_map.terrain_tag($game_player.x,$game_player.y))
       next 2 if $game_map && PBTerrain.isPinkFlower?($game_map.terrain_tag($game_player.x,$game_player.y))
       next 1 if $game_map && PBTerrain.isYellowFlower?($game_map.terrain_tag($game_player.x,$game_player.y))
       next 0
       }
    })
    
    MultipleForms.register(:FLABEBE,{
    "getFormOnCreation"=>proc{|pokemon|
       next 4 if $game_map && PBTerrain.isBlueFlower?($game_map.terrain_tag($game_player.x,$game_player.y))
       next [0,1,2,3][rand(4)] if $game_map && PBTerrain.isYellowFlower?($game_map.terrain_tag($game_player.x,$game_player.y)) || PBTerrain.isPinkFlower?($game_map.terrain_tag($game_player.x,$game_player.y)) || PBTerrain.isRedFlower?($game_map.terrain_tag($game_player.x,$game_player.y))
       next 0
    }
    })

    Be sure to keep the multipleforms.copy for Floette and Florges!
     
    Last edited:
    Back
    Top