Update 6.8

This commit is contained in:
chardub
2026-07-10 15:42:06 -04:00
parent 5b85e72cb2
commit 6a6f126a18
7871 changed files with 493194 additions and 224826 deletions
@@ -22,25 +22,32 @@ def applyTrainerRandomEvents(trainer,event_type=nil)
#time_passed = trainer.getTimeSinceLastAction
#return trainer if time_passed < TIME_FOR_RANDOM_EVENTS
catch_chance_for_number_in_team = [100,40,30,20,10,5,0]
unfuse_chance_for_number_in_team = [0,10,10,5,5,0,0]
fuse_chance_for_number_in_team = [0,0,40,60,65,75,85]
# Weighted chances out of 10
#Odds of certain events depends on nb. of pokemon in current party
catch_chance = catch_chance_for_number_in_team[trainer.currentTeam.length]
unfuse_chance = unfuse_chance_for_number_in_team[trainer.currentTeam.length]
fuse_chance = fuse_chance_for_number_in_team[trainer.currentTeam.length]
# Chances out of 100
weighted_events = [
[:CATCH, 3],
[:FUSE, 6],
[:REVERSE, 1],
[:UNFUSE, 2]
[:CATCH, catch_chance], #Depends on nb of pokemon in team. 40% if only 1, then DECREASES with the nb.
[:FUSE, fuse_chance], #Depends on nb of pokemon in team. 40% if 2, then INCREASES with the nb.
[:REVERSE, 10],
[:UNFUSE, unfuse_chance] #Depends on nb of pokemon in team. 10% if 1 or 2, 5% if 3 or 4. .
]
# Create a flat array of events based on weight
event_pool = weighted_events.flat_map { |event, weight| [event] * weight }
selected_event = event_pool.sample
selected_event = event_type if event_type
#Random event guaranteed after 1st rematch only (can still fail if they don't have the requirements tho)
if selected_event.nil? && trainer.nb_rematches == 1
selected_event = event_pool.sample until selected_event
end
if selected_event
echoln "Trying to do random event: #{selected_event}"
end
return trainer if selected_event.nil?
original_team = trainer.currentTeam.clone
@@ -55,9 +62,6 @@ def applyTrainerRandomEvents(trainer,event_type=nil)
trainer = reverse_random_team_pokemon(trainer)
end
new_team = trainer.currentTeam
echoln original_team
echoln new_team
team_changed = original_team != new_team
trainer.set_pending_action(team_changed)
printNPCTrainerCurrentTeam(trainer)
@@ -67,24 +71,26 @@ end
def chooseEncounterType(trainerClass)
water_trainer_classes = [:SWIMMER_F, :SWIMMER_M, :FISHERMAN]
water_trainer_classes = [:SWIMMER_F, :SWIMMER_M,:SWIMMER2_M,:SWIMMER2_F, :FISHERMAN, :SURFER, :DIVER_M, :DIVER_F]
hybrid_trainer_classes = [:COOLTRAINER_M, :COOLTRAINER_F, :TRIATHLETE_SWIM_M, :TRIATHLETE_SWIM_F,
:TRIATHLETE_RUN_M, :TRIATHLETE_RUN_F, :SAILOR, :TUBER_M, :TUBER_F]
if water_trainer_classes.include?(trainerClass )
chance_of_land_encounter = 1
chance_of_land_encounter = 0
chance_of_surf_encounter= 5
chance_of_cave_encounter = 1
chance_of_cave_encounter = 0
chance_of_fishing_encounter = 5
elsif hybrid_trainer_classes.include?(trainerClass )
chance_of_land_encounter = 5
chance_of_surf_encounter= 2
chance_of_cave_encounter = 5
chance_of_fishing_encounter = 2
else
chance_of_land_encounter = 5
chance_of_surf_encounter= 1
chance_of_surf_encounter= 0
chance_of_cave_encounter = 5
chance_of_fishing_encounter = 1
end
if pbCheckHiddenMoveBadge(Settings::BADGE_FOR_SURF, false)
chance_of_surf_encounter =0
chance_of_fishing_encounter = 0
end
$PokemonEncounters.has_water_encounters?
possible_encounter_types = []
if $PokemonEncounters.has_land_encounters?
possible_encounter_types += [:Land] * chance_of_land_encounter
@@ -96,7 +102,6 @@ def chooseEncounterType(trainerClass)
possible_encounter_types += [:GoodRod] * chance_of_fishing_encounter
possible_encounter_types += [:Water] * chance_of_surf_encounter
end
echoln "possible_encounter_types: #{possible_encounter_types}"
return getTimeBasedEncounter(possible_encounter_types.sample)
end
@@ -112,16 +117,41 @@ def catch_new_team_pokemon(trainer)
return trainer if !encounter_type
echoln "Catching a pokemon via encounter_type #{encounter_type}"
wild_pokemon = $PokemonEncounters.choose_wild_pokemon(encounter_type)
echoln wild_pokemon
# 3 rolls for favorite type, then normal roll
wild_pokemon = select_npc_new_pokemon(encounter_type, trainer.favorite_type)
if wild_pokemon
trainer.currentTeam << Pokemon.new(wild_pokemon[0],wild_pokemon[1])
trainer_highest_level = get_trainer_highest_level(trainer)
species = wild_pokemon[0]
level = [wild_pokemon[1], trainer_highest_level].min
original_trainer =pbLoadTrainer(trainer.trainerType,trainer.trainerName,0)
trainer.currentTeam << Pokemon.new(species,level,original_trainer)
trainer.log_catch_event(wild_pokemon[0])
end
return trainer
end
# 3 rolls for favorite type, then normal roll
def select_npc_new_pokemon(encounter_type, favorite_type)
(1..3).each { |i|
wild_pokemon = $PokemonEncounters.choose_wild_pokemon(encounter_type)
next unless wild_pokemon
species = wild_pokemon[0]
if GameData::Species.get(species)&.hasType?(favorite_type)
return wild_pokemon
end
}
return $PokemonEncounters.choose_wild_pokemon(encounter_type)
end
def get_trainer_highest_level(trainer)
highest_level = 1
trainer.currentTeam.each do |pokemon|
highest_level = pokemon.level if pokemon.level > highest_level
end
return highest_level
end
def reverse_random_team_pokemon(trainer)
@@ -136,6 +166,7 @@ def reverse_random_team_pokemon(trainer)
head_pokemon = get_head_species_from_symbol(pokemon_to_reverse.species)
pokemon_to_reverse.species = getFusedPokemonIdFromSymbols(head_pokemon,body_pokemon)
pokemon_to_reverse.pif_sprite=nil
trainer.currentTeam.push(pokemon_to_reverse)
trainer.log_reverse_event(old_species,pokemon_to_reverse.species)
return trainer
@@ -148,18 +179,19 @@ def unfuse_random_team_pokemon(trainer)
return trainer if trainer.currentTeam.length > 5
pokemon_to_unfuse = eligible_pokemon.sample
echoln pokemon_to_unfuse.owner.name
echoln trainer.trainerName
return trainer if pokemon_to_unfuse.owner.name != trainer.trainerName
body_pokemon = get_body_id_from_symbol(pokemon_to_unfuse.species)
head_pokemon = get_head_id_from_symbol(pokemon_to_unfuse.species)
level = calculateUnfuseLevelOldMethod(pokemon_to_unfuse,false)
if pokemon_to_unfuse.item
trainer.inventory << pokemon_to_unfuse.item.id
end
trainer.currentTeam.delete(pokemon_to_unfuse)
trainer.currentTeam.push(Pokemon.new(body_pokemon,level))
trainer.currentTeam.push(Pokemon.new(head_pokemon,level))
original_trainer =pbLoadTrainer(trainer.trainerType,trainer.trainerName,0)
trainer.currentTeam.push(Pokemon.new(body_pokemon,level,original_trainer))
trainer.currentTeam.push(Pokemon.new(head_pokemon,level,original_trainer))
trainer.log_unfusion_event(pokemon_to_unfuse.species, body_pokemon, head_pokemon)
return trainer
end
@@ -173,7 +205,8 @@ def fuse_random_team_pokemon(trainer)
head_pokemon = pokemon_to_fuse[1]
fusion_species = getFusedPokemonIdFromSymbols(body_pokemon.species,head_pokemon.species)
level = (body_pokemon.level + head_pokemon.level)/2
fused_pokemon = Pokemon.new(fusion_species,level)
original_trainer =pbLoadTrainer(trainer.trainerType,trainer.trainerName,0)
fused_pokemon = Pokemon.new(fusion_species,level,original_trainer)
trainer.currentTeam.delete(body_pokemon)
trainer.currentTeam.delete(head_pokemon)