mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Merge branch 'master' into dev
This commit is contained in:
@@ -109,6 +109,9 @@ class PokemonEncounters
|
||||
# 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 !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
|
||||
encounter_chance = @step_chances[enc_type].to_f
|
||||
min_steps_needed = (8 - encounter_chance / 10).clamp(0, 8).to_f
|
||||
@@ -181,8 +184,9 @@ class PokemonEncounters
|
||||
# taking into account Repels and ability effects.
|
||||
def allow_encounter?(enc_data, repel_active = false)
|
||||
return false if !enc_data
|
||||
return true if pbPokeRadarOnShakingGrass
|
||||
# Repel
|
||||
if repel_active && !pbPokeRadarOnShakingGrass
|
||||
if repel_active
|
||||
first_pkmn = (Settings::REPEL_COUNTS_FAINTED_POKEMON) ? $Trainer.first_pokemon : $Trainer.first_able_pokemon
|
||||
if first_pkmn && enc_data[1] < first_pkmn.level
|
||||
@chance_accumulator = 0
|
||||
|
||||
@@ -43,7 +43,8 @@ end
|
||||
|
||||
def pbUsePokeRadar
|
||||
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
|
||||
pbPokeRadarHighlightGrass
|
||||
return true
|
||||
@@ -80,9 +81,8 @@ def pbPokeRadarHighlightGrass(showmessage=true)
|
||||
s = (rand(100) < 25) ? 1 : 0
|
||||
if $PokemonTemp.pokeradar && $PokemonTemp.pokeradar[2] > 0
|
||||
v = [(65536 / Settings::SHINY_POKEMON_CHANCE) - $PokemonTemp.pokeradar[2] * 200, 200].max
|
||||
v = 0xFFFF / v
|
||||
v = rand(65536) / v
|
||||
s = 2 if v == 0
|
||||
v = (65536 / v.to_f).ceil
|
||||
s = 2 if rand(65536) < v
|
||||
end
|
||||
grasses.push([x,y,i,s])
|
||||
end
|
||||
@@ -162,7 +162,8 @@ EncounterModifier.register(proc { |encounter|
|
||||
rarity = 0 # 0 = rustle, 1 = vigorous rustle, 2 = shiny rustle
|
||||
$PokemonTemp.pokeradar[3].each { |g| rarity = g[3] if g[2] == ring }
|
||||
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
|
||||
encounter = [$PokemonTemp.pokeradar[0], $PokemonTemp.pokeradar[1]]
|
||||
$PokemonTemp.forceSingleBattle = true
|
||||
@@ -172,7 +173,12 @@ EncounterModifier.register(proc { |encounter|
|
||||
break if encounter && encounter[0] != $PokemonTemp.pokeradar[0]
|
||||
encounter = $PokemonEncounters.choose_wild_pokemon($PokemonEncounters.encounter_type)
|
||||
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
|
||||
else # Not chaining; will start one
|
||||
# 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
|
||||
$PokemonTemp.pokeradar[0] = species
|
||||
$PokemonTemp.pokeradar[1] = level
|
||||
$PokemonTemp.pokeradar[2] += 1
|
||||
$PokemonTemp.pokeradar[2] = 40 if $PokemonTemp.pokeradar[2]>40
|
||||
$PokemonTemp.pokeradar[2] = [$PokemonTemp.pokeradar[2] + 1, 40].min
|
||||
# Catching makes the next Radar encounter more likely to continue the chain
|
||||
$PokemonTemp.pokeradar[4] = (decision == 4)
|
||||
pbPokeRadarHighlightGrass(false)
|
||||
else
|
||||
pbPokeRadarCancel
|
||||
@@ -231,7 +238,7 @@ Events.onMapChange += proc { |_sender,_e|
|
||||
# Item handlers
|
||||
################################################################################
|
||||
ItemHandlers::UseInField.add(:POKERADAR,proc { |item|
|
||||
next (pbCanUsePokeRadar?) ? pbUsePokeRadar : 0
|
||||
next (pbUsePokeRadar) ? 1 : 0
|
||||
})
|
||||
|
||||
ItemHandlers::UseFromBag.add(:POKERADAR,proc { |item|
|
||||
|
||||
Reference in New Issue
Block a user