Advertisement
Guest User

Hidden Encounters - REVISED, AGAIN

a guest
Dec 30th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #In PokeBall_CatchEffects, look for the Lure Ball catch modifier code. Replace it with the following:
  2.  
  3. BallHandlers::ModifyCatchRate.add(:LUREBALL,proc { |ball,catchRate,battle,battler,ultraBeast|
  4.   multiplier = (NEWEST_BATTLE_MECHANICS) ? 5 : 3
  5.   catchRate *= multiplier if $PokemonTemp.encounterType==EncounterTypes::OldRod ||
  6.                              $PokemonTemp.encounterType==EncounterTypes::GoodRod ||
  7.                              $PokemonTemp.encounterType==EncounterTypes::SuperRod ||
  8.                              # ------ Derx: Addition of Hidden Fishing Rod encounter types
  9.                              $PokemonTemp.encounterType==EncounterTypes::HiddenORod ||
  10.                              $PokemonTemp.encounterType==EncounterTypes::HiddenGRod ||
  11.                              $PokemonTemp.encounterType==EncounterTypes::HiddenSRod
  12.                              # ------ Derx: End of Hidden Fishing Rod additions
  13.   next [catchRate,255].min
  14. })
  15.  
  16. #In PField_Visuals, not far underneath the code you just replaced, look for "if $PokemonGlobal.surfing || $PokemonGlobal.diving",
  17. #and replace the section about the various fishing rods with the following:
  18.  
  19.     elsif $PokemonTemp.encounterType &&
  20.        ($PokemonTemp.encounterType==EncounterTypes::OldRod ||
  21.        $PokemonTemp.encounterType==EncounterTypes::GoodRod ||
  22.        $PokemonTemp.encounterType==EncounterTypes::SuperRod ||
  23.        # ------ Derx: Addition of Hidden Fishing Rod encounter types
  24.        $PokemonTemp.encounterType==EncounterTypes::HiddenORod ||
  25.        $PokemonTemp.encounterType==EncounterTypes::HiddenGRod ||
  26.        $PokemonTemp.encounterType==EncounterTypes::HiddenSRod)
  27.        # ------ Derx: End of Hidden Fishing Rod additions
  28.  
  29. In PField_Battles, look for "def pbGetEnvironment", and replace the section about the various fishing rods with the following:
  30.  
  31.   if $PokemonTemp.encounterType==EncounterTypes::OldRod ||
  32.      $PokemonTemp.encounterType==EncounterTypes::GoodRod ||
  33.      $PokemonTemp.encounterType==EncounterTypes::SuperRod
  34.      # ------ Derx: Addition of the Hidden Fishing Rod Encounter Types
  35.      $PokemonTemp.encounterType==EncounterTypes::HiddenORod ||
  36.      $PokemonTemp.encounterType==EncounterTypes::HiddenGRod ||
  37.      $PokemonTemp.encounterType==EncounterTypes::HiddenSRod
  38.      # ------ Derx: End of Hidden Fishing Rod additions
  39.      
  40. #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
  41. #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
  42. #them. IMPORTANT NOTE: If you've added other encounter types to this section, you'll have to adjust the values in the tables provided
  43. #here to make them work.
  44.  
  45. # https://pastebin.com/QwLqjNA5
  46.  
  47. #In PField_RoamingPokemon, look for the pbRoamingMethodAllowed(encType) section and replace it with the following:
  48.  
  49. def pbRoamingMethodAllowed(encType)
  50.   encounter = $PokemonEncounters.pbEncounterType
  51.   case encType
  52.   when 0   # Any encounter method (except triggered ones and Bug Contest)
  53.     return true if encounter==EncounterTypes::Land ||
  54.                    encounter==EncounterTypes::LandMorning ||
  55.                    encounter==EncounterTypes::LandDay ||
  56.                    encounter==EncounterTypes::LandNight ||
  57.                    encounter==EncounterTypes::Water ||
  58.                    encounter==EncounterTypes::Cave ||
  59.                    # ------ Derx: Addition of Hidden Encounter Types to Roaming checks
  60.                    encounter==EncounterTypes::HiddenLand ||
  61.                    encounter==EncounterTypes::HiddenWater ||
  62.                    encounter==EncounterTypes::HiddenCave
  63.                    # ------ Derx: End of Hidden Encounters being added to Roaming checks
  64.   when 1   # Grass (except Bug Contest)/walking in caves only
  65.     return true if encounter==EncounterTypes::Land ||
  66.                    encounter==EncounterTypes::LandMorning ||
  67.                    encounter==EncounterTypes::LandDay ||
  68.                    encounter==EncounterTypes::LandNight ||
  69.                    encounter==EncounterTypes::Cave ||
  70.                    # ------ Derx: Addition of Hidden Encounter Types to Roaming checks
  71.                    encounter==EncounterTypes::HiddenLand ||
  72.                    encounter==EncounterTypes::HiddenCave
  73.                    # ------ Derx: End of Hidden Encounters being added to Roaming checks
  74.   when 2   # Surfing only
  75.     return true if encounter==EncounterTypes::Water ||
  76.                    # ------ Derx: Addition of Hidden Encounter Types to Roaming checks
  77.                    encounter==EncounterTypes::HiddenWater
  78.                    # ------ Derx: End of Hidden Encounters being added to Roaming checks
  79.   when 3   # Fishing only
  80.     return true if encounter==EncounterTypes::OldRod ||
  81.                    encounter==EncounterTypes::GoodRod ||
  82.                    encounter==EncounterTypes::SuperRod ||
  83.                    # ------ Derx: Addition of Hidden Encounter Types to Roaming checks
  84.                    encounter==EncounterTypes::HiddenORod ||
  85.                    encounter==EncounterTypes::HiddenGRod ||
  86.                    encounter==EncounterTypes::HiddenSRod
  87.                    # ------ Derx: End of Hidden Encounters being added to Roaming checks
  88.   when 4   # Water-based only
  89.     return true if encounter==EncounterTypes::Water ||
  90.                    encounter==EncounterTypes::OldRod ||
  91.                    encounter==EncounterTypes::GoodRod ||
  92.                    encounter==EncounterTypes::SuperRod ||
  93.                    # ------ Derx: Addition of Hidden Encounter Types to Roaming checks
  94.                    encounter==EncounterTypes::HiddenWater ||
  95.                    encounter==EncounterTypes::HiddenORod ||
  96.                    encounter==EncounterTypes::HiddenGRod ||
  97.                    encounter==EncounterTypes::HiddenSRod
  98.                    # ------ Derx: End of Hidden Encounters being added to Roaming checks
  99.   end
  100.   return false
  101. end
  102.  
  103. #In PField_FieldMoves, look for "def PBRockSmashRandomEncounter" and replace it with the following:
  104.  
  105. def pbRockSmashRandomEncounter
  106.   if rand(100)<25
  107.     # ------ Derx: Addition of Hidden Rock Smash encounter type to the Rock Smash encounter checks
  108.     if rand(100) < 15 && $PokemonEncounters.hasEncounter?(EncounterTypes::HiddenRSmash)
  109.       pbEncounter(EncounterTypes::HiddenRSmash)
  110.     else
  111.       pbEncounter(EncounterTypes::RockSmash)
  112.     end
  113.     # ------ Derx: End of Hidden Rock Smash addition
  114.   end
  115. end
  116.  
  117. #In PItem_ItemEffects, look for the line that says "ItemHandlers::UseInField.add(:OLDROD,proc { |item|", and replace everything from
  118. #that line to the end of the entry for the Super Rod (two entries below it) with the following code:
  119.  
  120. ItemHandlers::UseInField.add(:OLDROD,proc { |item|
  121.   terrain = pbFacingTerrainTag
  122.   notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
  123.   if !PBTerrain.isWater?(terrain) || (!notCliff && !$PokemonGlobal.surfing)
  124.     pbMessage(_INTL("Can't use that here."))
  125.     next 0
  126.   end
  127.   encounter = $PokemonEncounters.hasEncounter?(EncounterTypes::OldRod)
  128.   if pbFishing(encounter,1)
  129.     # ------ Derx: Addition of Hidden Old Rod encounter type to the Old Rod encounter checks
  130.     if rand(100) < 15 && $PokemonEncounters.hasEncounter?(EncounterTypes::HiddenORod)
  131.       pbEncounter(EncounterTypes::HiddenORod)
  132.     else
  133.       pbEncounter(EncounterTypes::OldRod)
  134.     end
  135.     # ------ Derx: End of Hidden Old Rod addition
  136.   end
  137.   next 1
  138. })
  139.  
  140. ItemHandlers::UseInField.add(:GOODROD,proc { |item|
  141.   terrain = pbFacingTerrainTag
  142.   notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
  143.   if !PBTerrain.isWater?(terrain) || (!notCliff && !$PokemonGlobal.surfing)
  144.     pbMessage(_INTL("Can't use that here."))
  145.     next 0
  146.   end
  147.   encounter = $PokemonEncounters.hasEncounter?(EncounterTypes::GoodRod)
  148.   if pbFishing(encounter,2)
  149.     # ------ Derx: Addition of Hidden Good Rod encounter type to the Good Rod encounter checks
  150.     if rand(100) < 15 && $PokemonEncounters.hasEncounter?(EncounterTypes::HiddenGRod)
  151.       pbEncounter(EncounterTypes::HiddenGRod)
  152.     else
  153.       pbEncounter(EncounterTypes::GoodRod)
  154.     end
  155.     # ------ Derx: End of Hidden Good Rod addition
  156.   end
  157.   next 1
  158. })
  159.  
  160. ItemHandlers::UseInField.add(:SUPERROD,proc { |item|
  161.   terrain = pbFacingTerrainTag
  162.   notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
  163.   if !PBTerrain.isWater?(terrain) || (!notCliff && !$PokemonGlobal.surfing)
  164.     pbMessage(_INTL("Can't use that here."))
  165.     next 0
  166.   end
  167.   encounter = $PokemonEncounters.hasEncounter?(EncounterTypes::SuperRod)
  168.   if pbFishing(encounter,3)
  169.     # ------ Derx: Addition of Hidden Super Rod encounter type to the Super Rod encounter checks
  170.     if rand(100) < 15 && $PokemonEncounters.hasEncounter?(EncounterTypes::HiddenSRod)
  171.       pbEncounter(EncounterTypes::HiddenSRod)
  172.     else
  173.       pbEncounter(EncounterTypes::SuperRod)
  174.     end
  175.     # ------ Derx: End of Hidden Super Rod addition
  176.   end
  177.   next 1
  178. })
  179.  
  180. #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
  181. #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
  182. #define a preset battle theme for Hidden Encounters in metadata.txt
  183.  
  184. #First, in PSystem_FileUtilities, you'll need to find "def pbGetWildBattleBGM(_wildParty)". Replace the entire section with the
  185. #following:
  186.  
  187. def pbGetWildBattleBGM(_wildParty)   # wildParty is an array of Pokémon objects
  188.  
  189. # ------ Derx: Sets up an array for playing an alternate battle BGM for Hidden Encounters
  190.   altbgm = [EncounterTypes::HiddenLand,
  191.             EncounterTypes::HiddenCave,
  192.             EncounterTypes::HiddenWater,
  193.             EncounterTypes::HiddenORod,
  194.             EncounterTypes::HiddenGRod,
  195.             EncounterTypes::HiddenSRod,
  196.             EncounterTypes::HiddenRSmash]
  197. # ------ Derx: End of array setup for Alternate BGM for Hidden Encounters
  198.  
  199.   if $PokemonGlobal.nextBattleBGM
  200.     return $PokemonGlobal.nextBattleBGM.clone
  201.   end
  202.   ret = nil
  203.   if !ret
  204.     # Check map-specific metadata
  205.     # ------ Derx: Calls on the above array to determine if the BGM for Hidden Battle should be pulled from metadata
  206.     if altbgm.include?($PokemonTemp.encounterType)
  207.       music = pbGetMetadata(0,MetadataHiddenBattleBGM)
  208.     else
  209.       music = pbGetMetadata($game_map.map_id,MetadataMapWildBattleBGM)
  210.     end
  211.     # ------ Derx: End of Hidden Battle BGM related code
  212.     ret = pbStringToAudioFile(music) if music && music!=""
  213.   end
  214.   if !ret
  215.     # Check global metadata
  216.     # ------ Derx: Calls on the above array to determine if the BGM for Hidden Battle should be pulled from metadata
  217.     if altbgm.include?($PokemonTemp.encounterType)
  218.       music = pbGetMetadata(0,MetadataHiddenBattleBGM)
  219.     else
  220.       music = pbGetMetadata(0,MetadataWildBattleBGM)
  221.     end
  222.     # ------ Derx: End of Hidden Battle BGM related code
  223.     ret = pbStringToAudioFile(music) if music && music!=""
  224.   end
  225.   ret = pbStringToAudioFile("Battle wild") if !ret
  226.   return ret
  227. end
  228.  
  229. #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,
  230. #right after "MetadataPlayerH", place the following line
  231.  
  232. MetadataPlayerH          = 16
  233. MetadataHiddenBattleBGM  = 17 # Derx: Adds the ability to set the Hidden Battle BGM to the metadata
  234.  
  235. #While in Misc_Data, not far under those edits, in "module PokemonMetadata", look
  236. #for ""PlayerH"          => [MetadataPlayerH,          "esssssss", :PBTrainers]," and replace it with the following lines:
  237.  
  238.      "PlayerH"          => [MetadataPlayerH,          "esssssss", :PBTrainers],
  239.      "HiddenBattleBGM"  => [MetadataHiddenBattleBGM,  "s"] # Derx: Adds the ability to set the Hidden Battle BGM to the metadata
  240.      
  241.  
  242. #Remember to have the comma there after the line about PlayerH!!!!
  243.  
  244. #Finally, in Editor_MapConnectionEditor, search for "class MapScreenScene, and in the GLOBALMETADATA=[ array, at the bottom of it,
  245. #replace the line about PlayerH with the following.
  246.  
  247.      ["PlayerH",PlayerProperty,
  248.         _INTL("Specifies player H.")],
  249. # ------- Derx: Changes made for Hidden Battle BGM being definable in metadata
  250.      ["HiddenBattleBGM",BGMProperty,
  251.         _INTL("Default BGM for Hidden Pokémon battles.")]
  252. # ------ Derx: End of changes for Hidden Battle BGMs
  253.  
  254. #Similar thing as above, the comma after PlayerH is necessary here!!!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement