• 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.
Resource icon

Hidden Encounters 2020-12-28

Hidden Encounters is a sort of sidegrade expansions to the concept of Audino/Rustling Grass, introduced in Gen 5 games. Instead of random spots of grass rustling with special encounters in them, every tile with a valid encounter table has a second encounter table, which has a 15% chance of triggering, and getting an encounter from its Hidden variant. If your map has any of the Land variants, and you also have HiddenLand in your Encounters.txt, there is a 15% chance you will have encounters pulled from HiddenLand. Of important note is that the Hidden Encounters have less slots than their normal variants. You can, of course, change this in the script the same way you would any encounter table. Same with the encounter ratios. In the resource, every encounter slot shares an equal-ish value of being encountered.

The script also allows you to set a theme to play for Hidden Encounters. All you have to do is define it in Metadata.txt as a brand new field called HiddenBattleBGM.

You can define the following fields now in Encounters.txt to pull up the Alternate Encounter Table:
  • HiddenLand
  • HiddenWater
  • HiddenCave
  • HiddenOldRod
  • HiddenGoodRod
  • HiddenSuperRod
  • HiddenBugContest

Each of these fields is fairly self explanatory to what they correspond to. HiddenLand corresponds to all Land-based Encounter Tables.

A video of all of this in action can be seen if you click on Additional Information.

----------------------------------------------
Code
----------------------------------------------

In PokeBall_CatchEffects, look for the Lure Ball catch modifier code. Replace it with the following:

Ruby:
Expand Collapse Copy
BallHandlers::ModifyCatchRate.add(:LUREBALL,proc { |ball,catchRate,battle,battler,ultraBeast|
  multiplier = (NEWEST_BATTLE_MECHANICS) ? 5 : 3
  catchRate *= multiplier if $PokemonTemp.encounterType==EncounterTypes::OldRod ||
                             $PokemonTemp.encounterType==EncounterTypes::GoodRod ||
                             $PokemonTemp.encounterType==EncounterTypes::SuperRod ||
                             # ------ Derx: Addition of Hidden Fishing Rod encounter types
                             $PokemonTemp.encounterType==EncounterTypes::HiddenORod ||
                             $PokemonTemp.encounterType==EncounterTypes::HiddenGRod ||
                             $PokemonTemp.encounterType==EncounterTypes::HiddenSRod
                             # ------ Derx: End of Hidden Fishing Rod additions
  next [catchRate,255].min
})

In PField_Visuals, not far underneath the code you just replaced, look for "if $PokemonGlobal.surfing || $PokemonGlobal.diving", and replace the section about the various fishing rods with the following:

Ruby:
Expand Collapse Copy
    elsif $PokemonTemp.encounterType &&
       ($PokemonTemp.encounterType==EncounterTypes::OldRod ||
       $PokemonTemp.encounterType==EncounterTypes::GoodRod ||
       $PokemonTemp.encounterType==EncounterTypes::SuperRod ||
       # ------ Derx: Addition of Hidden Fishing Rod encounter types
       $PokemonTemp.encounterType==EncounterTypes::HiddenORod ||
       $PokemonTemp.encounterType==EncounterTypes::HiddenGRod ||
       $PokemonTemp.encounterType==EncounterTypes::HiddenSRod)
       # ------ Derx: End of Hidden Fishing Rod additions

In PField_Battles, look for "def pbGetEnvironment", and replace the section about the various fishing rods with the following:

Ruby:
Expand Collapse Copy
  if $PokemonTemp.encounterType==EncounterTypes::OldRod ||
     $PokemonTemp.encounterType==EncounterTypes::GoodRod ||
     $PokemonTemp.encounterType==EncounterTypes::SuperRod
     # ------ Derx: Addition of the Hidden Fishing Rod Encounter Types
     $PokemonTemp.encounterType==EncounterTypes::HiddenORod ||
     $PokemonTemp.encounterType==EncounterTypes::HiddenGRod ||
     $PokemonTemp.encounterType==EncounterTypes::HiddenSRod
     # ------ Derx: End of Hidden Fishing Rod additions

A bunch of changes in PField_Encounters. With how many there are, I have compiled all of them into a pastebin for easier viewing. All of my changes are marked with "Derx:" comments. They'll usually be beside a line, or surounding my changes at the top and bottom of them. IMPORTANT NOTE: If you've added other encounter types to this section, you'll have to adjust the values in the tables provided here to make them work.



In PField_RoamingPokemon, look for the pbRoamingMethodAllowed(encType) section and replace it with the following:

