#==============================================================================
# ■ Trainer Classes with Game-Altering Effects
#==============================================================================
module TrainerClasses
# Define your trainer classes and their effects here.
# Each class should be a hash with the following keys:
# :name => The name of the trainer class.
# :description => A short description of the class.
# :effects => A hash of effects and their values.
TRAINER_CLASSES = {
"Breeder" => {
:name => "Breeder",
:description => "Masters of Pokémon breeding.",
:effects => {
:egg_hatch_rate => 0.5, # 50% faster hatching (multiplier)
}
},
"Hunter" => {
:name => "Hunter",
:description => "Skilled at catching wild Pokémon.",
:effects => {
:catch_rate_bonus => 1.2, # 20% increased catch rate (multiplier)
:shiny_rate_bonus => 1.5, # 50% increased shiny rate (multiplier)
}
},
"Ace Trainer" => {
:name => "Ace Trainer",
:description => "Exceptional trainers with a knack for battle.",
:effects => {
:exp_gain_bonus => 1.2, # 20% increased EXP gain (multiplier)
}
},
"Lucky Trainer" => {
:name => "Lucky Trainer",
:description => "Blessed by fortune, luck is on their side.",
:effects => {
:shiny_rate_bonus => 2.0, # Double Shiny Odds (multiplier)
:exp_gain_bonus => 1.1, # 10% increased EXP gain (multiplier)
:catch_rate_bonus => 1.1, # 10% increased catch rate (multiplier)
}
}
}
# Get the effects for a given trainer class.
def self.get_effects(trainer_class_name)
return TRAINER_CLASSES[trainer_class_name][:effects] if TRAINER_CLASSES.has_key?(trainer_class_name)
return {} # Return empty hash if class not found
end
end
#==============================================================================
# ■ Applying Effects in Relevant Scripts
#==============================================================================
#------------------------------------------------------------------------------
# Egg Hatching (PokemonEgg)
#------------------------------------------------------------------------------
class PokemonEgg
alias :__old_initialize__ :initialize
def initialize(*args)
__old_initialize__(*args)
trainer_class = $Trainer.trainer_type
effects = TrainerClasses.get_effects(trainer_class)
if effects[:egg_hatch_rate]
@steps_to_hatch = (@steps_to_hatch * effects[:egg_hatch_rate]).to_i # Apply reduction
end
end
end
#------------------------------------------------------------------------------
# Catch Rate (Battle)
#------------------------------------------------------------------------------
class Battle
alias :__old_pbCatch__ :pbCatch
def pbCatch(pkmn)
catch_rate = pkmn.catchRate
trainer_class = $Trainer.trainer_type
effects = TrainerClasses.get_effects(trainer_class)
if effects[:catch_rate_bonus]
catch_rate = (catch_rate * effects[:catch_rate_bonus]).to_i # Apply bonus
end
__old_pbCatch__(pkmn, catch_rate)
end
end
#------------------------------------------------------------------------------
# Shiny Rate (Pokemon)
#------------------------------------------------------------------------------
class Pokemon
alias :__old_initialize__ :initialize
def initialize(*args)
__old_initialize__(*args)
trainer_class = $Trainer.trainer_type
effects = TrainerClasses.get_effects(trainer_class)
if effects[:shiny_rate_bonus]
@personalID = rand(2**16) | (rand(2**16) << 16) if rand(8192) < (8192/effects[:shiny_rate_bonus]).floor
end
end
end
#------------------------------------------------------------------------------
# EXP Gain (Battle)
#------------------------------------------------------------------------------
class Battle::BattlePeer
alias :__old_pbGainExpOne__ :pbGainExpOne
def pbGainExpOne(winner,defeated,exp)
trainer_class = $Trainer.trainer_type
effects = TrainerClasses.get_effects(trainer_class)
if effects[:exp_gain_bonus]
exp = (exp * effects[:exp_gain_bonus]).floor
end
__old_pbGainExpOne__(winner,defeated,exp)
end
end
#==============================================================================
# Example Usage (Setting Trainer Class)
#==============================================================================
# In a script event or other appropriate place:
# $Trainer.trainer_type = "Hunter" # Set the trainer's class
# puts $Trainer.trainer_type # Check the trainer's class
#==============================================================================
# End of Script
#==============================================================================