mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Tweaks to encounter chance calculator and Rock Smash
This commit is contained in:
@@ -373,7 +373,7 @@ def pbBattleOnStepTaken(repel_active)
|
|||||||
return if !$PokemonEncounters.encounter_possible_here?
|
return if !$PokemonEncounters.encounter_possible_here?
|
||||||
encounterType = $PokemonEncounters.encounter_type
|
encounterType = $PokemonEncounters.encounter_type
|
||||||
return if encounterType < 0
|
return if encounterType < 0
|
||||||
return if !$PokemonEncounters.step_triggers_encounter?(encounterType)
|
return if !$PokemonEncounters.encounter_triggered?(encounterType, repel_active)
|
||||||
$PokemonTemp.encounterType = encounterType
|
$PokemonTemp.encounterType = encounterType
|
||||||
encounter = $PokemonEncounters.choose_wild_pokemon(encounterType)
|
encounter = $PokemonEncounters.choose_wild_pokemon(encounterType)
|
||||||
encounter = EncounterModifier.trigger(encounter)
|
encounter = EncounterModifier.trigger(encounter)
|
||||||
|
|||||||
@@ -100,9 +100,9 @@ class PokemonEncounters
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether a wild encounter should happen, based on the probability of
|
# Returns whether a wild encounter should happen, based on its encounter
|
||||||
# one triggering upon taking a step.
|
# chance. Called when taking a step and by Rock Smash.
|
||||||
def step_triggers_encounter?(enc_type)
|
def encounter_triggered?(enc_type, repel_active = false, triggered_by_step = true)
|
||||||
if enc_type < 0 || enc_type > EncounterTypes::Probabilities.length
|
if enc_type < 0 || enc_type > EncounterTypes::Probabilities.length
|
||||||
raise ArgumentError.new(_INTL("Encounter type out of range"))
|
raise ArgumentError.new(_INTL("Encounter type out of range"))
|
||||||
end
|
end
|
||||||
@@ -116,8 +116,10 @@ class PokemonEncounters
|
|||||||
encounter_chance = @step_chances[enc_type].to_f
|
encounter_chance = @step_chances[enc_type].to_f
|
||||||
min_steps_needed = (8 - encounter_chance / 10).clamp(0, 8).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
|
# Apply modifiers to the encounter chance and the minimum steps amount
|
||||||
encounter_chance += @chance_accumulator / 200
|
if triggered_by_step
|
||||||
encounter_chance *= 0.8 if $PokemonGlobal.bicycle
|
encounter_chance += @chance_accumulator / 200
|
||||||
|
encounter_chance *= 0.8 if $PokemonGlobal.bicycle
|
||||||
|
end
|
||||||
if !Settings::FLUTES_CHANGE_WILD_ENCOUNTER_LEVELS
|
if !Settings::FLUTES_CHANGE_WILD_ENCOUNTER_LEVELS
|
||||||
encounter_chance /= 2 if $PokemonMap.blackFluteUsed
|
encounter_chance /= 2 if $PokemonMap.blackFluteUsed
|
||||||
min_steps_needed *= 2 if $PokemonMap.blackFluteUsed
|
min_steps_needed *= 2 if $PokemonMap.blackFluteUsed
|
||||||
@@ -140,7 +142,7 @@ class PokemonEncounters
|
|||||||
min_steps_needed *= 2
|
min_steps_needed *= 2
|
||||||
when :SNOWCLOAK
|
when :SNOWCLOAK
|
||||||
if $game_screen.weather_type == PBFieldWeather::Snow ||
|
if $game_screen.weather_type == PBFieldWeather::Snow ||
|
||||||
$game_screen.weather_type == PBFieldWeather::Blizzard
|
$game_screen.weather_type == PBFieldWeather::Blizzard
|
||||||
encounter_chance /= 2
|
encounter_chance /= 2
|
||||||
min_steps_needed *= 2
|
min_steps_needed *= 2
|
||||||
end
|
end
|
||||||
@@ -160,14 +162,17 @@ class PokemonEncounters
|
|||||||
end
|
end
|
||||||
# Wild encounters are much less likely to happen for the first few steps
|
# Wild encounters are much less likely to happen for the first few steps
|
||||||
# after a previous wild encounter
|
# after a previous wild encounter
|
||||||
if @step_count < min_steps_needed
|
if triggered_by_step && @step_count < min_steps_needed
|
||||||
@step_count += 1
|
@step_count += 1
|
||||||
return false if rand(100) >= encounter_chance * 5 / (@step_chances[enc_type] + @chance_accumulator / 200)
|
return false if rand(100) >= encounter_chance * 5 / (@step_chances[enc_type] + @chance_accumulator / 200)
|
||||||
end
|
end
|
||||||
# Decide whether the wild encounter should actually happen
|
# Decide whether the wild encounter should actually happen
|
||||||
return true if rand(100) < encounter_chance
|
return true if rand(100) < encounter_chance
|
||||||
# If encounter didn't happen, make the next step more likely to produce one
|
# 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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -423,8 +428,8 @@ def pbGenerateWildPokemon(species,level,isRoamer=false)
|
|||||||
return genwildpoke
|
return genwildpoke
|
||||||
end
|
end
|
||||||
|
|
||||||
# Used by fishing rods and Headbutt/Rock Smash/Sweet Scent. Skips the
|
# Used by fishing rods and Headbutt/Rock Smash/Sweet Scent to generate a wild
|
||||||
# probability checks in def step_triggers_encounter? above.
|
# Pokémon (or two) for a triggered wild encounter.
|
||||||
def pbEncounter(enc_type)
|
def pbEncounter(enc_type)
|
||||||
$PokemonTemp.encounterType = enc_type
|
$PokemonTemp.encounterType = enc_type
|
||||||
encounter1 = $PokemonEncounters.choose_wild_pokemon(enc_type)
|
encounter1 = $PokemonEncounters.choose_wild_pokemon(enc_type)
|
||||||
|
|||||||
@@ -592,9 +592,7 @@ HiddenMoveHandlers::UseMove.add(:HEADBUTT,proc { |move,pokemon|
|
|||||||
# Rock Smash
|
# Rock Smash
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbRockSmashRandomEncounter
|
def pbRockSmashRandomEncounter
|
||||||
encounter_data = GameData::Encounter.get($game_map.map_id, $PokemonGlobal.encounter_version)
|
if $PokemonEncounters.encounter_triggered?(EncounterTypes::RockSmash, false, false)
|
||||||
chance = (encounter_data) ? encounter_data.step_chances[EncounterTypes::RockSmash] || 50 : 50
|
|
||||||
if rand(100) < chance
|
|
||||||
pbEncounter(EncounterTypes::RockSmash)
|
pbEncounter(EncounterTypes::RockSmash)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ def pbEncounterTypeEditor(enc_data, enc_type)
|
|||||||
loop do
|
loop do
|
||||||
if need_refresh
|
if need_refresh
|
||||||
commands.clear
|
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]))
|
commands.push(_INTL("Encounter type={1}", EncounterTypes::Names[enc_type]))
|
||||||
if enc_data.types[enc_type] && enc_data.types[enc_type].length > 0
|
if enc_data.types[enc_type] && enc_data.types[enc_type].length > 0
|
||||||
enc_data.types[enc_type].each do |slot|
|
enc_data.types[enc_type].each do |slot|
|
||||||
@@ -272,7 +272,7 @@ def pbEncounterTypeEditor(enc_data, enc_type)
|
|||||||
ret = pbCommands2(list, commands, -1, ret)
|
ret = pbCommands2(list, commands, -1, ret)
|
||||||
if ret == 0 # Edit step chance
|
if ret == 0 # Edit step chance
|
||||||
old_step_chance = enc_data.step_chances[enc_type] || 0
|
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
|
if new_step_chance != old_step_chance
|
||||||
enc_data.step_chances[enc_type] = new_step_chance
|
enc_data.step_chances[enc_type] = new_step_chance
|
||||||
need_refresh = true
|
need_refresh = true
|
||||||
|
|||||||
Reference in New Issue
Block a user