Added Gen 9 forms code, evolution code, some item effects

This commit is contained in:
Maruno17
2024-06-08 19:35:45 +01:00
parent 6c3d9e77ad
commit 5e23984765
26 changed files with 678 additions and 495 deletions

View File

@@ -149,6 +149,12 @@ MultipleForms.register(:UNOWN, {
}
})
MultipleForms.register(:DUNSPARCE, {
"getFormOnCreation" => proc { |pkmn|
next (rand(100) == 0) ? 1 : 0 # 99% form 0, 1% form 1
}
})
MultipleForms.register(:SPINDA, {
"alterBitmap" => proc { |pkmn, bitmap|
pbSpindaSpots(pkmn, bitmap)
@@ -266,7 +272,7 @@ MultipleForms.register(:ROTOM, {
MultipleForms.register(:GIRATINA, {
"getForm" => proc { |pkmn|
next 1 if pkmn.hasItem?(:GRISEOUSORB)
next 1 if pkmn.hasItem?(:GRISEOUSORB) && Settings::MECHANICS_GENERATION <= 8
next 1 if $game_map&.metadata&.has_flag?("DistortionWorld")
next 0
}
@@ -602,14 +608,14 @@ MultipleForms.register(:TOXEL, {
MultipleForms.copy(:TOXEL, :TOXTRICITY)
MultipleForms.register(:SINISTEA, {
MultipleForms.register(:POLTEAGEIST, {
"getFormOnCreation" => proc { |pkmn|
next 1 if rand(100) < 10 # Antique
next 0 # Phony
}
})
MultipleForms.copy(:SINISTEA, :POLTEAGEIST)
MultipleForms.copy(:POLTEAGEIST, :SINISTEA)
# A Milcery will always have the same flavor, but it is randomly chosen.
MultipleForms.register(:MILCERY, {
@@ -728,34 +734,96 @@ MultipleForms.register(:CALYREX, {
}
})
MultipleForms.register(:LECHONK, {
"getForm" => proc { |pkmn|
next pkmn.gender
}
})
MultipleForms.copy(:LECHONK, :OINKOLOGNE)
MultipleForms.register(:TANDEMAUS, {
"getFormOnCreation" => proc { |pkmn|
next (rand(100) == 0) ? 1 : 0 # 99% form 0, 1% form 1
}
})
MultipleForms.copy(:TANDEMAUS, :MAUSHOLD)
MultipleForms.register(:SQUAWKABILLY, {
"getFormOnCreation" => proc { |pkmn|
next rand(4)
}
})
MultipleForms.register(:TATSUGIRI, {
"getFormOnCreation" => proc { |pkmn|
next rand(3)
}
})
# NOTE: Wild Dudunsparce is always form 0.
# NOTE: Wild Gimmighoul is always form 0.
MultipleForms.register(:POLTCHAGEIST, {
"getFormOnCreation" => proc { |pkmn|
next 1 if rand(100) < 10 # Artisan
next 0 # Counterfeit
}
})
MultipleForms.copy(:POLTCHAGEIST, :SINISCHA)
MultipleForms.register(:OGERPON, {
"getForm" => proc { |pkmn|
next 1 if pkmn.hasItem?(:WELLSPRINGMASK)
next 2 if pkmn.hasItem?(:HEARTHFLAMEMASK)
next 3 if pkmn.hasItem?(:CORNERSTONEMASK)
next 0
}
})
#===============================================================================
# Regional forms
# This code is for determining the form of a Pokémon in an egg created at the
# Day Care, where that Pokémon's species has regional forms. The regional form
# chosen depends on the region in which the egg was produced (not where it
# hatches).
# hatches). The form should have a flag called "EggInRegion_2" where the number
# is the number of the region in which the egg was produced.
#===============================================================================
# The code in this proc assumes that the appropriate regional form for a Pokémon
# is equal to the region's number. This may not be true in your game.
# Note that this proc only produces a non-zero form number if the species has a
# defined form with that number, which means it can be used for both Alolan and
# Galarian forms separately (and for Meowth which has both).
MultipleForms.register(:RATTATA, {
"getFormOnEggCreation" => proc { |pkmn|
if $game_map
map_pos = $game_map.metadata&.town_map_position
next map_pos[0] if map_pos &&
GameData::Species.get_species_form(pkmn.species, map_pos[0]).form == map_pos[0]
region_num = map_pos[0]
found_form = -1
GameData::Species.each_form_for_species(pkmn.species) do |sp_data|
sp_data.flags.each do |flag|
if flag[/^EggInRegion_(\d+)$/i] && $~[1].to_i == region_num
found_form = sp_data.form
break
end
end
break if found_form >= 0
end
next found_form if found_form >= 0
end
next 0
}
})
MultipleForms.copy(:RATTATA, :SANDSHREW, :VULPIX, :DIGLETT, :MEOWTH, :GEODUDE,
:GRIMER, :PONYTA, :FARFETCHD, :CORSOLA, :ZIGZAGOON,
:DARUMAKA, :YAMASK, :STUNFISK, :SLOWPOKE, :ARTICUNO, :ZAPDOS,
:MOLTRES)
MultipleForms.copy(
# Alolan forms
:RATTATA, :SANDSHREW, :VULPIX, :DIGLETT, :MEOWTH, :GEODUDE, :GRIMER,
# Galarian forms (excluding Meowth which is above)
:PONYTA, :SLOWPOKE, :FARFETCHD, :ARTICUNO, :ZAPDOS, :MOLTRES, :CORSOLA,
:ZIGZAGOON, :DARUMAKA, :YAMASK, :STUNFISK,
# Hisuian forms
:GROWLITHE, :VOLTORB, :QWILFISH, :SNEASEL, :ZORUA,
# Paldean forms
:TAUROS, :WOOPER
)
#===============================================================================
# Regional forms
@@ -790,3 +858,21 @@ MultipleForms.register(:KOFFING, {
})
MultipleForms.copy(:KOFFING, :MIMEJR)
# Hisuian forms
MultipleForms.register(:QUILAVA, {
"getForm" => proc { |pkmn|
next if pkmn.form_simple >= 2
if $game_map
map_pos = $game_map.metadata&.town_map_position
next 1 if map_pos && map_pos[0] == 3 # Hisui region
end
next 0
}
})
MultipleForms.copy(:QUILAVA,
:DEWOTT, :PETILILL, :RUFFLET, :GOOMY, :BERGMITE, :DARTRIX)
# Paldean forms
# None!

View File

@@ -360,6 +360,9 @@ class Battle::Move::UserLosesHalfHP < Battle::Move::RecoilMove
# NOTE: This move's recoil is not prevented by Rock Head/Magic Guard.
amt = pbRecoilDamage(user, target)
amt = 1 if amt < 1
if user.pokemon.isSpecies?(:BASCULIN) && [2, 3].include?(user.pokemon.form)
user.pokemon.evolution_counter += amt
end
user.pbReduceHP(amt, false)
@battle.pbDisplay(_INTL("{1} is damaged by recoil!", user.pbThis))
user.pbItemHPHealCheck

View File

@@ -252,8 +252,10 @@ class Pokemon
# @param value [Integer] new HP value
def hp=(value)
@hp = value.clamp(0, @totalhp)
heal_status if @hp == 0
@ready_to_evolve = false if @hp == 0
return if @hp > 0
heal_status
@ready_to_evolve = false
@evolution_counter = 0 if isSpecies?(:BASCULIN) || isSpecies?(:YAMASK)
end
# Sets this Pokémon's status. See {GameData::Status} for all possible status effects.
@@ -988,6 +990,16 @@ class Pokemon
end
end
# Checks whether this Pokemon can evolve because of levelling up in battle.
# This also checks call_level_up as above.
# @return [Symbol, nil] the ID of the species to evolve into
def check_evolution_on_battle_level_up
return check_evolution_internal do |pkmn, new_species, method, parameter|
success = GameData::Evolution.get(method).call_battle_level_up(pkmn, parameter)
next (success) ? new_species : nil
end
end
# Checks whether this Pokemon can evolve because of using an item on it.
# @param item_used [Symbol, GameData::Item, nil] the item being used
# @return [Symbol, nil] the ID of the species to evolve into