mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 21:54:58 +00:00
Yet more Rubocopping
This commit is contained in:
@@ -321,7 +321,7 @@ class Battle
|
||||
def pbAbleCount(idxBattler = 0)
|
||||
party = pbParty(idxBattler)
|
||||
count = 0
|
||||
party.each { |pkmn| count += 1 if pkmn && pkmn.able? }
|
||||
party.each { |pkmn| count += 1 if pkmn&.able? }
|
||||
return count
|
||||
end
|
||||
|
||||
|
||||
@@ -465,11 +465,11 @@ class Battle
|
||||
end
|
||||
infected.each do |idxParty|
|
||||
strain = $player.party[idxParty].pokerusStrain
|
||||
if idxParty > 0 && $player.party[idxParty - 1].pokerusStage == 0
|
||||
$player.party[idxParty - 1].givePokerus(strain) if rand(3) == 0 # 33%
|
||||
if idxParty > 0 && $player.party[idxParty - 1].pokerusStage == 0 && rand(3) == 0 # 33%
|
||||
$player.party[idxParty - 1].givePokerus(strain)
|
||||
end
|
||||
if idxParty < $player.party.length - 1 && $player.party[idxParty + 1].pokerusStage == 0
|
||||
$player.party[idxParty + 1].givePokerus(strain) if rand(3) == 0 # 33%
|
||||
if idxParty < $player.party.length - 1 && $player.party[idxParty + 1].pokerusStage == 0 && rand(3) == 0 # 33%
|
||||
$player.party[idxParty + 1].givePokerus(strain)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,13 +11,13 @@ class Battle
|
||||
expAll = $player.has_exp_all || $bag.has?(:EXPALL)
|
||||
p1 = pbParty(0)
|
||||
@battlers.each do |b|
|
||||
next unless b && b.opposes? # Can only gain Exp from fainted foes
|
||||
next unless b&.opposes? # Can only gain Exp from fainted foes
|
||||
next if b.participants.length == 0
|
||||
next unless b.fainted? || b.captured
|
||||
# Count the number of participants
|
||||
numPartic = 0
|
||||
b.participants.each do |partic|
|
||||
next unless p1[partic] && p1[partic].able? && pbIsOwner?(0, partic)
|
||||
next unless p1[partic]&.able? && pbIsOwner?(0, partic)
|
||||
numPartic += 1
|
||||
end
|
||||
# Find which Pokémon have an Exp Share
|
||||
@@ -199,7 +199,7 @@ class Battle
|
||||
if curLevel > newLevel
|
||||
# Gained all the Exp now, end the animation
|
||||
pkmn.calc_stats
|
||||
battler.pbUpdate(false) if battler
|
||||
battler&.pbUpdate(false)
|
||||
@scene.pbRefreshOne(battler.index) if battler
|
||||
break
|
||||
end
|
||||
@@ -211,11 +211,11 @@ class Battle
|
||||
oldSpAtk = pkmn.spatk
|
||||
oldSpDef = pkmn.spdef
|
||||
oldSpeed = pkmn.speed
|
||||
if battler && battler.pokemon
|
||||
if battler&.pokemon
|
||||
battler.pokemon.changeHappiness("levelup")
|
||||
end
|
||||
pkmn.calc_stats
|
||||
battler.pbUpdate(false) if battler
|
||||
battler&.pbUpdate(false)
|
||||
@scene.pbRefreshOne(battler.index) if battler
|
||||
pbDisplayPaused(_INTL("{1} grew to Lv. {2}!", pkmn.name, curLevel))
|
||||
@scene.pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense,
|
||||
@@ -260,7 +260,7 @@ class Battle
|
||||
pbDisplayPaused(_INTL("1, 2, and... ... ... Ta-da!")) { pbSEPlay("Battle ball drop") }
|
||||
pbDisplayPaused(_INTL("{1} forgot how to use {2}. And...", pkmnName, oldMoveName))
|
||||
pbDisplay(_INTL("{1} learned {2}!", pkmnName, moveName)) { pbSEPlay("Pkmn move learnt") }
|
||||
battler.pbCheckFormOnMovesetChange if battler
|
||||
battler&.pbCheckFormOnMovesetChange
|
||||
break
|
||||
elsif pbDisplayConfirm(_INTL("Give up on learning {1}?", moveName))
|
||||
pbDisplay(_INTL("{1} did not learn {2}.", pkmnName, moveName))
|
||||
|
||||
@@ -12,7 +12,7 @@ class Battle
|
||||
return false if idxParty >= party.length
|
||||
return false if !party[idxParty]
|
||||
if party[idxParty].egg?
|
||||
partyScene.pbDisplay(_INTL("An Egg can't battle!")) if partyScene
|
||||
partyScene&.pbDisplay(_INTL("An Egg can't battle!"))
|
||||
return false
|
||||
end
|
||||
if !pbIsOwner?(idxBattler, idxParty)
|
||||
@@ -24,11 +24,11 @@ class Battle
|
||||
return false
|
||||
end
|
||||
if party[idxParty].fainted?
|
||||
partyScene.pbDisplay(_INTL("{1} has no energy left to battle!", party[idxParty].name)) if partyScene
|
||||
partyScene&.pbDisplay(_INTL("{1} has no energy left to battle!", party[idxParty].name))
|
||||
return false
|
||||
end
|
||||
if pbFindBattler(idxParty, idxBattler)
|
||||
partyScene.pbDisplay(_INTL("{1} is already in battle!", party[idxParty].name)) if partyScene
|
||||
partyScene&.pbDisplay(_INTL("{1} is already in battle!", party[idxParty].name))
|
||||
return false
|
||||
end
|
||||
return true
|
||||
@@ -45,45 +45,43 @@ class Battle
|
||||
# Pokémon
|
||||
allSameSideBattlers(idxBattler).each do |b|
|
||||
next if choices[b.index][0] != :SwitchOut || choices[b.index][1] != idxParty
|
||||
partyScene.pbDisplay(_INTL("{1} has already been selected.",
|
||||
pbParty(idxBattler)[idxParty].name)) if partyScene
|
||||
partyScene&.pbDisplay(_INTL("{1} has already been selected.",
|
||||
pbParty(idxBattler)[idxParty].name))
|
||||
return false
|
||||
end
|
||||
# Check whether battler can switch out
|
||||
battler = @battlers[idxBattler]
|
||||
return true if battler.fainted?
|
||||
# Ability/item effects that allow switching no matter what
|
||||
if battler.abilityActive?
|
||||
if Battle::AbilityEffects.triggerCertainSwitching(battler.ability, battler, self)
|
||||
return true
|
||||
end
|
||||
if battler.abilityActive? &&
|
||||
Battle::AbilityEffects.triggerCertainSwitching(battler.ability, battler, self)
|
||||
return true
|
||||
end
|
||||
if battler.itemActive?
|
||||
if Battle::ItemEffects.triggerCertainSwitching(battler.item, battler, self)
|
||||
return true
|
||||
end
|
||||
if battler.itemActive? &&
|
||||
Battle::ItemEffects.triggerCertainSwitching(battler.item, battler, self)
|
||||
return true
|
||||
end
|
||||
# Other certain switching effects
|
||||
return true if Settings::MORE_TYPE_EFFECTS && battler.pbHasType?(:GHOST)
|
||||
# Other certain trapping effects
|
||||
if battler.trappedInBattle?
|
||||
partyScene.pbDisplay(_INTL("{1} can't be switched out!", battler.pbThis)) if partyScene
|
||||
partyScene&.pbDisplay(_INTL("{1} can't be switched out!", battler.pbThis))
|
||||
return false
|
||||
end
|
||||
# Trapping abilities/items
|
||||
allOtherSideBattlers(idxBattler).each do |b|
|
||||
next if !b.abilityActive?
|
||||
if Battle::AbilityEffects.triggerTrappingByTarget(b.ability, battler, b, self)
|
||||
partyScene.pbDisplay(_INTL("{1}'s {2} prevents switching!",
|
||||
b.pbThis, b.abilityName)) if partyScene
|
||||
partyScene&.pbDisplay(_INTL("{1}'s {2} prevents switching!",
|
||||
b.pbThis, b.abilityName))
|
||||
return false
|
||||
end
|
||||
end
|
||||
allOtherSideBattlers(idxBattler).each do |b|
|
||||
next if !b.itemActive?
|
||||
if Battle::ItemEffects.triggerTrappingByTarget(b.item, battler, b, self)
|
||||
partyScene.pbDisplay(_INTL("{1}'s {2} prevents switching!",
|
||||
b.pbThis, b.itemName)) if partyScene
|
||||
partyScene&.pbDisplay(_INTL("{1}'s {2} prevents switching!",
|
||||
b.pbThis, b.itemName))
|
||||
return false
|
||||
end
|
||||
end
|
||||
@@ -119,8 +117,8 @@ class Battle
|
||||
elsif !pbCanSwitch?(idxBattler, idxParty, partyScene)
|
||||
next false
|
||||
end
|
||||
if shouldRegister
|
||||
next false if idxParty < 0 || !pbRegisterSwitch(idxBattler, idxParty)
|
||||
if shouldRegister && (idxParty < 0 || !pbRegisterSwitch(idxBattler, idxParty))
|
||||
next false
|
||||
end
|
||||
ret = idxParty
|
||||
next true
|
||||
@@ -187,10 +185,10 @@ class Battle
|
||||
switched.push(idxBattler)
|
||||
else # Player's Pokémon has fainted in a wild battle
|
||||
switch = false
|
||||
if !pbDisplayConfirm(_INTL("Use next Pokémon?"))
|
||||
switch = (pbRun(idxBattler, true) <= 0)
|
||||
else
|
||||
if pbDisplayConfirm(_INTL("Use next Pokémon?"))
|
||||
switch = true
|
||||
else
|
||||
switch = (pbRun(idxBattler, true) <= 0)
|
||||
end
|
||||
if switch
|
||||
idxPlayerPartyNew = pbGetReplacementPokemonIndex(idxBattler) # Owner chooses
|
||||
|
||||
@@ -56,14 +56,14 @@ class Battle
|
||||
return if !item
|
||||
return if !GameData::Item.get(item).consumed_after_use?
|
||||
if pbOwnedByPlayer?(idxBattler)
|
||||
if $bag && $bag.can_add?(item)
|
||||
if $bag&.can_add?(item)
|
||||
$bag.add(item)
|
||||
else
|
||||
raise _INTL("Couldn't return unused item to Bag somehow.")
|
||||
end
|
||||
else
|
||||
items = pbGetOwnerItems(idxBattler)
|
||||
items.push(item) if items
|
||||
items&.push(item)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -75,24 +75,22 @@ class Battle
|
||||
return 1
|
||||
end
|
||||
# Abilities that guarantee escape
|
||||
if battler.abilityActive?
|
||||
if Battle::AbilityEffects.triggerCertainEscapeFromBattle(battler.ability, battler)
|
||||
pbShowAbilitySplash(battler, true)
|
||||
pbHideAbilitySplash(battler)
|
||||
pbSEPlay("Battle flee")
|
||||
pbDisplayPaused(_INTL("You got away safely!"))
|
||||
@decision = 3
|
||||
return 1
|
||||
end
|
||||
if battler.abilityActive? &&
|
||||
Battle::AbilityEffects.triggerCertainEscapeFromBattle(battler.ability, battler)
|
||||
pbShowAbilitySplash(battler, true)
|
||||
pbHideAbilitySplash(battler)
|
||||
pbSEPlay("Battle flee")
|
||||
pbDisplayPaused(_INTL("You got away safely!"))
|
||||
@decision = 3
|
||||
return 1
|
||||
end
|
||||
# Held items that guarantee escape
|
||||
if battler.itemActive?
|
||||
if Battle::ItemEffects.triggerCertainEscapeFromBattle(battler.item, battler)
|
||||
pbSEPlay("Battle flee")
|
||||
pbDisplayPaused(_INTL("{1} fled using its {2}!", battler.pbThis, battler.itemName))
|
||||
@decision = 3
|
||||
return 1
|
||||
end
|
||||
if battler.itemActive? &&
|
||||
Battle::ItemEffects.triggerCertainEscapeFromBattle(battler.item, battler)
|
||||
pbSEPlay("Battle flee")
|
||||
pbDisplayPaused(_INTL("{1} fled using its {2}!", battler.pbThis, battler.itemName))
|
||||
@decision = 3
|
||||
return 1
|
||||
end
|
||||
# Other certain trapping effects
|
||||
if battler.trappedInBattle?
|
||||
|
||||
@@ -161,10 +161,10 @@ class Battle
|
||||
next if advance
|
||||
# Check for all done
|
||||
priority.each do |b|
|
||||
if !b.fainted? && !b.movedThisRound?
|
||||
advance = true if @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift
|
||||
end
|
||||
break if advance
|
||||
next if b.fainted?
|
||||
next if b.movedThisRound? || ![:UseMove, :Shift].include?(@choices[b.index][0])
|
||||
advance = true
|
||||
break
|
||||
end
|
||||
next if advance
|
||||
# All Pokémon have moved; end the loop
|
||||
|
||||
@@ -223,7 +223,7 @@ class Battle
|
||||
if !moveUser # User isn't in battle, get it from the party
|
||||
party = pbParty(pos.effects[PBEffects::FutureSightUserIndex])
|
||||
pkmn = party[pos.effects[PBEffects::FutureSightUserPartyIndex]]
|
||||
if pkmn && pkmn.able?
|
||||
if pkmn&.able?
|
||||
moveUser = Battler.new(self, pos.effects[PBEffects::FutureSightUserIndex])
|
||||
moveUser.pbInitDummyPokemon(pkmn, pos.effects[PBEffects::FutureSightUserPartyIndex])
|
||||
end
|
||||
@@ -504,12 +504,11 @@ class Battle
|
||||
b.pbItemHPHealCheck
|
||||
b.pbFaint if b.fainted?
|
||||
end
|
||||
if perishSongUsers.length > 0
|
||||
# If all remaining Pokemon fainted by a Perish Song triggered by a single side
|
||||
if (perishSongUsers.find_all { |idxBattler| opposes?(idxBattler) }.length == perishSongUsers.length) ||
|
||||
(perishSongUsers.find_all { |idxBattler| !opposes?(idxBattler) }.length == perishSongUsers.length)
|
||||
pbJudgeCheckpoint(@battlers[perishSongUsers[0]])
|
||||
end
|
||||
# Judge if all remaining Pokemon fainted by a Perish Song triggered by a single side
|
||||
if perishSongUsers.length > 0 &&
|
||||
((perishSongUsers.find_all { |idxBattler| opposes?(idxBattler) }.length == perishSongUsers.length) ||
|
||||
(perishSongUsers.find_all { |idxBattler| !opposes?(idxBattler) }.length == perishSongUsers.length))
|
||||
pbJudgeCheckpoint(@battlers[perishSongUsers[0]])
|
||||
end
|
||||
# Check for end of battle
|
||||
if @decision > 0
|
||||
|
||||
@@ -136,17 +136,17 @@ class Battle::Battler
|
||||
#=============================================================================
|
||||
def hasMega?
|
||||
return false if @effects[PBEffects::Transform]
|
||||
return @pokemon && @pokemon.hasMegaForm?
|
||||
return @pokemon&.hasMegaForm?
|
||||
end
|
||||
|
||||
def mega?; return @pokemon && @pokemon.mega?; end
|
||||
def mega?; return @pokemon&.mega?; end
|
||||
|
||||
def hasPrimal?
|
||||
return false if @effects[PBEffects::Transform]
|
||||
return @pokemon && @pokemon.hasPrimalForm?
|
||||
return @pokemon&.hasPrimalForm?
|
||||
end
|
||||
|
||||
def primal?; return @pokemon && @pokemon.primal?; end
|
||||
def primal?; return @pokemon&.primal?; end
|
||||
|
||||
def shadowPokemon?; return false; end
|
||||
|
||||
@@ -184,11 +184,11 @@ class Battle::Battler
|
||||
|
||||
def shiny?
|
||||
return @effects[PBEffects::Illusion].shiny? if @effects[PBEffects::Illusion]
|
||||
return @pokemon && @pokemon.shiny?
|
||||
return @pokemon&.shiny?
|
||||
end
|
||||
|
||||
def super_shiny?
|
||||
return @pokemon && @pokemon.super_shiny?
|
||||
return @pokemon&.super_shiny?
|
||||
end
|
||||
|
||||
def owned?
|
||||
@@ -295,7 +295,7 @@ class Battle::Battler
|
||||
end
|
||||
|
||||
def isSpecies?(species)
|
||||
return @pokemon && @pokemon.isSpecies?(species)
|
||||
return @pokemon&.isSpecies?(species)
|
||||
end
|
||||
|
||||
# Returns the active types of this Pokémon. The array should not include the
|
||||
@@ -311,8 +311,8 @@ class Battle::Battler
|
||||
ret.push(:NORMAL) if ret.length == 0
|
||||
end
|
||||
# Add the third type specially.
|
||||
if withType3 && @effects[PBEffects::Type3]
|
||||
ret.push(@effects[PBEffects::Type3]) if !ret.include?(@effects[PBEffects::Type3])
|
||||
if withType3 && @effects[PBEffects::Type3] && !ret.include?(@effects[PBEffects::Type3])
|
||||
ret.push(@effects[PBEffects::Type3])
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
@@ -277,14 +277,13 @@ class Battle::Battler
|
||||
end
|
||||
end
|
||||
# Zygarde - Power Construct
|
||||
if isSpecies?(:ZYGARDE) && self.ability == :POWERCONSTRUCT && endOfRound
|
||||
if @hp <= @totalhp / 2 && @form < 2 # Turn into Complete Forme
|
||||
newForm = @form + 2
|
||||
@battle.pbDisplay(_INTL("You sense the presence of many!"))
|
||||
@battle.pbShowAbilitySplash(self, true)
|
||||
@battle.pbHideAbilitySplash(self)
|
||||
pbChangeForm(newForm, _INTL("{1} transformed into its Complete Forme!", pbThis))
|
||||
end
|
||||
if isSpecies?(:ZYGARDE) && self.ability == :POWERCONSTRUCT && endOfRound &&
|
||||
@hp <= @totalhp / 2 && @form < 2 # Turn into Complete Forme
|
||||
newForm = @form + 2
|
||||
@battle.pbDisplay(_INTL("You sense the presence of many!"))
|
||||
@battle.pbShowAbilitySplash(self, true)
|
||||
@battle.pbHideAbilitySplash(self)
|
||||
pbChangeForm(newForm, _INTL("{1} transformed into its Complete Forme!", pbThis))
|
||||
end
|
||||
# Morpeko - Hunger Switch
|
||||
if isSpecies?(:MORPEKO) && hasActiveAbility?(:HUNGERSWITCH) && endOfRound
|
||||
|
||||
@@ -281,11 +281,11 @@ class Battle::Battler
|
||||
|
||||
def pbCanSleepYawn?
|
||||
return false if self.status != :NONE
|
||||
if affectedByTerrain?
|
||||
return false if [:Electric, :Misty].include?(@battle.field.terrain)
|
||||
if affectedByTerrain? && [:Electric, :Misty].include?(@battle.field.terrain)
|
||||
return false
|
||||
end
|
||||
if !hasActiveAbility?(:SOUNDPROOF)
|
||||
return false if @battle.allBattlers.any? { |b| b.effects[PBEffects::Uproar] > 0 }
|
||||
if !hasActiveAbility?(:SOUNDPROOF) && @battle.allBattlers.any? { |b| b.effects[PBEffects::Uproar] > 0 }
|
||||
return false
|
||||
end
|
||||
if Battle::AbilityEffects.triggerStatusImmunityNonIgnorable(self.ability, self, :SLEEP)
|
||||
return false
|
||||
@@ -454,19 +454,17 @@ class Battle::Battler
|
||||
@battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!", pbThis(true))) if showMessages
|
||||
return false
|
||||
end
|
||||
if selfInflicted || !@battle.moldBreaker
|
||||
if hasActiveAbility?(:OWNTEMPO)
|
||||
if showMessages
|
||||
@battle.pbShowAbilitySplash(self)
|
||||
if Battle::Scene::USE_ABILITY_SPLASH
|
||||
@battle.pbDisplay(_INTL("{1} doesn't become confused!", pbThis))
|
||||
else
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} prevents confusion!", pbThis, abilityName))
|
||||
end
|
||||
@battle.pbHideAbilitySplash(self)
|
||||
if (selfInflicted || !@battle.moldBreaker) && hasActiveAbility?(:OWNTEMPO)
|
||||
if showMessages
|
||||
@battle.pbShowAbilitySplash(self)
|
||||
if Battle::Scene::USE_ABILITY_SPLASH
|
||||
@battle.pbDisplay(_INTL("{1} doesn't become confused!", pbThis))
|
||||
else
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} prevents confusion!", pbThis, abilityName))
|
||||
end
|
||||
return false
|
||||
@battle.pbHideAbilitySplash(self)
|
||||
end
|
||||
return false
|
||||
end
|
||||
if pbOwnSide.effects[PBEffects::Safeguard] > 0 && !selfInflicted &&
|
||||
!(user && user.hasActiveAbility?(:INFILTRATOR))
|
||||
|
||||
@@ -118,7 +118,8 @@ class Battle::Battler
|
||||
return @stages[stat] <= -6
|
||||
end
|
||||
|
||||
def pbCanLowerStatStage?(stat, user = nil, move = nil, showFailMsg = false, ignoreContrary = false, ignoreMirrorArmor = false)
|
||||
def pbCanLowerStatStage?(stat, user = nil, move = nil, showFailMsg = false,
|
||||
ignoreContrary = false, ignoreMirrorArmor = false)
|
||||
return false if fainted?
|
||||
if !@battle.moldBreaker
|
||||
# Contrary
|
||||
@@ -126,12 +127,14 @@ class Battle::Battler
|
||||
return pbCanRaiseStatStage?(stat, user, move, showFailMsg, true)
|
||||
end
|
||||
# Mirror Armor
|
||||
if hasActiveAbility?(:MIRRORARMOR) && !ignoreMirrorArmor && user && user.index != @index
|
||||
return true if !statStageAtMin?(stat)
|
||||
if hasActiveAbility?(:MIRRORARMOR) && !ignoreMirrorArmor &&
|
||||
user && user.index != @index && !statStageAtMin?(stat)
|
||||
return true
|
||||
end
|
||||
end
|
||||
if !user || user.index != @index # Not self-inflicted
|
||||
if @effects[PBEffects::Substitute] > 0 && (ignoreMirrorArmor || !(move && move.ignoresSubstitute?(user)))
|
||||
if @effects[PBEffects::Substitute] > 0 &&
|
||||
(ignoreMirrorArmor || !(move && move.ignoresSubstitute?(user)))
|
||||
@battle.pbDisplay(_INTL("{1} is protected by its substitute!", pbThis)) if showFailMsg
|
||||
return false
|
||||
end
|
||||
@@ -328,13 +331,12 @@ class Battle::Battler
|
||||
pbThis, user.pbThis(true), user.abilityName))
|
||||
return false
|
||||
end
|
||||
if abilityActive?
|
||||
if Battle::AbilityEffects.triggerStatLossImmunity(self.ability, self, :ATTACK, @battle, false) ||
|
||||
Battle::AbilityEffects.triggerStatLossImmunityNonIgnorable(self.ability, self, :ATTACK, @battle, false)
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} prevented {3}'s {4} from working!",
|
||||
pbThis, abilityName, user.pbThis(true), user.abilityName))
|
||||
return false
|
||||
end
|
||||
if abilityActive? &&
|
||||
(Battle::AbilityEffects.triggerStatLossImmunity(self.ability, self, :ATTACK, @battle, false) ||
|
||||
Battle::AbilityEffects.triggerStatLossImmunityNonIgnorable(self.ability, self, :ATTACK, @battle, false))
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} prevented {3}'s {4} from working!",
|
||||
pbThis, abilityName, user.pbThis(true), user.abilityName))
|
||||
return false
|
||||
end
|
||||
allAllies.each do |b|
|
||||
next if !b.abilityActive?
|
||||
|
||||
@@ -378,7 +378,7 @@ class Battle::Battler
|
||||
|
||||
def pbItemsOnUnnerveEnding
|
||||
@battle.pbPriority(true).each do |b|
|
||||
b.pbHeldItemTriggerCheck if b.item && b.item.is_berry?
|
||||
b.pbHeldItemTriggerCheck if b.item&.is_berry?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -175,12 +175,11 @@ class Battle::Battler
|
||||
elsif @effects[PBEffects::Encore] > 0 && choice[1] >= 0 &&
|
||||
@battle.pbCanShowCommands?(@index)
|
||||
idxEncoredMove = pbEncoredMoveIndex
|
||||
if idxEncoredMove >= 0 && @battle.pbCanChooseMove?(@index, idxEncoredMove, false)
|
||||
if choice[1] != idxEncoredMove # Change move if battler was Encored mid-round
|
||||
choice[1] = idxEncoredMove
|
||||
choice[2] = @moves[idxEncoredMove]
|
||||
choice[3] = -1 # No target chosen
|
||||
end
|
||||
if idxEncoredMove >= 0 && choice[1] != idxEncoredMove &&
|
||||
@battle.pbCanChooseMove?(@index, idxEncoredMove, false) # Change move if battler was Encored mid-round
|
||||
choice[1] = idxEncoredMove
|
||||
choice[2] = @moves[idxEncoredMove]
|
||||
choice[3] = -1 # No target chosen
|
||||
end
|
||||
end
|
||||
# Labels the move being used as "move"
|
||||
@@ -203,19 +202,17 @@ class Battle::Battler
|
||||
move = choice[2] # In case disobedience changed the move to be used
|
||||
return if !move # if move was not chosen somehow
|
||||
# Subtract PP
|
||||
if !specialUsage
|
||||
if !pbReducePP(move)
|
||||
@battle.pbDisplay(_INTL("{1} used {2}!", pbThis, move.name))
|
||||
@battle.pbDisplay(_INTL("But there was no PP left for the move!"))
|
||||
@lastMoveUsed = nil
|
||||
@lastMoveUsedType = nil
|
||||
@lastRegularMoveUsed = nil
|
||||
@lastRegularMoveTarget = -1
|
||||
@lastMoveFailed = true
|
||||
pbCancelMoves
|
||||
pbEndTurn(choice)
|
||||
return
|
||||
end
|
||||
if !specialUsage && !pbReducePP(move)
|
||||
@battle.pbDisplay(_INTL("{1} used {2}!", pbThis, move.name))
|
||||
@battle.pbDisplay(_INTL("But there was no PP left for the move!"))
|
||||
@lastMoveUsed = nil
|
||||
@lastMoveUsedType = nil
|
||||
@lastRegularMoveUsed = nil
|
||||
@lastRegularMoveTarget = -1
|
||||
@lastMoveFailed = true
|
||||
pbCancelMoves
|
||||
pbEndTurn(choice)
|
||||
return
|
||||
end
|
||||
# Stance Change
|
||||
if isSpecies?(:AEGISLASH) && self.ability == :STANCECHANGE
|
||||
@@ -356,21 +353,21 @@ class Battle::Battler
|
||||
end
|
||||
end
|
||||
# Protean
|
||||
if user.hasActiveAbility?([:LIBERO, :PROTEAN]) && !move.callsAnotherMove? && !move.snatched
|
||||
if user.pbHasOtherType?(move.calcType) && !GameData::Type.get(move.calcType).pseudo_type
|
||||
@battle.pbShowAbilitySplash(user)
|
||||
user.pbChangeTypes(move.calcType)
|
||||
typeName = GameData::Type.get(move.calcType).name
|
||||
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!", user.pbThis, typeName))
|
||||
@battle.pbHideAbilitySplash(user)
|
||||
# NOTE: The GF games say that if Curse is used by a non-Ghost-type
|
||||
# Pokémon which becomes Ghost-type because of Protean, it should
|
||||
# target and curse itself. I think this is silly, so I'm making it
|
||||
# choose a random opponent to curse instead.
|
||||
if move.function == "CurseTargetOrLowerUserSpd1RaiseUserAtkDef1" && targets.length == 0
|
||||
choice[3] = -1
|
||||
targets = pbFindTargets(choice, move, user)
|
||||
end
|
||||
if user.hasActiveAbility?([:LIBERO, :PROTEAN]) &&
|
||||
!move.callsAnotherMove? && !move.snatched &&
|
||||
user.pbHasOtherType?(move.calcType) && !GameData::Type.get(move.calcType).pseudo_type
|
||||
@battle.pbShowAbilitySplash(user)
|
||||
user.pbChangeTypes(move.calcType)
|
||||
typeName = GameData::Type.get(move.calcType).name
|
||||
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!", user.pbThis, typeName))
|
||||
@battle.pbHideAbilitySplash(user)
|
||||
# NOTE: The GF games say that if Curse is used by a non-Ghost-type
|
||||
# Pokémon which becomes Ghost-type because of Protean, it should
|
||||
# target and curse itself. I think this is silly, so I'm making it
|
||||
# choose a random opponent to curse instead.
|
||||
if move.function == "CurseTargetOrLowerUserSpd1RaiseUserAtkDef1" && targets.length == 0
|
||||
choice[3] = -1
|
||||
targets = pbFindTargets(choice, move, user)
|
||||
end
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -486,7 +483,7 @@ class Battle::Battler
|
||||
end
|
||||
pbProcessMoveHit(move, b, newTargets, 0, false) if success
|
||||
b.lastMoveFailed = true if !success
|
||||
targets.each { |otherB| otherB.pbFaint if otherB && otherB.fainted? }
|
||||
targets.each { |otherB| otherB.pbFaint if otherB&.fainted? }
|
||||
user.pbFaint if user.fainted?
|
||||
end
|
||||
# Magic Coat's bouncing back (move has no targets)
|
||||
@@ -502,14 +499,14 @@ class Battle::Battler
|
||||
success = pbProcessMoveHit(move, mc, [], 0, false)
|
||||
end
|
||||
mc.lastMoveFailed = true if !success
|
||||
targets.each { |b| b.pbFaint if b && b.fainted? }
|
||||
targets.each { |b| b.pbFaint if b&.fainted? }
|
||||
user.pbFaint if user.fainted?
|
||||
end
|
||||
end
|
||||
# Move-specific effects after all hits
|
||||
targets.each { |b| move.pbEffectAfterAllHits(user, b) }
|
||||
# Faint if 0 HP
|
||||
targets.each { |b| b.pbFaint if b && b.fainted? }
|
||||
targets.each { |b| b.pbFaint if b&.fainted? }
|
||||
user.pbFaint if user.fainted?
|
||||
# External/general effects after all hits. Eject Button, Shell Bell, etc.
|
||||
pbEffectsAfterMove(user, targets, move, realNumHits)
|
||||
@@ -707,7 +704,7 @@ class Battle::Battler
|
||||
@battle.pbPriority(true).each { |b| b.pbItemHPHealCheck }
|
||||
# Animate battlers fainting (checks all battlers rather than just targets
|
||||
# because Flame Burst's splash damage affects non-targets)
|
||||
@battle.pbPriority(true).each { |b| b.pbFaint if b && b.fainted? }
|
||||
@battle.pbPriority(true).each { |b| b.pbFaint if b&.fainted? }
|
||||
end
|
||||
@battle.pbJudgeCheckpoint(user, move)
|
||||
# Main effect (recoil/drain, etc.)
|
||||
@@ -716,7 +713,7 @@ class Battle::Battler
|
||||
move.pbEffectAgainstTarget(user, b)
|
||||
end
|
||||
move.pbEffectGeneral(user)
|
||||
targets.each { |b| b.pbFaint if b && b.fainted? }
|
||||
targets.each { |b| b.pbFaint if b&.fainted? }
|
||||
user.pbFaint if user.fainted?
|
||||
# Additional effect
|
||||
if !user.hasActiveAbility?(:SHEERFORCE)
|
||||
@@ -761,13 +758,12 @@ class Battle::Battler
|
||||
end
|
||||
end
|
||||
# Fainting
|
||||
targets.each { |b| b.pbFaint if b && b.fainted? }
|
||||
targets.each { |b| b.pbFaint if b&.fainted? }
|
||||
user.pbFaint if user.fainted?
|
||||
# Dragon Darts' second half of attack
|
||||
if move.pbRepeatHit? && hitNum == 0
|
||||
if targets.any? { |b| !b.fainted? && !b.damageState.unaffected }
|
||||
pbProcessMoveHit(move, user, all_targets, 1, skipAccuracyCheck)
|
||||
end
|
||||
if move.pbRepeatHit? && hitNum == 0 &&
|
||||
targets.any? { |b| !b.fainted? && !b.damageState.unaffected }
|
||||
pbProcessMoveHit(move, user, all_targets, 1, skipAccuracyCheck)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -265,12 +265,10 @@ class Battle::Battler
|
||||
end
|
||||
end
|
||||
# Paralysis
|
||||
if @status == :PARALYSIS
|
||||
if @battle.pbRandom(100) < 25
|
||||
pbContinueStatus
|
||||
@lastMoveFailed = true
|
||||
return false
|
||||
end
|
||||
if @status == :PARALYSIS && @battle.pbRandom(100) < 25
|
||||
pbContinueStatus
|
||||
@lastMoveFailed = true
|
||||
return false
|
||||
end
|
||||
# Infatuation
|
||||
if @effects[PBEffects::Attract] >= 0
|
||||
@@ -358,10 +356,9 @@ class Battle::Battler
|
||||
end
|
||||
target.damageState.protected = true
|
||||
@battle.successStates[user.index].protected = true
|
||||
if move.pbContactMove?(user) && user.affectedByContactEffect?
|
||||
if user.pbCanLowerStatStage?(:ATTACK, target)
|
||||
user.pbLowerStatStage(:ATTACK, (Settings::MECHANICS_GENERATION >= 8) ? 1 : 2, target)
|
||||
end
|
||||
if move.pbContactMove?(user) && user.affectedByContactEffect? &&
|
||||
user.pbCanLowerStatStage?(:ATTACK, target)
|
||||
user.pbLowerStatStage(:ATTACK, (Settings::MECHANICS_GENERATION >= 8) ? 1 : 2, target)
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -389,8 +386,9 @@ class Battle::Battler
|
||||
end
|
||||
target.damageState.protected = true
|
||||
@battle.successStates[user.index].protected = true
|
||||
if move.pbContactMove?(user) && user.affectedByContactEffect?
|
||||
user.pbPoison(target) if user.pbCanPoison?(target, false)
|
||||
if move.pbContactMove?(user) && user.affectedByContactEffect? &&
|
||||
user.pbCanPoison?(target, false)
|
||||
user.pbPoison(target)
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -402,10 +400,9 @@ class Battle::Battler
|
||||
end
|
||||
target.damageState.protected = true
|
||||
@battle.successStates[user.index].protected = true
|
||||
if move.pbContactMove?(user) && user.affectedByContactEffect?
|
||||
if user.pbCanLowerStatStage?(:DEFENSE, target)
|
||||
user.pbLowerStatStage(:DEFENSE, 2, target)
|
||||
end
|
||||
if move.pbContactMove?(user) && user.affectedByContactEffect? &&
|
||||
user.pbCanLowerStatStage?(:DEFENSE, target)
|
||||
user.pbLowerStatStage(:DEFENSE, 2, target)
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -550,8 +547,8 @@ class Battle::Battler
|
||||
end
|
||||
end
|
||||
if target.effects[PBEffects::SkyDrop] >= 0 &&
|
||||
target.effects[PBEffects::SkyDrop] != user.index
|
||||
miss = true if !move.hitsFlyingTargets?
|
||||
target.effects[PBEffects::SkyDrop] != user.index && !move.hitsFlyingTargets?
|
||||
miss = true
|
||||
end
|
||||
end
|
||||
target.damageState.invulnerable = true if miss
|
||||
@@ -572,9 +569,7 @@ class Battle::Battler
|
||||
def pbMissMessage(move, user, target)
|
||||
if target.damageState.affection_missed
|
||||
@battle.pbDisplay(_INTL("{1} avoided the move in time with your shout!", target.pbThis))
|
||||
elsif move.pbTarget(user).num_targets > 1
|
||||
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis))
|
||||
elsif target.effects[PBEffects::TwoTurnAttack]
|
||||
elsif move.pbTarget(user).num_targets > 1 || target.effects[PBEffects::TwoTurnAttack]
|
||||
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis))
|
||||
elsif !move.pbMissMessage(user, target)
|
||||
@battle.pbDisplay(_INTL("{1}'s attack missed!", user.pbThis))
|
||||
|
||||
@@ -45,27 +45,26 @@ class Battle::Battler
|
||||
end
|
||||
if target.opposes?(user)
|
||||
# Rage
|
||||
if target.effects[PBEffects::Rage] && !target.fainted?
|
||||
if target.pbCanRaiseStatStage?(:ATTACK, target)
|
||||
@battle.pbDisplay(_INTL("{1}'s rage is building!", target.pbThis))
|
||||
target.pbRaiseStatStage(:ATTACK, 1, target)
|
||||
end
|
||||
if target.effects[PBEffects::Rage] && !target.fainted? &&
|
||||
target.pbCanRaiseStatStage?(:ATTACK, target)
|
||||
@battle.pbDisplay(_INTL("{1}'s rage is building!", target.pbThis))
|
||||
target.pbRaiseStatStage(:ATTACK, 1, target)
|
||||
end
|
||||
# Beak Blast
|
||||
if target.effects[PBEffects::BeakBlast]
|
||||
PBDebug.log("[Lingering effect] #{target.pbThis}'s Beak Blast")
|
||||
if move.pbContactMove?(user) && user.affectedByContactEffect?
|
||||
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
|
||||
if move.pbContactMove?(user) && user.affectedByContactEffect? &&
|
||||
target.pbCanBurn?(user, false, self)
|
||||
target.pbBurn(user)
|
||||
end
|
||||
end
|
||||
# Shell Trap (make the trapper move next if the trap was triggered)
|
||||
if target.effects[PBEffects::ShellTrap] &&
|
||||
@battle.choices[target.index][0] == :UseMove && !target.movedThisRound?
|
||||
if target.damageState.hpLost > 0 && !target.damageState.substitute && move.physicalMove?
|
||||
target.tookPhysicalHit = true
|
||||
target.effects[PBEffects::MoveNext] = true
|
||||
target.effects[PBEffects::Quash] = 0
|
||||
end
|
||||
if target.effects[PBEffects::ShellTrap] && move.physicalMove? &&
|
||||
@battle.choices[target.index][0] == :UseMove && !target.movedThisRound? &&
|
||||
target.damageState.hpLost > 0 && !target.damageState.substitute
|
||||
target.tookPhysicalHit = true
|
||||
target.effects[PBEffects::MoveNext] = true
|
||||
target.effects[PBEffects::Quash] = 0
|
||||
end
|
||||
# Grudge
|
||||
if target.effects[PBEffects::Grudge] && target.fainted?
|
||||
@@ -74,10 +73,9 @@ class Battle::Battler
|
||||
user.pbThis, move.name))
|
||||
end
|
||||
# Destiny Bond (recording that it should apply)
|
||||
if target.effects[PBEffects::DestinyBond] && target.fainted?
|
||||
if user.effects[PBEffects::DestinyBondTarget] < 0
|
||||
user.effects[PBEffects::DestinyBondTarget] = target.index
|
||||
end
|
||||
if target.effects[PBEffects::DestinyBond] && target.fainted? &&
|
||||
user.effects[PBEffects::DestinyBondTarget] < 0
|
||||
user.effects[PBEffects::DestinyBondTarget] = target.index
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -114,10 +112,10 @@ class Battle::Battler
|
||||
if user.abilityActive?
|
||||
Battle::AbilityEffects.triggerOnEndOfUsingMove(user.ability, user, targets, move, @battle)
|
||||
end
|
||||
# Greninja - Battle Bond
|
||||
if !user.fainted? && !user.effects[PBEffects::Transform] &&
|
||||
user.isSpecies?(:GRENINJA) && user.ability == :BATTLEBOND
|
||||
if !@battle.pbAllFainted?(user.idxOpposingSide) &&
|
||||
!@battle.pbAllFainted?(user.idxOpposingSide)
|
||||
# Greninja - Battle Bond
|
||||
if user.isSpecies?(:GRENINJA) && user.ability == :BATTLEBOND &&
|
||||
!@battle.battleBond[user.index & 1][user.pokemonIndex]
|
||||
numFainted = 0
|
||||
targets.each { |b| numFainted += 1 if b.damageState.fainted }
|
||||
@@ -129,11 +127,8 @@ class Battle::Battler
|
||||
user.pbChangeForm(2, _INTL("{1} became Ash-Greninja!", user.pbThis))
|
||||
end
|
||||
end
|
||||
end
|
||||
# Cramorant = Gulp Missile
|
||||
if !user.fainted? && !user.effects[PBEffects::Transform] &&
|
||||
user.isSpecies?(:CRAMORANT) && user.ability == :GULPMISSILE && user.form == 0
|
||||
if !@battle.pbAllFainted?(user.idxOpposingSide) &&
|
||||
# Cramorant = Gulp Missile
|
||||
if user.isSpecies?(:CRAMORANT) && user.ability == :GULPMISSILE && user.form == 0 &&
|
||||
((move.id == :SURF && numHits > 0) || (move.id == :DIVE && move.chargingTurn))
|
||||
# NOTE: Intentionally no ability splash or message here.
|
||||
user.pbChangeForm((user.hp > user.totalhp / 2) ? 1 : 2, nil)
|
||||
@@ -181,16 +176,13 @@ class Battle::Battler
|
||||
def pbEffectsAfterMove2(user, targets, move, numHits, switched_battlers)
|
||||
# Target's held item (Eject Button, Red Card, Eject Pack)
|
||||
@battle.pbPriority(true).each do |b|
|
||||
if targets.any? { |targetB| targetB.index == b.index }
|
||||
if !b.damageState.unaffected && b.damageState.calcDamage > 0 && b.itemActive?
|
||||
Battle::ItemEffects.triggerAfterMoveUseFromTarget(b.item, b, user, move, switched_battlers, @battle)
|
||||
end
|
||||
if targets.any? { |targetB| targetB.index == b.index } &&
|
||||
!b.damageState.unaffected && b.damageState.calcDamage > 0 && b.itemActive?
|
||||
Battle::ItemEffects.triggerAfterMoveUseFromTarget(b.item, b, user, move, switched_battlers, @battle)
|
||||
end
|
||||
# Target's Eject Pack
|
||||
if switched_battlers.empty? && b.index != user.index
|
||||
if b.pbItemOnStatDropped(user)
|
||||
switched_battlers.push(b.index)
|
||||
end
|
||||
if switched_battlers.empty? && b.index != user.index && b.pbItemOnStatDropped(user)
|
||||
switched_battlers.push(b.index)
|
||||
end
|
||||
end
|
||||
# User's held item (Life Orb, Shell Bell, Throat Spray, Eject Pack)
|
||||
@@ -199,16 +191,14 @@ class Battle::Battler
|
||||
end
|
||||
# Target's ability (Berserk, Color Change, Emergency Exit, Pickpocket, Wimp Out)
|
||||
@battle.pbPriority(true).each do |b|
|
||||
if targets.any? { |targetB| targetB.index == b.index }
|
||||
if !b.damageState.unaffected && !switched_battlers.include?(b.index) && b.abilityActive?
|
||||
Battle::AbilityEffects.triggerAfterMoveUseFromTarget(b.ability, b, user, move, switched_battlers, @battle)
|
||||
end
|
||||
if targets.any? { |targetB| targetB.index == b.index } &&
|
||||
!b.damageState.unaffected && !switched_battlers.include?(b.index) && b.abilityActive?
|
||||
Battle::AbilityEffects.triggerAfterMoveUseFromTarget(b.ability, b, user, move, switched_battlers, @battle)
|
||||
end
|
||||
# Target's Emergency Exit, Wimp Out (including for Pokémon hurt by Flame Burst)
|
||||
if switched_battlers.empty? && move.damagingMove? && b.index != user.index
|
||||
if b.pbAbilitiesOnDamageTaken(user)
|
||||
switched_battlers.push(b.index)
|
||||
end
|
||||
if switched_battlers.empty? && move.damagingMove? &&
|
||||
b.index != user.index && b.pbAbilitiesOnDamageTaken(user)
|
||||
switched_battlers.push(b.index)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -216,16 +206,12 @@ class Battle::Battler
|
||||
# Everything in this method is negated by Sheer Force.
|
||||
def pbEffectsAfterMove3(user, targets, move, numHits, switched_battlers)
|
||||
# User's held item that switches it out (Eject Pack)
|
||||
if switched_battlers.empty?
|
||||
if user.pbItemOnStatDropped(user)
|
||||
switched_battlers.push(user.index)
|
||||
end
|
||||
if switched_battlers.empty? && user.pbItemOnStatDropped(user)
|
||||
switched_battlers.push(user.index)
|
||||
end
|
||||
# User's ability (Emergency Exit, Wimp Out)
|
||||
if switched_battlers.empty? && move.damagingMove?
|
||||
if user.pbAbilitiesOnDamageTaken(user)
|
||||
switched_battlers.push(user.index)
|
||||
end
|
||||
if switched_battlers.empty? && move.damagingMove? && user.pbAbilitiesOnDamageTaken(user)
|
||||
switched_battlers.push(user.index)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -140,7 +140,7 @@ class Battle::Move
|
||||
def ignoresSubstitute?(user) # user is the Pokémon using this move
|
||||
if Settings::MECHANICS_GENERATION >= 6
|
||||
return true if soundMove?
|
||||
return true if user && user.hasActiveAbility?(:INFILTRATOR)
|
||||
return true if user&.hasActiveAbility?(:INFILTRATOR)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -31,28 +31,29 @@ class Battle::Move
|
||||
#=============================================================================
|
||||
def pbCalcTypeModSingle(moveType, defType, user, target)
|
||||
ret = Effectiveness.calculate_one(moveType, defType)
|
||||
# Ring Target
|
||||
if target.hasActiveItem?(:RINGTARGET)
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if Effectiveness.ineffective_type?(moveType, defType)
|
||||
end
|
||||
# Foresight
|
||||
if user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :GHOST &&
|
||||
Effectiveness.ineffective_type?(moveType, defType)
|
||||
end
|
||||
# Miracle Eye
|
||||
if target.effects[PBEffects::MiracleEye]
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :DARK &&
|
||||
Effectiveness.ineffective_type?(moveType, defType)
|
||||
end
|
||||
# Delta Stream's weather
|
||||
if target.effectiveWeather == :StrongWinds
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING &&
|
||||
Effectiveness.super_effective_type?(moveType, defType)
|
||||
if Effectiveness.ineffective_type?(moveType, defType)
|
||||
# Ring Target
|
||||
if target.hasActiveItem?(:RINGTARGET)
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
# Foresight
|
||||
if (user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]) &&
|
||||
defType == :GHOST
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
# Miracle Eye
|
||||
if target.effects[PBEffects::MiracleEye] && defType == :DARK
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
elsif Effectiveness.super_effective_type?(moveType, defType)
|
||||
# Delta Stream's weather
|
||||
if target.effectiveWeather == :StrongWinds && defType == :FLYING
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
end
|
||||
# Grounded Flying-type Pokémon become susceptible to Ground moves
|
||||
if !target.airborne?
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING && moveType == :GROUND
|
||||
if !target.airborne? && defType == :FLYING && moveType == :GROUND
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
return ret
|
||||
end
|
||||
@@ -493,9 +494,9 @@ class Battle::Move
|
||||
def pbAdditionalEffectChance(user, target, effectChance = 0)
|
||||
return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
|
||||
ret = (effectChance > 0) ? effectChance : @addlEffect
|
||||
if Settings::MECHANICS_GENERATION >= 6 || @function != "EffectDependsOnEnvironment"
|
||||
ret *= 2 if user.hasActiveAbility?(:SERENEGRACE) ||
|
||||
user.pbOwnSide.effects[PBEffects::Rainbow] > 0
|
||||
if (Settings::MECHANICS_GENERATION >= 6 || @function != "EffectDependsOnEnvironment") &&
|
||||
(user.hasActiveAbility?(:SERENEGRACE) || user.pbOwnSide.effects[PBEffects::Rainbow] > 0)
|
||||
ret *= 2
|
||||
end
|
||||
ret = 100 if $DEBUG && Input.press?(Input::CTRL)
|
||||
return ret
|
||||
@@ -507,9 +508,8 @@ class Battle::Move
|
||||
return 0 if flinchingMove?
|
||||
return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
|
||||
ret = 0
|
||||
if user.hasActiveAbility?(:STENCH, true)
|
||||
ret = 10
|
||||
elsif user.hasActiveItem?([:KINGSROCK, :RAZORFANG], true)
|
||||
if user.hasActiveAbility?(:STENCH, true) ||
|
||||
user.hasActiveItem?([:KINGSROCK, :RAZORFANG], true)
|
||||
ret = 10
|
||||
end
|
||||
ret *= 2 if user.hasActiveAbility?(:SERENEGRACE) ||
|
||||
|
||||
@@ -1427,9 +1427,7 @@ class Battle::Move::RaiseUserAndAlliesAtkDef1 < Battle::Move
|
||||
def pbEffectAgainstTarget(user, target)
|
||||
showAnim = true
|
||||
if target.pbCanRaiseStatStage?(:ATTACK, user, self)
|
||||
if target.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
||||
showAnim = false
|
||||
end
|
||||
showAnim = false if target.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
||||
end
|
||||
if target.pbCanRaiseStatStage?(:DEFENSE, user, self)
|
||||
target.pbRaiseStatStage(:DEFENSE, 1, user, showAnim)
|
||||
@@ -1477,9 +1475,7 @@ class Battle::Move::RaisePlusMinusUserAndAlliesAtkSpAtk1 < Battle::Move
|
||||
def pbEffectAgainstTarget(user, target)
|
||||
showAnim = true
|
||||
if target.pbCanRaiseStatStage?(:ATTACK, user, self)
|
||||
if target.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
||||
showAnim = false
|
||||
end
|
||||
showAnim = false if target.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
||||
end
|
||||
if target.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self)
|
||||
target.pbRaiseStatStage(:SPECIAL_ATTACK, 1, user, showAnim)
|
||||
@@ -1532,9 +1528,7 @@ class Battle::Move::RaisePlusMinusUserAndAlliesDefSpDef1 < Battle::Move
|
||||
def pbEffectAgainstTarget(user, target)
|
||||
showAnim = true
|
||||
if target.pbCanRaiseStatStage?(:DEFENSE, user, self)
|
||||
if target.pbRaiseStatStage(:DEFENSE, 1, user, showAnim)
|
||||
showAnim = false
|
||||
end
|
||||
showAnim = false if target.pbRaiseStatStage(:DEFENSE, 1, user, showAnim)
|
||||
end
|
||||
if target.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, user, self)
|
||||
target.pbRaiseStatStage(:SPECIAL_DEFENSE, 1, user, showAnim)
|
||||
@@ -1579,9 +1573,7 @@ class Battle::Move::RaiseGroundedGrassBattlersAtkSpAtk1 < Battle::Move
|
||||
def pbEffectAgainstTarget(user, target)
|
||||
showAnim = true
|
||||
if target.pbCanRaiseStatStage?(:ATTACK, user, self)
|
||||
if target.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
||||
showAnim = false
|
||||
end
|
||||
showAnim = false if target.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
||||
end
|
||||
if target.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self)
|
||||
target.pbRaiseStatStage(:SPECIAL_ATTACK, 1, user, showAnim)
|
||||
@@ -1729,9 +1721,7 @@ class Battle::Move::UserStealTargetPositiveStatStages < Battle::Move
|
||||
GameData::Stat.each_battle do |s|
|
||||
next if target.stages[s.id] <= 0
|
||||
if user.pbCanRaiseStatStage?(s.id, user, self)
|
||||
if user.pbRaiseStatStage(s.id, target.stages[s.id], user, showAnim)
|
||||
showAnim = false
|
||||
end
|
||||
showAnim = false if user.pbRaiseStatStage(s.id, target.stages[s.id], user, showAnim)
|
||||
end
|
||||
target.statsLoweredThisRound = true
|
||||
target.statsDropped = true
|
||||
|
||||
@@ -209,8 +209,8 @@ class Battle::Move::ParalyzeFlinchTarget < Battle::Move
|
||||
return if target.damageState.substitute
|
||||
chance = pbAdditionalEffectChance(user, target, 10)
|
||||
return if chance == 0
|
||||
if @battle.pbRandom(100) < chance
|
||||
target.pbParalyze(user) if target.pbCanParalyze?(user, false, self)
|
||||
if target.pbCanParalyze?(user, false, self) && @battle.pbRandom(100) < chance
|
||||
target.pbParalyze(user)
|
||||
end
|
||||
target.pbFlinch(user) if @battle.pbRandom(100) < chance
|
||||
end
|
||||
@@ -258,8 +258,8 @@ class Battle::Move::BurnFlinchTarget < Battle::Move
|
||||
return if target.damageState.substitute
|
||||
chance = pbAdditionalEffectChance(user, target, 10)
|
||||
return if chance == 0
|
||||
if @battle.pbRandom(100) < chance
|
||||
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
|
||||
if target.pbCanBurn?(user, false, self) && @battle.pbRandom(100) < chance
|
||||
target.pbBurn(user)
|
||||
end
|
||||
target.pbFlinch(user) if @battle.pbRandom(100) < chance
|
||||
end
|
||||
@@ -317,8 +317,8 @@ class Battle::Move::FreezeFlinchTarget < Battle::Move
|
||||
return if target.damageState.substitute
|
||||
chance = pbAdditionalEffectChance(user, target, 10)
|
||||
return if chance == 0
|
||||
if @battle.pbRandom(100) < chance
|
||||
target.pbFreeze if target.pbCanFreeze?(user, false, self)
|
||||
if target.pbCanFreeze?(user, false, self) && @battle.pbRandom(100) < chance
|
||||
target.pbFreeze
|
||||
end
|
||||
target.pbFlinch(user) if @battle.pbRandom(100) < chance
|
||||
end
|
||||
@@ -429,7 +429,7 @@ class Battle::Move::CureUserPartyStatus < Battle::Move
|
||||
def pbMoveFailed?(user, targets)
|
||||
has_effect = @battle.allSameSideBattlers(user).any? { |b| b.status != :NONE }
|
||||
if !has_effect
|
||||
has_effect = @battle.pbParty(user.index).any? { |pkmn| pkmn && pkmn.able? && pkmn.status != :NONE }
|
||||
has_effect = @battle.pbParty(user.index).any? { |pkmn| pkmn&.able? && pkmn.status != :NONE }
|
||||
end
|
||||
if !has_effect
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
|
||||
@@ -221,13 +221,12 @@ end
|
||||
class Battle::Move::TwoTurnAttackOneTurnInSun < Battle::Move::TwoTurnMove
|
||||
def pbIsChargingTurn?(user)
|
||||
ret = super
|
||||
if !user.effects[PBEffects::TwoTurnAttack]
|
||||
if [:Sun, :HarshSun].include?(user.effectiveWeather)
|
||||
@powerHerb = false
|
||||
@chargingTurn = true
|
||||
@damagingTurn = true
|
||||
return false
|
||||
end
|
||||
if !user.effects[PBEffects::TwoTurnAttack] &&
|
||||
[:Sun, :HarshSun].include?(user.effectiveWeather)
|
||||
@powerHerb = false
|
||||
@chargingTurn = true
|
||||
@damagingTurn = true
|
||||
return false
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
@@ -175,9 +175,7 @@ class Battle::Move::CurseTargetOrLowerUserSpd1RaiseUserAtkDef1 < Battle::Move
|
||||
end
|
||||
showAnim = true
|
||||
if user.pbCanRaiseStatStage?(:ATTACK, user, self)
|
||||
if user.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
||||
showAnim = false
|
||||
end
|
||||
showAnim = false if user.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
|
||||
end
|
||||
if user.pbCanRaiseStatStage?(:DEFENSE, user, self)
|
||||
user.pbRaiseStatStage(:DEFENSE, 1, user, showAnim)
|
||||
@@ -562,9 +560,7 @@ class Battle::Move::PowerDependsOnUserStockpile < Battle::Move
|
||||
showAnim = true
|
||||
if user.effects[PBEffects::StockpileDef] > 0 &&
|
||||
user.pbCanLowerStatStage?(:DEFENSE, user, self)
|
||||
if user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim)
|
||||
showAnim = false
|
||||
end
|
||||
showAnim = false if user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim)
|
||||
end
|
||||
if user.effects[PBEffects::StockpileSpDef] > 0 &&
|
||||
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user, self)
|
||||
@@ -611,11 +607,9 @@ class Battle::Move::HealUserDependingOnUserStockpile < Battle::Move
|
||||
@battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!", user.pbThis))
|
||||
showAnim = true
|
||||
if user.effects[PBEffects::StockpileDef] > 0 &&
|
||||
user.pbCanLowerStatStage?(:DEFENSE, user, self)
|
||||
if user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim)
|
||||
user.pbCanLowerStatStage?(:DEFENSE, user, self) && user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim)
|
||||
showAnim = false
|
||||
end
|
||||
end
|
||||
if user.effects[PBEffects::StockpileSpDef] > 0 &&
|
||||
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user, self)
|
||||
user.pbLowerStatStage(:SPECIAL_DEFENSE, user.effects[PBEffects::StockpileSpDef], user, showAnim)
|
||||
|
||||
@@ -112,24 +112,24 @@ class Battle::Scene
|
||||
end
|
||||
|
||||
def pbFrameUpdate(cw = nil)
|
||||
cw.update if cw
|
||||
cw&.update
|
||||
@battle.battlers.each_with_index do |b, i|
|
||||
next if !b
|
||||
@sprites["dataBox_#{i}"].update(@frameCounter) if @sprites["dataBox_#{i}"]
|
||||
@sprites["pokemon_#{i}"].update(@frameCounter) if @sprites["pokemon_#{i}"]
|
||||
@sprites["shadow_#{i}"].update(@frameCounter) if @sprites["shadow_#{i}"]
|
||||
@sprites["dataBox_#{i}"]&.update(@frameCounter)
|
||||
@sprites["pokemon_#{i}"]&.update(@frameCounter)
|
||||
@sprites["shadow_#{i}"]&.update(@frameCounter)
|
||||
end
|
||||
end
|
||||
|
||||
def pbRefresh
|
||||
@battle.battlers.each_with_index do |b, i|
|
||||
next if !b
|
||||
@sprites["dataBox_#{i}"].refresh if @sprites["dataBox_#{i}"]
|
||||
@sprites["dataBox_#{i}"]&.refresh
|
||||
end
|
||||
end
|
||||
|
||||
def pbRefreshOne(idxBattler)
|
||||
@sprites["dataBox_#{idxBattler}"].refresh if @sprites["dataBox_#{idxBattler}"]
|
||||
@sprites["dataBox_#{idxBattler}"]&.refresh
|
||||
end
|
||||
|
||||
def pbRefreshEverything
|
||||
|
||||
@@ -70,7 +70,7 @@ class Battle::Scene
|
||||
cw = @sprites["fightWindow"]
|
||||
cw.battler = battler
|
||||
moveIndex = 0
|
||||
if battler.moves[@lastMove[idxBattler]] && battler.moves[@lastMove[idxBattler]].id
|
||||
if battler.moves[@lastMove[idxBattler]]&.id
|
||||
moveIndex = @lastMove[idxBattler]
|
||||
end
|
||||
cw.shiftMode = (@battle.pbCanShift?(idxBattler)) ? 1 : 0
|
||||
@@ -98,14 +98,14 @@ class Battle::Scene
|
||||
if Input.trigger?(Input::LEFT)
|
||||
cw.index -= 1 if (cw.index & 1) == 1
|
||||
elsif Input.trigger?(Input::RIGHT)
|
||||
if battler.moves[cw.index + 1] && battler.moves[cw.index + 1].id
|
||||
cw.index += 1 if (cw.index & 1) == 0
|
||||
if battler.moves[cw.index + 1]&.id && (cw.index & 1) == 0
|
||||
cw.index += 1
|
||||
end
|
||||
elsif Input.trigger?(Input::UP)
|
||||
cw.index -= 2 if (cw.index & 2) == 2
|
||||
elsif Input.trigger?(Input::DOWN)
|
||||
if battler.moves[cw.index + 2] && battler.moves[cw.index + 2].id
|
||||
cw.index += 2 if (cw.index & 2) == 0
|
||||
if battler.moves[cw.index + 2]&.id && (cw.index & 2) == 0
|
||||
cw.index += 2
|
||||
end
|
||||
end
|
||||
pbPlayCursorSE if cw.index != oldIndex
|
||||
|
||||
@@ -137,8 +137,8 @@ class Battle::Scene
|
||||
a[2] = true if a[1].animDone?
|
||||
end
|
||||
pbUpdate
|
||||
if !inPartyAnimation?
|
||||
break if !sendOutAnims.any? { |a| !a[2] }
|
||||
if !inPartyAnimation? && !sendOutAnims.any? { |a| !a[2] }
|
||||
break
|
||||
end
|
||||
end
|
||||
fadeAnim.dispose
|
||||
@@ -165,7 +165,7 @@ class Battle::Scene
|
||||
# Recall animation
|
||||
recallAnim = Animation::BattlerRecall.new(@sprites, @viewport, idxBattler)
|
||||
loop do
|
||||
recallAnim.update if recallAnim
|
||||
recallAnim&.update
|
||||
pbUpdate
|
||||
break if recallAnim.animDone?
|
||||
end
|
||||
@@ -495,7 +495,7 @@ class Battle::Scene
|
||||
animID = pbFindMoveAnimation(moveID, user.index, hitNum)
|
||||
return if !animID
|
||||
anim = animID[0]
|
||||
target = (targets && targets.is_a?(Array)) ? targets[0] : targets
|
||||
target = (targets.is_a?(Array)) ? targets[0] : targets
|
||||
animations = pbLoadBattleAnimations
|
||||
return if !animations
|
||||
pbSaveShadows {
|
||||
@@ -510,7 +510,7 @@ class Battle::Scene
|
||||
# Plays a common animation.
|
||||
def pbCommonAnimation(animName, user = nil, target = nil)
|
||||
return if nil_or_empty?(animName)
|
||||
target = target[0] if target && target.is_a?(Array)
|
||||
target = target[0] if target.is_a?(Array)
|
||||
animations = pbLoadBattleAnimations
|
||||
return if !animations
|
||||
animations.each do |a|
|
||||
@@ -534,7 +534,7 @@ class Battle::Scene
|
||||
animPlayer = PBAnimationPlayerX.new(animation, user, target, self, oppMove)
|
||||
# Apply a transformation to the animation based on where the user and target
|
||||
# actually are. Get the centres of each sprite.
|
||||
userHeight = (userSprite && userSprite.bitmap && !userSprite.bitmap.disposed?) ? userSprite.bitmap.height : 128
|
||||
userHeight = (userSprite&.bitmap && !userSprite.bitmap.disposed?) ? userSprite.bitmap.height : 128
|
||||
if targetSprite
|
||||
targetHeight = (targetSprite.bitmap && !targetSprite.bitmap.disposed?) ? targetSprite.bitmap.height : 128
|
||||
else
|
||||
|
||||
@@ -161,7 +161,7 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
|
||||
|
||||
def dispose
|
||||
super
|
||||
@buttonBitmap.dispose if @buttonBitmap
|
||||
@buttonBitmap&.dispose
|
||||
end
|
||||
|
||||
def z=(value)
|
||||
@@ -191,7 +191,7 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
|
||||
|
||||
def refresh
|
||||
@msgBox.refresh
|
||||
@cmdWindow.refresh if @cmdWindow
|
||||
@cmdWindow&.refresh
|
||||
refreshButtons
|
||||
end
|
||||
end
|
||||
@@ -310,10 +310,10 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
|
||||
|
||||
def dispose
|
||||
super
|
||||
@buttonBitmap.dispose if @buttonBitmap
|
||||
@typeBitmap.dispose if @typeBitmap
|
||||
@megaEvoBitmap.dispose if @megaEvoBitmap
|
||||
@shiftBitmap.dispose if @shiftBitmap
|
||||
@buttonBitmap&.dispose
|
||||
@typeBitmap&.dispose
|
||||
@megaEvoBitmap&.dispose
|
||||
@shiftBitmap&.dispose
|
||||
end
|
||||
|
||||
def z=(value)
|
||||
@@ -510,7 +510,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
|
||||
|
||||
def dispose
|
||||
super
|
||||
@buttonBitmap.dispose if @buttonBitmap
|
||||
@buttonBitmap&.dispose
|
||||
end
|
||||
|
||||
def z=(value)
|
||||
|
||||
@@ -52,7 +52,7 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
|
||||
bgFilename = ["Graphics/Pictures/Battle/databox_thin",
|
||||
"Graphics/Pictures/Battle/databox_thin_foe"][@battler.index % 2]
|
||||
end
|
||||
@databoxBitmap.dispose if @databoxBitmap
|
||||
@databoxBitmap&.dispose
|
||||
@databoxBitmap = AnimatedBitmap.new(bgFilename)
|
||||
# Determine the co-ordinates of the data box and the left edge padding width
|
||||
if onPlayerSide
|
||||
@@ -500,7 +500,7 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
|
||||
end
|
||||
|
||||
def dispose
|
||||
@_iconBitmap.dispose if @_iconBitmap
|
||||
@_iconBitmap&.dispose
|
||||
@_iconBitmap = nil
|
||||
self.bitmap = nil if !self.disposed?
|
||||
super
|
||||
@@ -552,7 +552,7 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
|
||||
|
||||
def setPokemonBitmap(pkmn, back = false)
|
||||
@pkmn = pkmn
|
||||
@_iconBitmap.dispose if @_iconBitmap
|
||||
@_iconBitmap&.dispose
|
||||
@_iconBitmap = GameData::Species.sprite_bitmap_from_pokemon(@pkmn, back)
|
||||
self.bitmap = (@_iconBitmap) ? @_iconBitmap.bitmap : nil
|
||||
pbSetPosition
|
||||
@@ -563,7 +563,7 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
|
||||
# recommendation is to create a PictureEx animation and push it into
|
||||
# the @battleAnimations array.
|
||||
def pbPlayIntroAnimation(pictureEx = nil)
|
||||
@pkmn.play_cry if @pkmn
|
||||
@pkmn&.play_cry
|
||||
end
|
||||
|
||||
QUARTER_ANIM_PERIOD = Graphics.frame_rate * 3 / 20
|
||||
@@ -617,7 +617,7 @@ class Battle::Scene::BattlerShadowSprite < RPG::Sprite
|
||||
end
|
||||
|
||||
def dispose
|
||||
@_iconBitmap.dispose if @_iconBitmap
|
||||
@_iconBitmap&.dispose
|
||||
@_iconBitmap = nil
|
||||
self.bitmap = nil if !self.disposed?
|
||||
super
|
||||
@@ -647,7 +647,7 @@ class Battle::Scene::BattlerShadowSprite < RPG::Sprite
|
||||
|
||||
def setPokemonBitmap(pkmn)
|
||||
@pkmn = pkmn
|
||||
@_iconBitmap.dispose if @_iconBitmap
|
||||
@_iconBitmap&.dispose
|
||||
@_iconBitmap = GameData::Species.shadow_bitmap_from_pokemon(@pkmn)
|
||||
self.bitmap = (@_iconBitmap) ? @_iconBitmap.bitmap : nil
|
||||
pbSetPosition
|
||||
|
||||
@@ -10,7 +10,7 @@ class Battle::Scene::Animation
|
||||
end
|
||||
|
||||
def dispose
|
||||
@tempSprites.each { |s| s.dispose if s }
|
||||
@tempSprites.each { |s| s&.dispose }
|
||||
end
|
||||
|
||||
def createProcesses; end
|
||||
@@ -47,7 +47,7 @@ class Battle::Scene::Animation
|
||||
|
||||
def update
|
||||
return if @animDone
|
||||
@tempSprites.each { |s| s.update if s }
|
||||
@tempSprites.each { |s| s&.update }
|
||||
finished = true
|
||||
@pictureEx.each_with_index do |p, i|
|
||||
next if !p.running?
|
||||
|
||||
@@ -140,9 +140,9 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation
|
||||
startsIndex = idxBall / ballsPerTrainer
|
||||
teamIndex = idxBall % ballsPerTrainer
|
||||
ret = @partyStarts[startsIndex] + teamIndex
|
||||
if startsIndex < @partyStarts.length - 1
|
||||
if startsIndex < @partyStarts.length - 1 && ret >= @partyStarts[startsIndex + 1]
|
||||
# There is a later trainer, don't spill over into its team
|
||||
return -1 if ret >= @partyStarts[startsIndex + 1]
|
||||
return -1
|
||||
end
|
||||
return ret
|
||||
end
|
||||
@@ -332,7 +332,7 @@ class Battle::Scene::Animation::PlayerFade < Battle::Scene::Animation
|
||||
end
|
||||
# Move and fade party bar/balls
|
||||
delay = 3
|
||||
if @sprites["partyBar_0"] && @sprites["partyBar_0"].visible
|
||||
if @sprites["partyBar_0"]&.visible
|
||||
partyBar = addSprite(@sprites["partyBar_0"])
|
||||
partyBar.moveDelta(delay, 16, -Graphics.width / 4, 0) if @fullAnim
|
||||
partyBar.moveOpacity(delay, 12, 0)
|
||||
@@ -377,7 +377,7 @@ class Battle::Scene::Animation::TrainerFade < Battle::Scene::Animation
|
||||
end
|
||||
# Move and fade party bar/balls
|
||||
delay = 3
|
||||
if @sprites["partyBar_1"] && @sprites["partyBar_1"].visible
|
||||
if @sprites["partyBar_1"]&.visible
|
||||
partyBar = addSprite(@sprites["partyBar_1"])
|
||||
partyBar.moveDelta(delay, 16, Graphics.width / 4, 0) if @fullAnim
|
||||
partyBar.moveOpacity(delay, 12, 0)
|
||||
@@ -722,12 +722,10 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation
|
||||
ball.setZ(0, batSprite.z + 1)
|
||||
@ballSpriteIndex = (@success) ? @tempSprites.length - 1 : -1
|
||||
# Set up trainer sprite (only visible in Safari Zone battles)
|
||||
if @showingTrainer && traSprite
|
||||
if traSprite.bitmap.width >= traSprite.bitmap.height * 2
|
||||
trainer = addSprite(traSprite, PictureOrigin::Bottom)
|
||||
# Trainer animation
|
||||
ballStartX, ballStartY = trainerThrowingFrames(ball, trainer, traSprite)
|
||||
end
|
||||
if @showingTrainer && traSprite && traSprite.bitmap.width >= traSprite.bitmap.height * 2
|
||||
trainer = addSprite(traSprite, PictureOrigin::Bottom)
|
||||
# Trainer animation
|
||||
ballStartX, ballStartY = trainerThrowingFrames(ball, trainer, traSprite)
|
||||
end
|
||||
delay = ball.totalDuration # 0 or 7
|
||||
# Poké Ball arc animation
|
||||
|
||||
@@ -115,12 +115,10 @@ class Battle::AI
|
||||
end
|
||||
end
|
||||
# Log Full Restores (HP healer and status curer)
|
||||
if losthp > 0 || battler.status != :NONE
|
||||
if fullRestoreItems.include?(i)
|
||||
usableHPItems.push([i, (preferFullRestore) ? 3 : 7, 999])
|
||||
usableStatusItems.push([i, (preferFullRestore) ? 3 : 9])
|
||||
next
|
||||
end
|
||||
if fullRestoreItems.include?(i) && (losthp > 0 || battler.status != :NONE)
|
||||
usableHPItems.push([i, (preferFullRestore) ? 3 : 7, 999])
|
||||
usableStatusItems.push([i, (preferFullRestore) ? 3 : 9])
|
||||
next
|
||||
end
|
||||
# Log single status-curing items
|
||||
if oneStatusItems.include?(i)
|
||||
|
||||
@@ -48,8 +48,8 @@ class Battle::AI
|
||||
skill >= PBTrainerAI.highSkill
|
||||
toxicHP = battler.totalhp / 16
|
||||
nextToxicHP = toxicHP * (battler.effects[PBEffects::Toxic] + 1)
|
||||
if battler.hp <= nextToxicHP && battler.hp > toxicHP * 2
|
||||
shouldSwitch = true if pbAIRandom(100) < 80
|
||||
if battler.hp <= nextToxicHP && battler.hp > toxicHP * 2 && pbAIRandom(100) < 80
|
||||
shouldSwitch = true
|
||||
end
|
||||
end
|
||||
# Pokémon is Encored into an unfavourable move
|
||||
@@ -62,8 +62,8 @@ class Battle::AI
|
||||
scoreSum += pbGetMoveScore(battler.moves[idxEncoredMove], battler, b, skill)
|
||||
scoreCount += 1
|
||||
end
|
||||
if scoreCount > 0 && scoreSum / scoreCount <= 20
|
||||
shouldSwitch = true if pbAIRandom(100) < 80
|
||||
if scoreCount > 0 && scoreSum / scoreCount <= 20 && pbAIRandom(100) < 80
|
||||
shouldSwitch = true
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -72,9 +72,9 @@ class Battle::AI
|
||||
if @battle.pbSideSize(battler.index + 1) == 1 &&
|
||||
!battler.pbDirectOpposing.fainted? && skill >= PBTrainerAI.highSkill
|
||||
opp = battler.pbDirectOpposing
|
||||
if opp.effects[PBEffects::HyperBeam] > 0 ||
|
||||
(opp.hasActiveAbility?(:TRUANT) && opp.effects[PBEffects::Truant])
|
||||
shouldSwitch = false if pbAIRandom(100) < 80
|
||||
if (opp.effects[PBEffects::HyperBeam] > 0 ||
|
||||
(opp.hasActiveAbility?(:TRUANT) && opp.effects[PBEffects::Truant])) && pbAIRandom(100) < 80
|
||||
shouldSwitch = false
|
||||
end
|
||||
end
|
||||
# Sudden Death rule - I'm not sure what this means
|
||||
@@ -103,9 +103,8 @@ class Battle::AI
|
||||
# Don't switch to this if too little HP
|
||||
if spikes > 0
|
||||
spikesDmg = [8, 6, 4][spikes - 1]
|
||||
if pkmn.hp <= pkmn.totalhp / spikesDmg
|
||||
next if !pkmn.hasType?(:FLYING) && !pkmn.hasActiveAbility?(:LEVITATE)
|
||||
end
|
||||
next if pkmn.hp <= pkmn.totalhp / spikesDmg &&
|
||||
!pkmn.hasType?(:FLYING) && !pkmn.hasActiveAbility?(:LEVITATE)
|
||||
end
|
||||
end
|
||||
# moveType is the type of the target's last used move
|
||||
@@ -136,7 +135,7 @@ class Battle::AI
|
||||
end
|
||||
if @battle.pbRegisterSwitch(idxBattler, list[0])
|
||||
PBDebug.log("[AI] #{battler.pbThis} (#{idxBattler}) will switch with " +
|
||||
"#{@battle.pbParty(idxBattler)[list[0]].name}")
|
||||
@battle.pbParty(idxBattler)[list[0]].name)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,9 +61,9 @@ class Battle::AI
|
||||
# Decide whether all choices are bad, and if so, try switching instead
|
||||
if !wildBattler && skill >= PBTrainerAI.highSkill
|
||||
badMoves = false
|
||||
if (maxScore <= 20 && user.turnCount > 2) ||
|
||||
(maxScore <= 40 && user.turnCount > 5)
|
||||
badMoves = true if pbAIRandom(100) < 80
|
||||
if ((maxScore <= 20 && user.turnCount > 2) ||
|
||||
(maxScore <= 40 && user.turnCount > 5)) && pbAIRandom(100) < 80
|
||||
badMoves = true
|
||||
end
|
||||
if !badMoves && totalScore < 100 && user.turnCount > 1
|
||||
badMoves = true
|
||||
@@ -160,13 +160,12 @@ class Battle::AI
|
||||
return 0 if score <= 0
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
# Prefer damaging moves if AI has no more Pokémon or AI is less clever
|
||||
if @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0
|
||||
if !(skill >= PBTrainerAI.highSkill && @battle.pbAbleNonActiveCount(target.idxOwnSide) > 0)
|
||||
if move.statusMove?
|
||||
score /= 1.5
|
||||
elsif target.hp <= target.totalhp / 2
|
||||
score *= 1.5
|
||||
end
|
||||
if @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0 &&
|
||||
!(skill >= PBTrainerAI.highSkill && @battle.pbAbleNonActiveCount(target.idxOwnSide) > 0)
|
||||
if move.statusMove?
|
||||
score /= 1.5
|
||||
elsif target.hp <= target.totalhp / 2
|
||||
score *= 1.5
|
||||
end
|
||||
end
|
||||
# Don't prefer attacking the target if they'd be semi-invulnerable
|
||||
@@ -266,18 +265,16 @@ class Battle::AI
|
||||
end
|
||||
# Prefer flinching external effects (note that move effects which cause
|
||||
# flinching are dealt with in the function code part of score calculation)
|
||||
if skill >= PBTrainerAI.mediumSkill && !move.flinchingMove?
|
||||
if !target.hasActiveAbility?(:INNERFOCUS) &&
|
||||
!target.hasActiveAbility?(:SHIELDDUST) &&
|
||||
target.effects[PBEffects::Substitute] == 0
|
||||
canFlinch = false
|
||||
if user.hasActiveItem?([:KINGSROCK, :RAZORFANG])
|
||||
canFlinch = true
|
||||
elsif user.hasActiveAbility?(:STENCH)
|
||||
canFlinch = true
|
||||
end
|
||||
realDamage *= 1.3 if canFlinch
|
||||
if skill >= PBTrainerAI.mediumSkill && !move.flinchingMove? &&
|
||||
!target.hasActiveAbility?(:INNERFOCUS) &&
|
||||
!target.hasActiveAbility?(:SHIELDDUST) &&
|
||||
target.effects[PBEffects::Substitute] == 0
|
||||
canFlinch = false
|
||||
if user.hasActiveItem?([:KINGSROCK, :RAZORFANG]) ||
|
||||
user.hasActiveAbility?(:STENCH)
|
||||
canFlinch = true
|
||||
end
|
||||
realDamage *= 1.3 if canFlinch
|
||||
end
|
||||
# Convert damage to percentage of target's remaining HP
|
||||
damagePercentage = realDamage * 100.0 / target.hp
|
||||
|
||||
@@ -859,9 +859,7 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetAttack1"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:ATTACK, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:ATTACK, user)
|
||||
score += target.stages[:ATTACK] * 20
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
hasPhysicalAttack = false
|
||||
@@ -876,6 +874,8 @@ class Battle::AI
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
else
|
||||
score += 20 if target.stages[:ATTACK] > 0
|
||||
@@ -892,10 +892,10 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetDefense1"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||
score += target.stages[:DEFENSE] * 20
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
elsif target.stages[:DEFENSE] > 0
|
||||
score += 20
|
||||
@@ -903,15 +903,15 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetSpeed1", "LowerTargetSpeed1WeakerInGrassyTerrain"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:SPEED, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:SPEED, user)
|
||||
score += target.stages[:SPEED] * 10
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
aspeed = pbRoughStat(user, :SPEED, skill)
|
||||
ospeed = pbRoughStat(target, :SPEED, skill)
|
||||
score += 30 if aspeed < ospeed && aspeed * 2 > ospeed
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
elsif user.stages[:SPEED] > 0
|
||||
score += 20
|
||||
@@ -919,9 +919,7 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetSpAtk1"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||
score += user.stages[:SPECIAL_ATTACK] * 20
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
hasSpecicalAttack = false
|
||||
@@ -936,6 +934,8 @@ class Battle::AI
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
else
|
||||
score += 20 if user.stages[:SPECIAL_ATTACK] > 0
|
||||
@@ -952,10 +952,10 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetSpDef1"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user)
|
||||
score += target.stages[:SPECIAL_DEFENSE] * 20
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
elsif target.stages[:SPECIAL_DEFENSE] > 0
|
||||
score += 20
|
||||
@@ -963,10 +963,10 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetAccuracy1", "LowerTargetAccuracy2", "LowerTargetAccuracy3"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:ACCURACY, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:ACCURACY, user)
|
||||
score += target.stages[:ACCURACY] * 10
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
elsif target.stages[:ACCURACY] > 0
|
||||
score += 20
|
||||
@@ -974,10 +974,10 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetEvasion1", "LowerTargetEvasion2", "LowerTargetEvasion3"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:EVASION, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:EVASION, user)
|
||||
score += target.stages[:EVASION] * 10
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
elsif target.stages[:EVASION] > 0
|
||||
score += 20
|
||||
@@ -985,10 +985,10 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetEvasion1RemoveSideEffects"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:EVASION, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:EVASION, user)
|
||||
score += target.stages[:EVASION] * 10
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
elsif target.stages[:EVASION] > 0
|
||||
score += 20
|
||||
@@ -1009,9 +1009,7 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetAttack2", "LowerTargetAttack3"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:ATTACK, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:ATTACK, user)
|
||||
score += 40 if user.turnCount == 0
|
||||
score += target.stages[:ATTACK] * 20
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
@@ -1027,6 +1025,8 @@ class Battle::AI
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
else
|
||||
score += 10 if user.turnCount == 0
|
||||
@@ -1044,11 +1044,11 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetDefense2", "LowerTargetDefense3"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||
score += 40 if user.turnCount == 0
|
||||
score += target.stages[:DEFENSE] * 20
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
else
|
||||
score += 10 if user.turnCount == 0
|
||||
@@ -1057,9 +1057,7 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetSpeed2", "LowerTargetSpeed3"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:SPEED, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:SPEED, user)
|
||||
score += 20 if user.turnCount == 0
|
||||
score += target.stages[:SPEED] * 20
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
@@ -1067,6 +1065,8 @@ class Battle::AI
|
||||
ospeed = pbRoughStat(target, :SPEED, skill)
|
||||
score += 30 if aspeed < ospeed && aspeed * 2 > ospeed
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
else
|
||||
score += 10 if user.turnCount == 0
|
||||
@@ -1078,9 +1078,7 @@ class Battle::AI
|
||||
target.hasActiveAbility?(:OBLIVIOUS)
|
||||
score -= 90
|
||||
elsif move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||
score += 40 if user.turnCount == 0
|
||||
score += target.stages[:SPECIAL_ATTACK] * 20
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
@@ -1096,6 +1094,8 @@ class Battle::AI
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
else
|
||||
score += 10 if user.turnCount == 0
|
||||
@@ -1113,11 +1113,11 @@ class Battle::AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetSpDef2", "LowerTargetSpDef3"
|
||||
if move.statusMove?
|
||||
if !target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user)
|
||||
score += 40 if user.turnCount == 0
|
||||
score += target.stages[:SPECIAL_DEFENSE] * 20
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
else
|
||||
score += 10 if user.turnCount == 0
|
||||
@@ -1323,9 +1323,7 @@ class Battle::AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "SetUserTypesToUserMoveType"
|
||||
if !user.canChangeType?
|
||||
score -= 90
|
||||
else
|
||||
if user.canChangeType?
|
||||
has_possible_type = false
|
||||
user.eachMoveWithIndex do |m, i|
|
||||
break if Settings::MECHANICS_GENERATION >= 6 && i > 0
|
||||
@@ -1335,6 +1333,8 @@ class Battle::AI
|
||||
break
|
||||
end
|
||||
score -= 90 if !has_possible_type
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "SetUserTypesToResistLastAttack"
|
||||
@@ -1350,9 +1350,7 @@ class Battle::AI
|
||||
aType = m.pbCalcType(user)
|
||||
break
|
||||
end
|
||||
if !aType
|
||||
score -= 90
|
||||
else
|
||||
if aType
|
||||
has_possible_type = false
|
||||
GameData::Type.each do |t|
|
||||
next if t.pseudo_type || user.pbHasType?(t.id) ||
|
||||
@@ -1361,6 +1359,8 @@ class Battle::AI
|
||||
break
|
||||
end
|
||||
score -= 90 if !has_possible_type
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -1793,9 +1793,7 @@ class Battle::AI
|
||||
if target.effects[PBEffects::Encore] > 0
|
||||
score -= 90
|
||||
elsif aspeed > ospeed
|
||||
if !target.lastRegularMoveUsed
|
||||
score -= 90
|
||||
else
|
||||
if target.lastRegularMoveUsed
|
||||
moveData = GameData::Move.get(target.lastRegularMoveUsed)
|
||||
if moveData.category == 2 && # Status move
|
||||
[:User, :BothSides].include?(moveData.target)
|
||||
@@ -1805,6 +1803,8 @@ class Battle::AI
|
||||
Effectiveness.ineffective?(pbCalcTypeMod(moveData.type, target, user))
|
||||
score += 60
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -2056,9 +2056,7 @@ class Battle::AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "SwitchOutUserPassOnEffects"
|
||||
if !@battle.pbCanChooseNonActive?(user.index)
|
||||
score -= 100
|
||||
else
|
||||
if @battle.pbCanChooseNonActive?(user.index)
|
||||
score -= 40 if user.effects[PBEffects::Confusion] > 0
|
||||
total = 0
|
||||
GameData::Stat.each_battle { |s| total += user.stages[s.id] }
|
||||
@@ -2075,6 +2073,8 @@ class Battle::AI
|
||||
end
|
||||
score += 75 if !hasDamagingMove
|
||||
end
|
||||
else
|
||||
score -= 100
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "TrapTargetInBattle"
|
||||
@@ -2505,9 +2505,7 @@ class Battle::AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetAttack1BypassSubstitute"
|
||||
if !target.pbCanLowerStatStage?(:ATTACK, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:ATTACK, user)
|
||||
score += target.stages[:ATTACK] * 20
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
hasPhysicalAttack = false
|
||||
@@ -2522,6 +2520,8 @@ class Battle::AI
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetAtkSpAtk1"
|
||||
@@ -2537,11 +2537,11 @@ class Battle::AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetSpAtk2", "LowerTargetSpAtk3"
|
||||
if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user)
|
||||
score += 40 if user.turnCount == 0
|
||||
score += target.stages[:SPECIAL_ATTACK] * 20
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "RaiseGroundedGrassBattlersAtkSpAtk1"
|
||||
@@ -3005,7 +3005,7 @@ class Battle::AI
|
||||
end
|
||||
GameData::Stat.each_main_battle { |s| score += 10 if user.stages[s.id] <= 0 }
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
hasDamagingAttack = user.moves.any? { |m| next m && m.damagingMove? }
|
||||
hasDamagingAttack = user.moves.any? { |m| next m&.damagingMove? }
|
||||
score += 20 if hasDamagingAttack
|
||||
end
|
||||
end
|
||||
@@ -3031,7 +3031,7 @@ class Battle::AI
|
||||
end
|
||||
GameData::Stat.each_main_battle { |s| score += 10 if user.stages[s.id] <= 0 }
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
hasDamagingAttack = user.moves.any? { |m| next m && m.damagingMove? }
|
||||
hasDamagingAttack = user.moves.any? { |m| next m&.damagingMove? }
|
||||
score += 20 if hasDamagingAttack
|
||||
end
|
||||
end
|
||||
@@ -3064,11 +3064,11 @@ class Battle::AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "LowerTargetDefense1DoublePowerInGravity"
|
||||
if !target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||
score -= 90
|
||||
else
|
||||
if target.pbCanLowerStatStage?(:DEFENSE, user)
|
||||
score += 20
|
||||
score += target.stages[:DEFENSE] * 20
|
||||
else
|
||||
score -= 90
|
||||
end
|
||||
score += 30 if @battle.field.effects[PBEffects::Gravity] > 0
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -28,28 +28,29 @@ class Battle::AI
|
||||
#=============================================================================
|
||||
def pbCalcTypeModSingle(moveType, defType, user, target)
|
||||
ret = Effectiveness.calculate_one(moveType, defType)
|
||||
# Ring Target
|
||||
if target.hasActiveItem?(:RINGTARGET)
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if Effectiveness.ineffective_type?(moveType, defType)
|
||||
end
|
||||
# Foresight
|
||||
if user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :GHOST &&
|
||||
Effectiveness.ineffective_type?(moveType, defType)
|
||||
end
|
||||
# Miracle Eye
|
||||
if target.effects[PBEffects::MiracleEye]
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :DARK &&
|
||||
Effectiveness.ineffective_type?(moveType, defType)
|
||||
end
|
||||
# Delta Stream's weather
|
||||
if target.effectiveWeather == :StrongWinds
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING &&
|
||||
Effectiveness.super_effective_type?(moveType, defType)
|
||||
if Effectiveness.ineffective_type?(moveType, defType)
|
||||
# Ring Target
|
||||
if target.hasActiveItem?(:RINGTARGET)
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
# Foresight
|
||||
if (user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]) &&
|
||||
defType == :GHOST
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
# Miracle Eye
|
||||
if target.effects[PBEffects::MiracleEye] && defType == :DARK
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
elsif Effectiveness.super_effective_type?(moveType, defType)
|
||||
# Delta Stream's weather
|
||||
if target.effectiveWeather == :StrongWinds && defType == :FLYING
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
end
|
||||
# Grounded Flying-type Pokémon become susceptible to Ground moves
|
||||
if !target.airborne?
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING && moveType == :GROUND
|
||||
if !target.airborne? && defType == :FLYING && moveType == :GROUND
|
||||
ret = Effectiveness::NORMAL_EFFECTIVE_ONE
|
||||
end
|
||||
return ret
|
||||
end
|
||||
@@ -256,7 +257,7 @@ class Battle::AI
|
||||
when "HitOncePerUserTeamMember" # Beat Up
|
||||
mult = 0
|
||||
@battle.eachInTeamFromBattlerIndex(user.index) do |pkmn, _i|
|
||||
mult += 1 if pkmn && pkmn.able? && pkmn.status == :NONE
|
||||
mult += 1 if pkmn&.able? && pkmn.status == :NONE
|
||||
end
|
||||
baseDmg *= mult
|
||||
when "TwoTurnAttackOneTurnInSun" # Solar Beam
|
||||
@@ -390,26 +391,20 @@ class Battle::AI
|
||||
)
|
||||
end
|
||||
end
|
||||
if skill >= PBTrainerAI.bestSkill && target.itemActive?
|
||||
# NOTE: Type-weakening berries aren't suitable for checking at the start
|
||||
# of the round.
|
||||
if target.item && !target.item.is_berry?
|
||||
if skill >= PBTrainerAI.bestSkill && target.itemActive? && (target.item && !target.item.is_berry?)
|
||||
Battle::ItemEffects.triggerDamageCalcFromTarget(
|
||||
target.item, user, target, move, multipliers, baseDmg, type
|
||||
)
|
||||
end
|
||||
end
|
||||
# Global abilities
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
if (@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||
|
||||
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY)
|
||||
if skill >= PBTrainerAI.mediumSkill && ((@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||
|
||||
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY))
|
||||
if @battle.pbCheckGlobalAbility(:AURABREAK)
|
||||
multipliers[:base_damage_multiplier] *= 2 / 3.0
|
||||
else
|
||||
multipliers[:base_damage_multiplier] *= 4 / 3.0
|
||||
end
|
||||
end
|
||||
end
|
||||
# Parental Bond
|
||||
if skill >= PBTrainerAI.mediumSkill && user.hasActiveAbility?(:PARENTALBOND)
|
||||
multipliers[:base_damage_multiplier] *= 1.25
|
||||
@@ -418,11 +413,9 @@ class Battle::AI
|
||||
# TODO
|
||||
# Helping Hand - n/a
|
||||
# Charge
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
if user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC
|
||||
if skill >= PBTrainerAI.mediumSkill && (user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC)
|
||||
multipliers[:base_damage_multiplier] *= 2
|
||||
end
|
||||
end
|
||||
# Mud Sport and Water Sport
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
if type == :ELECTRIC
|
||||
@@ -456,25 +449,17 @@ class Battle::AI
|
||||
end
|
||||
end
|
||||
# Badge multipliers
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
if @battle.internalBattle
|
||||
# Don't need to check the Atk/Sp Atk-boosting badges because the AI
|
||||
# won't control the player's Pokémon.
|
||||
if target.pbOwnedByPlayer?
|
||||
if skill >= PBTrainerAI.highSkill && @battle.internalBattle && target.pbOwnedByPlayer?
|
||||
if move.physicalMove?(type) && @battle.pbPlayer.badge_count >= Settings::NUM_BADGES_BOOST_DEFENSE
|
||||
multipliers[:defense_multiplier] *= 1.1
|
||||
elsif move.specialMove?(type) && @battle.pbPlayer.badge_count >= Settings::NUM_BADGES_BOOST_SPDEF
|
||||
multipliers[:defense_multiplier] *= 1.1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# Multi-targeting attacks
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
if pbTargetsMultiple?(move, user)
|
||||
if skill >= PBTrainerAI.highSkill && pbTargetsMultiple?(move, user)
|
||||
multipliers[:final_damage_multiplier] *= 0.75
|
||||
end
|
||||
end
|
||||
# Weather
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
case user.effectiveWeather
|
||||
@@ -502,31 +487,26 @@ class Battle::AI
|
||||
# Critical hits - n/a
|
||||
# Random variance - n/a
|
||||
# STAB
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
if type && user.pbHasType?(type)
|
||||
if skill >= PBTrainerAI.mediumSkill && (type && user.pbHasType?(type))
|
||||
if user.hasActiveAbility?(:ADAPTABILITY)
|
||||
multipliers[:final_damage_multiplier] *= 2
|
||||
else
|
||||
multipliers[:final_damage_multiplier] *= 1.5
|
||||
end
|
||||
end
|
||||
end
|
||||
# Type effectiveness
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
typemod = pbCalcTypeMod(type, user, target)
|
||||
multipliers[:final_damage_multiplier] *= typemod.to_f / Effectiveness::NORMAL_EFFECTIVE
|
||||
end
|
||||
# Burn
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
if user.status == :BURN && move.physicalMove?(type) &&
|
||||
if skill >= PBTrainerAI.highSkill && (user.status == :BURN && move.physicalMove?(type) &&
|
||||
!user.hasActiveAbility?(:GUTS) &&
|
||||
!(Settings::MECHANICS_GENERATION >= 6 && move.function == "DoublePowerIfUserPoisonedBurnedParalyzed") # Facade
|
||||
!(Settings::MECHANICS_GENERATION >= 6 && move.function == "DoublePowerIfUserPoisonedBurnedParalyzed")) # Facade
|
||||
multipliers[:final_damage_multiplier] /= 2
|
||||
end
|
||||
end
|
||||
# Aurora Veil, Reflect, Light Screen
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
if !move.ignoresReflect? && !user.hasActiveAbility?(:INFILTRATOR)
|
||||
if skill >= PBTrainerAI.highSkill && (!move.ignoresReflect? && !user.hasActiveAbility?(:INFILTRATOR))
|
||||
if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0
|
||||
if @battle.pbSideBattlerCount(target) > 1
|
||||
multipliers[:final_damage_multiplier] *= 2 / 3.0
|
||||
@@ -547,13 +527,10 @@ class Battle::AI
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# Minimize
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
if target.effects[PBEffects::Minimize] && move.tramplesMinimize?(2)
|
||||
if skill >= PBTrainerAI.highSkill && (target.effects[PBEffects::Minimize] && move.tramplesMinimize?(2))
|
||||
multipliers[:final_damage_multiplier] *= 2
|
||||
end
|
||||
end
|
||||
# Move-specific base damage modifiers
|
||||
# TODO
|
||||
# Move-specific final damage modifiers
|
||||
@@ -572,20 +549,16 @@ class Battle::AI
|
||||
if c >= 0 && user.abilityActive?
|
||||
c = Battle::AbilityEffects.triggerCriticalCalcFromUser(user.ability, user, target, c)
|
||||
end
|
||||
if skill >= PBTrainerAI.bestSkill
|
||||
if c >= 0 && !moldBreaker && target.abilityActive?
|
||||
if skill >= PBTrainerAI.bestSkill && (c >= 0 && !moldBreaker && target.abilityActive?)
|
||||
c = Battle::AbilityEffects.triggerCriticalCalcFromTarget(target.ability, user, target, c)
|
||||
end
|
||||
end
|
||||
# Item effects that alter critical hit rate
|
||||
if c >= 0 && user.itemActive?
|
||||
c = Battle::ItemEffects.triggerCriticalCalcFromUser(user.item, user, target, c)
|
||||
end
|
||||
if skill >= PBTrainerAI.bestSkill
|
||||
if c >= 0 && target.itemActive?
|
||||
if skill >= PBTrainerAI.bestSkill && (c >= 0 && target.itemActive?)
|
||||
c = Battle::ItemEffects.triggerCriticalCalcFromTarget(target.item, user, target, c)
|
||||
end
|
||||
end
|
||||
# Other efffects
|
||||
c = -1 if target.pbOwnSide.effects[PBEffects::LuckyChant] > 0
|
||||
if c >= 0
|
||||
@@ -659,28 +632,22 @@ class Battle::AI
|
||||
)
|
||||
end
|
||||
end
|
||||
if skill >= PBTrainerAI.bestSkill
|
||||
if target.abilityActive? && !moldBreaker
|
||||
if skill >= PBTrainerAI.bestSkill && (target.abilityActive? && !moldBreaker)
|
||||
Battle::AbilityEffects.triggerAccuracyCalcFromTarget(
|
||||
target.ability, modifiers, user, target, move, type
|
||||
)
|
||||
end
|
||||
end
|
||||
# Item effects that alter accuracy calculation
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
if user.itemActive?
|
||||
if skill >= PBTrainerAI.mediumSkill && user.itemActive?
|
||||
Battle::ItemEffects.triggerAccuracyCalcFromUser(
|
||||
user.item, modifiers, user, target, move, type
|
||||
)
|
||||
end
|
||||
end
|
||||
if skill >= PBTrainerAI.bestSkill
|
||||
if target.itemActive?
|
||||
if skill >= PBTrainerAI.bestSkill && target.itemActive?
|
||||
Battle::ItemEffects.triggerAccuracyCalcFromTarget(
|
||||
target.item, modifiers, user, target, move, type
|
||||
)
|
||||
end
|
||||
end
|
||||
# Other effects, inc. ones that set accuracy_multiplier or evasion_stage to specific values
|
||||
if skill >= PBTrainerAI.mediumSkill
|
||||
if @battle.field.effects[PBEffects::Gravity] > 0
|
||||
@@ -699,15 +666,15 @@ class Battle::AI
|
||||
user.effects[PBEffects::LockOnPos] == target.index
|
||||
end
|
||||
if skill >= PBTrainerAI.highSkill
|
||||
if move.function == "BadPoisonTarget" # Toxic
|
||||
modifiers[:base_accuracy] = 0 if Settings::MORE_TYPE_EFFECTS && move.statusMove? &&
|
||||
user.pbHasType?(:POISON)
|
||||
if move.function == "BadPoisonTarget" && (Settings::MORE_TYPE_EFFECTS && move.statusMove? &&
|
||||
user.pbHasType?(:POISON)) # Toxic
|
||||
modifiers[:base_accuracy] = 0
|
||||
end
|
||||
if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(move.function)
|
||||
modifiers[:base_accuracy] = move.accuracy + user.level - target.level
|
||||
modifiers[:accuracy_multiplier] = 0 if target.level > user.level
|
||||
if skill >= PBTrainerAI.bestSkill
|
||||
modifiers[:accuracy_multiplier] = 0 if target.hasActiveAbility?(:STURDY)
|
||||
if skill >= PBTrainerAI.bestSkill && target.hasActiveAbility?(:STURDY)
|
||||
modifiers[:accuracy_multiplier] = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,8 +4,9 @@ module Battle::CatchAndStoreMixin
|
||||
#=============================================================================
|
||||
def pbStorePokemon(pkmn)
|
||||
# Nickname the Pokémon (unless it's a Shadow Pokémon)
|
||||
if !pkmn.shadowPokemon? && $PokemonSystem.givenicknames == 0
|
||||
if pbDisplayConfirm(_INTL("Would you like to give a nickname to {1}?", pkmn.name))
|
||||
if !pkmn.shadowPokemon?
|
||||
if $PokemonSystem.givenicknames == 0 &&
|
||||
pbDisplayConfirm(_INTL("Would you like to give a nickname to {1}?", pkmn.name))
|
||||
nickname = @scene.pbNameEntry(_INTL("{1}'s nickname?", pkmn.speciesName), pkmn)
|
||||
pkmn.name = nickname
|
||||
end
|
||||
@@ -166,7 +167,7 @@ module Battle::CatchAndStoreMixin
|
||||
# Definite capture, no need to perform randomness checks
|
||||
return 4 if x >= 255 || Battle::PokeBallEffects.isUnconditional?(ball, self, battler)
|
||||
# Second half of the shakes calculation
|
||||
y = (65536 / ((255.0 / x)**0.1875)).floor
|
||||
y = (65_536 / ((255.0 / x)**0.1875)).floor
|
||||
# Critical capture check
|
||||
if Settings::ENABLE_CRITICAL_CAPTURES
|
||||
dex_modifier = 0
|
||||
@@ -187,7 +188,7 @@ module Battle::CatchAndStoreMixin
|
||||
# Calculate the number of shakes
|
||||
if c > 0 && pbRandom(256) < c
|
||||
@criticalCapture = true
|
||||
return 4 if pbRandom(65536) < y
|
||||
return 4 if pbRandom(65_536) < y
|
||||
return 0
|
||||
end
|
||||
end
|
||||
@@ -195,7 +196,7 @@ module Battle::CatchAndStoreMixin
|
||||
numShakes = 0
|
||||
4.times do |i|
|
||||
break if numShakes < i
|
||||
numShakes += 1 if pbRandom(65536) < y
|
||||
numShakes += 1 if pbRandom(65_536) < y
|
||||
end
|
||||
return numShakes
|
||||
end
|
||||
|
||||
@@ -494,7 +494,7 @@ class PBAnimation < Array
|
||||
when 0 # Play SE
|
||||
if i.name && i.name != ""
|
||||
pbSEPlay("Anim/" + i.name, i.volume, i.pitch)
|
||||
elsif user && user.pokemon
|
||||
elsif user&.pokemon
|
||||
name = GameData::Species.cry_filename_from_pokemon(user.pokemon)
|
||||
pbSEPlay(name, i.volume, i.pitch) if name
|
||||
end
|
||||
@@ -517,16 +517,16 @@ class PBAnimation < Array
|
||||
bgColor.opacity = i.opacity || 0
|
||||
end
|
||||
when 2 # Move/recolour background graphic
|
||||
if bgGraphic.bitmap != nil
|
||||
oldbg[0] = bgGraphic.ox || 0
|
||||
oldbg[1] = bgGraphic.oy || 0
|
||||
oldbg[2] = bgGraphic.opacity || 0
|
||||
oldbg[3] = bgGraphic.color.clone || Color.new(0, 0, 0, 0)
|
||||
else
|
||||
if bgGraphic.bitmap.nil?
|
||||
oldbg[0] = 0
|
||||
oldbg[1] = 0
|
||||
oldbg[2] = bgColor.opacity || 0
|
||||
oldbg[3] = bgColor.color.clone || Color.new(0, 0, 0, 0)
|
||||
else
|
||||
oldbg[0] = bgGraphic.ox || 0
|
||||
oldbg[1] = bgGraphic.oy || 0
|
||||
oldbg[2] = bgGraphic.opacity || 0
|
||||
oldbg[3] = bgGraphic.color.clone || Color.new(0, 0, 0, 0)
|
||||
end
|
||||
when 3 # Set foreground graphic (immediate)
|
||||
if i.name && i.name != ""
|
||||
@@ -543,16 +543,16 @@ class PBAnimation < Array
|
||||
foColor.opacity = i.opacity || 0
|
||||
end
|
||||
when 4 # Move/recolour foreground graphic
|
||||
if foGraphic.bitmap != nil
|
||||
oldfo[0] = foGraphic.ox || 0
|
||||
oldfo[1] = foGraphic.oy || 0
|
||||
oldfo[2] = foGraphic.opacity || 0
|
||||
oldfo[3] = foGraphic.color.clone || Color.new(0, 0, 0, 0)
|
||||
else
|
||||
if foGraphic.bitmap.nil?
|
||||
oldfo[0] = 0
|
||||
oldfo[1] = 0
|
||||
oldfo[2] = foColor.opacity || 0
|
||||
oldfo[3] = foColor.color.clone || Color.new(0, 0, 0, 0)
|
||||
else
|
||||
oldfo[0] = foGraphic.ox || 0
|
||||
oldfo[1] = foGraphic.oy || 0
|
||||
oldfo[2] = foGraphic.opacity || 0
|
||||
oldfo[3] = foGraphic.color.clone || Color.new(0, 0, 0, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -562,7 +562,14 @@ class PBAnimation < Array
|
||||
next if !i.duration || i.duration <= 0
|
||||
next if frame < i.frame || frame > i.frame + i.duration
|
||||
fraction = (frame - i.frame).to_f / i.duration
|
||||
if bgGraphic.bitmap != nil
|
||||
if bgGraphic.bitmap.nil?
|
||||
bgColor.opacity = oldbg[2] + ((i.opacity - oldbg[2]) * fraction) if i.opacity != nil
|
||||
cr = (i.colorRed != nil) ? oldbg[3].red + ((i.colorRed - oldbg[3].red) * fraction) : oldbg[3].red
|
||||
cg = (i.colorGreen != nil) ? oldbg[3].green + ((i.colorGreen - oldbg[3].green) * fraction) : oldbg[3].green
|
||||
cb = (i.colorBlue != nil) ? oldbg[3].blue + ((i.colorBlue - oldbg[3].blue) * fraction) : oldbg[3].blue
|
||||
ca = (i.colorAlpha != nil) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
|
||||
bgColor.color = Color.new(cr, cg, cb, ca)
|
||||
else
|
||||
bgGraphic.ox = oldbg[0] - ((i.bgX - oldbg[0]) * fraction) if i.bgX != nil
|
||||
bgGraphic.oy = oldbg[1] - ((i.bgY - oldbg[1]) * fraction) if i.bgY != nil
|
||||
bgGraphic.opacity = oldbg[2] + ((i.opacity - oldbg[2]) * fraction) if i.opacity != nil
|
||||
@@ -571,19 +578,19 @@ class PBAnimation < Array
|
||||
cb = (i.colorBlue != nil) ? oldbg[3].blue + ((i.colorBlue - oldbg[3].blue) * fraction) : oldbg[3].blue
|
||||
ca = (i.colorAlpha != nil) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
|
||||
bgGraphic.color = Color.new(cr, cg, cb, ca)
|
||||
else
|
||||
bgColor.opacity = oldbg[2] + ((i.opacity - oldbg[2]) * fraction) if i.opacity != nil
|
||||
cr = (i.colorRed != nil) ? oldbg[3].red + ((i.colorRed - oldbg[3].red) * fraction) : oldbg[3].red
|
||||
cg = (i.colorGreen != nil) ? oldbg[3].green + ((i.colorGreen - oldbg[3].green) * fraction) : oldbg[3].green
|
||||
cb = (i.colorBlue != nil) ? oldbg[3].blue + ((i.colorBlue - oldbg[3].blue) * fraction) : oldbg[3].blue
|
||||
ca = (i.colorAlpha != nil) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
|
||||
bgColor.color = Color.new(cr, cg, cb, ca)
|
||||
end
|
||||
when 4
|
||||
next if !i.duration || i.duration <= 0
|
||||
next if frame < i.frame || frame > i.frame + i.duration
|
||||
fraction = (frame - i.frame).to_f / i.duration
|
||||
if foGraphic.bitmap != nil
|
||||
if foGraphic.bitmap.nil?
|
||||
foColor.opacity = oldfo[2] + ((i.opacity - oldfo[2]) * fraction) if i.opacity != nil
|
||||
cr = (i.colorRed != nil) ? oldfo[3].red + ((i.colorRed - oldfo[3].red) * fraction) : oldfo[3].red
|
||||
cg = (i.colorGreen != nil) ? oldfo[3].green + ((i.colorGreen - oldfo[3].green) * fraction) : oldfo[3].green
|
||||
cb = (i.colorBlue != nil) ? oldfo[3].blue + ((i.colorBlue - oldfo[3].blue) * fraction) : oldfo[3].blue
|
||||
ca = (i.colorAlpha != nil) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
|
||||
foColor.color = Color.new(cr, cg, cb, ca)
|
||||
else
|
||||
foGraphic.ox = oldfo[0] - ((i.bgX - oldfo[0]) * fraction) if i.bgX != nil
|
||||
foGraphic.oy = oldfo[1] - ((i.bgY - oldfo[1]) * fraction) if i.bgY != nil
|
||||
foGraphic.opacity = oldfo[2] + ((i.opacity - oldfo[2]) * fraction) if i.opacity != nil
|
||||
@@ -592,13 +599,6 @@ class PBAnimation < Array
|
||||
cb = (i.colorBlue != nil) ? oldfo[3].blue + ((i.colorBlue - oldfo[3].blue) * fraction) : oldfo[3].blue
|
||||
ca = (i.colorAlpha != nil) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
|
||||
foGraphic.color = Color.new(cr, cg, cb, ca)
|
||||
else
|
||||
foColor.opacity = oldfo[2] + ((i.opacity - oldfo[2]) * fraction) if i.opacity != nil
|
||||
cr = (i.colorRed != nil) ? oldfo[3].red + ((i.colorRed - oldfo[3].red) * fraction) : oldfo[3].red
|
||||
cg = (i.colorGreen != nil) ? oldfo[3].green + ((i.colorGreen - oldfo[3].green) * fraction) : oldfo[3].green
|
||||
cb = (i.colorBlue != nil) ? oldfo[3].blue + ((i.colorBlue - oldfo[3].blue) * fraction) : oldfo[3].blue
|
||||
ca = (i.colorAlpha != nil) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
|
||||
foColor.color = Color.new(cr, cg, cb, ca)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -700,10 +700,10 @@ class PBAnimationPlayerX
|
||||
@user = (oppMove) ? target : user # Just used for playing user's cry
|
||||
@usersprite = (user) ? scene.sprites["pokemon_#{user.index}"] : nil
|
||||
@targetsprite = (target) ? scene.sprites["pokemon_#{target.index}"] : nil
|
||||
@userbitmap = (@usersprite && @usersprite.bitmap) ? @usersprite.bitmap : nil # not to be disposed
|
||||
@targetbitmap = (@targetsprite && @targetsprite.bitmap) ? @targetsprite.bitmap : nil # not to be disposed
|
||||
@userbitmap = @usersprite&.bitmap # not to be disposed
|
||||
@targetbitmap = @targetsprite&.bitmap # not to be disposed
|
||||
@scene = scene
|
||||
@viewport = (scene) ? scene.viewport : nil
|
||||
@viewport = scene&.viewport
|
||||
@inEditor = inEditor
|
||||
@looping = false
|
||||
@animbitmap = nil # Animation sheet graphic
|
||||
@@ -761,9 +761,9 @@ class PBAnimationPlayerX
|
||||
end
|
||||
|
||||
def dispose
|
||||
@animbitmap.dispose if @animbitmap
|
||||
@animbitmap&.dispose
|
||||
(2...MAX_SPRITES).each do |i|
|
||||
@animsprites[i].dispose if @animsprites[i]
|
||||
@animsprites[i]&.dispose
|
||||
end
|
||||
@bgGraphic.dispose
|
||||
@bgColor.dispose
|
||||
@@ -792,7 +792,7 @@ class PBAnimationPlayerX
|
||||
if animFrame >= @animation.length
|
||||
@frame = (@looping) ? 0 : -1
|
||||
if @frame < 0
|
||||
@animbitmap.dispose if @animbitmap
|
||||
@animbitmap&.dispose
|
||||
@animbitmap = nil
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1179,8 +1179,8 @@ Battle::AbilityEffects::AccuracyCalcFromTarget.add(:UNAWARE,
|
||||
|
||||
Battle::AbilityEffects::AccuracyCalcFromTarget.add(:WONDERSKIN,
|
||||
proc { |ability, mods, user, target, move, type|
|
||||
if move.statusMove? && user.opposes?(target)
|
||||
mods[:base_accuracy] = 50 if mods[:base_accuracy] > 50
|
||||
if move.statusMove? && user.opposes?(target) && mods[:base_accuracy] > 50
|
||||
mods[:base_accuracy] = 50
|
||||
end
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1421,11 +1421,10 @@ Battle::ItemEffects::OnBeingHit.add(:STICKYBARB,
|
||||
user.item = target.item
|
||||
target.item = nil
|
||||
target.effects[PBEffects::Unburden] = true if target.hasActiveAbility?(:UNBURDEN)
|
||||
if battle.wildBattle? && !user.opposes?
|
||||
if !user.initialItem && user.item == target.initialItem
|
||||
user.setInitialItem(user.item)
|
||||
target.setInitialItem(nil)
|
||||
end
|
||||
if battle.wildBattle? && !user.opposes? &&
|
||||
!user.initialItem && user.item == target.initialItem
|
||||
user.setInitialItem(user.item)
|
||||
target.setInitialItem(nil)
|
||||
end
|
||||
battle.pbDisplay(_INTL("{1}'s {2} was transferred to {3}!",
|
||||
target.pbThis, user.itemName, user.pbThis(true)))
|
||||
|
||||
@@ -26,7 +26,7 @@ class Battle::FakeBattler
|
||||
def super_shiny?; return @pokemon.super_shiny?; end
|
||||
|
||||
def isSpecies?(check_species)
|
||||
return @pokemon && @pokemon.isSpecies?(check_species)
|
||||
return @pokemon&.isSpecies?(check_species)
|
||||
end
|
||||
|
||||
def fainted?; return false; end
|
||||
|
||||
@@ -87,8 +87,9 @@ class BattlePalaceBattle < Battle
|
||||
return false
|
||||
end
|
||||
# though incorrect, just for convenience (actually checks Torment later)
|
||||
if thispkmn.effects[PBEffects::Torment] && thispkmn.lastMoveUsed
|
||||
return false if thismove.id == thispkmn.lastMoveUsed
|
||||
if thispkmn.effects[PBEffects::Torment] &&
|
||||
thispkmn.lastMoveUsed && thismove.id == thispkmn.lastMoveUsed
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -53,9 +53,7 @@ class BattleArenaBattle < Battle
|
||||
end
|
||||
|
||||
def pbCanSwitchLax?(idxBattler, _idxParty, partyScene = nil)
|
||||
if partyScene
|
||||
partyScene.pbDisplay(_INTL("{1} can't be switched out!", @battlers[idxBattler].pbThis))
|
||||
end
|
||||
partyScene&.pbDisplay(_INTL("{1} can't be switched out!", @battlers[idxBattler].pbThis))
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -366,8 +364,8 @@ class Battle::Scene
|
||||
ensure
|
||||
pbDisposeMessageWindow(msgwindow)
|
||||
dimmingvp.dispose
|
||||
infowindow.contents.dispose if infowindow && infowindow.contents
|
||||
infowindow.dispose if infowindow
|
||||
infowindow&.contents&.dispose
|
||||
infowindow&.dispose
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user