Updated happiness values (assuming Timburr/Stunfisk not changing are mistakes), added new type of evolution that triggers after any battle, added code to let Galarian Farfetch'd evolve after dealing 3 critical hits

This commit is contained in:
Maruno17
2021-07-09 21:44:58 +01:00
parent ae7661edc5
commit 33f0403945
9 changed files with 1405 additions and 1367 deletions

View File

@@ -7,6 +7,7 @@ module GameData
attr_reader :level_up_proc attr_reader :level_up_proc
attr_reader :use_item_proc attr_reader :use_item_proc
attr_reader :on_trade_proc attr_reader :on_trade_proc
attr_reader :after_battle_proc
attr_reader :event_proc attr_reader :event_proc
attr_reader :after_evolution_proc attr_reader :after_evolution_proc
@@ -26,6 +27,7 @@ module GameData
@level_up_proc = hash[:level_up_proc] @level_up_proc = hash[:level_up_proc]
@use_item_proc = hash[:use_item_proc] @use_item_proc = hash[:use_item_proc]
@on_trade_proc = hash[:on_trade_proc] @on_trade_proc = hash[:on_trade_proc]
@after_battle_proc = hash[:after_battle_proc]
@event_proc = hash[:event_proc] @event_proc = hash[:event_proc]
@after_evolution_proc = hash[:after_evolution_proc] @after_evolution_proc = hash[:after_evolution_proc]
end end
@@ -42,6 +44,10 @@ module GameData
return (@on_trade_proc) ? @on_trade_proc.call(*args) : nil return (@on_trade_proc) ? @on_trade_proc.call(*args) : nil
end end
def call_after_battle(*args)
return (@after_battle_proc) ? @after_battle_proc.call(*args) : nil
end
def call_event(*args) def call_event(*args)
return (@event_proc) ? @event_proc.call(*args) : nil return (@event_proc) ? @event_proc.call(*args) : nil
end end
@@ -604,6 +610,19 @@ GameData::Evolution.register({
} }
}) })
#===============================================================================
# Evolution methods that are triggered after any battle
#===============================================================================
GameData::Evolution.register({
:id => :BattleDealCriticalHit,
:parameter => Integer,
:after_battle_proc => proc { |pkmn, party_index, parameter|
next $PokemonTemp.party_critical_hits_dealt &&
$PokemonTemp.party_critical_hits_dealt[party_index] &&
$PokemonTemp.party_critical_hits_dealt[party_index] >= parameter
}
})
#=============================================================================== #===============================================================================
# Evolution methods that are triggered by an event # Evolution methods that are triggered by an event
#=============================================================================== #===============================================================================

View File

@@ -272,6 +272,7 @@ class PokeBattle_Move
@battle.pbDisplay(_INTL("The substitute took damage for {1}!",target.pbThis(true))) @battle.pbDisplay(_INTL("The substitute took damage for {1}!",target.pbThis(true)))
end end
if target.damageState.critical if target.damageState.critical
$PokemonTemp.party_critical_hits_dealt[user.pokemonIndex] += 1 if user.pbOwnedByPlayer?
if numTargets>1 if numTargets>1
@battle.pbDisplay(_INTL("A critical hit on {1}!",target.pbThis(true))) @battle.pbDisplay(_INTL("A critical hit on {1}!",target.pbThis(true)))
else else

View File

