• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • Eevee Expo's webhost has been having technical issues since Nov. 20th and you might be unable to connect to our site. Staff are also facing issues connecting, so please send a DM to Cat on-site or through Discord directly for faster service!
Resource icon

v19 Dark Grass Like in Black and White Games 1

This resource pertains to version 19 of Pokémon Essentials.
##################################################################
# Dark Grass like in BW/B2W2 (can be extended to Flabebe/Oricorio grass #
# by Juliorain and (big shout out to Vendily!) #
##################################################################
V 19.1. For v17.2 scroll down; its in the spoiler below

Remember to have your 1) secondary BGM at the ready, 2) secondary grass in your tileset, 3) you know to assign the terrain value to the tile via the debug editor

In v19 making new terrain types is actually a lot easier because now we can assign properties directly into the terrain tag itself, rather than creating like 5 different methods that checks for the the terrain and gives it their associated properties. But it can be a little trickier when you're working with EncTypes. Audio is roughly the same, apart from a terrain tag call name change.


Step 1:
in
Class:TerrainTag

add a new attr reader; it can be any name, but to save yourself from headaches I recommend you name it
attr_reader :dgrass_wild_encounters

in def intialize
add a hash that ideally matches your new variable, declare it as a bool and set its default value to false
@dgrass_wild_encounters = hash[:dgrass_wild_encounters] || false

find your Tall Grass

GameData::TerrainTag.register({
:id => :TallGrass,
:id_number => 10,
:deep_bush => true,
:land_wild_encounters => true,
:double_wild_encounters => true,
:battle_environment => :TallGrass,
:must_walk => true
})
copy/paste it. update its id number to something that is unused (best practice is to set it to lowest unused, which is 17 in vanilla essentials)
remove the :must_walk and replace :land_wild_encounters => true with your new :dgrass_wild_encounters => true

Step 2)

Go to EncounterType
and make a new encounter type by copypasting Land

GameData::EncounterType.register({
:id => :LandMorning,
:type => :land,
:trigger_chance => 21,
:old_slots => [20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1]
})

place it after LandNight for ease of placement in your Encounter data and replace :id with DarkGrass and :type with :darkgrass.

NOTE: :darkgrass is the id of the Encounter type and :DarkGrass is the name of the encounter type the game reads from your encounter.txt file

I am currently facing issues with PokeRadar compatibility so hang tight!


tuck your :dark grass in def has_land_encounters? . This method determines that your encounter will be triggered by walking over specified tiles.
# Returns whether land-like encounters have been defined for the current map.
# Applies only to encounters triggered by moving around.
def has_land_encounters?
GameData::EncounterType.each do |enc_type|
next if ![:land, :contest, :darkgrass].include?(enc_type.type)
return true if has_encounter_type?(enc_type.id)
end
return false
end

then in def encounter_possible_here does what the method says and is a bool check on whether it is possible to generate encounters
# Returns whether the player's current location allows wild encounters to
# trigger upon taking a step.
def encounter_possible_here?
return true if $PokemonGlobal.surfing
terrain_tag = $game_map.terrain_tag($game_player.x, $game_player.y)
return false if terrain_tag.ice
return true if has_cave_encounters? # i.e. this map is a cave
return true if has_land_encounters? && terrain_tag.land_wild_encounters || has_land_encounters? && terrain_tag.dgrass_wild_encounter
return false
end

after the OR evaluation you need to repeat the first check since it has to take :darkgrass from the array and checks your encounter data if it exists. You'll need to repeat the check here for every single new type of encounter grass you add.

finally this is the code that generates the encounter. notis the all caps after the ret = :DarkGrass is because it is now looking for the name of the encounter in your encounters.txt file. If you want to make each encounter time based, then add in the line ret = find_valid_encounter_type_for_time(:DarkGrass, time) if !ret, but you'd need to make a new enc type for each type of time encounter. HOWEVER, you do not need to do the last step every time if you assign the :darkgrass id to each of the timed encounters.
# Returns the encounter method that the current encounter should be generated
# from, depending on the player's current location.
def encounter_type
time = pbGetTimeNow
ret = nil
if $PokemonGlobal.surfing
ret = find_valid_encounter_type_for_time(:Water, time)
else # Land/Cave (can have both in the same map)
if has_land_encounters? && $game_map.terrain_tag($game_player.x, $game_player.y).land_wild_encounters
ret = :BugContest if pbInBugContest? && has_encounter_type?(:BugContest)
ret = find_valid_encounter_type_for_time(:Land, time) if !ret
end
if has_land_encounters? && $game_map.terrain_tag($game_player.x, $game_player.y).dgrass_wild_encounters
ret = :DarkGrass
end
if !ret && has_cave_encounters?
ret = find_valid_encounter_type_for_time(:Cave, time)
end
end
return ret
end

3) Same as in v17.2 but actually a lot easier. go to Utilities_BattleAudio

and insert this chunk of code:
if !ret && $game_map && GameData::TerrainTag.try_get($game_player.terrain_tag).dgrass_wild_encounters== true
ret = pbStringToAudioFile("name of your wild battle theme here")
end
on line 9

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:
Expand Collapse Copy
  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:
Expand Collapse Copy
   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:
Expand Collapse Copy
  DarkGrass    = 13
  DarkGrassMorn = 14
  DarkGrassDay = 15
  DarkGrassNite = 16

into Module EncounterTypes

followed by:

Code:
Expand Collapse Copy
       "DarkGrass",
     "DarkGrassMorn",
     "DarkGrassDay",
     "DarkGrassNite"

within the module. Remember to watch for your commas!

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

Code:
Expand Collapse Copy
     [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:
Expand Collapse Copy
  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:
Expand Collapse Copy
    elsif self.isCave?
      return EncounterTypes::Cave

paste:

Code:
Expand Collapse Copy
     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:
Expand Collapse Copy
  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:
Expand Collapse Copy
  if $PokemonGlobal.nextBattleBGM
    return $PokemonGlobal.nextBattleBGM.clone
  end
ret=nil

add the three lines of code:

Code:
Expand Collapse Copy
   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
Views
2,228
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from juliorain

Latest updates

  1. v19.1 Compatibility

    So this doesn't work in the same way. V 19 is MUCH easier to do. Remember to have your 1)...
Back
Top