Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PBTargets
- SingleNonUser = 0x00
- NoTarget = 0x01
- RandomOpposing = 0x02
- AllOpposing = 0x04
- AllNonUsers = 0x08
- User = 0x10
- UserSide = 0x20
- BothSides = 0x40
- OpposingSide = 0x80
- Partner = 0x100
- UserOrPartner = 0x200
- SingleOpposing = 0x400
- OppositeOpposing = 0x800
- end
- class PokeBattle_Move
- attr_accessor(:id)
- attr_reader(:battle)
- attr_reader(:name)
- attr_reader(:function)
- attr_reader(:basedamage)
- attr_reader(:type)
- attr_reader(:accuracy)
- attr_reader(:addlEffect)
- attr_reader(:target)
- attr_reader(:priority)
- attr_reader(:flags)
- attr_reader(:thismove)
- attr_accessor(:pp)
- attr_accessor(:totalpp)
- NOTYPE = 0x01
- IGNOREPKMNTYPES = 0x02
- NOWEIGHTING = 0x04
- NOCRITICAL = 0x08
- NOREFLECT = 0x10
- SELFCONFUSE = 0x20
- ################################################################################
- # Creating a move
- ################################################################################
- def initialize(battle,move)
- @id = move.id
- @battle = battle
- @name = PBMoves.getName(id) # Get the move's name
- # Get data on the move
- movedata = PBMoveData.new(id)
- @function = movedata.function
- @basedamage = movedata.basedamage
- @type = movedata.type
- @accuracy = movedata.accuracy
- @addlEffect = movedata.addlEffect
- @target = movedata.target
- @priority = movedata.priority
- @flags = movedata.flags
- @category = movedata.category
- @thismove = move
- @pp = move.pp # Can be changed with Mimic/Transform
- end
- # This is the code actually used to generate a PokeBattle_Move object. The
- # object generated is a subclass of this one which depends on the move's
- # function code (found in the script section PokeBattle_MoveEffect).
- def PokeBattle_Move.pbFromPBMove(battle,move)
- move=PBMove.new(0) if !move
- movedata=PBMoveData.new(move.id)
- className=sprintf("PokeBattle_Move_%03X",movedata.function)
- if Object.const_defined?(className)
- return Kernel.const_get(className).new(battle,move)
- else
- return PokeBattle_UnimplementedMove.new(battle,move)
- end
- end
- ################################################################################
- # About the move
- ################################################################################
- def totalpp
- return @totalpp if @totalpp && @totalpp>0
- return @thismove.totalpp if @thismove
- end
- def to_int
- return @id
- end
- def pbType(type,attacker,opponent)
- if type>=0 && isConst?(attacker.ability,PBAbilities,:NORMALIZE)
- type=getConst(PBTypes,:NORMAL) || 0
- end
- return type
- end
- def pbIsPhysical?(type,attacker=nil)
- if USEMOVECATEGORY
- return @category==0
- else
- return !PBTypes.isSpecialType?(type)
- end
- end
- def pbIsSpecial?(type,attacker=nil)
- if USEMOVECATEGORY
- return @category==1
- else
- return PBTypes.isSpecialType?(type)
- end
- end
- def pbTargetsAll?(attacker)
- if @target==PBTargets::AllOpposing # All opposing Pokémon
- # TODO: should apply even if partner faints during an attack
- return attacker.pbOpposing1.hp>0 && attacker.pbOpposing2.hp>0
- end
- return false
- end
- def pbNumHits
- return 1
- end
- def pbIsMultiHit # not the same as pbNumHits>1
- return false
- end
- def pbTwoTurnAttack(attacker)
- return false
- end
- def pbAdditionalEffect(attacker,opponent)
- end
- ################################################################################
- # This move's type effectiveness
- ################################################################################
- def pbTypeModifier(type,attacker,opponent)
- return 4 if type<0
- return 4 if isConst?(type,PBTypes,:GROUND) && opponent.pbHasType?(:FLYING) &&
- isConst?(opponent.item,PBItems,:IRONBALL)
- atype=type # attack type
- otype1=opponent.type1
- otype2=opponent.type2
- if isConst?(otype1,PBTypes,:FLYING) && opponent.effects[PBEffects::Roost]
- if isConst?(otype2,PBTypes,:FLYING)
- otype1=getConst(PBTypes,:NORMAL) || 0
- else
- otype1=otype2
- end
- end
- if isConst?(otype2,PBTypes,:FLYING) && opponent.effects[PBEffects::Roost]
- otype2=otype1
- end
- mod1=PBTypes.getEffectiveness(atype,otype1)
- mod2=(otype1==otype2) ? 2 : PBTypes.getEffectiveness(atype,otype2)
- if isConst?(opponent.item,PBItems,:RINGTARGET)
- mod1=2 if mod1==0
- mod2=2 if mod2==0
- end
- if isConst?(attacker.ability,PBAbilities,:SCRAPPY) ||
- opponent.effects[PBEffects::Foresight]
- mod1=2 if isConst?(otype1,PBTypes,:GHOST) &&
- (isConst?(atype,PBTypes,:NORMAL) || isConst?(atype,PBTypes,:FIGHTING))
- mod2=2 if isConst?(otype2,PBTypes,:GHOST) &&
- (isConst?(atype,PBTypes,:NORMAL) || isConst?(atype,PBTypes,:FIGHTING))
- end
- if opponent.effects[PBEffects::Ingrain] ||
- opponent.effects[PBEffects::SmackDown] ||
- attacker.pbOwnSide.effects[PBEffects::Gravity]>0 ||
- attacker.pbOpposingSide.effects[PBEffects::Gravity]>0
- mod1=2 if isConst?(otype1,PBTypes,:FLYING) && isConst?(atype,PBTypes,:GROUND)
- mod2=2 if isConst?(otype2,PBTypes,:FLYING) && isConst?(atype,PBTypes,:GROUND)
- end
- if opponent.effects[PBEffects::MiracleEye]
- mod1=2 if isConst?(otype1,PBTypes,:DARK) && isConst?(atype,PBTypes,:PSYCHIC)
- mod2=2 if isConst?(otype2,PBTypes,:DARK) && isConst?(atype,PBTypes,:PSYCHIC)
- end
- return mod1*mod2
- end
- def pbTypeModMessages(type,attacker,opponent)
- return 4 if type<0
- if opponent.hp>0
- if isConst?(opponent.ability,PBAbilities,:FLASHFIRE) &&
- isConst?(type,PBTypes,:FIRE)
- if !opponent.effects[PBEffects::FlashFire]
- opponent.effects[PBEffects::FlashFire]=true
- @battle.pbDisplay(_INTL("{1}'s {2} raised its FIRE power!",
- opponent.pbThis,PBAbilities.getName(opponent.ability)))
- else
- @battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",
- opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))
- end
- return 0
- end
- if (isConst?(opponent.ability,PBAbilities,:STORMDRAIN) && isConst?(type,PBTypes,:WATER)) ||
- (isConst?(opponent.ability,PBAbilities,:LIGHTNINGROD) && isConst?(type,PBTypes,:ELECTRIC))
- if opponent.pbCanIncreaseStatStage?(PBStats::SPATK)
- opponent.pbIncreaseStatBasic(PBStats::SPATK,1)
- @battle.pbCommonAnimation("StatUp",opponent,nil)
- @battle.pbDisplay(_INTL("{1}'s {2} raised its SP. ATTACK!",
- opponent.pbThis,PBAbilities.getName(opponent.ability)))
- else
- @battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",
- opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))
- end
- return 0
- end
- if isConst?(opponent.ability,PBAbilities,:MOTORDRIVE) &&
- isConst?(type,PBTypes,:ELECTRIC)
- if opponent.pbCanIncreaseStatStage?(PBStats::SPEED)
- opponent.pbIncreaseStatBasic(PBStats::SPEED,1)
- @battle.pbCommonAnimation("StatUp",opponent,nil)
- @battle.pbDisplay(_INTL("{1}'s {2} raised its SPEED!",
- opponent.pbThis,PBAbilities.getName(opponent.ability)))
- else
- @battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",
- opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))
- end
- return 0
- end
- if isConst?(opponent.ability,PBAbilities,:SAPSIPPER) &&
- isConst?(type,PBTypes,:GRASS)
- if opponent.pbCanIncreaseStatStage?(PBStats::ATTACK)
- opponent.pbIncreaseStatBasic(PBStats::ATTACK,1)
- @battle.pbCommonAnimation("StatUp",opponent,nil)
- @battle.pbDisplay(_INTL("{1}'s {2} raised its ATTACK!",
- opponent.pbThis,PBAbilities.getName(opponent.ability)))
- else
- @battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",
- opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))
- end
- return 0
- end
- if (isConst?(opponent.ability,PBAbilities,:DRYSKIN) && isConst?(type,PBTypes,:WATER)) ||
- (isConst?(opponent.ability,PBAbilities,:VOLTABSORB) && isConst?(type,PBTypes,:ELECTRIC)) ||
- (isConst?(opponent.ability,PBAbilities,:WATERABSORB) && isConst?(type,PBTypes,:WATER))
- if opponent.effects[PBEffects::HealBlock]==0
- if opponent.pbRecoverHP((opponent.totalhp/4).floor,true)==0
- @battle.pbDisplay(_INTL("{1}'s {2} made {3} useless!",
- opponent.pbThis,PBAbilities.getName(opponent.ability),@name))
- else
- @battle.pbDisplay(_INTL("{1}'s {2} restored its HP!",
- opponent.pbThis,PBAbilities.getName(opponent.ability)))
- end
- return 0
- end
- end
- end
- typemod=pbTypeModifier(type,attacker,opponent)
- if typemod==0
- @battle.pbDisplay(_INTL("It doesn't affect {1}...",opponent.pbThis(true)))
- end
- return typemod
- end
- ################################################################################
- # This move's accuracy check
- ################################################################################
- def pbAccuracyCheck(attacker,opponent)
- baseaccuracy=@accuracy
- return true if baseaccuracy==0
- return true if isConst?(attacker.ability,PBAbilities,:NOGUARD) ||
- isConst?(opponent.ability,PBAbilities,:NOGUARD)
- return true if opponent.effects[PBEffects::Telekinesis]>0
- # One-hit KO accuracy handled elsewhere
- if @function==0x08 || @function==0x15 # Thunder or Hurricane
- baseaccuracy=50 if @battle.pbWeather==PBWeather::SUNNYDAY
- baseaccuracy=100 if @battle.pbWeather==PBWeather::RAINDANCE
- end
- if @function==0x0D # Blizzard
- baseaccuracy=100 if @battle.pbWeather==PBWeather::HAIL
- end
- accstage=attacker.stages[PBStats::ACCURACY]
- accstage=0 if isConst?(opponent.ability,PBAbilities,:UNAWARE)
- accuracy=(accstage>=0) ? (accstage+3)*100.0/3 : 300.0/(3-accstage)
- evastage=opponent.stages[PBStats::EVASION]
- evastage-=2 if attacker.pbOwnSide.effects[PBEffects::Gravity]>0 ||
- attacker.pbOpposingSide.effects[PBEffects::Gravity]>0
- evastage=-6 if evastage<-6
- evastage=0 if opponent.effects[PBEffects::Foresight] ||
- opponent.effects[PBEffects::MiracleEye] ||
- @function==0xA9 || # Chip Away
- isConst?(attacker.ability,PBAbilities,:UNAWARE)
- evasion=(evastage>=0) ? (evastage+3)*100.0/3 : 300.0/(3-evastage)
- if isConst?(attacker.ability,PBAbilities,:COMPOUNDEYES)
- accuracy*=1.3
- end
- if isConst?(attacker.item,PBItems,:MICLEBERRY)
- if (isConst?(attacker.ability,PBAbilities,:GLUTTONY) && attacker.hp<=(attacker.totalhp/2).floor) ||
- attacker.hp<=(attacker.totalhp/4).floor
- accuracy*=1.2
- attacker.pokemon.itemRecycle=attacker.item
- attacker.pokemon.itemInitial=0 if attacker.pokemon.itemInitial==attacker.item
- attacker.item=0
- end
- end
- if isConst?(attacker.ability,PBAbilities,:VICTORYSTAR)
- accuracy*=1.1
- end
- partner=attacker.pbPartner
- if partner && isConst?(partner.ability,PBAbilities,:VICTORYSTAR)
- accuracy*=1.1
- end
- if isConst?(attacker.item,PBItems,:WIDELENS)
- accuracy*=1.1
- end
- if isConst?(attacker.ability,PBAbilities,:HUSTLE) && @basedamage>0 &&
- pbIsPhysical?(pbType(@type,attacker=nil,opponent))
- accuracy*=0.8
- end
- if isConst?(opponent.ability,PBAbilities,:WONDERSKIN) && @basedamage==0 &&
- attacker.pbIsOpposing?(opponent.index)
- accuracy/=2
- end
- if isConst?(opponent.ability,PBAbilities,:TANGLEDFEET) &&
- opponent.effects[PBEffects::Confusion]>0
- evasion*=1.2
- end
- if @battle.pbWeather==PBWeather::SANDSTORM && isConst?(opponent.ability,PBAbilities,:SANDVEIL)
- evasion*=1.2
- end
- if @battle.pbWeather==PBWeather::HAIL && isConst?(opponent.ability,PBAbilities,:SNOWCLOAK)
- evasion*=1.2
- end
- if isConst?(opponent.item,PBItems,:BRIGHTPOWDER)
- evasion*=1.1
- end
- if isConst?(opponent.item,PBItems,:LAXINCENSE)
- evasion*=1.1
- end
- return @battle.pbRandom(100)<(baseaccuracy*accuracy/evasion)
- end
- ################################################################################
- # Damage calculation and modifiers
- ################################################################################
- def pbIsCritical?(attacker,opponent)
- if isConst?(opponent.ability,PBAbilities,:BATTLEARMOR) ||
- isConst?(opponent.ability,PBAbilities,:SHELLARMOR)
- return false
- end
- return false if opponent.pbOwnSide.effects[PBEffects::LuckyChant]>0
- return true if @function==0xA0 # Frost Breath
- c=0
- ratios=[16,8,4,3,2]
- c+=attacker.effects[PBEffects::FocusEnergy]
- c+=1 if (@flags&0x80)!=0 # flag h: Has high critical hit rate
- if (attacker.inHyperMode? rescue false) && isConst?(self.type,PBTypes,:SHADOW)
- c+=1
- end
- if isConst?(attacker.species,PBSpecies,:CHANSEY) &&
- isConst?(attacker.item,PBItems,:LUCKYPUNCH)
- c+=2
- end
- if isConst?(attacker.species,PBSpecies,:FARFETCHD) &&
- isConst?(attacker.item,PBItems,:STICK)
- c+=2
- end
- c+=1 if isConst?(attacker.ability,PBAbilities,:SUPERLUCK)
- c+=1 if isConst?(attacker.item,PBItems,:SCOPELENS)
- c+=1 if isConst?(attacker.item,PBItems,:RAZORCLAW)
- c=4 if c>4
- return @battle.pbRandom(ratios[c])==0
- end
- def pbBaseDamage(basedmg,attacker,opponent)
- return basedmg
- end
- def pbCalcDamage(attacker,opponent,options=0)
- opponent.damagestate.critical=false
- opponent.damagestate.typemod=0
- opponent.damagestate.calcdamage=0
- opponent.damagestate.hplost=0
- return 0 if @basedamage==0
- if (options&NOCRITICAL)==0
- opponent.damagestate.critical=pbIsCritical?(attacker,opponent)
- end
- stagemul=[10,10,10,10,10,10,10,15,20,25,30,35,40]
- stagediv=[40,35,30,25,20,15,10,10,10,10,10,10,10]
- basedmg=@basedamage
- basedmg=pbBaseDamage(basedmg,attacker,opponent)
- if (options&NOTYPE)==0
- type=pbType(@type,attacker,opponent)
- else
- type=-1 # Will be treated as physical
- end
- atk=attacker.attack
- defense=opponent.defense
- spatk=attacker.spatk
- spdef=opponent.spdef
- # Gym Badges (internal battles only)
- if @battle.internalbattle
- if @battle.pbOwnedByPlayer?(attacker.index)
- atk=(atk*1.1).floor if @battle.pbPlayer.numbadges>=BADGESBOOSTATTACK
- end
- if @battle.pbOwnedByPlayer?(opponent.index)
- defense=(defense*1.1).floor if @battle.pbPlayer.numbadges>=BADGESBOOSTDEFENSE
- end
- if @battle.pbOwnedByPlayer?(attacker.index)
- spatk=(spatk*1.1).floor if @battle.pbPlayer.numbadges>=BADGESBOOSTSPATK
- end
- if @battle.pbOwnedByPlayer?(opponent.index)
- spdef=(spdef*1.1).floor if @battle.pbPlayer.numbadges>=BADGESBOOSTSPDEF
- end
- end
- #Stat Stages
- atkstage=attacker.stages[PBStats::ATTACK]+6
- spatkstage=attacker.stages[PBStats::SPATK]+6
- defstage=opponent.stages[PBStats::DEFENSE]+6
- spdefstage=opponent.stages[PBStats::SPDEF]+6
- defstage=spdefstage=6 if @function==0xA9 # Chip Away
- if isConst?(attacker.ability,PBAbilities,:UNAWARE)
- defstage=spdefstage=6
- end
- if isConst?(opponent.ability,PBAbilities,:UNAWARE)
- atkstage=spatkstage=6
- end
- if opponent.damagestate.critical
- atkstage=6 if atkstage<6
- spatkstage=6 if spatkstage<6
- defstage=6 if defstage>6
- spdefstage=6 if spdefstage>6
- end
- atk=(atk*stagemul[atkstage]/stagediv[atkstage]).floor
- spatk=(spatk*stagemul[spatkstage]/stagediv[spatkstage]).floor
- defense=(defense*stagemul[defstage]/stagediv[defstage]).floor
- spdef=(spdef*stagemul[spdefstage]/stagediv[spdefstage]).floor
- # Helping Hand
- if attacker.effects[PBEffects::HelpingHand] && (options&SELFCONFUSE)==0
- basedmg=(basedmg*1.5).floor
- end
- if isConst?(attacker.ability,PBAbilities,:TECHNICIAN) && basedmg<=60
- basedmg=(basedmg*1.5).floor
- end
- if isConst?(opponent.ability,PBAbilities,:MARVELSCALE) && opponent.status>0
- defense=(defense*1.5).floor
- end
- if opponent.pbHasType?(:ROCK) && @battle.pbWeather==PBWeather::SANDSTORM
- spdef=(spdef*1.5).floor
- end
- if isConst?(opponent.item,PBItems,:EVIOLITE)
- evos=pbGetEvolvedFormData(opponent.species)
- if evos && evos.length>0
- defense=(defense*1.5).floor
- spdef=(spdef*1.5).floor
- end
- end
- # Type boosting items
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:SILKSCARF) && isConst?(type,PBTypes,:NORMAL)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:BLACKBELT) && isConst?(type,PBTypes,:FIGHTING)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:SHARPBEAK) && isConst?(type,PBTypes,:FLYING)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:POISONBARB) && isConst?(type,PBTypes,:POISON)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:SOFTSAND) && isConst?(type,PBTypes,:GROUND)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:HARDSTONE) && isConst?(type,PBTypes,:ROCK)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:SILVERPOWDER) && isConst?(type,PBTypes,:BUG)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:SPELLTAG) && isConst?(type,PBTypes,:GHOST)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:METALCOAT) && isConst?(type,PBTypes,:STEEL)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:CHARCOAL) && isConst?(type,PBTypes,:FIRE)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:MYSTICWATER) && isConst?(type,PBTypes,:WATER)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:MIRACLESEED) && isConst?(type,PBTypes,:GRASS)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:MAGNET) && isConst?(type,PBTypes,:ELECTRIC)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:TWISTEDSPOON) && isConst?(type,PBTypes,:PSYCHIC)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:NEVERMELTICE) && isConst?(type,PBTypes,:ICE)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:DRAGONFANG) && isConst?(type,PBTypes,:DRAGON)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:BLACKGLASSES) && isConst?(type,PBTypes,:DARK)
- # Plates
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:FISTPLATE) && isConst?(type,PBTypes,:FIGHTING)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:SKYPLATE) && isConst?(type,PBTypes,:FLYING)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:TOXICPLATE) && isConst?(type,PBTypes,:POISON)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:EARTHPLATE) && isConst?(type,PBTypes,:GROUND)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:STONEPLATE) && isConst?(type,PBTypes,:ROCK)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:INSECTPLATE) && isConst?(type,PBTypes,:BUG)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:SPOOKYPLATE) && isConst?(type,PBTypes,:GHOST)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:IRONPLATE) && isConst?(type,PBTypes,:STEEL)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:FLAMEPLATE) && isConst?(type,PBTypes,:FIRE)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:SPLASHPLATE) && isConst?(type,PBTypes,:WATER)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:MEADOWPLATE) && isConst?(type,PBTypes,:GRASS)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:ZAPPLATE) && isConst?(type,PBTypes,:ELECTRIC)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:MINDPLATE) && isConst?(type,PBTypes,:PSYCHIC)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:ICICLEPLATE) && isConst?(type,PBTypes,:ICE)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:DRACOPLATE) && isConst?(type,PBTypes,:DRAGON)
- basedmg=(basedmg*1.2).floor if isConst?(attacker.item,PBItems,:DREADPLATE) && isConst?(type,PBTypes,:DARK)
- # Gems
- if (isConst?(attacker.item,PBItems,:NORMALGEM) && isConst?(type,PBTypes,:NORMAL)) ||
- (isConst?(attacker.item,PBItems,:FIGHTINGGEM) && isConst?(type,PBTypes,:FIGHTING)) ||
- (isConst?(attacker.item,PBItems,:FLYINGGEM) && isConst?(type,PBTypes,:FLYING)) ||
- (isConst?(attacker.item,PBItems,:POISONGEM) && isConst?(type,PBTypes,:POISON)) ||
- (isConst?(attacker.item,PBItems,:GROUNDGEM) && isConst?(type,PBTypes,:GROUND)) ||
- (isConst?(attacker.item,PBItems,:ROCKGEM) && isConst?(type,PBTypes,:ROCK)) ||
- (isConst?(attacker.item,PBItems,:BUGGEM) && isConst?(type,PBTypes,:BUG)) ||
- (isConst?(attacker.item,PBItems,:GHOSTGEM) && isConst?(type,PBTypes,:GHOST)) ||
- (isConst?(attacker.item,PBItems,:STEELGEM) && isConst?(type,PBTypes,:STEEL)) ||
- (isConst?(attacker.item,PBItems,:FIREGEM) && isConst?(type,PBTypes,:FIRE)) ||
- (isConst?(attacker.item,PBItems,:WATERGEM) && isConst?(type,PBTypes,:WATER)) ||
- (isConst?(attacker.item,PBItems,:GRASSGEM) && isConst?(type,PBTypes,:GRASS)) ||
- (isConst?(attacker.item,PBItems,:ELECTRICGEM) && isConst?(type,PBTypes,:ELECTRIC)) ||
- (isConst?(attacker.item,PBItems,:PSYCHICGEM) && isConst?(type,PBTypes,:PSYCHIC)) ||
- (isConst?(attacker.item,PBItems,:ICEGEM) && isConst?(type,PBTypes,:ICE)) ||
- (isConst?(attacker.item,PBItems,:DRAGONGEM) && isConst?(type,PBTypes,:DRAGON)) ||
- (isConst?(attacker.item,PBItems,:DARKGEM) && isConst?(type,PBTypes,:DARK))
- basedmg=(basedmg*1.5).floor
- attacker.pokemon.itemRecycle=attacker.item
- attacker.pokemon.itemInitial=0 if attacker.pokemon.itemInitial==attacker.item
- attacker.item=0
- end
- if isConst?(attacker.item,PBItems,:ROCKINCENSE) && isConst?(type,PBTypes,:ROCK)
- basedmg=(basedmg*1.2).floor
- end
- if isConst?(attacker.item,PBItems,:ROSEINCENSE) && isConst?(type,PBTypes,:GRASS)
- basedmg=(basedmg*1.2).floor
- end
- if isConst?(attacker.item,PBItems,:SEAINCENSE) && isConst?(type,PBTypes,:WATER)
- basedmg=(basedmg*1.2).floor
- end
- if isConst?(attacker.item,PBItems,:WAVEINCENSE) && isConst?(type,PBTypes,:WATER)
- basedmg=(basedmg*1.2).floor
- end
- if isConst?(attacker.item,PBItems,:ODDINCENSE) && isConst?(type,PBTypes,:PSYCHIC)
- basedmg=(basedmg*1.2).floor
- end
- atk=(atk*1.5).floor if isConst?(attacker.item,PBItems,:CHOICEBAND)
- spatk=(spatk*1.5).floor if isConst?(attacker.item,PBItems,:CHOICESPECS)
- if isConst?(attacker.species,PBSpecies,:PIKACHU) && isConst?(attacker.item,PBItems,:LIGHTBALL)
- basedmg*=2
- end
- if (isConst?(attacker.species,PBSpecies,:CUBONE) ||
- isConst?(attacker.species,PBSpecies,:MAROWAK)) &&
- isConst?(attacker.item,PBItems,:THICKCLUB)
- atk*=2
- end
- if isConst?(opponent.species,PBSpecies,:DITTO) && !opponent.effects[PBEffects::Transform] &&
- isConst?(opponent.item,PBItems,:METALPOWDER)
- basedmg/=2
- end
- if isConst?(attacker.species,PBSpecies,:CLAMPERL) &&
- isConst?(attacker.item,PBItems,:DEEPSEATOOTH)
- spatk*=2
- end
- if isConst?(opponent.species,PBSpecies,:CLAMPERL) &&
- isConst?(opponent.item,PBItems,:DEEPSEASCALE)
- spdef*=2
- end
- if (isConst?(attacker.species,PBSpecies,:LATIAS) ||
- isConst?(attacker.species,PBSpecies,:LATIOS)) &&
- isConst?(attacker.item,PBItems,:SOULDEW) && !@battle.rules["souldewclause"]
- spatk*=1.5
- end
- if (isConst?(opponent.species,PBSpecies,:LATIAS) ||
- isConst?(opponent.species,PBSpecies,:LATIOS)) &&
- isConst?(opponent.item,PBItems,:SOULDEW) && !@battle.rules["souldewclause"]
- spdef*=1.5
- end
- if isConst?(attacker.species,PBSpecies,:DIALGA) &&
- isConst?(attacker.item,PBItems,:ADAMANTORB) &&
- (isConst?(type,PBTypes,:DRAGON) || isConst?(type,PBTypes,:STEEL))
- basedmg=(basedmg*1.2).floor
- end
- if isConst?(attacker.species,PBSpecies,:PALKIA) &&
- isConst?(attacker.item,PBItems,:LUSTROUSORB) &&
- (isConst?(type,PBTypes,:DRAGON) || isConst?(type,PBTypes,:WATER))
- basedmg=(basedmg*1.2).floor
- end
- if isConst?(attacker.species,PBSpecies,:GIRATINA) &&
- isConst?(attacker.item,PBItems,:GRISEOUSORB) &&
- (isConst?(type,PBTypes,:DRAGON) || isConst?(type,PBTypes,:GHOST))
- basedmg=(basedmg*1.2).floor
- end
- if isConst?(opponent.ability,PBAbilities,:MULTISCALE) && opponent.hp==opponent.totalhp
- basedmg=(basedmg/2).floor
- end
- if isConst?(attacker.ability,PBAbilities,:HUGEPOWER)
- if isConst?(attacker.pokemon.ability,PBAbilities,:HUGEPOWER)
- atk*=2
- else
- atk=(atk*1.5).floor
- end
- end
- atk*=2 if isConst?(attacker.ability,PBAbilities,:PUREPOWER)
- atk=(atk*1.5).floor if isConst?(attacker.ability,PBAbilities,:HUSTLE)
- if isConst?(attacker.ability,PBAbilities,:GUTS) &&
- (attacker.status==PBStatuses::BURN ||
- attacker.status==PBStatuses::PARALYSIS ||
- attacker.status==PBStatuses::POISON)
- atk=(atk*1.5).floor
- end
- if (isConst?(attacker.ability,PBAbilities,:PLUS) ||
- isConst?(attacker.ability,PBAbilities,:MINUS))
- partner=attacker.pbPartner
- if partner && (isConst?(partner.ability,PBAbilities,:PLUS) ||
- isConst?(partner.ability,PBAbilities,:MINUS))
- spatk=(spatk*1.5).floor
- end
- end
- if isConst?(attacker.ability,PBAbilities,:FLASHFIRE) &&
- attacker.effects[PBEffects::FlashFire] && isConst?(type,PBTypes,:FIRE)
- basedmg=(basedmg*1.5).floor
- end
- if isConst?(opponent.ability,PBAbilities,:DRYSKIN) && isConst?(type,PBTypes,:FIRE)
- basedmg=(basedmg*1.25).floor
- end
- if isConst?(attacker.ability,PBAbilities,:RIVALRY) &&
- attacker.gender!=2 && opponent.gender!=2
- if attacker.gender==opponent.gender
- basedmg=(basedmg*1.25).floor
- else
- basedmg=(basedmg*0.75).floor
- end
- end
- if isConst?(attacker.ability,PBAbilities,:IRONFIST) &&
- (@flags&0x200)!=0 # flag j: Is punching move
- basedmg=(basedmg*1.2).floor
- end
- if isConst?(attacker.ability,PBAbilities,:RECKLESS)
- if @function==0xFA || # Take Down, etc.
- @function==0xFB || # Double-Edge, etc.
- @function==0xFC || # Head Smash
- @function==0xFD || # Volt Tackle
- @function==0xFE || # Flare Blitz
- @function==0x10B || # Jump Kick, Hi Jump Kick
- @function==0x130 # Shadow End
- basedmg=(basedmg*1.2).floor
- end
- end
- if isConst?(attacker.ability,PBAbilities,:SLOWSTART) && attacker.turncount<5
- atk=(atk/2).floor
- end
- if @battle.pbWeather==PBWeather::SUNNYDAY
- if isConst?(attacker.ability,PBAbilities,:SOLARPOWER)
- spatk=(spatk*1.5).floor
- end
- if isConst?(attacker.ability,PBAbilities,:FLOWERGIFT) ||
- isConst?(attacker.pbPartner.ability,PBAbilities,:FLOWERGIFT)
- atk=(atk*1.5).floor
- end
- if isConst?(opponent.ability,PBAbilities,:FLOWERGIFT) ||
- isConst?(opponent.pbPartner.ability,PBAbilities,:FLOWERGIFT)
- spdef=(spdef*1.5).floor
- end
- end
- if @battle.pbWeather==PBWeather::SANDSTORM
- if isConst?(attacker.ability,PBAbilities,:SANDFORCE) &&
- (isConst?(type,PBTypes,:ROCK) || isConst?(type,PBTypes,:GROUND) ||
- isConst?(type,PBTypes,:STEEL))
- basedmg=(basedmg*1.3).floor
- end
- end
- # Burns
- if attacker.status == PBStatuses::BURN &&
- !isConst?(attacker.ability,PBAbilities,:GUTS)
- atk=(atk/2).floor
- end
- if isConst?(attacker.ability,PBAbilities,:TOXICBOOST) && attacker.status==PBStatuses::POISON
- atk=(atk*1.5).floor
- end
- if isConst?(attacker.ability,PBAbilities,:FLAREBOOST) && attacker.status==PBStatuses::BURN
- spatk=(spatk*1.5).floor
- end
- if attacker.hp<=(attacker.totalhp/3).floor
- modbasedmg=(basedmg*1.5).floor
- basedmg=modbasedmg if isConst?(attacker.ability,PBAbilities,:OVERGROW) && isConst?(type,PBTypes,:GRASS)
- basedmg=modbasedmg if isConst?(attacker.ability,PBAbilities,:BLAZE) && isConst?(type,PBTypes,:FIRE)
- basedmg=modbasedmg if isConst?(attacker.ability,PBAbilities,:TORRENT) && isConst?(type,PBTypes,:WATER)
- basedmg=modbasedmg if isConst?(attacker.ability,PBAbilities,:SWARM) && isConst?(type,PBTypes,:BUG)
- end
- if isConst?(attacker.ability,PBAbilities,:DEFEATIST) &&
- attacker.hp<=(attacker.totalhp/2).floor
- atk=(atk/2).floor
- spatk=(spatk/2).floor
- end
- if isConst?(type,PBTypes,:ELECTRIC)
- for i in 0...4
- if @battle.battlers[i].effects[PBEffects::MudSport]
- basedmg=(basedmg/3).floor
- break # Not cumulative
- end
- end
- end
- if isConst?(type,PBTypes,:FIRE)
- for i in 0...4
- if @battle.battlers[i].effects[PBEffects::WaterSport]
- basedmg=(basedmg/3).floor
- break # Not cumulative
- end
- end
- end
- if isConst?(opponent.ability,PBAbilities,:THICKFAT) &&
- (isConst?(type,PBTypes,:ICE) || isConst?(type,PBTypes,:FIRE))
- basedmg=(basedmg/2).floor
- end
- if isConst?(opponent.ability,PBAbilities,:HEATPROOF) && isConst?(type,PBTypes,:FIRE)
- basedmg=(basedmg/2).floor
- end
- if isConst?(opponent.ability,PBAbilities,:TINTEDLENS) &&
- PBTypes.isNotVeryEffective?(type,opponent.type1,opponent.type2)
- basedmg=(basedmg*2)
- end
- if isConst?(opponent.ability,PBAbilities,:SNIPER) && opponent.damagestate.critical
- basedmg=(basedmg*1.5).floor
- end
- #Damage formula
- if type>=0 && pbIsSpecial?(type,attacker=nil)
- atk=spatk
- defense=spdef if @function!=0x122 # Psyshock
- end
- defense=1 if defense<1
- atk=1 if atk<1
- damage=(((2*attacker.level/5+2).floor*atk*basedmg/defense).floor/50).floor
- if pbTargetsAll?(attacker)
- damage=(damage*0.75).floor
- end
- #Weather
- weather=@battle.pbWeather
- if weather==PBWeather::SUNNYDAY
- if isConst?(type,PBTypes,:FIRE)
- damage=(damage*1.5).floor
- elsif isConst?(type,PBTypes,:WATER)
- damage>>=1
- end
- end
- if weather==PBWeather::RAINDANCE
- if isConst?(type,PBTypes,:WATER)
- damage=(damage*1.5).floor
- elsif isConst?(type,PBTypes,:FIRE)
- damage>>=1
- end
- end
- damage+=2
- if (options&IGNOREPKMNTYPES)==0
- #Same Type Attack Bonus
- if attacker.pbHasType?(type)
- if isConst?(attacker.ability,PBAbilities,:ADAPTABILITY)
- damage=(damage*2).floor
- else
- damage=(damage*1.5).floor
- end
- end
- #Type Effectiveness
- typemod=pbTypeModMessages(type,attacker,opponent)
- damage=(damage*typemod/4).floor
- opponent.damagestate.typemod=typemod
- if typemod==0
- opponent.damagestate.calcdamage=0
- opponent.damagestate.critical=false
- return 0
- end
- if typemod>4 # Super-effective
- if (isConst?(opponent.ability,PBAbilities,:SOLIDROCK) ||
- isConst?(opponent.ability,PBAbilities,:FILTER))
- damage=(damage*0.75).floor
- end
- if isConst?(attacker.item,PBItems,:EXPERTBELT)
- damage=(damage*1.2).floor
- end
- if (isConst?(opponent.item,PBItems,:CHOPLEBERRY) && isConst?(type,PBTypes,:FIGHTING)) ||
- (isConst?(opponent.item,PBItems,:COBABERRY) && isConst?(type,PBTypes,:FLYING)) ||
- (isConst?(opponent.item,PBItems,:KEBIABERRY) && isConst?(type,PBTypes,:POISON)) ||
- (isConst?(opponent.item,PBItems,:SHUCABERRY) && isConst?(type,PBTypes,:GROUND)) ||
- (isConst?(opponent.item,PBItems,:CHARTIBERRY) && isConst?(type,PBTypes,:ROCK)) ||
- (isConst?(opponent.item,PBItems,:TANGABERRY) && isConst?(type,PBTypes,:BUG)) ||
- (isConst?(opponent.item,PBItems,:KASIBBERRY) && isConst?(type,PBTypes,:GHOST)) ||
- (isConst?(opponent.item,PBItems,:BABIRIBERRY) && isConst?(type,PBTypes,:STEEL)) ||
- (isConst?(opponent.item,PBItems,:OCCABERRY) && isConst?(type,PBTypes,:FIRE)) ||
- (isConst?(opponent.item,PBItems,:PASSHOBERRY) && isConst?(type,PBTypes,:WATER)) ||
- (isConst?(opponent.item,PBItems,:RINDOBERRY) && isConst?(type,PBTypes,:GRASS)) ||
- (isConst?(opponent.item,PBItems,:WACANBERRY) && isConst?(type,PBTypes,:ELECTRIC)) ||
- (isConst?(opponent.item,PBItems,:PAYAPABERRY) && isConst?(type,PBTypes,:PSYCHIC)) ||
- (isConst?(opponent.item,PBItems,:YACHEBERRY) && isConst?(type,PBTypes,:ICE)) ||
- (isConst?(opponent.item,PBItems,:HABANBERRY) && isConst?(type,PBTypes,:DRAGON)) ||
- (isConst?(opponent.item,PBItems,:COLBURBERRY) && isConst?(type,PBTypes,:DARK))
- damage=(damage/2).floor
- opponent.pokemon.itemRecycle=opponent.item
- opponent.pokemon.itemInitial=0 if opponent.pokemon.itemInitial==opponent.item
- opponent.item=0
- end
- end
- if (isConst?(opponent.item,PBItems,:CHILANBERRY) && isConst?(type,PBTypes,:NORMAL))
- damage=(damage/2).floor
- opponent.pokemon.itemRecycle=opponent.item
- opponent.pokemon.itemInitial=0 if opponent.pokemon.itemInitial==opponent.item
- opponent.item=0
- end
- else
- opponent.damagestate.typemod=4
- end
- if isConst?(attacker.item,PBItems,:MUSCLEBAND) && pbIsPhysical?(type,attacker=nil)
- damage=(damage*1.1).floor
- end
- if isConst?(attacker.item,PBItems,:WISEGLASSES) && pbIsSpecial?(type,attacker=nil)
- damage=(damage*1.1).floor
- end
- damage=pbModifyDamage(damage,attacker,opponent)
- # Charge
- if attacker.effects[PBEffects::Charge]>0 && isConst?(type,PBTypes,:ELECTRIC)
- damage=(damage*2).floor
- end
- if !opponent.damagestate.critical && (options&NOREFLECT)==0 &&
- !isConst?(attacker.ability,PBAbilities,:INFILTRATOR)
- #Reflect
- oppside=opponent.pbOwnSide
- if oppside.effects[PBEffects::Reflect]>0 && pbIsPhysical?(type,attacker=nil)
- # if opponent has a partner [TODO: should apply even if partner faints during an attack]
- if opponent.pbPartner.hp>0
- damage=(damage*2/3).floor
- else
- damage=(damage/2).floor
- end
- end
- #Light Screen
- if oppside.effects[PBEffects::LightScreen]>0 && pbIsSpecial?(type,attacker=nil)
- # if opponent has a partner [TODO: should apply even if partner faints during an attack]
- if opponent.pbPartner.hp>0
- damage=(damage*2/3).floor
- else
- damage=(damage/2).floor
- end
- end
- end
- #Damage weighting
- if (options&NOWEIGHTING)==0
- random=85+@battle.pbRandom(16)
- damage=(damage*random/100).floor
- end
- if opponent.damagestate.critical
- damage*=2
- end
- damage=1 if damage<1
- opponent.damagestate.calcdamage=damage
- return damage
- end
- def pbModifyDamage(damage,attacker,opponent)
- return damage
- end
- def pbReduceHPDamage(damage,attacker,opponent)
- endure=false
- if opponent.effects[PBEffects::Substitute]>0 && (!attacker || attacker.index!=opponent.index)
- damage=opponent.effects[PBEffects::Substitute] if damage>opponent.effects[PBEffects::Substitute]
- opponent.effects[PBEffects::Substitute]-=damage
- opponent.damagestate.substitute=true
- @battle.scene.pbDamageAnimation(opponent,0)
- @battle.pbDisplayPaused(_INTL("The SUBSTITUTE took damage for {1}!",opponent.name))
- if opponent.effects[PBEffects::Substitute]<=0
- opponent.effects[PBEffects::Substitute]=0
- @battle.pbDisplayPaused(_INTL("{1}'s SUBSTITUTE faded!",opponent.name))
- end
- opponent.damagestate.hplost=damage
- damage=0
- else
- if damage>=opponent.hp
- damage=opponent.hp
- if @function==0xE9 # False Swipe
- damage=damage-1
- elsif opponent.effects[PBEffects::Endure]
- damage=damage-1
- opponent.damagestate.endured=true
- elsif isConst?(opponent.ability,PBAbilities,:STURDY) && damage==opponent.totalhp
- opponent.damagestate.sturdy=true
- damage=damage-1
- elsif opponent.damagestate.focussash && damage==opponent.totalhp
- opponent.damagestate.focussashused=true
- damage=damage-1
- opponent.pokemon.itemRecycle=opponent.item
- opponent.pokemon.itemInitial=0 if opponent.pokemon.itemInitial==opponent.item
- opponent.item=0
- elsif opponent.damagestate.focusband
- opponent.damagestate.focusbandused=true
- damage=damage-1
- end
- damage=0 if damage<0
- end
- oldhp=opponent.hp
- opponent.hp-=damage
- effectiveness=0
- if opponent.damagestate.typemod<4
- effectiveness=1 # "Not very effective"
- elsif opponent.damagestate.typemod>4
- effectiveness=2 # "Super effective"
- end
- if opponent.damagestate.typemod!=0
- @battle.scene.pbDamageAnimation(opponent,effectiveness)
- end
- @battle.scene.pbHPChanged(opponent,oldhp)
- opponent.damagestate.hplost=damage
- end
- return damage
- end
- ################################################################################
- # Effects
- ################################################################################
- def pbEffectMessages(attacker,opponent,ignoretype=false)
- if opponent.damagestate.critical
- @battle.pbDisplay(_INTL("A critical hit!"))
- end
- if !pbIsMultiHit
- if opponent.damagestate.typemod>4
- @battle.pbDisplay(_INTL("It's super effective!"))
- elsif opponent.damagestate.typemod>=1 && opponent.damagestate.typemod<4
- @battle.pbDisplay(_INTL("It's not very effective..."))
- end
- end
- if opponent.damagestate.endured
- @battle.pbDisplay(_INTL("{1} endured the hit!",opponent.pbThis))
- elsif opponent.damagestate.sturdy
- @battle.pbDisplay(_INTL("{1} hung on with STURDY!",opponent.pbThis))
- elsif opponent.damagestate.focussashused
- @battle.pbDisplay(_INTL("{1} hung on using its FOCUS SASH!",opponent.pbThis))
- elsif opponent.damagestate.focusbandused
- @battle.pbDisplay(_INTL("{1} hung on using its FOCUS BAND!",opponent.pbThis))
- end
- if opponent.damagestate.hplost>=1 && !opponent.damagestate.substitute
- if !ignoretype
- movetype=pbType(@type,attacker,opponent)
- if isConst?(opponent.ability,PBAbilities,:ANGERPOINT)
- if opponent.pbCanIncreaseStatStage?(PBStats::ATTACK) &&
- opponent.damagestate.critical
- opponent.stages[PBStats::ATTACK]=6
- @battle.pbCommonAnimation("StatUp",opponent,nil)
- @battle.pbDisplay(_INTL("{1}'s {2} maxed its ATTACK!",
- opponent.pbThis,PBAbilities.getName(opponent.ability)))
- end
- end
- if isConst?(opponent.ability,PBAbilities,:JUSTIFIED) &&
- isConst?(movetype,PBTypes,:DARK)
- if opponent.pbCanIncreaseStatStage?(PBStats::ATTACK)
- opponent.pbIncreaseStatBasic(PBStats::ATTACK,1)
- @battle.pbCommonAnimation("StatUp",opponent,nil)
- @battle.pbDisplay(_INTL("{1}'s {2} raised its ATTACK!",
- opponent.pbThis,PBAbilities.getName(opponent.ability)))
- end
- end
- if isConst?(opponent.ability,PBAbilities,:RATTLED) &&
- (isConst?(movetype,PBTypes,:BUG) ||
- isConst?(movetype,PBTypes,:DARK) ||
- isConst?(movetype,PBTypes,:GHOST))
- if opponent.pbCanIncreaseStatStage?(PBStats::SPEED)
- opponent.pbIncreaseStatBasic(PBStats::SPEED,1)
- @battle.pbCommonAnimation("StatUp",opponent,nil)
- @battle.pbDisplay(_INTL("{1}'s {2} raised its SPEED!",
- opponent.pbThis,PBAbilities.getName(opponent.ability)))
- end
- end
- if isConst?(opponent.ability,PBAbilities,:WEAKARMOR) && pbIsPhysical?(type,attacker=nil,movetype)
- if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,false,true)
- opponent.pbReduceStatBasic(PBStats::DEFENSE,1)
- @battle.pbCommonAnimation("StatDown",opponent,nil)
- @battle.pbDisplay(_INTL("{1}'s {2} lowered its DEFENSE!",
- opponent.pbThis,PBAbilities.getName(opponent.ability)))
- end
- if opponent.pbCanIncreaseStatStage?(PBStats::SPEED)
- opponent.pbIncreaseStatBasic(PBStats::SPEED,1)
- @battle.pbCommonAnimation("StatUp",opponent,nil)
- @battle.pbDisplay(_INTL("{1}'s {2} raised its SPEED!",
- opponent.pbThis,PBAbilities.getName(opponent.ability)))
- end
- end
- if isConst?(opponent.item,PBItems,:ABSORBBULB) &&
- isConst?(movetype,PBTypes,:WATER)
- if opponent.pbCanIncreaseStatStage?(PBStats::SPATK)
- opponent.pbIncreaseStatBasic(PBStats::SPATK,1)
- @battle.pbCommonAnimation("StatUp",opponent,nil)
- @battle.pbDisplay(_INTL("{1}'s {2} raised its SP. ATTACK!",
- opponent.pbThis,PBItems.getName(opponent.item)))
- opponent.pokemon.itemRecycle=opponent.item
- opponent.pokemon.itemInitial=0 if opponent.pokemon.itemInitial==opponent.item
- opponent.item=0
- end
- end
- if isConst?(opponent.item,PBItems,:CELLBATTERY) &&
- isConst?(movetype,PBTypes,:ELECTRIC)
- if opponent.pbCanIncreaseStatStage?(PBStats::ATTACK)
- opponent.pbIncreaseStatBasic(PBStats::ATTACK,1)
- @battle.pbCommonAnimation("StatUp",opponent,nil)
- @battle.pbDisplay(_INTL("{1}'s {2} raised its ATTACK!",
- opponent.pbThis,PBItems.getName(opponent.item)))
- opponent.pokemon.itemRecycle=opponent.item
- opponent.pokemon.itemInitial=0 if opponent.pokemon.itemInitial==opponent.item
- opponent.item=0
- end
- end
- end
- if isConst?(opponent.item,PBItems,:AIRBALLOON)
- opponent.pokemon.itemRecycle=opponent.item
- opponent.pokemon.itemInitial=0 if opponent.pokemon.itemInitial==opponent.item
- opponent.item=0
- @battle.pbDisplay(_INTL("{1}'s AIR BALLOON burst!",opponent.pbThis))
- end
- end
- end
- def pbEffectFixedDamage(damage,attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
- type=@type
- type=pbType(type,attacker,opponent)
- typemod=pbTypeModMessages(type,attacker,opponent)
- opponent.damagestate.critical=false
- opponent.damagestate.typemod=0
- opponent.damagestate.calcdamage=0
- opponent.damagestate.hplost=0
- if typemod!=0
- opponent.damagestate.calcdamage=damage
- opponent.damagestate.typemod=4
- pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
- damage=1 if damage<1 # HP reduced can't be less than 1
- damage=pbReduceHPDamage(damage,attacker,opponent)
- pbEffectMessages(attacker,opponent)
- pbOnDamageLost(damage,attacker,opponent)
- return damage
- end
- return 0
- end
- def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
- return 0 if !opponent
- damage=pbCalcDamage(attacker,opponent)
- if opponent.damagestate.typemod!=0
- pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
- end
- damage=pbReduceHPDamage(damage,attacker,opponent)
- pbEffectMessages(attacker,opponent)
- pbOnDamageLost(damage,attacker,opponent)
- return damage # The HP lost by the opponent due to this attack
- end
- ################################################################################
- # Using the move
- ################################################################################
- def pbOnStartUse(attacker)
- return true
- end
- def pbAddTarget(targets,attacker)
- end
- def pbSuccessCheck(attacker,opponent,numtargets)
- end
- def pbDisplayUseMessage(attacker)
- # Return values:
- # -1 if the attack should exit as a failure
- # 1 if the attack should exit as a success
- # 0 if the attack should proceed its effect
- # 2 if Bide is storing energy
- @battle.pbDisplayBrief(_INTL("{1} used {2}!",attacker.pbThis,name))
- return 0
- end
- def pbShowAnimation(id,attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
- return if !showanimation
- @battle.pbAnimation(id,attacker,opponent,hitnum)
- end
- def pbOnDamageLost(damage,attacker,opponent)
- #Used by Counter/Mirror Coat/Revenge/Focus Punch/Bide
- type=@type
- type=pbType(type,attacker,opponent)
- if opponent.effects[PBEffects::Bide]>0
- opponent.effects[PBEffects::BideDamage]+=damage
- opponent.effects[PBEffects::BideTarget]=attacker.index
- end
- if @function==90 # Hidden Power
- type=getConst(PBTypes,:NORMAL) || 0
- end
- if pbIsPhysical?(type,attacker=nil)
- opponent.effects[PBEffects::Counter]=damage
- opponent.effects[PBEffects::CounterTarget]=attacker.index
- end
- if pbIsSpecial?(type,attacker=nil)
- opponent.effects[PBEffects::MirrorCoat]=damage
- opponent.effects[PBEffects::MirrorCoatTarget]=attacker.index
- end
- opponent.lastHPLost=damage # for Revenge/Focus Punch/Metal Burst
- opponent.lastAttacker=attacker.index # for Revenge/Metal Burst
- end
- def pbMoveFailed(attacker,opponent)
- # Called to determine whether the move failed
- return false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement