Resource icon

Dark Grass Like in Black and White Games

##################################################################
# Dark Grass like in BW/B2W2 (can be extended to Flabebe/Oricorio grass #
# by Juliorain and (big shout out to Vendily!) #
##################################################################

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
paste:

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.
Credits
Juliorain + Vendily
Author
juliorain
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from juliorain

  • Rotom Pokedex
    Rotom Pokedex
    Rotom Pokedex UI and an example scene for using them!
Top