Ruby:
Expand Collapse Copy
def pbRoamingMethodAllowed(encType)
  encounter = $PokemonEncounters.pbEncounterType
  case encType
  when 0   # Any encounter method (except triggered ones and Bug Contest)
    return true if encounter==EncounterTypes::Land ||
                   encounter==EncounterTypes::LandMorning ||
                   encounter==EncounterTypes::LandDay ||
                   encounter==EncounterTypes::LandNight ||
                   encounter==EncounterTypes::Water ||
                   encounter==EncounterTypes::Cave ||
                   # ------ Derx: Addition of Hidden Encounter Types to Roaming checks
                   encounter==EncounterTypes::HiddenLand ||
                   encounter==EncounterTypes::HiddenWater ||
                   encounter==EncounterTypes::HiddenCave
                   # ------ Derx: End of Hidden Encounters being added to Roaming checks
  when 1   # Grass (except Bug Contest)/walking in caves only
    return true if encounter==EncounterTypes::Land ||
                   encounter==EncounterTypes::LandMorning ||
                   encounter==EncounterTypes::LandDay ||
                   encounter==EncounterTypes::LandNight ||
                   encounter==EncounterTypes::Cave ||
                   # ------ Derx: Addition of Hidden Encounter Types to Roaming checks
                   encounter==EncounterTypes::HiddenLand ||
                   encounter==EncounterTypes::HiddenCave
                   # ------ Derx: End of Hidden Encounters being added to Roaming checks
  when 2   # Surfing only
    return true if encounter==EncounterTypes::Water ||
                   # ------ Derx: Addition of Hidden Encounter Types to Roaming checks
                   encounter==EncounterTypes::HiddenWater
                   # ------ Derx: End of Hidden Encounters being added to Roaming checks
  when 3   # Fishing only
    return true if encounter==EncounterTypes::OldRod ||
                   encounter==EncounterTypes::GoodRod ||
                   encounter==EncounterTypes::SuperRod ||
                   # ------ Derx: Addition of Hidden Encounter Types to Roaming checks
                   encounter==EncounterTypes::HiddenORod ||
                   encounter==EncounterTypes::HiddenGRod ||
                   encounter==EncounterTypes::HiddenSRod
                   # ------ Derx: End of Hidden Encounters being added to Roaming checks
  when 4   # Water-based only
    return true if encounter==EncounterTypes::Water ||
                   encounter==EncounterTypes::OldRod ||
                   encounter==EncounterTypes::GoodRod ||
                   encounter==EncounterTypes::SuperRod ||
                   # ------ Derx: Addition of Hidden Encounter Types to Roaming checks
                   encounter==EncounterTypes::HiddenWater ||
                   encounter==EncounterTypes::HiddenORod ||
                   encounter==EncounterTypes::HiddenGRod ||
                   encounter==EncounterTypes::HiddenSRod
                   # ------ Derx: End of Hidden Encounters being added to Roaming checks
  end
  return false
end

IN PField_FieldMoves, look for "def PBRockSmashRandomEncounter" and replace it with the following:

Ruby:
Expand Collapse Copy
def pbRockSmashRandomEncounter
  if rand(100)<25
    # ------ Derx: Addition of Hidden Rock Smash encounter type to the Rock Smash encounter checks
    if rand(100) < 15 && $PokemonEncounters.hasEncounter?(EncounterTypes::HiddenRSmash)
      pbEncounter(EncounterTypes::HiddenRSmash)
    else
      pbEncounter(EncounterTypes::RockSmash)
    end
    # ------ Derx: End of Hidden Rock Smash addition
  end
end

In PItem_ItemEffects, look for the line that says "ItemHandlers::UseInField.add(:OLDROD,proc { |item|", and replace everything from that line to the end of the entry for the Super Rod (two entries below it) with the following code:

Ruby:
Expand Collapse Copy
ItemHandlers::UseInField.add(:OLDROD,proc { |item|
  terrain = pbFacingTerrainTag
  notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
  if !PBTerrain.isWater?(terrain) || (!notCliff && !$PokemonGlobal.surfing)
    pbMessage(_INTL("Can't use that here."))
    next 0
  end
  encounter = $PokemonEncounters.hasEncounter?(EncounterTypes::OldRod)
  if pbFishing(encounter,1)
    # ------ Derx: Addition of Hidden Old Rod encounter type to the Old Rod encounter checks
    if rand(100) < 15 && $PokemonEncounters.hasEncounter?(EncounterTypes::HiddenORod)
      pbEncounter(EncounterTypes::HiddenORod)
    else
      pbEncounter(EncounterTypes::OldRod)
    end
    # ------ Derx: End of Hidden Old Rod addition
  end
  next 1
})

ItemHandlers::UseInField.add(:GOODROD,proc { |item|
  terrain = pbFacingTerrainTag
  notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
  if !PBTerrain.isWater?(terrain) || (!notCliff && !$PokemonGlobal.surfing)
    pbMessage(_INTL("Can't use that here."))
    next 0
  end
  encounter = $PokemonEncounters.hasEncounter?(EncounterTypes::GoodRod)
  if pbFishing(encounter,2)
    # ------ Derx: Addition of Hidden Good Rod encounter type to the Good Rod encounter checks
    if rand(100) < 15 && $PokemonEncounters.hasEncounter?(EncounterTypes::HiddenGRod)
      pbEncounter(EncounterTypes::HiddenGRod)
    else
      pbEncounter(EncounterTypes::GoodRod)
    end
    # ------ Derx: End of Hidden Good Rod addition
  end
  next 1
})

