Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PokeBattle_Battler
- #===============================================================================
- # Sleep
- #===============================================================================
- def pbCanSleep?(attacker,showMessages,move=nil,ignorestatus=false)
- return false if isFainted?
- selfsleep=(attacker && attacker.index==self.index)
- if !ignorestatus && status==PBStatuses::SLEEP
- @battle.pbDisplay(_INTL("{1} sta già dormendo!",pbThis)) if showMessages
- return false
- end
- if !selfsleep
- if self.status!=0 ||
- (@effects[PBEffects::Substitute]>0 && (!move || !move.ignoresSubstitute?(attacker)))
- @battle.pbDisplay(_INTL("Ma fallisce!")) if showMessages
- return false
- end
- end
- if !self.isAirborne?(attacker && attacker.hasMoldBreaker)
- if @battle.field.effects[PBEffects::ElectricTerrain]>0
- @battle.pbDisplay(_INTL("Il terreno elettrico ha impedito a {1} di addormentarsi!",pbThis(true))) if showMessages
- return false
- elsif @battle.field.effects[PBEffects::MistyTerrain]>0
- @battle.pbDisplay(_INTL("Il campo nebbioso ha impedito a {1} di addormentarsi!",pbThis(true))) if showMessages
- return false
- end
- end
- if (attacker && attacker.hasMoldBreaker) || !hasWorkingAbility(:SOUNDPROOF)
- for i in 0...4
- if @battle.battlers[i].effects[PBEffects::Uproar]>0
- @battle.pbDisplay(_INTL("Ma la baraonda tiene {1} sveglio!",pbThis(true))) if showMessages
- return false
- end
- end
- end
- if !attacker || attacker.index==self.index || !attacker.hasMoldBreaker
- if hasWorkingAbility(:VITALSPIRIT) ||
- hasWorkingAbility(:INSOMNIA) ||
- hasWorkingAbility(:SWEETVEIL) ||
- (hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)) ||
- (hasWorkingAbility(:LEAFGUARD) && (@battle.pbWeather==PBWeather::SUNNYDAY ||
- @battle.pbWeather==PBWeather::HARSHSUN))
- abilityname=PBAbilities.getName(self.ability)
- @battle.pbDisplay(_INTL("{1} è rimasto sveglio grazie a {2}!",pbThis,abilityname)) if showMessages
- return false
- end
- if pbPartner.hasWorkingAbility(:SWEETVEIL) ||
- (pbPartner.hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS))
- abilityname=PBAbilities.getName(pbPartner.ability)
- @battle.pbDisplay(_INTL("{1} è rimasto sveglio grazie a {2} del Pokémon compagno!",pbThis,abilityname)) if showMessages
- return false
- end
- end
- if !selfsleep
- if pbOwnSide.effects[PBEffects::Safeguard]>0 &&
- (!attacker || !attacker.hasWorkingAbility(:INFILTRATOR))
- @battle.pbDisplay(_INTL("Il team di {1} è protetto da Salvaguardia!",pbThis)) if showMessages
- return false
- end
- end
- return true
- end
- def pbCanSleepYawn?
- return false if status!=0
- if !hasWorkingAbility(:SOUNDPROOF)
- for i in 0...4
- return false if @battle.battlers[i].effects[PBEffects::Uproar]>0
- end
- end
- if !self.isAirborne?
- return false if @battle.field.effects[PBEffects::ElectricTerrain]>0
- return false if @battle.field.effects[PBEffects::MistyTerrain]>0
- end
- if hasWorkingAbility(:VITALSPIRIT) ||
- hasWorkingAbility(:INSOMNIA) ||
- hasWorkingAbility(:SWEETVEIL) ||
- (hasWorkingAbility(:LEAFGUARD) && (@battle.pbWeather==PBWeather::SUNNYDAY ||
- @battle.pbWeather==PBWeather::HARSHSUN))
- return false
- end
- return false if pbPartner.hasWorkingAbility(:SWEETVEIL)
- return true
- end
- def pbSleep(msg=nil)
- self.status=PBStatuses::SLEEP
- self.statusCount=2+@battle.pbRandom(3)
- self.statusCount=(self.statusCount/2).floor if self.hasWorkingAbility(:EARLYBIRD)
- pbCancelMoves
- @battle.pbCommonAnimation("Sleep",self,nil)
- if msg && msg!=""
- @battle.pbDisplay(msg)
- else
- @battle.pbDisplay(_INTL("{1} si è addormentato!",pbThis))
- end
- PBDebug.log("[Status change] #{pbThis} fell asleep (#{self.statusCount} turns)")
- end
- def pbSleepSelf(duration=-1)
- self.status=PBStatuses::SLEEP
- if duration>0
- self.statusCount=duration
- else
- self.statusCount=2+@battle.pbRandom(3)
- end
- self.statusCount=(self.statusCount/2).floor if self.hasWorkingAbility(:EARLYBIRD)
- pbCancelMoves
- @battle.pbCommonAnimation("Sleep",self,nil)
- PBDebug.log("[Status change] #{pbThis} made itself fall asleep (#{self.statusCount} turns)")
- end
- #===============================================================================
- # Poison
- #===============================================================================
- def pbCanPoison?(attacker,showMessages,move=nil)
- return false if isFainted?
- if status==PBStatuses::POISON
- @battle.pbDisplay(_INTL("{1} è già avvelenato.",pbThis)) if showMessages
- return false
- end
- if self.status!=0 ||
- (@effects[PBEffects::Substitute]>0 && (!move || !move.ignoresSubstitute?(attacker)))
- @battle.pbDisplay(_INTL("Ma fallisce!")) if showMessages
- return false
- end
- if (pbHasType?(:POISON) || pbHasType?(:STEEL)) && !hasWorkingItem(:RINGTARGET)
- @battle.pbDisplay(_INTL("Non ha effetto su {1}...",pbThis(true))) if showMessages
- return false
- end
- if @battle.field.effects[PBEffects::MistyTerrain]>0 &&
- !self.isAirborne?(attacker && attacker.hasMoldBreaker)
- @battle.pbDisplay(_INTL("Il campo nebbioso ha impedito a {1} di essere avvelenato!",pbThis(true))) if showMessages
- return false
- end
- if !attacker || !attacker.hasMoldBreaker
- if hasWorkingAbility(:IMMUNITY) ||
- (hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)) ||
- (hasWorkingAbility(:LEAFGUARD) && (@battle.pbWeather==PBWeather::SUNNYDAY ||
- @battle.pbWeather==PBWeather::HARSHSUN))
- @battle.pbDisplay(_INTL("{2} di {1} impedisce l'avvelenamento!",pbThis,PBAbilities.getName(self.ability))) if showMessages
- return false
- end
- if pbPartner.hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)
- abilityname=PBAbilities.getName(pbPartner.ability)
- @battle.pbDisplay(_INTL("{2} del partner di {1} impedisce l'avvelenamento!",pbThis,abilityname)) if showMessages
- return false
- end
- end
- if pbOwnSide.effects[PBEffects::Safeguard]>0 &&
- (!attacker || !attacker.hasWorkingAbility(:INFILTRATOR))
- @battle.pbDisplay(_INTL("Il team di {1} è protetto da Salvaguardia!",pbThis)) if showMessages
- return false
- end
- return true
- end
- def pbCanPoisonSynchronize?(opponent)
- return false if isFainted?
- if (pbHasType?(:POISON) || pbHasType?(:STEEL)) && !hasWorkingItem(:RINGTARGET)
- @battle.pbDisplay(_INTL("{2} di {1} non ha avuto effetto su {3}!",
- opponent.pbThis,PBAbilities.getName(opponent.ability),pbThis(true)))
- return false
- end
- return false if self.status!=0
- if hasWorkingAbility(:IMMUNITY) ||
- (hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)) ||
- (hasWorkingAbility(:LEAFGUARD) && (@battle.pbWeather==PBWeather::SUNNYDAY ||
- @battle.pbWeather==PBWeather::HARSHSUN))
- @battle.pbDisplay(_INTL("{2} di {1} impedisce a {4} di {3} di funzionare!",
- pbThis,PBAbilities.getName(self.ability),
- opponent.pbThis(true),PBAbilities.getName(opponent.ability)))
- return false
- end
- if pbPartner.hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)
- @battle.pbDisplay(_INTL("{2} di {1} impedisce a {4} di {3} di funzionare!",
- pbPartner.pbThis,PBAbilities.getName(pbPartner.ability),
- opponent.pbThis(true),PBAbilities.getName(opponent.ability)))
- return false
- end
- return true
- end
- def pbCanPoisonSpikes?(moldbreaker=false)
- return false if isFainted?
- return false if self.status!=0
- return false if pbHasType?(:POISON) || pbHasType?(:STEEL)
- if !moldbreaker
- return false if hasWorkingAbility(:IMMUNITY) ||
- (hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)) ||
- (pbPartner.hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS))
- return false if hasWorkingAbility(:LEAFGUARD) &&
- (@battle.pbWeather==PBWeather::SUNNYDAY ||
- @battle.pbWeather==PBWeather::HARSHSUN)
- end
- return false if pbOwnSide.effects[PBEffects::Safeguard]>0
- return true
- end
- def pbPoison(attacker,msg=nil,toxic=false)
- self.status=PBStatuses::POISON
- self.statusCount=(toxic) ? 1 : 0
- self.effects[PBEffects::Toxic]=0
- @battle.pbCommonAnimation("Poison",self,nil)
- if msg && msg!=""
- @battle.pbDisplay(msg)
- else
- if toxic
- @battle.pbDisplay(_INTL("{1} è iperavvelenato!",pbThis))
- else
- @battle.pbDisplay(_INTL("{1} è avvelenato!",pbThis))
- end
- end
- if toxic
- PBDebug.log("[Status change] #{pbThis} was badly poisoned]")
- else
- PBDebug.log("[Status change] #{pbThis} was poisoned")
- end
- if attacker && self.index!=attacker.index &&
- self.hasWorkingAbility(:SYNCHRONIZE)
- if attacker.pbCanPoisonSynchronize?(self)
- PBDebug.log("[Ability triggered] #{self.pbThis}'s Synchronize")
- attacker.pbPoison(nil,_INTL("{2} di {1} ha avvelenato {3}!",self.pbThis,
- PBAbilities.getName(self.ability),attacker.pbThis(true)),toxic)
- end
- end
- end
- #===============================================================================
- # Burn
- #===============================================================================
- def pbCanBurn?(attacker,showMessages,move=nil)
- return false if isFainted?
- if self.status==PBStatuses::BURN
- @battle.pbDisplay(_INTL("{1} ha già una scottatura.",pbThis)) if showMessages
- return false
- end
- if self.status!=0 ||
- (@effects[PBEffects::Substitute]>0 && (!move || !move.ignoresSubstitute?(attacker)))
- @battle.pbDisplay(_INTL("Ma fallisce!")) if showMessages
- return false
- end
- if @battle.field.effects[PBEffects::MistyTerrain]>0 &&
- !self.isAirborne?(attacker && attacker.hasMoldBreaker)
- @battle.pbDisplay(_INTL("Il campo nebbioso ha impedito a {1} di scottarsi!",pbThis(true))) if showMessages
- return false
- end
- if pbHasType?(:FIRE) && !hasWorkingItem(:RINGTARGET)
- @battle.pbDisplay(_INTL("Non ha effetto su {1}...",pbThis(true))) if showMessages
- return false
- end
- if !attacker || !attacker.hasMoldBreaker
- if hasWorkingAbility(:WATERVEIL) ||
- (hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)) ||
- (hasWorkingAbility(:LEAFGUARD) && (@battle.pbWeather==PBWeather::SUNNYDAY ||
- @battle.pbWeather==PBWeather::HARSHSUN))
- @battle.pbDisplay(_INTL("{2} di {1} impedisce la scottatura!",pbThis,PBAbilities.getName(self.ability))) if showMessages
- return false
- end
- if pbPartner.hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)
- abilityname=PBAbilities.getName(pbPartner.ability)
- @battle.pbDisplay(_INTL("{2} del partner di {1} impedisce la scottatura!",pbThis,abilityname)) if showMessages
- return false
- end
- end
- if pbOwnSide.effects[PBEffects::Safeguard]>0 &&
- (!attacker || !attacker.hasWorkingAbility(:INFILTRATOR))
- @battle.pbDisplay(_INTL("Il team di {1} è protetto da Salvaguardia!",pbThis)) if showMessages
- return false
- end
- return true
- end
- def pbCanBurnSynchronize?(opponent)
- return false if isFainted?
- return false if self.status!=0
- if pbHasType?(:FIRE) && !hasWorkingItem(:RINGTARGET)
- @battle.pbDisplay(_INTL("{2} di {1} non ha avuto effetto su {3}!",
- opponent.pbThis,PBAbilities.getName(opponent.ability),pbThis(true)))
- return false
- end
- if hasWorkingAbility(:WATERVEIL) ||
- (hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)) ||
- (hasWorkingAbility(:LEAFGUARD) && (@battle.pbWeather==PBWeather::SUNNYDAY ||
- @battle.pbWeather==PBWeather::HARSHSUN))
- @battle.pbDisplay(_INTL("{2} di {1} impedisce a {4} di {3} di funzionare!",
- pbThis,PBAbilities.getName(self.ability),
- opponent.pbThis(true),PBAbilities.getName(opponent.ability)))
- return false
- end
- if pbPartner.hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)
- @battle.pbDisplay(_INTL("{2} di {1} impedisce a {4} di {3} di funzionare!",
- pbPartner.pbThis,PBAbilities.getName(pbPartner.ability),
- opponent.pbThis(true),PBAbilities.getName(opponent.ability)))
- return false
- end
- return true
- end
- def pbBurn(attacker,msg=nil)
- self.status=PBStatuses::BURN
- self.statusCount=0
- @battle.pbCommonAnimation("Burn",self,nil)
- if msg && msg!=""
- @battle.pbDisplay(msg)
- else
- @battle.pbDisplay(_INTL("{1} si è scottato!",pbThis))
- end
- PBDebug.log("[Status change] #{pbThis} was burned")
- if attacker && self.index!=attacker.index &&
- self.hasWorkingAbility(:SYNCHRONIZE)
- if attacker.pbCanBurnSynchronize?(self)
- PBDebug.log("[Ability triggered] #{self.pbThis}'s Synchronize")
- attacker.pbBurn(nil,_INTL("{2} di {1} ha scottato {3}!",self.pbThis,
- PBAbilities.getName(self.ability),attacker.pbThis(true)))
- end
- end
- end
- #===============================================================================
- # Paralyze
- #===============================================================================
- def pbCanParalyze?(attacker,showMessages,move=nil)
- return false if isFainted?
- if status==PBStatuses::PARALYSIS
- @battle.pbDisplay(_INTL("{1} è già paralizzato!",pbThis)) if showMessages
- return false
- end
- if self.status!=0 ||
- (@effects[PBEffects::Substitute]>0 && (!move || !move.ignoresSubstitute?(attacker)))
- @battle.pbDisplay(_INTL("Ma fallisce!")) if showMessages
- return false
- end
- if @battle.field.effects[PBEffects::MistyTerrain]>0 &&
- !self.isAirborne?(attacker && attacker.hasMoldBreaker)
- @battle.pbDisplay(_INTL("Il campo nebbioso impedisce la paralisi di {1}!",pbThis(true))) if showMessages
- return false
- end
- if pbHasType?(:ELECTRIC) && !hasWorkingItem(:RINGTARGET) && USENEWBATTLEMECHANICS
- @battle.pbDisplay(_INTL("Non ha effetto su {1}...",pbThis(true))) if showMessages
- return false
- end
- if !attacker || !attacker.hasMoldBreaker
- if hasWorkingAbility(:LIMBER) ||
- (hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)) ||
- (hasWorkingAbility(:LEAFGUARD) && (@battle.pbWeather==PBWeather::SUNNYDAY ||
- @battle.pbWeather==PBWeather::HARSHSUN))
- @battle.pbDisplay(_INTL("{2} di {1} impedisce la paralisi!",pbThis,PBAbilities.getName(self.ability))) if showMessages
- return false
- end
- if pbPartner.hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)
- abilityname=PBAbilities.getName(pbPartner.ability)
- @battle.pbDisplay(_INTL("{2} del partner di {1} impedisce la paralisi!",pbThis,abilityname)) if showMessages
- return false
- end
- end
- if pbOwnSide.effects[PBEffects::Safeguard]>0 &&
- (!attacker || !attacker.hasWorkingAbility(:INFILTRATOR))
- @battle.pbDisplay(_INTL("Il team di {1} è protetto da Salvaguardia!",pbThis)) if showMessages
- return false
- end
- return true
- end
- def pbCanParalyzeSynchronize?(opponent)
- return false if self.status!=0
- return false if @battle.field.effects[PBEffects::MistyTerrain]>0 && !self.isAirborne?
- return false if pbHasType?(:ELECTRIC) && !hasWorkingItem(:RINGTARGET) && USENEWBATTLEMECHANICS
- if hasWorkingAbility(:LIMBER) ||
- (hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)) ||
- (hasWorkingAbility(:LEAFGUARD) && (@battle.pbWeather==PBWeather::SUNNYDAY ||
- @battle.pbWeather==PBWeather::HARSHSUN))
- @battle.pbDisplay(_INTL("{2} di {1} impedisce a {4} di {3} di funzionare!",
- pbThis,PBAbilities.getName(self.ability),
- opponent.pbThis(true),PBAbilities.getName(opponent.ability)))
- return false
- end
- if pbPartner.hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)
- @battle.pbDisplay(_INTL("{2} di {1} impedisce a {4} di {3} di funzionare!",
- pbPartner.pbThis,PBAbilities.getName(pbPartner.ability),
- opponent.pbThis(true),PBAbilities.getName(opponent.ability)))
- return false
- end
- return true
- end
- def pbParalyze(attacker,msg=nil)
- self.status=PBStatuses::PARALYSIS
- self.statusCount=0
- @battle.pbCommonAnimation("Paralysis",self,nil)
- if msg && msg!=""
- @battle.pbDisplay(msg)
- else
- @battle.pbDisplay(_INTL("{1} è paralizzato! Forse non riuscirà ad attaccare!",pbThis))
- end
- PBDebug.log("[Status change] #{pbThis} was paralyzed")
- if attacker && self.index!=attacker.index &&
- self.hasWorkingAbility(:SYNCHRONIZE)
- if attacker.pbCanParalyzeSynchronize?(self)
- PBDebug.log("[Ability triggered] #{self.pbThis}'s Synchronize")
- attacker.pbParalyze(nil,_INTL("{2} di {1} ha paralizzato {3}! Forse non riuscirà ad attaccare!",
- self.pbThis,PBAbilities.getName(self.ability),attacker.pbThis(true)))
- end
- end
- end
- #===============================================================================
- # Freeze
- #===============================================================================
- def pbCanFreeze?(attacker,showMessages,move=nil)
- return false if isFainted?
- if status==PBStatuses::FROZEN
- @battle.pbDisplay(_INTL("{1} è già congelato!",pbThis)) if showMessages
- return false
- end
- if self.status!=0 ||
- (@effects[PBEffects::Substitute]>0 && (!move || !move.ignoresSubstitute?(attacker))) ||
- @battle.pbWeather==PBWeather::SUNNYDAY ||
- @battle.pbWeather==PBWeather::HARSHSUN
- @battle.pbDisplay(_INTL("Ma fallisce!")) if showMessages
- return false
- end
- if pbHasType?(:ICE) && !hasWorkingItem(:RINGTARGET)
- @battle.pbDisplay(_INTL("Non ha effetto su {1}...",pbThis(true))) if showMessages
- return false
- end
- if @battle.field.effects[PBEffects::MistyTerrain]>0 &&
- !self.isAirborne?(attacker && attacker.hasMoldBreaker)
- @battle.pbDisplay(_INTL("Il campo nebbioso ha impedito a {1} di congelarsi!",pbThis(true))) if showMessages
- return false
- end
- if !attacker || !attacker.hasMoldBreaker
- if hasWorkingAbility(:MAGMAARMOR) ||
- (hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)) ||
- (hasWorkingAbility(:LEAFGUARD) && (@battle.pbWeather==PBWeather::SUNNYDAY ||
- @battle.pbWeather==PBWeather::HARSHSUN))
- @battle.pbDisplay(_INTL("{2} di {1} impedisce il congelamento!",pbThis,PBAbilities.getName(self.ability))) if showMessages
- return false
- end
- if pbPartner.hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)
- abilityname=PBAbilities.getName(pbPartner.ability)
- @battle.pbDisplay(_INTL("{2} del partner di {1} impedisce il congelamento!",pbThis,abilityname)) if showMessages
- return false
- end
- end
- if pbOwnSide.effects[PBEffects::Safeguard]>0 &&
- (!attacker || !attacker.hasWorkingAbility(:INFILTRATOR))
- @battle.pbDisplay(_INTL("Il team di {1} è protetto da Salvaguardia!",pbThis)) if showMessages
- return false
- end
- return true
- end
- def pbFreeze(msg=nil)
- self.status=PBStatuses::FROZEN
- self.statusCount=0
- pbCancelMoves
- @battle.pbCommonAnimation("Frozen",self,nil)
- if msg && msg!=""
- @battle.pbDisplay(msg)
- else
- @battle.pbDisplay(_INTL("{1} è stato congelato!",pbThis))
- end
- PBDebug.log("[Status change] #{pbThis} was frozen")
- end
- #===============================================================================
- # Generalised status displays
- #===============================================================================
- def pbContinueStatus(showAnim=true)
- case self.status
- when PBStatuses::SLEEP
- @battle.pbCommonAnimation("Sleep",self,nil)
- @battle.pbDisplay(_INTL("{1} è addormentato.",pbThis))
- when PBStatuses::POISON
- @battle.pbCommonAnimation("Poison",self,nil)
- @battle.pbDisplay(_INTL("{1} è stato danneggiato dal veleno!",pbThis))
- when PBStatuses::BURN
- @battle.pbCommonAnimation("Burn",self,nil)
- @battle.pbDisplay(_INTL("{1} è stato danneggiato dalla scottatura!",pbThis))
- when PBStatuses::PARALYSIS
- @battle.pbCommonAnimation("Paralysis",self,nil)
- @battle.pbDisplay(_INTL("{1} è paralizzato! Non può agire!",pbThis))
- when PBStatuses::FROZEN
- @battle.pbCommonAnimation("Frozen",self,nil)
- @battle.pbDisplay(_INTL("{1} è congelato!",pbThis))
- end
- end
- def pbCureStatus(showMessages=true)
- oldstatus=self.status
- self.status=0
- self.statusCount=0
- if showMessages
- case oldstatus
- when PBStatuses::SLEEP
- @battle.pbDisplay(_INTL("{1} si è svegliato!",pbThis))
- when PBStatuses::POISON
- when PBStatuses::BURN
- when PBStatuses::PARALYSIS
- @battle.pbDisplay(_INTL("La paralisi di {1} è stata curata.",pbThis))
- when PBStatuses::FROZEN
- @battle.pbDisplay(_INTL("{1} si è scongelato!",pbThis))
- end
- end
- PBDebug.log("[Status change] #{pbThis}'s status was cured")
- end
- #===============================================================================
- # Confuse
- #===============================================================================
- def pbCanConfuse?(attacker=nil,showMessages=true,move=nil)
- return false if isFainted?
- if effects[PBEffects::Confusion]>0
- @battle.pbDisplay(_INTL("{1} è già confuso!",pbThis)) if showMessages
- return false
- end
- if @effects[PBEffects::Substitute]>0 && (!move || !move.ignoresSubstitute?(attacker))
- @battle.pbDisplay(_INTL("Ma fallisce!")) if showMessages
- return false
- end
- if !attacker || !attacker.hasMoldBreaker
- if hasWorkingAbility(:OWNTEMPO)
- @battle.pbDisplay(_INTL("{2} di {1} impedisce la confusione!",pbThis,PBAbilities.getName(self.ability))) if showMessages
- return false
- end
- end
- if pbOwnSide.effects[PBEffects::Safeguard]>0 &&
- (!attacker || !attacker.hasWorkingAbility(:INFILTRATOR))
- @battle.pbDisplay(_INTL("Il team di {1} è protetto da Salvaguardia!",pbThis)) if showMessages
- return false
- end
- return true
- end
- def pbCanConfuseSelf?(showMessages)
- return false if isFainted?
- if effects[PBEffects::Confusion]>0
- @battle.pbDisplay(_INTL("{1} è già confuso!",pbThis)) if showMessages
- return false
- end
- if hasWorkingAbility(:OWNTEMPO)
- @battle.pbDisplay(_INTL("{2} di {1} impedisce la confusione!",pbThis,PBAbilities.getName(self.ability))) if showMessages
- return false
- end
- return true
- end
- def pbConfuse
- @effects[PBEffects::Confusion]=2+@battle.pbRandom(4)
- @battle.pbCommonAnimation("Confusion",self,nil)
- PBDebug.log("[Lingering effect triggered] #{pbThis} became confused (#{@effects[PBEffects::Confusion]} turns)")
- end
- def pbConfuseSelf
- if pbCanConfuseSelf?(false)
- @effects[PBEffects::Confusion]=2+@battle.pbRandom(4)
- @battle.pbCommonAnimation("Confusion",self,nil)
- @battle.pbDisplay(_INTL("{1} è confuso!",pbThis))
- PBDebug.log("[Lingering effect triggered] #{pbThis} became confused (#{@effects[PBEffects::Confusion]} turns)")
- end
- end
- def pbContinueConfusion
- @battle.pbCommonAnimation("Confusion",self,nil)
- @battle.pbDisplayBrief(_INTL("{1} è confuso!",pbThis))
- end
- def pbCureConfusion(showMessages=true)
- @effects[PBEffects::Confusion]=0
- @battle.pbDisplay(_INTL("{1} non è più confuso!",pbThis)) if showMessages
- PBDebug.log("[End of effect] #{pbThis} was cured of confusion")
- end
- #===============================================================================
- # Attraction
- #===============================================================================
- def pbCanAttract?(attacker,showMessages=true)
- return false if isFainted?
- return false if !attacker || attacker.isFainted?
- if @effects[PBEffects::Attract]>=0
- @battle.pbDisplay(_INTL("Ma fallisce!")) if showMessages
- return false
- end
- agender=attacker.gender
- ogender=self.gender
- if agender==2 || ogender==2 || agender==ogender
- @battle.pbDisplay(_INTL("Ma fallisce!")) if showMessages
- return false
- end
- if (!attacker || !attacker.hasMoldBreaker) && hasWorkingAbility(:OBLIVIOUS)
- @battle.pbDisplay(_INTL("{2} di {1} impedisce l'infatuazione!",pbThis,
- PBAbilities.getName(self.ability))) if showMessages
- return false
- end
- return true
- end
- def pbAttract(attacker,msg=nil)
- @effects[PBEffects::Attract]=attacker.index
- @battle.pbCommonAnimation("Attract",self,nil)
- if msg && msg!=""
- @battle.pbDisplay(msg)
- else
- @battle.pbDisplay(_INTL("{1} si è innamorato!",pbThis))
- end
- PBDebug.log("[Lingering effect triggered] #{pbThis} became infatuated (with #{attacker.pbThis(true)})")
- if self.hasWorkingItem(:DESTINYKNOT) &&
- attacker.pbCanAttract?(self,false)
- PBDebug.log("[Item triggered] #{pbThis}'s Destiny Knot")
- attacker.pbAttract(self,_INTL("{1}'s {2} made {3} fall in love!",pbThis,
- PBItems.getName(self.item),attacker.pbThis(true)))
- end
- end
- def pbAnnounceAttract(seducer)
- @battle.pbCommonAnimation("Attract",self,nil)
- @battle.pbDisplayBrief(_INTL("{1} è innamorato di {2}!",
- pbThis,seducer.pbThis(true)))
- end
- def pbContinueAttract
- @battle.pbDisplay(_INTL("{1} è innamorato! Non può attaccare!",pbThis))
- end
- def pbCureAttract
- @effects[PBEffects::Attract]=-1
- PBDebug.log("[End of effect] #{pbThis} was cured of infatuation")
- end
- #===============================================================================
- # Flinching
- #===============================================================================
- def pbFlinch(attacker)
- return false if (!attacker || !attacker.hasMoldBreaker) && hasWorkingAbility(:INNERFOCUS)
- @effects[PBEffects::Flinch]=true
- return true
- end
- #===============================================================================
- # Increase stat stages
- #===============================================================================
- def pbTooHigh?(stat)
- return @stages[stat]>=6
- end
- def pbCanIncreaseStatStage?(stat,attacker=nil,showMessages=false,move=nil,moldbreaker=false,ignoreContrary=false)
- if !moldbreaker
- if !attacker || attacker.index==self.index || !attacker.hasMoldBreaker
- if hasWorkingAbility(:CONTRARY) && !ignoreContrary
- return pbCanReduceStatStage?(stat,attacker,showMessages,moldbreaker,true)
- end
- end
- end
- return false if isFainted?
- if pbTooHigh?(stat)
- @battle.pbDisplay(_INTL("{2} di {1} non può aumentare!",
- pbThis,PBStats.getName(stat))) if showMessages
- return false
- end
- return true
- end
- def pbIncreaseStatBasic(stat,increment,attacker=nil,moldbreaker=false,ignoreContrary=false)
- if !moldbreaker
- if !attacker || attacker.index==self.index || !attacker.hasMoldBreaker
- if hasWorkingAbility(:CONTRARY) && !ignoreContrary
- return pbReduceStatBasic(stat,increment,attacker,moldbreaker,true)
- end
- increment*=2 if hasWorkingAbility(:SIMPLE)
- end
- end
- increment=[increment,6-@stages[stat]].min
- PBDebug.log("[Stat change] #{pbThis}'s #{PBStats.getName(stat)} rose by #{increment} stage(s) (was #{@stages[stat]}, now #{@stages[stat]+increment})")
- @stages[stat]+=increment
- return increment
- end
- def pbIncreaseStat(stat,increment,attacker,showMessages,move=nil,upanim=true,moldbreaker=false,ignoreContrary=false)
- if !moldbreaker
- if !attacker || attacker.index==self.index || !attacker.hasMoldBreaker
- if hasWorkingAbility(:CONTRARY) && !ignoreContrary
- return pbReduceStat(stat,increment,attacker,showMessages,move,upanim,moldbreaker,true)
- end
- end
- end
- return false if stat!=PBStats::ATTACK && stat!=PBStats::DEFENSE &&
- stat!=PBStats::SPATK && stat!=PBStats::SPDEF &&
- stat!=PBStats::SPEED && stat!=PBStats::EVASION &&
- stat!=PBStats::ACCURACY
- if pbCanIncreaseStatStage?(stat,attacker,showMessages,move,moldbreaker,ignoreContrary)
- increment=pbIncreaseStatBasic(stat,increment,attacker,moldbreaker,ignoreContrary)
- if increment>0
- if ignoreContrary
- @battle.pbDisplay(_INTL("{2} di {1} attivato!",pbThis,PBAbilities.getName(self.ability))) if upanim
- end
- @battle.pbCommonAnimation("StatUp",self,nil) if upanim
- arrStatTexts=[_INTL("{2} di {1} aumenta!",pbThis,PBStats.getName(stat)),
- _INTL("{2} di {1} aumenta velocemente!",pbThis,PBStats.getName(stat)),
- _INTL("{2} di {1} aumenta drasticamente!",pbThis,PBStats.getName(stat))]
- @battle.pbDisplay(arrStatTexts[[increment-1,2].min])
- return true
- end
- end
- return false
- end
- def pbIncreaseStatWithCause(stat,increment,attacker,cause,showanim=true,showmessage=true,moldbreaker=false,ignoreContrary=false)
- if !moldbreaker
- if !attacker || attacker.index==self.index || !attacker.hasMoldBreaker
- if hasWorkingAbility(:CONTRARY) && !ignoreContrary
- return pbReduceStatWithCause(stat,increment,attacker,cause,showanim,showmessage,moldbreaker,true)
- end
- end
- end
- return false if stat!=PBStats::ATTACK && stat!=PBStats::DEFENSE &&
- stat!=PBStats::SPATK && stat!=PBStats::SPDEF &&
- stat!=PBStats::SPEED && stat!=PBStats::EVASION &&
- stat!=PBStats::ACCURACY
- if pbCanIncreaseStatStage?(stat,attacker,false,nil,moldbreaker,ignoreContrary)
- increment=pbIncreaseStatBasic(stat,increment,attacker,moldbreaker,ignoreContrary)
- if increment>0
- if ignoreContrary
- @battle.pbDisplay(_INTL("{2} di {1} attivato!",pbThis,PBAbilities.getName(self.ability))) if upanim
- end
- @battle.pbCommonAnimation("StatUp",self,nil) if showanim
- if attacker.index==self.index
- arrStatTexts=[_INTL("{2} di {1} ha aumentato {3}!",pbThis,cause,PBStats.getName(stat)),
- _INTL("{2} di {1} ha aumentato {3} velocemente!",pbThis,cause,PBStats.getName(stat)),
- _INTL("{2} di {1} aumenta a vista d'occhio!",pbThis,PBStats.getName(stat))]
- else
- arrStatTexts=[_INTL("{2} di {1} ha aumentato {4} di {3}!",attacker.pbThis,cause,pbThis(true),PBStats.getName(stat)),
- _INTL("{2} di {1} ha aumentato velocemente {4} di {3}!",attacker.pbThis,cause,pbThis(true),PBStats.getName(stat)),
- _INTL("{2} di {1} ha aumentato drasticamente {4} di {3}!",attacker.pbThis,cause,pbThis(true),PBStats.getName(stat))]
- end
- @battle.pbDisplay(arrStatTexts[[increment-1,2].min]) if showmessage
- return true
- end
- end
- return false
- end
- #===============================================================================
- # Decrease stat stages
- #===============================================================================
- def pbTooLow?(stat)
- return @stages[stat]<=-6
- end
- # Tickle (04A) and Noble Roar (13A) can't use this, but replicate it instead.
- # (Reason is they lowers more than 1 stat independently, and therefore could
- # show certain messages twice which is undesirable.)
- def pbCanReduceStatStage?(stat,attacker=nil,showMessages=false,move=nil,moldbreaker=false,ignoreContrary=false)
- if !moldbreaker
- if !attacker || attacker.index==self.index || !attacker.hasMoldBreaker
- if hasWorkingAbility(:CONTRARY) && !ignoreContrary
- return pbCanIncreaseStatStage?(stat,attacker,showMessages,move,moldbreaker,true)
- end
- end
- end
- return false if isFainted?
- selfreduce=(attacker && attacker.index==self.index)
- if !selfreduce
- if @effects[PBEffects::Substitute]>0 && (!move || !move.ignoresSubstitute?(attacker))
- @battle.pbDisplay(_INTL("Ma fallisce!")) if showMessages
- return false
- end
- if pbOwnSide.effects[PBEffects::Mist]>0 &&
- (!attacker || !attacker.hasWorkingAbility(:INFILTRATOR))
- @battle.pbDisplay(_INTL("{1} è protetto dalla Nebbia!",pbThis)) if showMessages
- return false
- end
- if !moldbreaker && (!attacker || !attacker.hasMoldBreaker)
- if hasWorkingAbility(:CLEARBODY) || hasWorkingAbility(:WHITESMOKE)
- abilityname=PBAbilities.getName(self.ability)
- @battle.pbDisplay(_INTL("{2} di {1} impedisce l'abbassamento di statistiche!",pbThis,abilityname)) if showMessages
- return false
- end
- if pbHasType?(:GRASS)
- if hasWorkingAbility(:FLOWERVEIL)
- abilityname=PBAbilities.getName(self.ability)
- @battle.pbDisplay(_INTL("{2} di {1} impedisce l'abbassamento di statistiche!",pbThis,abilityname)) if showMessages
- return false
- elsif pbPartner.hasWorkingAbility(:FLOWERVEIL)
- abilityname=PBAbilities.getName(pbPartner.ability)
- @battle.pbDisplay(_INTL("{2} di {1} impedisce a {3} l'abbassamento di statistiche!",pbPartner.pbThis,abilityname,pbThis(true))) if showMessages
- return false
- end
- end
- if stat==PBStats::ATTACK && hasWorkingAbility(:HYPERCUTTER)
- abilityname=PBAbilities.getName(self.ability)
- @battle.pbDisplay(_INTL("{2} di {1} impedisce la perdita di Attacco",pbThis,abilityname)) if showMessages
- return false
- end
- if stat==PBStats::DEFENSE && hasWorkingAbility(:BIGPECKS)
- abilityname=PBAbilities.getName(self.ability)
- @battle.pbDisplay(_INTL("{2} di {1} impedisce la perdita di Difesa!",pbThis,abilityname)) if showMessages
- return false
- end
- if stat==PBStats::ACCURACY && hasWorkingAbility(:KEENEYE)
- abilityname=PBAbilities.getName(self.ability)
- @battle.pbDisplay(_INTL("{2} di {1} impedisce la perdita di precisione!",pbThis,abilityname)) if showMessages
- return false
- end
- end
- end
- if pbTooLow?(stat)
- @battle.pbDisplay(_INTL("{2} di {1} non può scendere oltre!",
- pbThis,PBStats.getName(stat))) if showMessages
- return false
- end
- return true
- end
- def pbReduceStatBasic(stat,increment,attacker=nil,moldbreaker=false,ignoreContrary=false)
- if !moldbreaker # moldbreaker is true only when Roar forces out a Pokémon into Sticky Web
- if !attacker || attacker.index==self.index || !attacker.hasMoldBreaker
- if hasWorkingAbility(:CONTRARY) && !ignoreContrary
- return pbIncreaseStatBasic(stat,increment,attacker,moldbreaker,true)
- end
- increment*=2 if hasWorkingAbility(:SIMPLE)
- end
- end
- increment=[increment,6+@stages[stat]].min
- PBDebug.log("[Stat change] #{pbThis}'s #{PBStats.getName(stat)} fell by #{increment} stage(s) (was #{@stages[stat]}, now #{@stages[stat]-increment})")
- @stages[stat]-=increment
- return increment
- end
- def pbReduceStat(stat,increment,attacker,showMessages,move=nil,downanim=true,moldbreaker=false,ignoreContrary=false)
- if !moldbreaker
- if !attacker || attacker.index==self.index || !attacker.hasMoldBreaker
- if hasWorkingAbility(:CONTRARY) && !ignoreContrary
- return pbIncreaseStat(stat,increment,attacker,showMessages,move,downanim,moldbreaker,true)
- end
- end
- end
- return false if stat!=PBStats::ATTACK && stat!=PBStats::DEFENSE &&
- stat!=PBStats::SPATK && stat!=PBStats::SPDEF &&
- stat!=PBStats::SPEED && stat!=PBStats::EVASION &&
- stat!=PBStats::ACCURACY
- if pbCanReduceStatStage?(stat,attacker,showMessages,move,moldbreaker,ignoreContrary)
- increment=pbReduceStatBasic(stat,increment,attacker,moldbreaker,ignoreContrary)
- if increment>0
- if ignoreContrary
- @battle.pbDisplay(_INTL("{2} di {1} attivato!",pbThis,PBAbilities.getName(self.ability))) if downanim
- end
- @battle.pbCommonAnimation("StatDown",self,nil) if downanim
- arrStatTexts=[_INTL("{2} di {1} cala!",pbThis,PBStats.getName(stat)),
- _INTL("{2} di {1} cala parecchio!",pbThis,PBStats.getName(stat)),
- _INTL("{2} di {1} cala a picco!",pbThis,PBStats.getName(stat))]
- @battle.pbDisplay(arrStatTexts[[increment-1,2].min])
- # Defiant
- if hasWorkingAbility(:DEFIANT) && (!attacker || attacker.pbIsOpposing?(self.index))
- pbIncreaseStatWithCause(PBStats::ATTACK,2,self,PBAbilities.getName(self.ability))
- end
- # Competitive
- if hasWorkingAbility(:COMPETITIVE) && (!attacker || attacker.pbIsOpposing?(self.index))
- pbIncreaseStatWithCause(PBStats::SPATK,2,self,PBAbilities.getName(self.ability))
- end
- return true
- end
- end
- return false
- end
- def pbReduceStatWithCause(stat,increment,attacker,cause,showanim=true,showmessage=true,moldbreaker=false,ignoreContrary=false)
- if !moldbreaker
- if !attacker || attacker.index==self.index || !attacker.hasMoldBreaker
- if hasWorkingAbility(:CONTRARY) && !ignoreContrary
- return pbIncreaseStatWithCause(stat,increment,attacker,cause,showanim,showmessage,moldbreaker,true)
- end
- end
- end
- return false if stat!=PBStats::ATTACK && stat!=PBStats::DEFENSE &&
- stat!=PBStats::SPATK && stat!=PBStats::SPDEF &&
- stat!=PBStats::SPEED && stat!=PBStats::EVASION &&
- stat!=PBStats::ACCURACY
- if pbCanReduceStatStage?(stat,attacker,false,nil,moldbreaker,ignoreContrary)
- increment=pbReduceStatBasic(stat,increment,attacker,moldbreaker,ignoreContrary)
- if increment>0
- if ignoreContrary
- @battle.pbDisplay(_INTL("{2} di {1} attivato!",pbThis,PBAbilities.getName(self.ability))) if downanim
- end
- @battle.pbCommonAnimation("StatDown",self,nil) if showanim
- if attacker.index==self.index
- arrStatTexts=[_INTL("{2} di {1} ha ridotto {3}!",pbThis,cause,PBStats.getName(stat)),
- _INTL("{2} di {1} ha ridotto di molto {3}!",pbThis,cause,PBStats.getName(stat)),
- _INTL("{2} di {1} ha ridotto di parecchio {3}!",pbThis,PBStats.getName(stat))]
- else
- arrStatTexts=[_INTL("{2} di {1} ha ridotto {4} di {3}!",attacker.pbThis,cause,pbThis(true),PBStats.getName(stat)),
- _INTL("{2} di {1} ha ridotto di molto {4} di {3}!",attacker.pbThis,cause,pbThis(true),PBStats.getName(stat)),
- _INTL("{2} di {1} ha ridotto di parecchio {4} di {3}!",attacker.pbThis,cause,pbThis(true),PBStats.getName(stat))]
- end
- @battle.pbDisplay(arrStatTexts[[increment-1,2].min]) if showmessage
- # Defiant
- if hasWorkingAbility(:DEFIANT) && (!attacker || attacker.pbIsOpposing?(self.index))
- pbIncreaseStatWithCause(PBStats::ATTACK,2,self,PBAbilities.getName(self.ability))
- end
- # Competitive
- if hasWorkingAbility(:COMPETITIVE) && (!attacker || attacker.pbIsOpposing?(self.index))
- pbIncreaseStatWithCause(PBStats::SPATK,2,self,PBAbilities.getName(self.ability))
- end
- return true
- end
- end
- return false
- end
- def pbReduceAttackStatIntimidate(opponent)
- return false if isFainted?
- if effects[PBEffects::Substitute]>0
- @battle.pbDisplay(_INTL("Il sostituto di {1} lo ha protetto da {3} di {2}!",
- pbThis,opponent.pbThis(true),PBAbilities.getName(opponent.ability)))
- return false
- end
- if !opponent.hasWorkingAbility(:CONTRARY)
- if pbOwnSide.effects[PBEffects::Mist]>0
- @battle.pbDisplay(_INTL("{1} è protetto da {3} di {2} dalla Nebbia!",
- pbThis,opponent.pbThis(true),PBAbilities.getName(opponent.ability)))
- return false
- end
- if hasWorkingAbility(:CLEARBODY) || hasWorkingAbility(:WHITESMOKE) ||
- hasWorkingAbility(:HYPERCUTTER) ||
- (hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS))
- abilityname=PBAbilities.getName(self.ability)
- oppabilityname=PBAbilities.getName(opponent.ability)
- @battle.pbDisplay(_INTL("{2} di {1} ha impedito a {4} di {3} di funzionare!",
- pbThis,abilityname,opponent.pbThis(true),oppabilityname))
- return false
- end
- if pbPartner.hasWorkingAbility(:FLOWERVEIL) && pbHasType?(:GRASS)
- abilityname=PBAbilities.getName(pbPartner.ability)
- oppabilityname=PBAbilities.getName(opponent.ability)
- @battle.pbDisplay(_INTL("{2} di {1} ha impedito a {4} di {3} di funzionare!",
- pbPartner.pbThis,abilityname,opponent.pbThis(true),oppabilityname))
- return false
- end
- end
- return pbReduceStatWithCause(PBStats::ATTACK,1,opponent,PBAbilities.getName(opponent.ability))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement