mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +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?
|
||||
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)
|
||||
|
||||
@@ -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
|
||||
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
|
||||
@@ -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
|
||||
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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user