ItemHandlers::UseInField.add(:SUPERROD,proc { |item|
  terrain = pbFacingTerrainTag
  notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
  if !PBTerrain.isWater?(terrain) || (!notCliff && !$PokemonGlobal.surfing)
    pbMessage(_INTL("Can't use that here."))
    next 0
  end
  encounter = $PokemonEncounters.hasEncounter?(EncounterTypes::SuperRod)
  if pbFishing(encounter,3)
    # ------ Derx: Addition of Hidden Super Rod encounter type to the Super Rod encounter checks
    if rand(100) < 15 && $PokemonEncounters.hasEncounter?(EncounterTypes::HiddenSRod)
      pbEncounter(EncounterTypes::HiddenSRod)
    else
      pbEncounter(EncounterTypes::SuperRod)
    end
    # ------ Derx: End of Hidden Super Rod addition
  end
  next 1
})

The following section is for if you want to have a custom battle bgm playing for Hidden Encounters. If you don't want to have a unique theme for Hidden Encounters, you can safely ignore this section of the code. If you do choose to use this code, you will be able to define a preset battle theme for Hidden Encounters in metadata.txt

First, in PSystem_FileUtilities, you'll need to find "def pbGetWildBattleBGM(_wildParty)". Replace the entire section with the following:

Ruby:
Expand Collapse Copy
def pbGetWildBattleBGM(_wildParty)   # wildParty is an array of Pokémon objects

# ------ Derx: Sets up an array for playing an alternate battle BGM for Hidden Encounters
  altbgm = [EncounterTypes::HiddenLand,
            EncounterTypes::HiddenCave,
            EncounterTypes::HiddenWater,
            EncounterTypes::HiddenORod,
            EncounterTypes::HiddenGRod,
            EncounterTypes::HiddenSRod,
            EncounterTypes::HiddenRSmash]
# ------ Derx: End of array setup for Alternate BGM for Hidden Encounters

  if $PokemonGlobal.nextBattleBGM
    return $PokemonGlobal.nextBattleBGM.clone
  end
  ret = nil
  if !ret
    # Check map-specific metadata
    # ------ Derx: Calls on the above array to determine if the BGM for Hidden Battle should be pulled from metadata
    if altbgm.include?($PokemonTemp.encounterType)
      music = pbGetMetadata(0,MetadataHiddenBattleBGM)
    else
      music = pbGetMetadata($game_map.map_id,MetadataMapWildBattleBGM)
    end
    # ------ Derx: End of Hidden Battle BGM related code
    ret = pbStringToAudioFile(music) if music && music!=""
  end
  if !ret
    # Check global metadata
    # ------ Derx: Calls on the above array to determine if the BGM for Hidden Battle should be pulled from metadata
    if altbgm.include?($PokemonTemp.encounterType)
      music = pbGetMetadata(0,MetadataHiddenBattleBGM)
    else
      music = pbGetMetadata(0,MetadataWildBattleBGM)
    end
    # ------ Derx: End of Hidden Battle BGM related code
    ret = pbStringToAudioFile(music) if music && music!=""
  end
  ret = pbStringToAudioFile("Battle wild") if !ret
  return ret
end
---- Derx: End of Hidden Battle BGM related code
    ret = pbStringToAudioFile(music) if music && music!=""
  end
  ret = pbStringToAudioFile("Battle wild") if !ret
  return ret
end

Afterward, you will need to go into Misc_Data. In there look for the section about "Global and map metadata". In the first list there, right after "MetadataPlayerH", place the following line

Ruby:
Expand Collapse Copy
MetadataPlayerH          = 16
MetadataHiddenBattleBGM     = 17 # Derx: Adds the ability to set the Hidden Battle BGM to the metadata

While in Misc_Data, not far under those edits, in "module PokemonMetadata", look for ""PlayerH" => [MetadataPlayerH, "esssssss", :PBTrainers]," and replace it with the following lines:

Ruby:
Expand Collapse Copy
     "PlayerH"          => [MetadataPlayerH,          "esssssss", :PBTrainers],
     "HiddenBattleBGM"  => [MetadataHiddenBattleBGM,  "s"] # Derx: Adds the ability to set the Hidden Battle BGM to the metadata

Remember to have the comma there after the line about PlayerH!!!!

Finally, in Editor_MapConnectionEditor, search for "class MapScreenScene, and in the GLOBALMETADATA=[ array, at the bottom of it, replace the line about PlayerH with the following.

Ruby:
Expand Collapse Copy
     ["PlayerH",PlayerProperty,
        _INTL("Specifies player H.")],
# ------- Derx: Changes made for Hidden Battle BGM being definable in metadata
     ["HiddenBattleBGM",BGMProperty,
        _INTL("Default BGM for Hidden Pokémon battles.")]
# ------ Derx: End of changes for Hidden Battle BGMs

Similar thing as above, the comma after PlayerH is necessary here!!!!
Credits
Credit goes to myself, DerxwnaKapsyla.
Author
DerxwnaKapsyla
Views
1,975
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from DerxwnaKapsyla

Latest updates

  1. Critical Fix for Trainer Battles

    The previous version of the tutorial had a quirk where the Hidden Encounter theme would play for...
Back
Top