|
|
|
|
@@ -1,9 +1,9 @@
|
|
|
|
|
class PokeBattle_Battler
|
|
|
|
|
# Fundamental to this object
|
|
|
|
|
attr_reader :battle
|
|
|
|
|
attr_reader :battle
|
|
|
|
|
attr_accessor :index
|
|
|
|
|
# The Pokémon and its properties
|
|
|
|
|
attr_reader :pokemon
|
|
|
|
|
attr_reader :pokemon
|
|
|
|
|
attr_accessor :pokemonIndex
|
|
|
|
|
attr_accessor :species
|
|
|
|
|
attr_accessor :type1
|
|
|
|
|
@@ -17,10 +17,10 @@ class PokeBattle_Battler
|
|
|
|
|
attr_accessor :spatk
|
|
|
|
|
attr_accessor :speed
|
|
|
|
|
attr_accessor :stages
|
|
|
|
|
attr_reader :totalhp
|
|
|
|
|
attr_reader :fainted # Boolean to mark whether self has fainted properly
|
|
|
|
|
attr_accessor :captured # Boolean to mark whether self was captured
|
|
|
|
|
attr_reader :dummy
|
|
|
|
|
attr_reader :totalhp
|
|
|
|
|
attr_reader :fainted # Boolean to mark whether self has fainted properly
|
|
|
|
|
attr_accessor :captured # Boolean to mark whether self was captured
|
|
|
|
|
attr_reader :dummy
|
|
|
|
|
attr_accessor :effects
|
|
|
|
|
# Things the battler has done in battle
|
|
|
|
|
attr_accessor :turnCount
|
|
|
|
|
@@ -32,16 +32,16 @@ class PokeBattle_Battler
|
|
|
|
|
attr_accessor :lastMoveUsed
|
|
|
|
|
attr_accessor :lastMoveUsedType
|
|
|
|
|
attr_accessor :lastRegularMoveUsed
|
|
|
|
|
attr_accessor :lastRegularMoveTarget # For Instruct
|
|
|
|
|
attr_accessor :lastRegularMoveTarget # For Instruct
|
|
|
|
|
attr_accessor :lastRoundMoved
|
|
|
|
|
attr_accessor :lastMoveFailed # For Stomping Tantrum
|
|
|
|
|
attr_accessor :lastRoundMoveFailed # For Stomping Tantrum
|
|
|
|
|
attr_accessor :lastMoveFailed # For Stomping Tantrum
|
|
|
|
|
attr_accessor :lastRoundMoveFailed # For Stomping Tantrum
|
|
|
|
|
attr_accessor :movesUsed
|
|
|
|
|
attr_accessor :currentMove # ID of multi-turn move currently being used
|
|
|
|
|
attr_accessor :tookDamage # Boolean for whether self took damage this round
|
|
|
|
|
attr_accessor :currentMove # ID of multi-turn move currently being used
|
|
|
|
|
attr_accessor :tookDamage # Boolean for whether self took damage this round
|
|
|
|
|
attr_accessor :tookPhysicalHit
|
|
|
|
|
attr_accessor :damageState
|
|
|
|
|
attr_accessor :initialHP # Set at the start of each move's usage
|
|
|
|
|
attr_accessor :initialHP # Set at the start of each move's usage
|
|
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
|
# Complex accessors
|
|
|
|
|
@@ -68,7 +68,6 @@ class PokeBattle_Battler
|
|
|
|
|
return @pokemon.ability_index >= 2
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ability=(value)
|
|
|
|
|
new_ability = GameData::Ability.try_get(value)
|
|
|
|
|
@ability_id = (new_ability) ? new_ability.id : nil
|
|
|
|
|
@@ -85,14 +84,14 @@ class PokeBattle_Battler
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def defense
|
|
|
|
|
return @spdef if @battle.field.effects[PBEffects::WonderRoom]>0
|
|
|
|
|
return @spdef if @battle.field.effects[PBEffects::WonderRoom] > 0
|
|
|
|
|
return @defense
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
attr_writer :defense
|
|
|
|
|
|
|
|
|
|
def spdef
|
|
|
|
|
return @defense if @battle.field.effects[PBEffects::WonderRoom]>0
|
|
|
|
|
return @defense if @battle.field.effects[PBEffects::WonderRoom] > 0
|
|
|
|
|
return @spdef
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@@ -101,18 +100,22 @@ class PokeBattle_Battler
|
|
|
|
|
attr_reader :hp
|
|
|
|
|
|
|
|
|
|
def hp=(value)
|
|
|
|
|
checkHPRelatedFormChange(value) #careful, setting @pokemon.hp also calls a method for changing the form on hp change so we should not change the form here, just update the graphics
|
|
|
|
|
@hp = value.to_i
|
|
|
|
|
@pokemon.hp = value.to_i if @pokemon
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def fainted?; return @hp<=0; end
|
|
|
|
|
def fainted?
|
|
|
|
|
return @hp <= 0;
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
alias isFainted? fainted?
|
|
|
|
|
|
|
|
|
|
attr_reader :status
|
|
|
|
|
|
|
|
|
|
def status=(value)
|
|
|
|
|
@effects[PBEffects::Truant] = false if @status == :SLEEP && value != :SLEEP
|
|
|
|
|
@effects[PBEffects::Toxic] = 0 if value != :POISON
|
|
|
|
|
@effects[PBEffects::Toxic] = 0 if value != :POISON
|
|
|
|
|
@status = value
|
|
|
|
|
@pokemon.status = value if @pokemon
|
|
|
|
|
self.statusCount = 0 if value != :POISON && value != :SLEEP
|
|
|
|
|
@@ -130,9 +133,17 @@ class PokeBattle_Battler
|
|
|
|
|
#=============================================================================
|
|
|
|
|
# Properties from Pokémon
|
|
|
|
|
#=============================================================================
|
|
|
|
|
def happiness; return @pokemon ? @pokemon.happiness : 0; end
|
|
|
|
|
def nature; return @pokemon ? @pokemon.nature : 0; end
|
|
|
|
|
def pokerusStage; return @pokemon ? @pokemon.pokerusStage : 0; end
|
|
|
|
|
def happiness
|
|
|
|
|
return @pokemon ? @pokemon.happiness : 0;
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def nature
|
|
|
|
|
return @pokemon ? @pokemon.nature : 0;
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def pokerusStage
|
|
|
|
|
return @pokemon ? @pokemon.pokerusStage : 0;
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
|
# Mega Evolution, Primal Reversion, Shadow Pokémon
|
|
|
|
|
@@ -142,7 +153,10 @@ class PokeBattle_Battler
|
|
|
|
|
return @pokemon && @pokemon.hasMegaForm?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def mega?; return @pokemon && @pokemon.mega?; end
|
|
|
|
|
def mega?
|
|
|
|
|
return @pokemon && @pokemon.mega?;
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
alias isMega? mega?
|
|
|
|
|
|
|
|
|
|
def hasPrimal?
|
|
|
|
|
@@ -150,13 +164,21 @@ class PokeBattle_Battler
|
|
|
|
|
return @pokemon && @pokemon.hasPrimalForm?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def primal?; return @pokemon && @pokemon.primal?; end
|
|
|
|
|
def primal?
|
|
|
|
|
return @pokemon && @pokemon.primal?;
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
alias isPrimal? primal?
|
|
|
|
|
|
|
|
|
|
def shadowPokemon?; return false; end
|
|
|
|
|
def shadowPokemon?
|
|
|
|
|
return false;
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
alias isShadow? shadowPokemon?
|
|
|
|
|
|
|
|
|
|
def inHyperMode?; return false; end
|
|
|
|
|
def inHyperMode?
|
|
|
|
|
return false;
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
|
# Display-only properties
|
|
|
|
|
@@ -192,6 +214,7 @@ class PokeBattle_Battler
|
|
|
|
|
return @effects[PBEffects::Illusion].shiny? if @effects[PBEffects::Illusion]
|
|
|
|
|
return @pokemon && @pokemon.shiny?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
alias isShiny? shiny?
|
|
|
|
|
|
|
|
|
|
def glitter?
|
|
|
|
|
@@ -202,6 +225,7 @@ class PokeBattle_Battler
|
|
|
|
|
return false if !@battle.wildBattle?
|
|
|
|
|
return $Trainer.owned?(displaySpecies)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
alias owned owned?
|
|
|
|
|
|
|
|
|
|
def abilityName
|
|
|
|
|
@@ -214,27 +238,27 @@ class PokeBattle_Battler
|
|
|
|
|
return (itm) ? itm.name : ""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def pbThis(lowerCase=false)
|
|
|
|
|
def pbThis(lowerCase = false)
|
|
|
|
|
if opposes?
|
|
|
|
|
if @battle.trainerBattle?
|
|
|
|
|
return lowerCase ? _INTL("the opposing {1}",name) : _INTL("The opposing {1}",name)
|
|
|
|
|
return lowerCase ? _INTL("the opposing {1}", name) : _INTL("The opposing {1}", name)
|
|
|
|
|
else
|
|
|
|
|
return lowerCase ? _INTL("the wild {1}",name) : _INTL("The wild {1}",name)
|
|
|
|
|
return lowerCase ? _INTL("the wild {1}", name) : _INTL("The wild {1}", name)
|
|
|
|
|
end
|
|
|
|
|
elsif !pbOwnedByPlayer?
|
|
|
|
|
return lowerCase ? _INTL("the ally {1}",name) : _INTL("The ally {1}",name)
|
|
|
|
|
return lowerCase ? _INTL("the ally {1}", name) : _INTL("The ally {1}", name)
|
|
|
|
|
end
|
|
|
|
|
return name
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def pbTeam(lowerCase=false)
|
|
|
|
|
def pbTeam(lowerCase = false)
|
|
|
|
|
if opposes?
|
|
|
|
|
return lowerCase ? _INTL("the opposing team") : _INTL("The opposing team")
|
|
|
|
|
end
|
|
|
|
|
return lowerCase ? _INTL("your team") : _INTL("Your team")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def pbOpposingTeam(lowerCase=false)
|
|
|
|
|
def pbOpposingTeam(lowerCase = false)
|
|
|
|
|
if opposes?
|
|
|
|
|
return lowerCase ? _INTL("your team") : _INTL("Your team")
|
|
|
|
|
end
|
|
|
|
|
@@ -246,46 +270,46 @@ class PokeBattle_Battler
|
|
|
|
|
#=============================================================================
|
|
|
|
|
def pbSpeed
|
|
|
|
|
return 1 if fainted?
|
|
|
|
|
stageMul = [2,2,2,2,2,2, 2, 3,4,5,6,7,8]
|
|
|
|
|
stageDiv = [8,7,6,5,4,3, 2, 2,2,2,2,2,2]
|
|
|
|
|
stageMul = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8]
|
|
|
|
|
stageDiv = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2]
|
|
|
|
|
stage = @stages[:SPEED] + 6
|
|
|
|
|
speed = @speed*stageMul[stage]/stageDiv[stage]
|
|
|
|
|
speed = @speed * stageMul[stage] / stageDiv[stage]
|
|
|
|
|
speedMult = 1.0
|
|
|
|
|
# Ability effects that alter calculated Speed
|
|
|
|
|
if abilityActive?
|
|
|
|
|
speedMult = BattleHandlers.triggerSpeedCalcAbility(self.ability,self,speedMult)
|
|
|
|
|
speedMult = BattleHandlers.triggerSpeedCalcAbility(self.ability, self, speedMult)
|
|
|
|
|
end
|
|
|
|
|
# Item effects that alter calculated Speed
|
|
|
|
|
if itemActive?
|
|
|
|
|
speedMult = BattleHandlers.triggerSpeedCalcItem(self.item,self,speedMult)
|
|
|
|
|
speedMult = BattleHandlers.triggerSpeedCalcItem(self.item, self, speedMult)
|
|
|
|
|
end
|
|
|
|
|
# Other effects
|
|
|
|
|
speedMult *= 2 if pbOwnSide.effects[PBEffects::Tailwind]>0
|
|
|
|
|
speedMult /= 2 if pbOwnSide.effects[PBEffects::Swamp]>0
|
|
|
|
|
speedMult *= 2 if pbOwnSide.effects[PBEffects::Tailwind] > 0
|
|
|
|
|
speedMult /= 2 if pbOwnSide.effects[PBEffects::Swamp] > 0
|
|
|
|
|
# Paralysis
|
|
|
|
|
if status == :PARALYSIS && !hasActiveAbility?(:QUICKFEET)
|
|
|
|
|
speedMult /= (Settings::MECHANICS_GENERATION >= 7) ? 2 : 4
|
|
|
|
|
end
|
|
|
|
|
# Badge multiplier
|
|
|
|
|
if @battle.internalBattle && pbOwnedByPlayer? &&
|
|
|
|
|
@battle.pbPlayer.badge_count >= Settings::NUM_BADGES_BOOST_SPEED
|
|
|
|
|
@battle.pbPlayer.badge_count >= Settings::NUM_BADGES_BOOST_SPEED
|
|
|
|
|
speedMult *= 1.1
|
|
|
|
|
end
|
|
|
|
|
# Calculation
|
|
|
|
|
return [(speed*speedMult).round,1].max
|
|
|
|
|
return [(speed * speedMult).round, 1].max
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def pbWeight
|
|
|
|
|
ret = (@pokemon) ? @pokemon.weight : 500
|
|
|
|
|
ret += @effects[PBEffects::WeightChange]
|
|
|
|
|
ret = 1 if ret<1
|
|
|
|
|
ret = 1 if ret < 1
|
|
|
|
|
if abilityActive? && !@battle.moldBreaker
|
|
|
|
|
ret = BattleHandlers.triggerWeightCalcAbility(self.ability,self,ret)
|
|
|
|
|
ret = BattleHandlers.triggerWeightCalcAbility(self.ability, self, ret)
|
|
|
|
|
end
|
|
|
|
|
if itemActive?
|
|
|
|
|
ret = BattleHandlers.triggerWeightCalcItem(self.item,self,ret)
|
|
|
|
|
ret = BattleHandlers.triggerWeightCalcItem(self.item, self, ret)
|
|
|
|
|
end
|
|
|
|
|
return [ret,1].max
|
|
|
|
|
return [ret, 1].max
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
|
@@ -293,11 +317,11 @@ class PokeBattle_Battler
|
|
|
|
|
#=============================================================================
|
|
|
|
|
def plainStats
|
|
|
|
|
ret = {}
|
|
|
|
|
ret[:ATTACK] = self.attack
|
|
|
|
|
ret[:DEFENSE] = self.defense
|
|
|
|
|
ret[:SPECIAL_ATTACK] = self.spatk
|
|
|
|
|
ret[:ATTACK] = self.attack
|
|
|
|
|
ret[:DEFENSE] = self.defense
|
|
|
|
|
ret[:SPECIAL_ATTACK] = self.spatk
|
|
|
|
|
ret[:SPECIAL_DEFENSE] = self.spdef
|
|
|
|
|
ret[:SPEED] = self.speed
|
|
|
|
|
ret[:SPEED] = self.speed
|
|
|
|
|
return ret
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@@ -313,7 +337,6 @@ class PokeBattle_Battler
|
|
|
|
|
return @pokemon.hasHeadOf?(check_species)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def isFusionOf(check_species)
|
|
|
|
|
return @pokemon.isFusionOf(check_species)
|
|
|
|
|
end
|
|
|
|
|
@@ -322,13 +345,12 @@ class PokeBattle_Battler
|
|
|
|
|
return @pokemon.isFusion?()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Returns the active types of this Pokémon. The array should not include the
|
|
|
|
|
# same type more than once, and should not include any invalid type numbers
|
|
|
|
|
# (e.g. -1).
|
|
|
|
|
def pbTypes(withType3=false)
|
|
|
|
|
def pbTypes(withType3 = false)
|
|
|
|
|
ret = [@type1]
|
|
|
|
|
ret.push(@type2) if @type2!=@type1
|
|
|
|
|
ret.push(@type2) if @type2 != @type1
|
|
|
|
|
# Burn Up erases the Fire-type.
|
|
|
|
|
ret.delete(:FIRE) if @effects[PBEffects::BurnUp]
|
|
|
|
|
# Roost erases the Flying-type. If there are no types left, adds the Normal-
|
|
|
|
|
@@ -373,6 +395,7 @@ class PokeBattle_Battler
|
|
|
|
|
return check_ability.include?(@ability_id) if check_ability.is_a?(Array)
|
|
|
|
|
return self.ability == check_ability
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
alias hasWorkingAbility hasActiveAbility?
|
|
|
|
|
|
|
|
|
|
# Applies to both losing self's ability (i.e. being replaced by another) and
|
|
|
|
|
@@ -385,8 +408,8 @@ class PokeBattle_Battler
|
|
|
|
|
# Form-changing abilities
|
|
|
|
|
:BATTLEBOND,
|
|
|
|
|
:DISGUISE,
|
|
|
|
|
# :FLOWERGIFT, # This can be stopped
|
|
|
|
|
# :FORECAST, # This can be stopped
|
|
|
|
|
# :FLOWERGIFT, # This can be stopped
|
|
|
|
|
# :FORECAST, # This can be stopped
|
|
|
|
|
:MULTITYPE,
|
|
|
|
|
:POWERCONSTRUCT,
|
|
|
|
|
:SCHOOLING,
|
|
|
|
|
@@ -427,11 +450,11 @@ class PokeBattle_Battler
|
|
|
|
|
return ability_blacklist.include?(abil.id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def itemActive?(ignoreFainted=false)
|
|
|
|
|
def itemActive?(ignoreFainted = false)
|
|
|
|
|
return false if fainted? && !ignoreFainted
|
|
|
|
|
return false if @effects[PBEffects::Embargo]>0
|
|
|
|
|
return false if @battle.field.effects[PBEffects::MagicRoom]>0
|
|
|
|
|
return false if hasActiveAbility?(:KLUTZ,ignoreFainted)
|
|
|
|
|
return false if @effects[PBEffects::Embargo] > 0
|
|
|
|
|
return false if @battle.field.effects[PBEffects::MagicRoom] > 0
|
|
|
|
|
return false if hasActiveAbility?(:KLUTZ, ignoreFainted)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@@ -440,6 +463,7 @@ class PokeBattle_Battler
|
|
|
|
|
return check_item.include?(@item_id) if check_item.is_a?(Array)
|
|
|
|
|
return self.item == check_item
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
alias hasWorkingItem hasActiveItem?
|
|
|
|
|
|
|
|
|
|
# Returns whether the specified item will be unlosable for this Pokémon.
|
|
|
|
|
@@ -448,9 +472,10 @@ class PokeBattle_Battler
|
|
|
|
|
return true if GameData::Item.get(check_item).is_mail?
|
|
|
|
|
return false if @effects[PBEffects::Transform]
|
|
|
|
|
# Items that change a Pokémon's form
|
|
|
|
|
if mega? # Check if item was needed for this Mega Evolution
|
|
|
|
|
if mega? # Check if item was needed for this Mega Evolution
|
|
|
|
|
return true if @pokemon.species_data.mega_stone == check_item
|
|
|
|
|
else # Check if item could cause a Mega Evolution
|
|
|
|
|
else
|
|
|
|
|
# Check if item could cause a Mega Evolution
|
|
|
|
|
GameData::Species.each do |data|
|
|
|
|
|
next if data.species != @species || data.unmega_form != @form
|
|
|
|
|
return true if data.mega_stone == check_item
|
|
|
|
|
@@ -516,15 +541,15 @@ class PokeBattle_Battler
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def takesIndirectDamage?(showMsg=false)
|
|
|
|
|
def takesIndirectDamage?(showMsg = false)
|
|
|
|
|
return false if fainted?
|
|
|
|
|
if hasActiveAbility?(:MAGICGUARD)
|
|
|
|
|
if showMsg
|
|
|
|
|
@battle.pbShowAbilitySplash(self)
|
|
|
|
|
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis))
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis))
|
|
|
|
|
else
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!",pbThis,abilityName))
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!", pbThis, abilityName))
|
|
|
|
|
end
|
|
|
|
|
@battle.pbHideAbilitySplash(self)
|
|
|
|
|
end
|
|
|
|
|
@@ -536,8 +561,8 @@ class PokeBattle_Battler
|
|
|
|
|
def takesSandstormDamage?
|
|
|
|
|
return false if !takesIndirectDamage?
|
|
|
|
|
return false if pbHasType?(:GROUND) || pbHasType?(:ROCK) || pbHasType?(:STEEL)
|
|
|
|
|
return false if inTwoTurnAttack?("0CA","0CB") # Dig, Dive
|
|
|
|
|
return false if hasActiveAbility?([:OVERCOAT,:SANDFORCE,:SANDRUSH,:SANDVEIL])
|
|
|
|
|
return false if inTwoTurnAttack?("0CA", "0CB") # Dig, Dive
|
|
|
|
|
return false if hasActiveAbility?([:OVERCOAT, :SANDFORCE, :SANDRUSH, :SANDVEIL])
|
|
|
|
|
return false if hasActiveItem?(:SAFETYGOGGLES)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
@@ -545,8 +570,8 @@ class PokeBattle_Battler
|
|
|
|
|
def takesHailDamage?
|
|
|
|
|
return false if !takesIndirectDamage?
|
|
|
|
|
return false if pbHasType?(:ICE)
|
|
|
|
|
return false if inTwoTurnAttack?("0CA","0CB") # Dig, Dive
|
|
|
|
|
return false if hasActiveAbility?([:OVERCOAT,:ICEBODY,:SNOWCLOAK])
|
|
|
|
|
return false if inTwoTurnAttack?("0CA", "0CB") # Dig, Dive
|
|
|
|
|
return false if hasActiveAbility?([:OVERCOAT, :ICEBODY, :SNOWCLOAK])
|
|
|
|
|
return false if hasActiveItem?(:SAFETYGOGGLES)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
@@ -557,10 +582,10 @@ class PokeBattle_Battler
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def affectedByPowder?(showMsg=false)
|
|
|
|
|
def affectedByPowder?(showMsg = false)
|
|
|
|
|
return false if fainted?
|
|
|
|
|
if pbHasType?(:GRASS) && Settings::MORE_TYPE_EFFECTS
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis)) if showMsg
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) if showMsg
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
if Settings::MECHANICS_GENERATION >= 6
|
|
|
|
|
@@ -568,9 +593,9 @@ class PokeBattle_Battler
|
|
|
|
|
if showMsg
|
|
|
|
|
@battle.pbShowAbilitySplash(self)
|
|
|
|
|
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis))
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis))
|
|
|
|
|
else
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!",pbThis,abilityName))
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!", pbThis, abilityName))
|
|
|
|
|
end
|
|
|
|
|
@battle.pbHideAbilitySplash(self)
|
|
|
|
|
end
|
|
|
|
|
@@ -578,7 +603,7 @@ class PokeBattle_Battler
|
|
|
|
|
end
|
|
|
|
|
if hasActiveItem?(:SAFETYGOGGLES)
|
|
|
|
|
if showMsg
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!",pbThis,itemName))
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!", pbThis, itemName))
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
@@ -587,50 +612,50 @@ class PokeBattle_Battler
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def canHeal?
|
|
|
|
|
return false if fainted? || @hp>=@totalhp
|
|
|
|
|
return false if @effects[PBEffects::HealBlock]>0
|
|
|
|
|
return false if fainted? || @hp >= @totalhp
|
|
|
|
|
return false if @effects[PBEffects::HealBlock] > 0
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def affectedByContactEffect?(showMsg=false)
|
|
|
|
|
def affectedByContactEffect?(showMsg = false)
|
|
|
|
|
return false if fainted?
|
|
|
|
|
if hasActiveItem?(:PROTECTIVEPADS)
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} protected itself with the {2}!",pbThis,itemName)) if showMsg
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} protected itself with the {2}!", pbThis, itemName)) if showMsg
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def movedThisRound?
|
|
|
|
|
return @lastRoundMoved && @lastRoundMoved==@battle.turnCount
|
|
|
|
|
return @lastRoundMoved && @lastRoundMoved == @battle.turnCount
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def usingMultiTurnAttack?
|
|
|
|
|
return true if @effects[PBEffects::TwoTurnAttack]
|
|
|
|
|
return true if @effects[PBEffects::HyperBeam]>0
|
|
|
|
|
return true if @effects[PBEffects::Rollout]>0
|
|
|
|
|
return true if @effects[PBEffects::Outrage]>0
|
|
|
|
|
return true if @effects[PBEffects::Uproar]>0
|
|
|
|
|
return true if @effects[PBEffects::Bide]>0
|
|
|
|
|
return true if @effects[PBEffects::HyperBeam] > 0
|
|
|
|
|
return true if @effects[PBEffects::Rollout] > 0
|
|
|
|
|
return true if @effects[PBEffects::Outrage] > 0
|
|
|
|
|
return true if @effects[PBEffects::Uproar] > 0
|
|
|
|
|
return true if @effects[PBEffects::Bide] > 0
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def inTwoTurnAttack?(*arg)
|
|
|
|
|
return false if !@effects[PBEffects::TwoTurnAttack]
|
|
|
|
|
ttaFunction = GameData::Move.get(@effects[PBEffects::TwoTurnAttack]).function_code
|
|
|
|
|
arg.each { |a| return true if a==ttaFunction }
|
|
|
|
|
arg.each { |a| return true if a == ttaFunction }
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def semiInvulnerable?
|
|
|
|
|
return inTwoTurnAttack?("0C9","0CA","0CB","0CC","0CD","0CE","14D")
|
|
|
|
|
return inTwoTurnAttack?("0C9", "0CA", "0CB", "0CC", "0CD", "0CE", "14D")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def pbEncoredMoveIndex
|
|
|
|
|
return -1 if @effects[PBEffects::Encore]==0 || !@effects[PBEffects::EncoreMove]
|
|
|
|
|
return -1 if @effects[PBEffects::Encore] == 0 || !@effects[PBEffects::EncoreMove]
|
|
|
|
|
ret = -1
|
|
|
|
|
eachMoveWithIndex do |m,i|
|
|
|
|
|
next if m.id!=@effects[PBEffects::EncoreMove]
|
|
|
|
|
eachMoveWithIndex do |m, i|
|
|
|
|
|
next if m.id != @effects[PBEffects::EncoreMove]
|
|
|
|
|
ret = i
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
@@ -638,42 +663,42 @@ class PokeBattle_Battler
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def initialItem
|
|
|
|
|
return @battle.initialItems[@index&1][@pokemonIndex]
|
|
|
|
|
return @battle.initialItems[@index & 1][@pokemonIndex]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def setInitialItem(newItem)
|
|
|
|
|
@battle.initialItems[@index&1][@pokemonIndex] = newItem
|
|
|
|
|
@battle.initialItems[@index & 1][@pokemonIndex] = newItem
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def recycleItem
|
|
|
|
|
return @battle.recycleItems[@index&1][@pokemonIndex]
|
|
|
|
|
return @battle.recycleItems[@index & 1][@pokemonIndex]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def setRecycleItem(newItem)
|
|
|
|
|
@battle.recycleItems[@index&1][@pokemonIndex] = newItem
|
|
|
|
|
@battle.recycleItems[@index & 1][@pokemonIndex] = newItem
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def belched?
|
|
|
|
|
return @battle.belch[@index&1][@pokemonIndex]
|
|
|
|
|
return @battle.belch[@index & 1][@pokemonIndex]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def setBelched
|
|
|
|
|
@battle.belch[@index&1][@pokemonIndex] = true
|
|
|
|
|
@battle.belch[@index & 1][@pokemonIndex] = true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
|
# Methods relating to this battler's position on the battlefield
|
|
|
|
|
#=============================================================================
|
|
|
|
|
# Returns whether the given position belongs to the opposing Pokémon's side.
|
|
|
|
|
def opposes?(i=0)
|
|
|
|
|
def opposes?(i = 0)
|
|
|
|
|
i = i.index if i.respond_to?("index")
|
|
|
|
|
return (@index&1)!=(i&1)
|
|
|
|
|
return (@index & 1) != (i & 1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Returns whether the given position/battler is near to self.
|
|
|
|
|
def near?(i)
|
|
|
|
|
i = i.index if i.respond_to?("index")
|
|
|
|
|
return @battle.nearBattlers?(@index,i)
|
|
|
|
|
return @battle.nearBattlers?(@index, i)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Returns whether self is owned by the player.
|
|
|
|
|
@@ -684,13 +709,13 @@ class PokeBattle_Battler
|
|
|
|
|
# Returns 0 if self is on the player's side, or 1 if self is on the opposing
|
|
|
|
|
# side.
|
|
|
|
|
def idxOwnSide
|
|
|
|
|
return @index&1
|
|
|
|
|
return @index & 1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Returns 1 if self is on the player's side, or 0 if self is on the opposing
|
|
|
|
|
# side.
|
|
|
|
|
def idxOpposingSide
|
|
|
|
|
return (@index&1)^1
|
|
|
|
|
return (@index & 1) ^ 1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Returns the data structure for this battler's side.
|
|
|
|
|
@@ -706,7 +731,7 @@ class PokeBattle_Battler
|
|
|
|
|
# Yields each unfainted ally Pokémon.
|
|
|
|
|
def eachAlly
|
|
|
|
|
@battle.battlers.each do |b|
|
|
|
|
|
yield b if b && !b.fainted? && !b.opposes?(@index) && b.index!=@index
|
|
|
|
|
yield b if b && !b.fainted? && !b.opposes?(@index) && b.index != @index
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@@ -717,7 +742,7 @@ class PokeBattle_Battler
|
|
|
|
|
|
|
|
|
|
# Returns the battler that is most directly opposite to self. unfaintedOnly is
|
|
|
|
|
# whether it should prefer to return a non-fainted battler.
|
|
|
|
|
def pbDirectOpposing(unfaintedOnly=false)
|
|
|
|
|
def pbDirectOpposing(unfaintedOnly = false)
|
|
|
|
|
@battle.pbGetOpposingIndicesInOrder(@index).each do |i|
|
|
|
|
|
next if !@battle.battlers[i]
|
|
|
|
|
break if unfaintedOnly && @battle.battlers[i].fainted?
|
|
|
|
|
@@ -728,6 +753,49 @@ class PokeBattle_Battler
|
|
|
|
|
@battle.pbGetOpposingIndicesInOrder(@index).each do |i|
|
|
|
|
|
return @battle.battlers[i] if @battle.battlers[i]
|
|
|
|
|
end
|
|
|
|
|
return @battle.battlers[(@index^1)]
|
|
|
|
|
return @battle.battlers[(@index ^ 1)]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#Changes the form VISUALLY in battles. The species is changed in the equivalent method in Pokemon class
|
|
|
|
|
def checkHPRelatedFormChange(new_hp)
|
|
|
|
|
if @ability_id == :SHIELDSDOWN
|
|
|
|
|
if @pokemon.isFusionOf(:MINIOR_M)
|
|
|
|
|
if new_hp <= (@totalhp / 2)
|
|
|
|
|
changeBattlerForm(:MINIOR_M, :MINIOR_C,nil, :SHELLSMASH)
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} changed to the Core Form!", pbThis))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if @pokemon.isFusionOf(:MINIOR_C)
|
|
|
|
|
if new_hp > (@totalhp / 2)
|
|
|
|
|
changeBattlerForm(:MINIOR_C, :MINIOR_M,nil, :SHELLSMASH)
|
|
|
|
|
@battle.pbDisplay(_INTL("{1} changed to the Meteor Form!", pbThis))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def changeBattlerForm(oldForm, newForm,commonAnimation=nil,moveAnimation=nil)
|
|
|
|
|
@pokemon.changeFormSpecies(oldForm, newForm)
|
|
|
|
|
if moveAnimation
|
|
|
|
|
changeFormSpeciesMoveAnimation(oldForm, newForm,moveAnimation)
|
|
|
|
|
else
|
|
|
|
|
changeFormSpeciesCommonAnimation(oldForm, newForm, commonAnimation)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#These methods only play the animation and change the graphics.
|
|
|
|
|
# To also change the species, call changeFormSpecies() instead
|
|
|
|
|
def changeFormSpeciesCommonAnimation(oldForm, newForm, animation = "UltraBurst2")
|
|
|
|
|
@battle.scene.pbChangePokemon(self, @pokemon)
|
|
|
|
|
@battle.scene.pbCommonAnimation(animation, self)
|
|
|
|
|
@battle.scene.pbRefreshOne(@index)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def changeFormSpeciesMoveAnimation(oldForm, newForm, moveID=:REFRESH)
|
|
|
|
|
@battle.scene.pbChangePokemon(self, @pokemon)
|
|
|
|
|
@battle.scene.pbAnimation(moveID, self,self)
|
|
|
|
|
@battle.scene.pbRefreshOne(@index)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|