Added evolution method for Galarian Yamask, minor refactoring in battle code, a Pokémon's ability no longer needs resetting when changing its ability_index

This commit is contained in:
Maruno17
2021-11-07 18:05:32 +00:00
parent ae7721316f
commit 34ab0b8afe
24 changed files with 109 additions and 52 deletions

View File

@@ -263,9 +263,6 @@ GameData::Evolution.register({
GameData::Evolution.register({
:id => :Shedinja,
:parameter => Integer,
:level_up_proc => proc { |pkmn, parameter|
next false # This is a dummy proc and shouldn't next true
},
:after_evolution_proc => proc { |pkmn, new_species, parameter, evo_species|
next false if $player.party_full?
next false if !$bag.has?(:POKEBALL)
@@ -697,3 +694,19 @@ GameData::Evolution.register({
next true
}
})
GameData::Evolution.register({
:id => :EventAfterDamageTaken,
:parameter => Integer,
:after_battle_proc => proc { |pkmn, party_index, parameter|
if $game_temp.party_direct_damage_taken &&
$game_temp.party_direct_damage_taken[party_index] &&
$game_temp.party_direct_damage_taken[party_index] >= parameter
pkmn.ready_to_evolve = true
end
next false
},
:event_proc => proc { |pkmn, parameter, value|
next pkmn.ready_to_evolve
}
})

View File

@@ -706,6 +706,10 @@ class PokeBattle_Battler
return @battle.pbOwnedByPlayer?(@index)
end
def wild?
return @battle.wildBattle? && opposes?
end
# Returns 0 if self is on the player's side, or 1 if self is on the opposing
# side.
def idxOwnSide

View File

@@ -86,6 +86,7 @@ class PokeBattle_Battler
# Do other things
@battle.pbClearChoice(@index) # Reset choice
pbOwnSide.effects[PBEffects::LastRoundFainted] = @battle.turnCount
$game_temp.party_direct_damage_taken[@pokemonIndex] = 0 if pbOwnedByPlayer?
# Check other battlers' abilities that trigger upon a battler fainting
pbAbilitiesOnFainting
# Check for end of primordial weather

View File

@@ -5,7 +5,7 @@ class PokeBattle_Battler
def pbProcessTurn(choice,tryFlee=true)
return false if fainted?
# Wild roaming Pokémon always flee if possible
if tryFlee && @battle.wildBattle? && opposes? &&
if tryFlee && wild? &&
@battle.rules["alwaysflee"] && @battle.pbCanRun?(@index)
pbBeginTurn(choice)
pbSEPlay("Battle flee")

View File

@@ -382,5 +382,6 @@ class PokeBattle_Move
target.lastHPLostFromFoe = damage # For Metal Burst
target.lastFoeAttacker.push(user.index) # For Metal Burst
end
$game_temp.party_direct_damage_taken[target.pokemonIndex] += damage if target.pbOwnedByPlayer?
end
end

View File

@@ -9,7 +9,7 @@ end
#===============================================================================
class PokeBattle_Move_DoesNothingCongratuations < PokeBattle_Move
def pbEffectGeneral(user)
if @battle.wildBattle? && user.opposes?
if user.wild?
@battle.pbDisplay(_INTL("Congratulations from {1}!",user.pbThis(true)))
else
@battle.pbDisplay(_INTL("Congratulations, {1}!",@battle.pbGetOwnerName(user.index)))

View File

@@ -4,7 +4,7 @@
#===============================================================================
class PokeBattle_Move_UserTakesTargetItem < PokeBattle_Move
def pbEffectAfterAllHits(user,target)
return if @battle.wildBattle? && user.opposes? # Wild Pokémon can't thieve
return if user.wild? # Wild Pokémon can't thieve
return if user.fainted?
return if target.damageState.unaffected || target.damageState.substitute
return if !target.item || user.item
@@ -14,8 +14,7 @@ class PokeBattle_Move_UserTakesTargetItem < PokeBattle_Move
itemName = target.itemName
user.item = target.item
# Permanently steal the item from wild Pokémon
if @battle.wildBattle? && target.opposes? && !user.initialItem &&
target.item == target.initialItem
if target.wild? && !user.initialItem && target.item == target.initialItem
user.setInitialItem(target.item)
target.pbRemoveItem
else
@@ -56,8 +55,7 @@ class PokeBattle_Move_TargetTakesUserItem < PokeBattle_Move
itemName = user.itemName
target.item = user.item
# Permanently steal the item from wild Pokémon
if @battle.wildBattle? && user.opposes? && !target.initialItem &&
user.item == user.initialItem
if user.wild? && !target.initialItem && user.item == user.initialItem
target.setInitialItem(user.item)
user.pbRemoveItem
else
@@ -74,7 +72,7 @@ end
#===============================================================================
class PokeBattle_Move_UserTargetSwapItems < PokeBattle_Move
def pbMoveFailed?(user,targets)
if @battle.wildBattle? && user.opposes?
if user.wild?
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -121,8 +119,7 @@ class PokeBattle_Move_UserTargetSwapItems < PokeBattle_Move
target.effects[PBEffects::ChoiceBand] = nil if !target.hasActiveAbility?(:GORILLATACTICS)
target.effects[PBEffects::Unburden] = (!target.item && oldTargetItem) if target.hasActiveAbility?(:UNBURDEN)
# Permanently steal the item from wild Pokémon
if @battle.wildBattle? && target.opposes? && !user.initialItem &&
oldTargetItem == target.initialItem
if target.wild? && !user.initialItem && oldTargetItem == target.initialItem
user.setInitialItem(oldTargetItem)
end
@battle.pbDisplay(_INTL("{1} switched items with its opponent!",user.pbThis))
@@ -180,7 +177,7 @@ class PokeBattle_Move_RemoveTargetItem < PokeBattle_Move
end
def pbEffectAfterAllHits(user,target)
return if @battle.wildBattle? && user.opposes? # Wild Pokémon can't knock off
return if user.wild? # Wild Pokémon can't knock off
return if user.fainted?
return if target.damageState.unaffected || target.damageState.substitute
return if !target.item || target.unlosableItem?(target.item)

View File

@@ -22,7 +22,7 @@ end
#===============================================================================
class PokeBattle_Move_SwitchOutUserStatusMove < PokeBattle_Move
def pbMoveFailed?(user,targets)
if @battle.wildBattle? && user.opposes?
if user.wild?
if !@battle.pbCanRun?(user.index)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -35,7 +35,7 @@ class PokeBattle_Move_SwitchOutUserStatusMove < PokeBattle_Move
end
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
return if @battle.wildBattle? && user.opposes?
return if user.wild?
@battle.pbDisplay(_INTL("{1} went back to {2}!",user.pbThis,
@battle.pbGetOwnerName(user.index)))
@battle.pbPursuit(user.index)
@@ -50,7 +50,7 @@ class PokeBattle_Move_SwitchOutUserStatusMove < PokeBattle_Move
end
def pbEffectGeneral(user)
if @battle.wildBattle? && user.opposes?
if user.wild?
@battle.pbDisplay(_INTL("{1} fled from battle!",user.pbThis))
@battle.decision = 3 # Escaped
end

View File

@@ -232,7 +232,8 @@ class PokeBattle_Battle
def pbGetOwnerFromBattlerIndex(idxBattler)
idxTrainer = pbGetOwnerIndexFromBattlerIndex(idxBattler)
return (opposes?(idxBattler)) ? @opponent[idxTrainer] : @player[idxTrainer]
trainer = (opposes?(idxBattler)) ? @opponent : @player
return (trainer.nil?) ? nil : trainer[idxTrainer]
end
def pbGetOwnerIndexFromPartyIndex(idxBattler,idxParty)
@@ -248,7 +249,8 @@ class PokeBattle_Battle
# switch another trainer's Pokémon.
def pbGetOwnerFromPartyIndex(idxBattler,idxParty)
idxTrainer = pbGetOwnerIndexFromPartyIndex(idxBattler,idxParty)
return (opposes?(idxBattler)) ? @opponent[idxTrainer] : @player[idxTrainer]
trainer = (opposes?(idxBattler)) ? @opponent : @player
return (trainer.nil?) ? nil : trainer[idxTrainer]
end
def pbGetOwnerName(idxBattler)

View File

@@ -156,7 +156,7 @@ class PokeBattle_Battle
idxBattler = b.index
next if !pbCanChooseNonActive?(idxBattler)
if !pbOwnedByPlayer?(idxBattler) # Opponent/ally is switching in
next if wildBattle? && opposes?(idxBattler) # Wild Pokémon can't switch
next if b.wild? # Wild Pokémon can't switch
idxPartyNew = pbSwitchInBetween(idxBattler)
opponent = pbGetOwnerFromBattlerIndex(idxBattler)
# NOTE: The player is only offered the chance to switch their own

View File

@@ -83,7 +83,7 @@ class PokeBattle_Battle
def pbCanMegaEvolve?(idxBattler)
return false if $game_switches[Settings::NO_MEGA_EVOLUTION]
return false if !@battlers[idxBattler].hasMega?
return false if wildBattle? && opposes?(idxBattler)
return false if @battlers[idxBattler].wild?
return true if $DEBUG && Input.press?(Input::CTRL)
return false if @battlers[idxBattler].effects[PBEffects::SkyDrop]>=0
return false if !pbHasMegaRing?(idxBattler)

View File

@@ -33,7 +33,7 @@ class PokeBattle_Battle
next if b.effects[PBEffects::SkyDrop]>=0
next if b.hasActiveAbility?(:TRUANT) && b.effects[PBEffects::Truant]
# Mega Evolve
if !wildBattle? || !b.opposes?
if !b.wild?
owner = pbGetOwnerIndexFromBattlerIndex(b.index)
pbMegaEvolve(b.index) if @megaEvolution[b.idxOwnSide][owner]==b.index
end
@@ -93,7 +93,7 @@ class PokeBattle_Battle
def pbAttackPhaseMegaEvolution
pbPriority.each do |b|
next if wildBattle? && b.opposes?
next if b.wild?
next unless @choices[b.index][0]==:UseMove && !b.fainted?
owner = pbGetOwnerIndexFromBattlerIndex(b.index)
next if @megaEvolution[b.idxOwnSide][owner]!=b.index

View File

@@ -1842,7 +1842,7 @@ BattleHandlers::UserAbilityEndOfMove.add(:MAGICIAN,
next if battle.futureSight
next if !move.pbDamagingMove?
next if user.item
next if battle.wildBattle? && user.opposes?
next if user.wild?
targets.each do |b|
next if b.damageState.unaffected || b.damageState.substitute
next if !b.item
@@ -1919,7 +1919,7 @@ BattleHandlers::TargetAbilityAfterMoveUse.add(:PICKPOCKET,
# NOTE: According to Bulbapedia, this can still trigger to steal the user's
# item even if it was switched out by a Red Card. This doesn't make
# sense, so this code doesn't do it.
next if battle.wildBattle? && target.opposes?
next if target.wild?
next if switched_battlers.include?(user.index) # User was switched out
next if !move.contactMove?
next if user.effects[PBEffects::Substitute]>0 || target.damageState.substitute

View File

@@ -5,7 +5,7 @@ class PokeBattle_AI
#=============================================================================
def pbChooseMoves(idxBattler)
user = @battle.battlers[idxBattler]
wildBattler = (@battle.wildBattle? && @battle.opposes?(idxBattler))
wildBattler = user.wild?
skill = 0
if !wildBattler
skill = @battle.pbGetOwnerFromBattlerIndex(user.index).skill_level || 0

View File

@@ -229,7 +229,7 @@ BattleHandlers::ItemOnStatDropped.add(:EJECTPACK,
next false if battler.effects[PBEffects::SkyDrop] >= 0 ||
battler.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSkyTargetCannotAct") # Sky Drop
next false if battle.pbAllFainted?(battler.idxOpposingSide)
next false if battle.wildBattle? && battler.opposes? # Wild Pokémon can't eject
next false if battler.wild? # Wild Pokémon can't eject
next false if !battle.pbCanSwitch?(battler.index) # Battler can't switch out
next false if !battle.pbCanChooseNonActive?(battler.index) # No Pokémon can switch in
battle.pbCommonAnimation("UseItem", battler)

View File

@@ -27,7 +27,11 @@ class PokeBattle_RealBattlePeer
player.party[player.party.length] = pkmn
return -1
end
pkmn.heal if Settings::HEAL_STORED_POKEMON
if Settings::HEAL_STORED_POKEMON
old_ready_evo = pkmn.ready_to_evolve
pkmn.heal
pkmn.ready_to_evolve = old_ready_evo
end
oldCurBox = pbCurrentBox
storedBox = $PokemonStorage.pbStoreCaught(pkmn)
if storedBox<0

View File

@@ -15,6 +15,7 @@ class Game_Temp
attr_accessor :encounter_type
attr_accessor :party_levels_before_battle
attr_accessor :party_critical_hits_dealt
attr_accessor :party_direct_damage_taken
def battle_rules
@battle_rules = {} if !@battle_rules
@@ -192,9 +193,11 @@ Events.onStartBattle += proc { |_sender|
# during battle and may need to evolve afterwards
$game_temp.party_levels_before_battle = []
$game_temp.party_critical_hits_dealt = []
$game_temp.party_direct_damage_taken = []
$player.party.each_with_index do |pkmn, i|
$game_temp.party_levels_before_battle[i] = pkmn.level
$game_temp.party_critical_hits_dealt[i] = 0
$game_temp.party_direct_damage_taken[i] = 0
end
}

View File

@@ -190,7 +190,11 @@ class PokemonStorage
else # Copying into box
pkmn = self[boxSrc,indexSrc]
raise "Trying to copy nil to storage" if !pkmn
pkmn.heal if Settings::HEAL_STORED_POKEMON
if Settings::HEAL_STORED_POKEMON
old_ready_evo = pkmn.ready_to_evolve
pkmn.heal
pkmn.ready_to_evolve = old_ready_evo
end
self[boxDst,indexDst] = pkmn
end
return true
@@ -210,7 +214,11 @@ class PokemonStorage
def pbMoveCaughtToBox(pkmn,box)
for i in 0...maxPokemon(box)
if self[box,i]==nil
pkmn.heal if box >= 0 && Settings::HEAL_STORED_POKEMON
if Settings::HEAL_STORED_POKEMON && box >= 0
old_ready_evo = pkmn.ready_to_evolve
pkmn.heal
pkmn.ready_to_evolve = old_ready_evo
end
self[box,i] = pkmn
return true
end
@@ -219,7 +227,11 @@ class PokemonStorage
end
def pbStoreCaught(pkmn)
pkmn.heal if Settings::HEAL_STORED_POKEMON if @currentBox >= 0
if Settings::HEAL_STORED_POKEMON && @currentBox >= 0
old_ready_evo = pkmn.ready_to_evolve
pkmn.heal
pkmn.ready_to_evolve = old_ready_evo
end
for i in 0...maxPokemon(@currentBox)
if self[@currentBox,i]==nil
self[@currentBox,i] = pkmn

View File

@@ -26,11 +26,6 @@ class Pokemon
# This Pokémon's shininess (true, false, nil). Is recalculated if made nil.
# @param value [Boolean, nil] whether this Pokémon is shiny
attr_writer :shiny
# The index of this Pokémon's ability (0, 1 are natural abilities, 2+ are
# hidden abilities)as defined for its species/form. An ability may not be
# defined at this index. Is recalculated (as 0 or 1) if made nil.
# @param value [Integer, nil] forced ability index (nil if none is set)
attr_writer :ability_index
# @return [Array<Pokemon::Move>] the moves known by this Pokémon
attr_accessor :moves
# @return [Array<Symbol>] the IDs of moves known by this Pokémon when it was obtained
@@ -80,6 +75,9 @@ class Pokemon
attr_accessor :fused
# @return [Integer] this Pokémon's personal ID
attr_accessor :personalID
# Used by Galarian Yamask to remember that it took sufficient damage from a
# battle and can evolve.
attr_accessor :ready_to_evolve
# Max total IVs
IV_STAT_LIMIT = 31
@@ -237,6 +235,7 @@ class Pokemon
def hp=(value)
@hp = value.clamp(0, @totalhp)
heal_status if @hp == 0
@ready_to_evolve = false if @hp == 0
end
# Sets this Pokémon's status. See {GameData::Status} for all possible status effects.
@@ -292,6 +291,7 @@ class Pokemon
heal_HP
heal_status
heal_PP
@ready_to_evolve = false
end
#=============================================================================
@@ -402,6 +402,7 @@ class Pokemon
return @super_shiny
end
# @param value [Boolean] whether this Pokémon is super shiny
def super_shiny=(value)
@super_shiny = value
@shiny = true if @super_shiny
@@ -411,12 +412,21 @@ class Pokemon
# Ability
#=============================================================================
# The index of this Pokémon's ability (0, 1 are natural abilities, 2+ are
# hidden abilities) as defined for its species/form. An ability may not be
# defined at this index. Is recalculated (as 0 or 1) if made nil.
# @return [Integer] the index of this Pokémon's ability
def ability_index
@ability_index = (@personalID & 1) if !@ability_index
return @ability_index
end
# @param value [Integer, nil] forced ability index (nil if none is set)
def ability_index=(value)
@ability_index = value
@ability = nil
end
# @return [GameData::Ability, nil] an Ability object corresponding to this Pokémon's ability
def ability
return GameData::Ability.try_get(ability_id)

View File

@@ -587,6 +587,7 @@ class PokemonEvolutionScene
@pokemon.species = @newspecies
@pokemon.form = 0 if @pokemon.isSpecies?(:MOTHIM)
@pokemon.calc_stats
@pokemon.ready_to_evolve = false
# See and own evolved species
$player.pokedex.register(@pokemon)
$player.pokedex.set_owned(@newspecies)

View File

@@ -1727,7 +1727,11 @@ class PokemonStorageScreen
end
if heldpoke || selected[0]==-1
p = (heldpoke) ? heldpoke : @storage[-1,index]
p.heal if Settings::HEAL_STORED_POKEMON
if Settings::HEAL_STORED_POKEMON
old_ready_evo = p.ready_to_evolve
p.heal
p.ready_to_evolve = old_ready_evo
end
end
@scene.pbStore(selected,heldpoke,destbox,firstfree)
if heldpoke
@@ -1771,7 +1775,11 @@ class PokemonStorageScreen
pbDisplay("Please remove the mail.")
return
end
@heldpkmn.heal if Settings::HEAL_STORED_POKEMON if box >= 0
if Settings::HEAL_STORED_POKEMON && box >= 0
old_ready_evo = @heldpkmn.ready_to_evolve
@heldpkmn.heal
@heldpkmn.ready_to_evolve = old_ready_evo
end
@scene.pbPlace(selected,@heldpkmn)
@storage[box,index] = @heldpkmn
if box==-1
@@ -1796,7 +1804,11 @@ class PokemonStorageScreen
pbDisplay("Please remove the mail.")
return false
end
@heldpkmn.heal if Settings::HEAL_STORED_POKEMON if box >= 0
if Settings::HEAL_STORED_POKEMON && box >= 0
old_ready_evo = @heldpkmn.ready_to_evolve
@heldpkmn.heal
@heldpkmn.ready_to_evolve = old_ready_evo
end
@scene.pbSwap(selected,@heldpkmn)
tmp = @storage[box,index]
@storage[box,index] = @heldpkmn

View File

@@ -20,17 +20,6 @@ Other notes:
"The Weakness Policy sharply raised {1}'s Sp. Atk!"
"The Weakness Policy was used up..."
New evolution methods:
- Milcery: spinning while holding an item. (Doesn't suit our control scheme.
We're not adding a way to easily spin on the spot just for this, cf.
not having to turn your computer upside-down to evolve Inkay.)
- Galarian Yamask: going to a particular spot after a battle in which it lost
49+ HP from a single attack and hasn't fainted since then;
healing doesn't affect this. (Utter nonsense, find a better
way - just evolve after a battle in which the damage was
taken.) Confirmed that the damage has to be dealt in a single
attack, not spread across multiple ones.
- Ask whether a captured Pokémon, or an added Pokémon, should be put in storage
or added to the party if the party is full. Also provide the option to look at
its Pokédex entry. Have a way to force adding it to the party for plot
@@ -58,6 +47,11 @@ toggled. (Probably don't bother implementing.)
Bicycle that can work on water.
New evolution methods:
- Milcery: spinning while holding an item. (Doesn't suit our control scheme.
We're not adding a way to easily spin on the spot just for this, cf.
not having to turn your computer upside-down to evolve Inkay.)
I think there are some alternate forms which don't have a hidden ability while
their base forms do. I don't think the compiler supports this, and instead
treats Abilities and HiddenAbilities separately. Can work around this by setting
@@ -100,6 +94,9 @@ New evolution methods:
- 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)
- Galarian Farfetch'd (performing 3 critical hits in a single battle)
- Galarian Yamask: going to a particular spot after a battle in which it lost
49+ HP in a single battle from direct attacks and hasn't
fainted since then; healing with Potions doesn't affect this.
Added AI for new moves/items/abilities.

View File

@@ -1438,7 +1438,7 @@ TutorMoves = ALLYSWITCH,ATTRACT,BRUTALSWING,CALMMIND,DARKPULSE,EARTHPOWER,EARTHQ
Pokedex = A clay slab with cursed engravings took possession of a Yamask. The slab is said to be absorbing the Yamask's dark power.
Generation = 8
Flags = InheritFormWithEverStone
Evolutions = RUNERIGUS,Level,34
Evolutions = RUNERIGUS,EventAfterDamageTaken,49
#-------------------------------
[DEERLING,1]
FormName = Summer Form

View File

@@ -1438,7 +1438,7 @@ TutorMoves = ALLYSWITCH,ATTRACT,BRUTALSWING,CALMMIND,DARKPULSE,EARTHPOWER,EARTHQ
Pokedex = A clay slab with cursed engravings took possession of a Yamask. The slab is said to be absorbing the Yamask's dark power.
Generation = 8
Flags = InheritFormWithEverStone
Evolutions = RUNERIGUS,Level,34
Evolutions = RUNERIGUS,EventAfterDamageTaken,49
#-------------------------------
[DEERLING,1]
FormName = Summer Form