@@ -13,7 +13,8 @@ end
class PokemonTemp class PokemonTemp
attr_accessor :encounterTriggered attr_accessor :encounterTriggered
attr_accessor :encounterType attr_accessor :encounterType
attr_accessor :evolutionLevels attr_accessor :party_levels_before_battle
attr_accessor :party_critical_hits_dealt
def battleRules def battleRules
@battleRules = {} if !@battleRules @battleRules = {} if !@battleRules
@@ -187,9 +188,11 @@ end
Events.onStartBattle += proc { |_sender| Events.onStartBattle += proc { |_sender|
# Record current levels of Pokémon in party, to see if they gain a level # Record current levels of Pokémon in party, to see if they gain a level
# during battle and may need to evolve afterwards # during battle and may need to evolve afterwards
$PokemonTemp.evolutionLevels = [] $PokemonTemp.party_levels_before_battle = []
$PokemonTemp.party_critical_hits_dealt = []
for i in 0...$Trainer.party.length for i in 0...$Trainer.party.length
$PokemonTemp.evolutionLevels[i] = $Trainer.party[i].level $PokemonTemp.party_levels_before_battle[i] = $Trainer.party[i].level
$PokemonTemp.party_critical_hits_dealt = 0
end end
} }
@@ -566,12 +569,12 @@ end
Events.onEndBattle += proc { |_sender,e| Events.onEndBattle += proc { |_sender,e|
decision = e[0] decision = e[0]
canLose = e[1] canLose = e[1]
if Settings::CHECK_EVOLUTION_AFTER_ALL_BATTLES || (decision!=2 && decision!=5) # not a loss or a draw # Check for evolutions
if $PokemonTemp.evolutionLevels pbEvolutionCheck if Settings::CHECK_EVOLUTION_AFTER_ALL_BATTLES ||
pbEvolutionCheck($PokemonTemp.evolutionLevels) (decision!=2 && decision!=5) # not a loss or a draw
$PokemonTemp.evolutionLevels = nil $PokemonTemp.party_levels_before_battle = nil
end $PokemonTemp.party_critical_hits_dealt = nil
end # Check for blacking out or gaining Pickup/Huney Gather items
case decision case decision
when 1, 4 # Win, capture when 1, 4 # Win, capture
$Trainer.pokemon_party.each do |pkmn| $Trainer.pokemon_party.each do |pkmn|
@@ -587,17 +590,25 @@ Events.onEndBattle += proc { |_sender,e|
end end
} }
def pbEvolutionCheck(currentLevels) def pbEvolutionCheck
for i in 0...currentLevels.length $Trainer.party.each_with_index do |pkmn, i|
pkmn = $Trainer.party[i] next if !pkmn || pkmn.egg?
next if !pkmn || (pkmn.hp==0 && !Settings::CHECK_EVOLUTION_FOR_FAINTED_POKEMON) next if pkmn.fainted? && !Settings::CHECK_EVOLUTION_FOR_FAINTED_POKEMON
next if currentLevels[i] && pkmn.level==currentLevels[i] # Find an evolution
newSpecies = pkmn.check_evolution_on_level_up new_species = nil
next if !newSpecies if new_species.nil? && $PokemonTemp.party_levels_before_battle &&
evo = PokemonEvolutionScene.new $PokemonTemp.party_levels_before_battle[i] &&
evo.pbStartScreen(pkmn,newSpecies) $PokemonTemp.party_levels_before_battle[i] < pkmn.level
evo.pbEvolution new_species = pkmn.check_evolution_on_level_up
evo.pbEndScreen end
new_species = pkmn.check_evolution_after_battle(i) if new_species.nil?
# Evolve Pokémon if possible
if !new_species.nil?
evo = PokemonEvolutionScene.new
evo.pbStartScreen(pkmn, new_species)
evo.pbEvolution
evo.pbEndScreen
end
end end
end end

View File

@@ -961,6 +961,15 @@ class Pokemon
} }
end end
# Checks whether this Pokemon can evolve after a battle.
# @return [Symbol, nil] the ID of the species to evolve into
def check_evolution_after_battle(party_index)
return check_evolution_internal { |pkmn, new_species, method, parameter|
success = GameData::Evolution.get(method).call_after_battle(pkmn, party_index, parameter)
next (success) ? new_species : nil
}
end
# Checks whether this Pokemon can evolve by a triggered event. # Checks whether this Pokemon can evolve by a triggered event.
# @param value [Integer] a value that may be used by the evolution method # @param value [Integer] a value that may be used by the evolution method
# @return [Symbol, nil] the ID of the species to evolve into # @return [Symbol, nil] the ID of the species to evolve into

View File

@@ -77,9 +77,6 @@ Can use Fly from within the Town Map if possible. (Good QoL, add if possible.)
Make example event that combines the Gen 8 fossils. Make example event that combines the Gen 8 fossils.
New evolution methods:
- Galarian Farfetch'd: performing 3 critical hits in a single battle.
Add AI for new moves/items/abilities. Add AI for new moves/items/abilities.
Zacian/Zamazenta need code that changes their movesets upon entering/leaving Zacian/Zamazenta need code that changes their movesets upon entering/leaving
@@ -136,6 +133,7 @@ is done regardless of Generation, and doesn't need to be limited to Gen 8+.
New evolution methods: New evolution methods:
- Kubfu (triggered by an event; Kubfu's form can be set beforehand by the event, - Kubfu (triggered by an event; Kubfu's form can be set beforehand by the event,
so don't worry about the multiple forms it can evolve into) so don't worry about the multiple forms it can evolve into)
- Galarian Farfetch'd (performing 3 critical hits in a single battle)
Escape Rope's code now supports both consumable and non-consumable versions, Escape Rope's code now supports both consumable and non-consumable versions,
depending on whether it is a key item. All it needs is a proper definition in depending on whether it is a key item. All it needs is a proper definition in

File diff suppressed because it is too large Load Diff

View File

@@ -368,7 +368,7 @@ Weight = 42.0
Pokedex = The stalks of leeks are thicker and longer in the Galar region. Farfetch'd that adapted to these stalks took on a unique form. Pokedex = The stalks of leeks are thicker and longer in the Galar region. Farfetch'd that adapted to these stalks took on a unique form.
Generation = 8 Generation = 8
WildItemCommon = LEEK WildItemCommon = LEEK
Evolutions = SIRFETCHD,HoldItem,DIREHIT Evolutions = SIRFETCHD,BattleDealCriticalHit,3
#------------------------------- #-------------------------------
[GRIMER,1] [GRIMER,1]
FormName = Alolan FormName = Alolan

File diff suppressed because it is too large Load Diff

View File

@@ -368,7 +368,7 @@ Weight = 42.0
Pokedex = The stalks of leeks are thicker and longer in the Galar region. Farfetch'd that adapted to these stalks took on a unique form. Pokedex = The stalks of leeks are thicker and longer in the Galar region. Farfetch'd that adapted to these stalks took on a unique form.
Generation = 8 Generation = 8
WildItemCommon = LEEK WildItemCommon = LEEK
Evolutions = SIRFETCHD,HoldItem,DIREHIT Evolutions = SIRFETCHD,BattleDealCriticalHit,3
#------------------------------- #-------------------------------
[GRIMER,1] [GRIMER,1]
FormName = Alolan FormName = Alolan