mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 14:14:59 +00:00
Fixed Poké Radar rustling grass not always causing a wild encounter when stepping in it, other tweaks to Poké Radar
This commit is contained in:
@@ -109,6 +109,9 @@ class PokemonEncounters
|
|||||||
# Check if enc_type has a defined step chance/encounter table
|
# Check if enc_type has a defined step chance/encounter table
|
||||||
return false if !@step_chances[enc_type] || @step_chances[enc_type] == 0
|
return false if !@step_chances[enc_type] || @step_chances[enc_type] == 0
|
||||||
return false if !has_encounter_type?(enc_type)
|
return false if !has_encounter_type?(enc_type)
|
||||||
|
# Poké Radar encounters always happen, ignoring the minimum step period and
|
||||||
|
# trigger probabilities
|
||||||
|
return true if pbPokeRadarOnShakingGrass
|
||||||
# Get base encounter chance and minimum steps grace period
|
# Get base encounter chance and minimum steps grace period
|
||||||
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
|
||||||
@@ -176,8 +179,9 @@ class PokemonEncounters
|
|||||||
# taking into account Repels and ability effects.
|
# taking into account Repels and ability effects.
|
||||||
def allow_encounter?(enc_data, repel_active = false)
|
def allow_encounter?(enc_data, repel_active = false)
|
||||||
return false if !enc_data
|
return false if !enc_data
|
||||||
|
return true if pbPokeRadarOnShakingGrass
|
||||||
# Repel
|
# Repel
|
||||||
if repel_active && !pbPokeRadarOnShakingGrass
|
if repel_active
|
||||||
first_pkmn = (Settings::REPEL_COUNTS_FAINTED_POKEMON) ? $Trainer.first_pokemon : $Trainer.first_able_pokemon
|
first_pkmn = (Settings::REPEL_COUNTS_FAINTED_POKEMON) ? $Trainer.first_pokemon : $Trainer.first_able_pokemon
|
||||||
if first_pkmn && enc_data[1] < first_pkmn.level
|
if first_pkmn && enc_data[1] < first_pkmn.level
|
||||||
@chance_accumulator = 0
|
@chance_accumulator = 0
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ end
|
|||||||
|
|
||||||
def pbUsePokeRadar
|
def pbUsePokeRadar
|
||||||
return false if !pbCanUsePokeRadar?
|
return false if !pbCanUsePokeRadar?
|
||||||
$PokemonTemp.pokeradar = [0,0,0,[]] if !$PokemonTemp.pokeradar
|
$PokemonTemp.pokeradar = [0,0,0,[],false] if !$PokemonTemp.pokeradar
|
||||||
|
$PokemonTemp.pokeradar[4] = false
|
||||||
$PokemonGlobal.pokeradarBattery = 50
|
$PokemonGlobal.pokeradarBattery = 50
|
||||||
pbPokeRadarHighlightGrass
|
pbPokeRadarHighlightGrass
|
||||||
return true
|
return true
|
||||||
@@ -80,9 +81,8 @@ def pbPokeRadarHighlightGrass(showmessage=true)
|
|||||||
s = (rand(100) < 25) ? 1 : 0
|
s = (rand(100) < 25) ? 1 : 0
|
||||||
if $PokemonTemp.pokeradar && $PokemonTemp.pokeradar[2] > 0
|
if $PokemonTemp.pokeradar && $PokemonTemp.pokeradar[2] > 0
|
||||||
v = [(65536 / Settings::SHINY_POKEMON_CHANCE) - $PokemonTemp.pokeradar[2] * 200, 200].max
|
v = [(65536 / Settings::SHINY_POKEMON_CHANCE) - $PokemonTemp.pokeradar[2] * 200, 200].max
|
||||||
v = 0xFFFF / v
|
v = (65536 / v.to_f).ceil
|
||||||
v = rand(65536) / v
|
s = 2 if rand(65536) < v
|
||||||
s = 2 if v == 0
|
|
||||||
end
|
end
|
||||||
grasses.push([x,y,i,s])
|
grasses.push([x,y,i,s])
|
||||||
end
|
end
|
||||||
@@ -162,7 +162,8 @@ EncounterModifier.register(proc { |encounter|
|
|||||||
rarity = 0 # 0 = rustle, 1 = vigorous rustle, 2 = shiny rustle
|
rarity = 0 # 0 = rustle, 1 = vigorous rustle, 2 = shiny rustle
|
||||||
$PokemonTemp.pokeradar[3].each { |g| rarity = g[3] if g[2] == ring }
|
$PokemonTemp.pokeradar[3].each { |g| rarity = g[3] if g[2] == ring }
|
||||||
if $PokemonTemp.pokeradar[2] > 0 # Chain count, i.e. is chaining
|
if $PokemonTemp.pokeradar[2] > 0 # Chain count, i.e. is chaining
|
||||||
if rarity == 2 || rand(100) < 86 + ring * 4 + ($PokemonTemp.pokeradar[2] / 4).floor
|
if rarity == 2 ||
|
||||||
|
rand(100) < 58 + ring * 10 + ($PokemonTemp.pokeradar[2] / 4) + ($PokemonTemp.pokeradar[4] ? 10 : 0)
|
||||||
# Continue the chain
|
# Continue the chain
|
||||||
encounter = [$PokemonTemp.pokeradar[0], $PokemonTemp.pokeradar[1]]
|
encounter = [$PokemonTemp.pokeradar[0], $PokemonTemp.pokeradar[1]]
|
||||||
$PokemonTemp.forceSingleBattle = true
|
$PokemonTemp.forceSingleBattle = true
|
||||||
@@ -172,7 +173,12 @@ EncounterModifier.register(proc { |encounter|
|
|||||||
break if encounter && encounter[0] != $PokemonTemp.pokeradar[0]
|
break if encounter && encounter[0] != $PokemonTemp.pokeradar[0]
|
||||||
encounter = $PokemonEncounters.choose_wild_pokemon($PokemonEncounters.encounter_type)
|
encounter = $PokemonEncounters.choose_wild_pokemon($PokemonEncounters.encounter_type)
|
||||||
end
|
end
|
||||||
pbPokeRadarCancel
|
if encounter[0] == $PokemonTemp.pokeradar[0] && encounter[1] == $PokemonTemp.pokeradar[1]
|
||||||
|
# Chain couldn't be broken somehow; continue it after all
|
||||||
|
$PokemonTemp.forceSingleBattle = true
|
||||||
|
else
|
||||||
|
pbPokeRadarCancel
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else # Not chaining; will start one
|
else # Not chaining; will start one
|
||||||
# Force random wild encounter, vigorous shaking means rarer species
|
# Force random wild encounter, vigorous shaking means rarer species
|
||||||
@@ -204,8 +210,9 @@ Events.onWildBattleEnd += proc { |_sender,e|
|
|||||||
if $PokemonTemp.pokeradar && (decision==1 || decision==4) # Defeated/caught
|
if $PokemonTemp.pokeradar && (decision==1 || decision==4) # Defeated/caught
|
||||||
$PokemonTemp.pokeradar[0] = species
|
$PokemonTemp.pokeradar[0] = species
|
||||||
$PokemonTemp.pokeradar[1] = level
|
$PokemonTemp.pokeradar[1] = level
|
||||||
$PokemonTemp.pokeradar[2] += 1
|
$PokemonTemp.pokeradar[2] = [$PokemonTemp.pokeradar[2] + 1, 40].min
|
||||||
$PokemonTemp.pokeradar[2] = 40 if $PokemonTemp.pokeradar[2]>40
|
# Catching makes the next Radar encounter more likely to continue the chain
|
||||||
|
$PokemonTemp.pokeradar[4] = (decision == 4)
|
||||||
pbPokeRadarHighlightGrass(false)
|
pbPokeRadarHighlightGrass(false)
|
||||||
else
|
else
|
||||||
pbPokeRadarCancel
|
pbPokeRadarCancel
|
||||||
@@ -231,7 +238,7 @@ Events.onMapChange += proc { |_sender,_e|
|
|||||||
# Item handlers
|
# Item handlers
|
||||||
################################################################################
|
################################################################################
|
||||||
ItemHandlers::UseInField.add(:POKERADAR,proc { |item|
|
ItemHandlers::UseInField.add(:POKERADAR,proc { |item|
|
||||||
next (pbCanUsePokeRadar?) ? pbUsePokeRadar : 0
|
next (pbUsePokeRadar) ? 1 : 0
|
||||||
})
|
})
|
||||||
|
|
||||||
ItemHandlers::UseFromBag.add(:POKERADAR,proc { |item|
|
ItemHandlers::UseFromBag.add(:POKERADAR,proc { |item|
|
||||||
|
|||||||
Reference in New Issue
Block a user