diff --git a/Data/Scripts/013_Overworld/002_PField_Field.rb b/Data/Scripts/013_Overworld/002_PField_Field.rb index 0504f4488..2883f5927 100644 --- a/Data/Scripts/013_Overworld/002_PField_Field.rb +++ b/Data/Scripts/013_Overworld/002_PField_Field.rb @@ -373,7 +373,7 @@ def pbBattleOnStepTaken(repel_active) return if !$PokemonEncounters.encounter_possible_here? encounterType = $PokemonEncounters.encounter_type return if encounterType < 0 - return if !$PokemonEncounters.step_triggers_encounter?(encounterType) + return if !$PokemonEncounters.encounter_triggered?(encounterType, repel_active) $PokemonTemp.encounterType = encounterType encounter = $PokemonEncounters.choose_wild_pokemon(encounterType) encounter = EncounterModifier.trigger(encounter) diff --git a/Data/Scripts/013_Overworld/007_PField_Encounters.rb b/Data/Scripts/013_Overworld/007_PField_Encounters.rb index 82f2da79a..14baec796 100644 --- a/Data/Scripts/013_Overworld/007_PField_Encounters.rb +++ b/Data/Scripts/013_Overworld/007_PField_Encounters.rb @@ -100,9 +100,9 @@ class PokemonEncounters return false end - # Returns whether a wild encounter should happen, based on the probability of - # one triggering upon taking a step. - def step_triggers_encounter?(enc_type) + # Returns whether a wild encounter should happen, based on its encounter + # chance. Called when taking a step and by Rock Smash. + def encounter_triggered?(enc_type, repel_active = false, triggered_by_step = true) if enc_type < 0 || enc_type > EncounterTypes::Probabilities.length raise ArgumentError.new(_INTL("Encounter type out of range")) end @@ -116,8 +116,10 @@ class PokemonEncounters encounter_chance = @step_chances[enc_type].to_f min_steps_needed = (8 - encounter_chance / 10).clamp(0, 8).to_f # Apply modifiers to the encounter chance and the minimum steps amount - encounter_chance += @chance_accumulator / 200 - encounter_chance *= 0.8 if $PokemonGlobal.bicycle + if triggered_by_step + encounter_chance += @chance_accumulator / 200 + encounter_chance *= 0.8 if $PokemonGlobal.bicycle + end if !Settings::FLUTES_CHANGE_WILD_ENCOUNTER_LEVELS encounter_chance /= 2 if $PokemonMap.blackFluteUsed min_steps_needed *= 2 if $PokemonMap.blackFluteUsed @@ -140,7 +142,7 @@ class PokemonEncounters min_steps_needed *= 2 when :SNOWCLOAK if $game_screen.weather_type == PBFieldWeather::Snow || - $game_screen.weather_type == PBFieldWeather::Blizzard + $game_screen.weather_type == PBFieldWeather::Blizzard encounter_chance /= 2 min_steps_needed *= 2 end @@ -160,14 +162,17 @@ class PokemonEncounters end # Wild encounters are much less likely to happen for the first few steps # after a previous wild encounter - if @step_count < min_steps_needed + if triggered_by_step && @step_count < min_steps_needed @step_count += 1 return false if rand(100) >= encounter_chance * 5 / (@step_chances[enc_type] + @chance_accumulator / 200) end # Decide whether the wild encounter should actually happen return true if rand(100) < encounter_chance # If encounter didn't happen, make the next step more likely to produce one - @chance_accumulator += @step_chances[enc_type] + if triggered_by_step + @chance_accumulator += @step_chances[enc_type] + @chance_accumulator = 0 if repel_active + end return false end @@ -423,8 +428,8 @@ def pbGenerateWildPokemon(species,level,isRoamer=false) return genwildpoke end -# Used by fishing rods and Headbutt/Rock Smash/Sweet Scent. Skips the -# probability checks in def step_triggers_encounter? above. +# Used by fishing rods and Headbutt/Rock Smash/Sweet Scent to generate a wild +# Pokémon (or two) for a triggered wild encounter. def pbEncounter(enc_type) $PokemonTemp.encounterType = enc_type encounter1 = $PokemonEncounters.choose_wild_pokemon(enc_type) diff --git a/Data/Scripts/013_Overworld/011_PField_FieldMoves.rb b/Data/Scripts/013_Overworld/011_PField_FieldMoves.rb index 35d897eff..4ca9dd865 100644 --- a/Data/Scripts/013_Overworld/011_PField_FieldMoves.rb +++ b/Data/Scripts/013_Overworld/011_PField_FieldMoves.rb @@ -592,9 +592,7 @@ HiddenMoveHandlers::UseMove.add(:HEADBUTT,proc { |move,pokemon| # Rock Smash #=============================================================================== def pbRockSmashRandomEncounter - encounter_data = GameData::Encounter.get($game_map.map_id, $PokemonGlobal.encounter_version) - chance = (encounter_data) ? encounter_data.step_chances[EncounterTypes::RockSmash] || 50 : 50 - if rand(100) < chance + if $PokemonEncounters.encounter_triggered?(EncounterTypes::RockSmash, false, false) pbEncounter(EncounterTypes::RockSmash) end end diff --git a/Data/Scripts/021_Debug/004_Editor_Screens.rb b/Data/Scripts/021_Debug/004_Editor_Screens.rb index 32ad4ad4e..b0233535c 100644 --- a/Data/Scripts/021_Debug/004_Editor_Screens.rb +++ b/Data/Scripts/021_Debug/004_Editor_Screens.rb @@ -259,7 +259,7 @@ def pbEncounterTypeEditor(enc_data, enc_type) loop do if need_refresh commands.clear - commands.push(_INTL("Step chance={1}", enc_data.step_chances[enc_type] || 0)) + commands.push(_INTL("Step chance={1}%", enc_data.step_chances[enc_type] || 0)) commands.push(_INTL("Encounter type={1}", EncounterTypes::Names[enc_type])) if enc_data.types[enc_type] && enc_data.types[enc_type].length > 0 enc_data.types[enc_type].each do |slot| @@ -272,7 +272,7 @@ def pbEncounterTypeEditor(enc_data, enc_type) ret = pbCommands2(list, commands, -1, ret) if ret == 0 # Edit step chance old_step_chance = enc_data.step_chances[enc_type] || 0 - new_step_chance = LimitProperty.new(180).set(_INTL("Step chance"), old_step_chance) + new_step_chance = LimitProperty.new(255).set(_INTL("Step chance"), old_step_chance) if new_step_chance != old_step_chance enc_data.step_chances[enc_type] = new_step_chance need_refresh = true