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

@@ -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