Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ############[CUSTOM ABILITIES]##################################################
- #===============================================================================
- # General additions for custom abilities.
- #===============================================================================
- # Adds a new ability type that triggers at the beginning of the round.
- module BattleHandlers
- SOREffectAbility = AbilityHandlerHash.new
- def self.triggerSOREffectAbility(ability,battler,battle)
- SOREffectAbility.trigger(ability,battler,battle)
- end
- end
- #===============================================================================
- # Custom Ability #1 - Leeching Fangs
- #===============================================================================
- BattleHandlers::UserAbilityOnHit.add(:LEECHINGFANGS,
- proc { |ability,user,target,move,battle|
- next false if !move.pbContactMove?(user)
- next false if !move.bitingMove?
- changehp=(user.totalhp/16).floor
- changehp*=1.3 if user.hasActiveItem?(:BIGROOT)
- if target.hasActiveAbility?(:LIQUIDOOZE) && target.abilityActive?(true)
- battle.pbShowAbilitySplash(user)
- battle.pbShowAbilitySplash(target)
- user.pbReduceHP(changehp,true)
- if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
- battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!",user.pbThis))
- end
- battle.pbHideAbilitySplash(user)
- battle.pbHideAbilitySplash(target)
- user.pbFaint if user.fainted?
- next
- else
- if user.canHeal?
- battle.pbShowAbilitySplash(user)
- user.pbRecoverHP(changehp,true)
- battle.pbDisplay(_INTL("{1} drained HP with {2}!",user.pbThis,user.abilityName))
- battle.pbHideAbilitySplash(user)
- end
- end
- }
- )
- #===============================================================================
- # Custom Ability #2 - Echo-Lock
- #===============================================================================
- BattleHandlers::AccuracyCalcUserAbility.add(:ECHOLOCK,
- proc { |ability,mods,user,target,move,type|
- mods[BASE_ACC] = 0 if move.soundMove?
- }
- )
- #===============================================================================
- # Custom Ability #3 - Inflatable
- #===============================================================================
- # Added def windMove? in "PokeBattle_Move"
- # Must add "q" flag to all appropriate moves in moves PBS file
- BattleHandlers::MoveImmunityTargetAbility.add(:INFLATABLE,
- proc { |ability,user,target,move,type,battle|
- next false if !move.windMove?
- next false if !target.pbCanRaiseStatStage?(PBStats::DEFENSE,target)
- target.pbRaiseStatStageByAbility(PBStats::DEFENSE,1,target)
- target.effects[PBEffects::WeightChange]+=25
- next true
- }
- )
- #===============================================================================
- # Custom Ability #4 - Wind Rider
- #===============================================================================
- # Added def windMove? in "PokeBattle_Move"
- # Must add "q" flag to all appropriate moves in moves PBS file
- BattleHandlers::MoveImmunityTargetAbility.add(:WINDRIDER,
- proc { |ability,user,target,move,type,battle|
- next false if !move.windMove?
- next false if !target.pbCanRaiseStatStage?(PBStats::SPEED,target)
- target.pbRaiseStatStageByAbility(PBStats::SPEED,1,target)
- target.effects[PBEffects::WeightChange]-=25
- next true
- }
- )
- BattleHandlers::SpeedCalcAbility.add(:WINDRIDER,
- proc { |ability,battler,mult|
- w = battler.battle.pbWeather
- next mult*2 if w==PBWeather::StrongWinds
- }
- )
- #===============================================================================
- # Custom Ability #5 - Cannon Fire
- #===============================================================================
- BattleHandlers::DamageCalcUserAbility.add(:CANNONFIRE,
- proc { |ability,user,target,move,mults,baseDmg,type|
- mults[BASE_DMG_MULT] *= 1.5 if move.bombMove?
- }
- )
- #===============================================================================
- # Custom Ability #6 - Sharpshooter
- #===============================================================================
- # Redirection immunity added to "def pbChangeTargets"
- BattleHandlers::AccuracyCalcUserAbility.add(:SHARPSHOOTER,
- proc { |ability,mods,user,target,move,type|
- mods[BASE_ACC] = 0 if move.damagingMove? && !move.contactMove?
- }
- )
- #===============================================================================
- # Custom Ability #7 - Sharp Edge
- #===============================================================================
- # Added def swordMove? in "PokeBattle_Move"
- # Must add "p" flag to all appropriate moves in moves PBS file
- BattleHandlers::DamageCalcUserAbility.add(:SHARPEDGE,
- proc { |ability,user,target,move,mults,baseDmg,type|
- mults[BASE_DMG_MULT] *= 1.2 if move.swordMove?
- }
- )
- #===============================================================================
- # Custom Ability #8 - Spellcaster
- #===============================================================================
- BattleHandlers::DamageCalcUserAbility.add(:SPELLCASTER,
- proc { |ability,user,target,move,mults,baseDmg,type|
- if (isConst?(move.type,PBTypes,:ICE) ||
- isConst?(move.type,PBTypes,:FIRE) ||
- isConst?(move.type,PBTypes,:ELECTRIC)) && move.specialMove?
- spellmove=true
- end
- mults[BASE_DMG_MULT] *= 1.2 if spellmove
- }
- )
- #===============================================================================
- # Custom Ability #9 - Icy Veins
- #===============================================================================
- # Hail immunity added to "def takesHailDamage?"
- BattleHandlers::DamageCalcUserAbility.add(:ICYVEINS,
- proc { |ability,user,target,move,mults,baseDmg,type|
- if user.battle.pbWeather==PBWeather::Hail &&
- (isConst?(type,PBTypes,:ICE) || isConst?(type,PBTypes,:WATER))
- mults[BASE_DMG_MULT] *= 1.3
- end
- }
- )
- #===============================================================================
- # Custom Ability #10 - Crystallized
- #===============================================================================
- # Damage reduction added to "DamageCalcTargetAbility.copy"
- #===============================================================================
- # Custom Ability #11 - Cold Blooded
- #===============================================================================
- BattleHandlers::DamageCalcTargetAbility.add(:COLDBLOODED,
- proc { |ability,user,target,move,mults,baseDmg,type|
- if isConst?(type,PBTypes,:FIRE)
- mults[BASE_DMG_MULT] *= 0.75
- elsif isConst?(type,PBTypes,:ICE)
- mults[BASE_DMG_MULT] *= 1.25
- end
- }
- )
- BattleHandlers::SpeedCalcAbility.add(:COLDBLOODED,
- proc { |ability,battler,mult|
- w = battler.battle.pbWeather
- next mult/1.5.floor if w==PBWeather::Hail
- next mult*1.5.floor if w==PBWeather::Sun || w==PBWeather::HarshSun
- }
- )
- BattleHandlers::TargetAbilityOnHit.add(:COLDBLOODED,
- proc { |ability,user,target,move,battle|
- if isConst?(move.calcType,PBTypes,:FIRE) &&
- target.pbCanRaiseStatStage?(PBStats::SPEED,target)
- target.pbRaiseStatStageByAbility(PBStats::SPEED,1,target)
- end
- if isConst?(move.calcType,PBTypes,:ICE) &&
- target.pbCanLowerStatStage?(PBStats::SPEED,target)
- target.pbLowerStatStageByAbility(PBStats::SPEED,1,target)
- end
- }
- )
- #===============================================================================
- # Custom Ability #12 - Iron Hide
- #===============================================================================
- BattleHandlers::TargetAbilityOnHit.add(:IRONHIDE,
- proc { |ability,user,target,move,battle|
- next false if !isConst?(move.calcType,PBTypes,:WATER)
- target.pbLowerStatStageByAbility(PBStats::SPEED,1,target)
- }
- )
- BattleHandlers::DamageCalcTargetAbility.add(:IRONHIDE,
- proc { |ability,user,target,move,mults,baseDmg,type|
- mults[FINAL_DMG_MULT] /= 2 if move.contactMove?
- }
- )
- #===============================================================================
- # Custom Ability #13 - Ethereal Body
- #===============================================================================
- BattleHandlers::MoveImmunityTargetAbility.add(:ETHEREALBODY,
- proc { |ability,user,target,move,type,battle|
- next false if !move.pbContactMove?(user)
- battle.pbShowAbilitySplash(target)
- if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
- battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true)))
- else
- battle.pbDisplay(_INTL("{1}'s {2} makes {3} ineffective!",target.pbThis,target.abilityName,move.name))
- end
- battle.pbHideAbilitySplash(target)
- next true
- }
- )
- #===============================================================================
- # Custom Ability #14 - Phantom Image
- #===============================================================================
- BattleHandlers::AccuracyCalcTargetAbility.add(:PHANTOMIMAGE,
- proc { |ability,mods,user,target,move,type|
- if target.speed>=user.speed*2
- mods[EVA_MULT] *= 2
- elsif target.speed>=user.speed*1.5
- mods[EVA_MULT] *= 1.5
- elsif target.speed>=user.speed*1.25
- mods[EVA_MULT] *= 1.25
- end
- }
- )
- #===============================================================================
- # Custom Ability #15 - Patriarchy
- #===============================================================================
- BattleHandlers::DamageCalcUserAbility.add(:PATRIARCHY,
- proc { |ability,user,target,move,mults,baseDmg,type|
- onlymales = true
- user.eachAlly do |b|
- onlymales = false if b.gender==1 || b.gender==2
- end
- mults[BASE_DMG_MULT] *= 1.25 if onlymales
- }
- )
- BattleHandlers::DamageCalcUserAllyAbility.add(:PATRIARCHY,
- proc { |ability,user,target,move,mults,baseDmg,type|
- onlymales = true
- user.eachAlly do |b|
- onlymales = false if b.gender==1 || b.gender==2
- end
- mults[BASE_DMG_MULT] *= 1.25 if onlymales
- }
- )
- #===============================================================================
- # Custom Ability #16 - Matriarchy
- #===============================================================================
- BattleHandlers::DamageCalcUserAbility.add(:MATRIARCHY,
- proc { |ability,user,target,move,mults,baseDmg,type|
- onlyfemales = true
- user.eachAlly do |b|
- onlyfemales = false if b.gender==0 || b.gender==2
- end
- mults[BASE_DMG_MULT] *= 1.25 if onlyfemales
- }
- )
- BattleHandlers::DamageCalcUserAllyAbility.add(:MATRIARCHY,
- proc { |ability,user,target,move,mults,baseDmg,type|
- onlyfemales = true
- user.eachAlly do |b|
- onlyfemales = false if b.gender==0 || b.gender==2
- end
- mults[BASE_DMG_MULT] *= 1.25 if onlyfemales
- }
- )
- #===============================================================================
- # Custom Ability #17 - Underdog
- #===============================================================================
- BattleHandlers::DamageCalcUserAbility.add(:UNDERDOG,
- proc { |ability,user,target,move,mults,baseDmg,type|
- userstage = 0
- targstage = 0
- for i in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPEED,PBStats::SPATK,
- PBStats::SPDEF,PBStats::EVASION,PBStats::ACCURACY]
- if user.stages[i]>0; userstage+=user.stages[i]; end
- if target.stages[i]>0; targstage+=target.stages[i]; end
- end
- bonus = 1
- bonus += 0.5 if targstage>=userstage+6
- bonus += 0.3 if targstage>=userstage+3
- bonus += 0.2 if targstage>=userstage+1
- bonus += 0.5 if target.level>=user.level+10
- bonus += 0.3 if user.hp<=user.totalhp/8 && target.hp>=target.totalhp/2
- bonus += 0.2 if user.status>0 && target.status==0
- mults[BASE_DMG_MULT] *= bonus
- }
- )
- #===============================================================================
- # Custom Ability #18 - Pack Leader
- #===============================================================================
- BattleHandlers::AbilityOnSwitchIn.add(:PACKLEADER,
- proc { |ability,battler,battle|
- next false if battle.pbAbleCount(battler)<4
- next false if battle.pbTeamLengthFromBattlerIndex(battler)<4
- next false if battle.pbParty(battler)[0] != battler.pokemon
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1} leads the pack!",battler.pbThis))
- battle.pbHideAbilitySplash(battler)
- }
- )
- BattleHandlers::DamageCalcUserAbility.add(:PACKLEADER,
- proc { |ability,user,target,move,mults,baseDmg,type|
- next false if user.battle.pbAbleCount(user)<4
- next false if user.battle.pbTeamLengthFromBattlerIndex(user)<4
- next false if user.battle.pbParty(user)[0] != user.pokemon
- mults[BASE_DMG_MULT] *= 1.5
- }
- )
- #===============================================================================
- # Custom Ability #19 - Pounce
- #===============================================================================
- BattleHandlers::PriorityChangeAbility.add(:POUNCE,
- proc { |ability,battler,move,pri|
- next pri+1 if battler.turnCount==1
- }
- )
- #===============================================================================
- # Custom Ability #20 - Nine Lives
- #===============================================================================
- # Damage and life reduction added to "def pbReduceDamage"
- # Survival message added to "def pbEndureKOMessage"
- # Life counter reset added to "def pbEndOfBattle"
- # Destiny Bond survival added to "def pbEffectsAfterMove"
- # Perish Song survival added to "def pbEndOfRoundPhase"
- # OHKO survival added to "class PokeBattle_Move_070"
- BattleHandlers::AbilityOnSwitchIn.add(:NINELIVES,
- proc { |ability,battler,battle|
- if battler.lives>0
- battle.pbShowAbilitySplash(battler)
- text="life" if battler.lives==1
- text="lives" if battler.lives>1
- battle.pbDisplay(_INTL("{1} has {2} {3} to spare!",battler.pbThis,battler.lives,text))
- battle.pbHideAbilitySplash(battler)
- end
- }
- )
- class PokeBattle_Pokemon
- attr_accessor :ninelives
- def lives
- return @ninelives || 9
- end
- def lives=(value)
- @ninelives=value
- end
- end
- class PokeBattle_Battler
- def lives; return @pokemon ? @pokemon.lives : 0; end
- end
- #===============================================================================
- # Custom Ability #21 - Bad Blood
- #===============================================================================
- BattleHandlers::AbilityOnSwitchIn.add(:BADBLOOD,
- proc { |ability,battler,battle|
- battle.eachBattler do |b|
- next if !b.hasActiveAbility?(:BADBLOOD)
- next if b.species == battler.species
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1} became enraged at the presence of a rival!",
- battler.pbThis,b.pbThis(true)))
- battle.pbHideAbilitySplash(battler)
- break
- end
- }
- )
- BattleHandlers::TrappingTargetAbility.add(:BADBLOOD,
- proc { |ability,switcher,bearer,battle|
- next true if switcher.hasActiveAbility(:BADBLOOD) &&
- switcher.species != bearer.species
- }
- )
- BattleHandlers::EOREffectAbility.add(:BADBLOOD,
- proc { |ability,battler,battle|
- feuds = 0
- battle.eachBattler do |b|
- next if b.index == battler.index
- next if b.species == battler.species
- next if !b.hasActiveAbility?(:BADBLOOD)
- feuds +=1
- end
- if feuds>0 && battler.pbCanRaiseStatStage?(PBStats::ATTACK,battler)
- battler.pbRaiseStatStageByAbility(PBStats::ATTACK,feuds,battler)
- end
- }
- )
- #===============================================================================
- # Custom Ability #22 - Wild Tantrum
- #===============================================================================
- BattleHandlers::AbilityOnSwitchIn.add(:WILDTANTRUM,
- proc { |ability,battler,battle|
- battle.pbShowAbilitySplash(battler)
- battler.effects[PBEffects::Rage] = true
- battle.pbDisplay(_INTL("{1}'s rage is out of control!",battler.pbThis))
- battle.pbHideAbilitySplash(battler)
- }
- )
- #===============================================================================
- # Custom Ability #23 - Headache
- #===============================================================================
- BattleHandlers::EOREffectAbility.add(:HEADACHE,
- proc { |ability,battler,battle|
- next if battler.effects[PBEffects::Confusion]==0
- if battler.pbCanRaiseStatStage?(PBStats::SPATK,battler)
- battler.pbRaiseStatStageByAbility(PBStats::SPATK,1,battler)
- end
- }
- )
- #===============================================================================
- # Custom Ability #24 - Numbing Poison
- #===============================================================================
- # Paralysis effects added to "class PokeBattle_PoisonMove"
- #===============================================================================
- # Custom Ability #25 - Searing Poison
- #===============================================================================
- # Burn effects added to "class PokeBattle_PoisonMove"
- #===============================================================================
- # Custom Ability #26 - Outbreak
- #===============================================================================
- BattleHandlers::TargetAbilityOnHit.add(:OUTBREAK,
- proc { |ability,user,target,move,battle|
- next false if !move.pbContactMove?(user)
- next false if user.status!=0
- next false if target.status==0 || target.asleep? || target.frozen?
- battle.pbShowAbilitySplash(target)
- msg = nil
- if target.poisoned?
- if user.pbCanPoison?(target,PokeBattle_SceneConstants::USE_ABILITY_SPLASH) &&
- user.affectedByContactEffect?(PokeBattle_SceneConstants::USE_ABILITY_SPLASH)
- msg = _INTL("{1}'s {2} spread its poison to {3}!",target.pbThis,target.abilityName,user.pbThis(true))
- user.pbPoison(target,msg)
- end
- elsif target.burned?
- if user.pbCanBurn?(target,PokeBattle_SceneConstants::USE_ABILITY_SPLASH) &&
- user.affectedByContactEffect?(PokeBattle_SceneConstants::USE_ABILITY_SPLASH)
- msg = _INTL("{1}'s {2} spread its burn to {3}!",target.pbThis,target.abilityName,user.pbThis(true))
- user.pbBurn(target,msg)
- end
- elsif target.paralyzed?
- if user.pbCanParalyze?(target,PokeBattle_SceneConstants::USE_ABILITY_SPLASH) &&
- user.affectedByContactEffect?(PokeBattle_SceneConstants::USE_ABILITY_SPLASH)
- msg = _INTL("{1}'s {2} spread its paralysis to {3}!",target.pbThis,target.abilityName,user.pbThis(true))
- user.pbParalyze(target,msg)
- end
- end
- battle.pbHideAbilitySplash(target)
- }
- )
- #===============================================================================
- # Custom Ability #27 - Sweet Dreams
- #===============================================================================
- BattleHandlers::EOREffectAbility.add(:SWEETDREAMS,
- proc { |ability,battler,battle|
- battle.eachBattler do |b|
- next if !b.asleep?
- next if !b.canHeal?
- next if !(b.near?(battler) || b.index == battler.index)
- battle.pbShowAbilitySplash(battler)
- b.pbRecoverHP(b.totalhp/8,true)
- if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
- battle.pbDisplay(_INTL("{1} is having a sweet dream!",b.pbThis))
- else
- battle.pbDisplay(_INTL("{1} is soothed by {2}'s {3}!",b.pbThis,
- battler.pbThis(true),battler.abilityName))
- end
- battle.pbHideAbilitySplash(battler)
- end
- }
- )
- #===============================================================================
- # Custom Ability #28 - Night Terrors
- #===============================================================================
- BattleHandlers::EOREffectAbility.add(:NIGHTTERRORS,
- proc { |ability,battler,battle|
- bearer = battle.pbCheckGlobalAbility(:SWEETDREAMS)
- next false if !battler.asleep?
- next false if bearer && bearer.near?(battler)
- battle.pbShowAbilitySplash(battler)
- if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
- battle.pbDisplay(_INTL("{1} thrashes about in its sleep!",battler.pbThis))
- else
- battle.pbDisplay(_INTL("{1} thrashes about due to its {2}!",battler.pbThis,battler.abilityName))
- end
- battle.pbHideAbilitySplash(battler)
- battle.eachBattler do |b|
- next if b.semiInvulnerable?
- next if !b.near?(battler)
- oldHP = b.hp
- b.damageState.reset
- b.damageState.initialHP = b.hp
- sleepMove = PokeBattle_Confusion.new(battle,nil)
- sleepMove.calcType = sleepMove.pbCalcType(battler)
- b.damageState.typeMod = sleepMove.pbCalcTypeMod(sleepMove.calcType,battler,b)
- sleepMove.pbCalcDamage(battler,b)
- bearer = battle.pbCheckGlobalAbility(:BADDREAMS)
- if battler.effects[PBEffects::Nightmare] || (bearer && bearer.near?(battler))
- b.damageState.calcDamage *= 2
- end
- sleepMove.pbReduceDamage(battler,b)
- b.hp -= b.damageState.hpLost
- sleepMove.pbAnimateHitAndHPLost(battler,[b])
- sleepMove.pbRecordDamageLost(battler,b)
- sleepMove.pbEndureKOMessage(b)
- b.pbItemHPHealCheck
- b.pbAbilitiesOnDamageTaken(oldHP)
- b.pbFaint if b.fainted?
- end
- }
- )
- #===============================================================================
- # Custom Ability #29 - Delivery
- #===============================================================================
- BattleHandlers::AbilityOnSwitchIn.add(:DELIVERY,
- proc { |ability,battler,battle|
- next false if battler.item==0 || battler.unlosableItem?(battler.item)
- recipient = nil
- battle.eachOtherSideBattler(battler.index) do |b|
- next if b.semiInvulnerable? || b.effects[PBEffects::SkyDrop]>=0
- next if b.item>0 || !b.near?(battler)
- if b == battler.pbDirectOpposing
- recipient = b
- break
- end
- recipient = b
- end
- if recipient
- battle.pbShowAbilitySplash(battler)
- recipient.item = battler.item
- battler.item = 0
- if battle.wildBattle? && recipient.initialItem==0 && battler.initialItem==recipient.item
- recipient.setInitialItem(recipient.item)
- battler.setInitialItem(0)
- end
- battle.pbDisplay(_INTL("{1}'s {2} was delivered to {3}!",battler.pbThis,
- recipient.itemName,recipient.pbThis(true)))
- battle.pbHideAbilitySplash(battler)
- recipient.pbHeldItemTriggerCheck
- end
- }
- )
- #===============================================================================
- # Custom Ability #30 - Graverobber
- #===============================================================================
- BattleHandlers::AbilityOnBattlerFainting.add(:GRAVEROBBER,
- proc { |ability,battler,fainted,battle|
- next false if battler.item>0
- next false if fainted.item==0 || fainted.unlosableItem?(fainted.item)
- next false if !fainted.near?(battler)
- battle.pbShowAbilitySplash(battler)
- battler.item = fainted.item
- fainted.item = 0
- if battle.wildBattle? && battler.initialItem==0 && fainted.initialItem==battler.item
- battler.setInitialItem(battler.item)
- fainted.setInitialItem(0)
- end
- battle.pbDisplay(_INTL("{1} robbed {2}'s {3}!",battler.pbThis,
- fainted.pbThis(true),battler.itemName))
- battle.pbHideAbilitySplash(battler)
- battler.pbHeldItemTriggerCheck
- }
- )
- #===============================================================================
- # Custom Ability #31 - Solidarity
- #===============================================================================
- BattleHandlers::AbilityOnSwitchIn.add(:SOLIDARITY,
- proc { |ability,battler,battle|
- foes = []
- battle.eachOtherSideBattler(battler.index) do |b|
- foes.push(b) if b.nature == battler.nature
- end
- if foes.length>0
- battle.pbShowAbilitySplash(battler)
- foes.each do |b|
- battle.pbDisplay(_INTL("{1} shares a common nature with {2}!",
- battler.pbThis,b.pbThis(true)))
- end
- battle.pbHideAbilitySplash(battler)
- end
- }
- )
- #===============================================================================
- # Custom Ability #32 - Mutate
- #===============================================================================
- # Form changing added to "def pbUseMove"
- #===============================================================================
- # Custom Ability #33 - Midnight Curse
- #===============================================================================
- BattleHandlers::AbilityOnSwitchIn.add(:MIDNIGHTCURSE,
- proc { |ability,battler,battle|
- if isConst?(battler.species,PBSpecies,:LYCANROC)
- outdoors = pbGetMetadata($game_map.map_id,MetadataOutdoor)
- newabils = [:DAYLIGHTRUSH,:MOONLITFRENZY,:TWILIGHTSHIFT]
- battle.pbShowAbilitySplash(battler,true,false)
- if PBDayNight.isNight? && outdoors
- battler.pbChangeForm(1,_INTL("Exposure to moonlight changed {1} into its Midnight form!",
- battler.pbThis)) if battler.form!=1
- elsif PBDayNight.isEvening? && outdoors
- battler.pbChangeForm(2,_INTL("Being caught in twilight changed {1} into its Dusk form!",
- battler.pbThis)) if battler.form!=2
- elsif PBDayNight.isDay? && outdoors
- battler.pbChangeForm(0,_INTL("Exposure to daylight reverted {1} into its Midday form!",
- battler.pbThis)) if battler.form!=0
- end
- battler.ability = getConst(PBAbilities,newabils[battler.form])
- battle.pbReplaceAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1} acquired {2}!",battler.pbThis,battler.abilityName))
- battle.pbHideAbilitySplash(battler)
- end
- }
- )
- #===============================================================================
- # Custom Ability #34 - Daylight Rush
- #===============================================================================
- BattleHandlers::DamageCalcUserAbility.add(:DAYLIGHTRUSH,
- proc { |ability,user,target,move,mults,baseDmg,type|
- daylight = true if PBDayNight.isDay? || PBWeather::Sun || PBWeather::HarshSun
- next false if !daylight
- firstToAct = true
- user.battle.eachBattler do |b|
- next if b.fainted?
- next if b.index==user.index
- next if b.battle.choices[target.index][0]!=:UseMove &&
- b.battle.choices[target.index][0]!=:Shift
- firstToAct = false if b.movedThisRound?
- end
- if firstToAct
- user.battle.pbShowAbilitySplash(user)
- user.battle.pbDisplay(_INTL("{1} strikes first!",user.pbThis))
- user.battle.pbHideAbilitySplash(user)
- mults[BASE_DMG_MULT] *= 1.3
- end
- }
- )
- #===============================================================================
- # Custom Ability #35 - Twilight Shift
- #===============================================================================
- # Start of round ability trigger added to "def pbAttackPhaseMoves"
- BattleHandlers::SOREffectAbility.add(:TWILIGHTSHIFT,
- proc { |ability,battler,battle|
- next false if !PBDayNight.isEvening?
- showAnim = true
- battle.pbShowAbilitySplash(battler)
- if battler.turnCount%2==0
- if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
- battle.pbDisplay(_INTL("{1} shifted in favor of moonlight!",battler.pbThis))
- else
- battle.pbDisplay(_INTL("{1}'s {2} embraced the moonlight!",battler.pbThis,battler.abilityName))
- end
- battle.pbHideAbilitySplash(battler)
- if battler.stages[PBStats::SPEED]>=2
- if battler.pbCanLowerStatStage?(PBStats::SPEED,battler)
- battler.pbLowerStatStage(PBStats::SPEED,2,battler,true)
- end
- end
- for i in [PBStats::ATTACK,PBStats::DEFENSE]
- if battler.pbCanRaiseStatStage?(i,battler)
- battler.pbRaiseStatStage(i,1,battler,showAnim)
- end
- showAnim = false
- end
- else
- if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
- battle.pbDisplay(_INTL("{1} shifted in favor of daylight!",battler.pbThis))
- else
- battle.pbDisplay(_INTL("{1}'s {2} embraced the daylight!",battler.pbThis,battler.abilityName))
- end
- battle.pbHideAbilitySplash(battler)
- for i in [PBStats::ATTACK,PBStats::DEFENSE]
- if battler.stages[i]>=1
- if battler.pbCanLowerStatStage?(i,battler)
- battler.pbLowerStatStage(i,1,battler,showAnim)
- end
- showAnim = false
- end
- end
- if battler.pbCanRaiseStatStage?(PBStats::SPEED,battler)
- battler.pbRaiseStatStage(PBStats::SPEED,2,battler,true)
- end
- end
- }
- )
- #===============================================================================
- # Custom Ability #36 - Moonlit Frenzy
- #===============================================================================
- BattleHandlers::TargetAbilityOnHit.add(:MOONLITFRENZY,
- proc { |ability,user,target,move,battle|
- next false if !PBDayNight.isNight?
- next false if !user.near?(target)
- next false if target.fainted?
- next false if target.asleep? || target.frozen?
- next false if user.semiInvulnerable? || target.semiInvulnerable?
- battle.pbShowAbilitySplash(target)
- if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
- battle.pbDisplay(_INTL("{1} retaliated in response to {2}'s attack!",target.pbThis,user.pbThis(true)))
- else
- battle.pbDisplay(_INTL("{1} retaliated with its {2}!",target.pbThis,target.abilityName))
- end
- oldHP = user.hp
- battle.pbHideAbilitySplash(target)
- user.damageState.reset
- user.damageState.initialHP = user.hp
- counterMove = PokeBattle_Confusion.new(battle,nil)
- counterMove.calcType = counterMove.pbCalcType(target)
- user.damageState.typeMod = counterMove.pbCalcTypeMod(counterMove.calcType,target,user)
- counterMove.pbCheckDamageAbsorption(target,user)
- counterMove.pbCalcDamage(target,user)
- user.damageState.calcDamage*=0.5
- counterMove.pbReduceDamage(target,user)
- user.hp -= user.damageState.hpLost
- counterMove.pbAnimateHitAndHPLost(target,[user])
- counterMove.pbRecordDamageLost(target,user)
- counterMove.pbEndureKOMessage(user)
- user.pbItemHPHealCheck
- user.pbAbilitiesOnDamageTaken(oldHP)
- user.pbFaint if user.fainted?
- }
- )
- #===============================================================================
- # Custom Ability #37 - Astral Plane
- #===============================================================================
- # Continuous type check added to "def pbAbilitiesOnFainting"
- # Continuous type check added to "def pbContinualAbilityChecks"
- BattleHandlers::AbilityOnSwitchIn.add(:ASTRALPLANE,
- proc { |ability,battler,battle|
- newType = getConst(PBTypes,:GHOST)
- typeName = PBTypes.getName(newType)
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("The {1} type is added to all battlers while on the {2}!",
- typeName,battler.abilityName))
- battle.pbHideAbilitySplash(battler)
- }
- )
- BattleHandlers::AbilityOnSwitchOut.add(:ASTRALPLANE,
- proc { |ability,battler,endOfBattle|
- next if endOfBattle
- newType = getConst(PBTypes,:GHOST)
- battler.eachAlly do |b|
- if b.effects[PBEffects::Type3]==newType
- b.effects[PBEffects::Type3] = -1
- end
- end
- battler.eachOpposing do |b|
- if b.effects[PBEffects::Type3]==newType
- b.effects[PBEffects::Type3] = -1
- end
- end
- }
- )
- #===============================================================================
- # Custom Ability #38 - Petrifying Gaze
- #===============================================================================
- BattleHandlers::AbilityOnSwitchIn.add(:PETRIFYINGGAZE,
- proc { |ability,battler,battle|
- newType = getConst(PBTypes,:ROCK)
- typeName = PBTypes.getName(newType)
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1} peered into the eyes of {2}!",
- battler.pbThis,battler.pbOpposingTeam(true)))
- battle.pbHideAbilitySplash(battler)
- battle.eachOtherSideBattler(battler.index) do |b|
- next if !b.near?(battler)
- next if b.pbHasType?(newType)
- next if b.semiInvulnerable? || b.effects[PBEffects::SkyDrop]>=0
- battle.pbDisplay(_INTL("The {1} type was added to {2}!",typeName,b.pbThis(true)))
- b.effects[PBEffects::Type3] = newType
- end
- }
- )
- #===============================================================================
- # Custom Ability #39 - Pheromone Lure
- #===============================================================================
- BattleHandlers::TrappingTargetAbility.add(:PHEROMONELURE,
- proc { |ability,switcher,bearer,battle|
- next false if switcher.gender>1 || bearer.gender>1
- next true if switcher.gender!=bearer.gender
- }
- )
- #===============================================================================
- # Custom Ability #40 - Seed Parasite
- #===============================================================================
- BattleHandlers::TargetAbilityOnHit.add(:SEEDPARASITE,
- proc { |ability,user,target,move,battle|
- next if !target.fainted?
- next if !move.pbContactMove?(user)
- next if user.pbHasType?(:GRASS) || user.effects[PBEffects::LeechSeed]>0
- battle.pbShowAbilitySplash(target)
- user.effects[PBEffects::LeechSeed] = target.index
- battle.pbDisplay(_INTL("A leech seed was attached to {1}!",user.pbThis(true)))
- battle.pbHideAbilitySplash(target)
- }
- )
- #===============================================================================
- # Custom Ability #41 - Spike Burst
- #===============================================================================
- BattleHandlers::TargetAbilityOnHit.add(:SPIKEBURST,
- proc { |ability,user,target,move,battle|
- if move.contactMove?
- if target.pbHasType?(:POISON)
- if user.pbOwnSide.effects[PBEffects::ToxicSpikes]<2
- battle.pbShowAbilitySplash(target)
- user.pbOwnSide.effects[PBEffects::ToxicSpikes] += 1
- battle.pbDisplay(_INTL("Poison spikes were scattered all around {1}'s feet!",user.pbThis(true)))
- battle.pbHideAbilitySplash(target)
- end
- else
- if user.pbOwnSide.effects[PBEffects::Spikes]<3
- battle.pbShowAbilitySplash(target)
- user.pbOwnSide.effects[PBEffects::Spikes] += 1
- battle.pbDisplay(_INTL("Spikes were scattered all around {1}'s feet!",user.pbThis(true)))
- battle.pbHideAbilitySplash(target)
- end
- end
- end
- }
- )
- #===============================================================================
- # Custom Ability #42 - Color Aura
- #===============================================================================
- BattleHandlers::AbilityOnSwitchIn.add(:COLORAURA,
- proc { |ability,battler,battle|
- choice = battler.pbDirectOpposing
- color = pbGetSpeciesData(choice.species,choice.form,SpeciesColor)
- next if choice.fainted?
- next if choice.effects[PBEffects::Substitute]>0 ||
- choice.effects[PBEffects::SkyDrop]>=0 ||
- choice.semiInvulnerable?
- next false if color<0 || color==nil
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1} reacted to the sight of {2}'s {3} coloring!",
- battler.pbThis,choice.pbThis(true),PBColors.getName(color).downcase))
- pbWait(5)
- battle.pbHideAbilitySplash(battler)
- if color==0 # Red
- battler.pbRaiseStatStage(PBStats::ATTACK,1,battler)
- elsif color==1 # Blue
- battler.pbRaiseStatStage(PBStats::DEFENSE,1,battler)
- elsif color==2 # Yellow
- battler.pbRaiseStatStage(PBStats::SPEED,1,battler)
- elsif color==3 # Green
- battler.pbRaiseStatStage(PBStats::SPDEF,1,battler)
- elsif color==4 # Black
- battler.pbRaiseStatStage(PBStats::EVASION,1,battler)
- elsif color==5 # Brown
- battler.effects[PBEffects::FocusEnergy] = 2
- battle.pbDisplay(_INTL("{1} is getting pumped!",battler.pbThis))
- elsif color==6 # Purple
- battler.pbRaiseStatStage(PBStats::SPATK,1,battler)
- elsif color==7 # Gray
- battle.pbDisplay(_INTL("{1}'s stats cannot be lowered while it sees gray!",battler.pbThis))
- elsif color==8 # White
- battler.pbRaiseStatStage(PBStats::ACCURACY,1,battler)
- elsif color==9 # Pink
- battle.pbDisplay(_INTL("{1} is immune to status conditions while it sees pink!",battler.pbThis))
- end
- }
- )
- BattleHandlers::StatLossImmunityAbility.add(:COLORAURA,
- proc { |ability,battler,stat,battle,showMessages|
- choice = battler.pbDirectOpposing
- color = pbGetSpeciesData(choice.species,choice.form,SpeciesColor)
- next false if color!=7
- if showMessages
- battle.pbShowAbilitySplash(battler)
- if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
- battle.pbDisplay(_INTL("{1}'s stats cannot be lowered!",battler.pbThis))
- else
- battle.pbDisplay(_INTL("{1}'s {2} prevents stat loss!",battler.pbThis,battler.abilityName))
- end
- battle.pbHideAbilitySplash(battler)
- end
- next true
- }
- )
- BattleHandlers::StatusImmunityAbility.add(:COLORAURA,
- proc { |ability,battler,status|
- choice = battler.pbDirectOpposing
- color = pbGetSpeciesData(choice.species,choice.form,SpeciesColor)
- next true if color==9
- }
- )
- #===============================================================================
- # Custom Ability #43 - Dancing Panic
- #===============================================================================
- # Added reverse effects in "class PokeBattle_StatUpMove"
- # Added reverse effects in "class PokeBattle_MultiStatUpMove"
- # Added reverse effects in "class PokeBattle_StatDownMove"
- # Added reverse effects in "class PokeBattle_TargetStatDownMove"
- # Added reverse effects in "class PokeBattle_TargetMultiStatDownMove"
- BattleHandlers::AbilityOnSwitchIn.add(:DANCINGPANIC,
- proc { |ability,battler,battle|
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1} makes other Pokémon dance to a frantic beat!",battler.pbThis))
- battle.pbHideAbilitySplash(battler)
- }
- )
- class PokeBattle_Move
- def pbReverseDanceEffect?(user)
- if @battle.pbCheckGlobalAbility(:DANCINGPANIC) && danceMove?
- return false if user.hasActiveAbility?(:DANCINGPANIC)
- return true
- end
- end
- end
- #===============================================================================
- # Custom Ability #44 - Bounty Hunter
- #===============================================================================
- # Effects added to "module PBEffects"
- # Effects added to "def pbInitEffects"
- # Exp. bonus added to "def pbGainExpOne"
- BattleHandlers::AbilityOnSwitchIn.add(:BOUNTYHUNTER,
- proc { |ability,battler,battle|
- target = []
- rarity = []
- battle.eachOtherSideBattler(battler.index) do |b|
- rareness = pbGetSpeciesData(b.species,b.form,SpeciesRareness)
- rareness/=2 if b.shiny?
- next if rareness>75
- target.push(b)
- rarity.push(rareness)
- end
- for i in 0...rarity.length
- if rarity[i]!=rarity.min
- rarity.delete_at(i)
- target.delete_at(i)
- end
- end
- if target.length>0
- target = target[0]
- target.effects[PBEffects::BountyTarget] = true
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1} identified {2} as the bounty target!",
- battler.pbThis,target.pbThis(true)))
- battle.pbHideAbilitySplash(battler)
- end
- }
- )
- BattleHandlers::UserAbilityOnHit.add(:BOUNTYHUNTER,
- proc { |ability,user,target,move,battle|
- if target.effects[PBEffects::BountyTarget] && target.fainted?
- battle.pbShowAbilitySplash(user)
- battle.pbDisplay(_INTL("{1} collected its bounty on {2}!",user.pbThis,target.pbThis(true)))
- if user.pbOwnedByPlayer? && battle.internalBattle
- bounty = (target.level+user.level)*(150+rand(50))
- rareness = pbGetSpeciesData(target.species,target.form,SpeciesRareness)
- rareness/=2 if target.shiny?
- battle.field.effects[PBEffects::PayDay] += (bounty/rareness).round
- battle.pbDisplay(_INTL("{1} was showered in coins!",user.pbThis))
- user.effects[PBEffects::BountyCollected] = (bounty/rareness).round
- end
- battle.pbHideAbilitySplash(user)
- if user.item==0 && (target.item>0 && !target.unlosableItem?(target.item))
- user.item = target.item
- target.item = 0
- if battle.wildBattle? && user.initialItem==0 && target.initialItem==user.item
- user.setInitialItem(user.item)
- target.setInitialItem(0)
- end
- battle.pbDisplay(_INTL("{1} took {2}'s {3} as a trophy!",
- user.pbThis,target.pbThis(true),user.itemName))
- else
- battle.pbDisplay(_INTL("But it failed!")) if !battle.internalBattle
- end
- end
- }
- )
- #===============================================================================
- # Custom Ability #45 - Honey Frenzy
- #===============================================================================
- # Re-Targetting added to "pbChangeTargets"
- BattleHandlers::AbilityOnSwitchIn.add(:HONEYFRENZY,
- proc { |ability,battler,battle|
- if !battler.hasActiveItem?(:HONEY)
- battle.eachBattler do |b|
- if b.hasActiveItem?(:HONEY)
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1} sniffs the presence of {2} on {3}!",
- battler.pbThis,b.itemName,b.pbThis(true)))
- battle.pbHideAbilitySplash(battler)
- end
- end
- end
- }
- )
- BattleHandlers::DamageCalcUserAbility.add(:HONEYFRENZY,
- proc { |ability,user,target,move,mults,baseDmg,type|
- targethoney=true if target.hasActiveItem?(:HONEY) && !user.hasActiveItem?(:HONEY)
- mults[BASE_DMG_MULT] *= 2 if targethoney
- }
- )
- BattleHandlers::EORHealingAbility.add(:HONEYFRENZY,
- proc { |ability,battler,battle|
- next false if !battler.hasActiveItem?(:HONEY)
- next false if !battler.canHeal?
- battle.pbShowAbilitySplash(battler)
- battler.pbRecoverHP(battler.totalhp/8).floor
- battle.pbDisplay(_INTL("{1}'s {2} restored some HP with its held {3}!",
- battler.pbThis,battler.abilityName,battler.itemName))
- battle.pbHideAbilitySplash(battler)
- }
- )
- BattleHandlers::SpeedCalcAbility.add(:HONEYFRENZY,
- proc { |ability,battler,mult|
- next mult/2 if battler.hasActiveItem?(:HONEY)
- }
- )
- class PokeBattle_Battler
- def pbHoneyFrenzyTarget(move,user,targets,priority,nearOnly)
- if user.hasActiveAbility?(:HONEYFRENZY)
- getID = pbGetMoveData(move.id,MOVE_FUNCTION_CODE)
- blacklist = ["0C9","0CA","0CB","0CC","0CD","0CE","14D"].include?(getID)
- usingmultiturn = (user.effects[PBEffects::TwoTurnAttack]!=0 && blacklist)
- if move.damagingMove? && targets.length==1 && !usingmultiturn
- newTarget = nil
- priority.each do |b|
- next if b.index==user.index || b.index==targets[0].index
- next if !b.hasActiveItem?(:HONEY)
- next if b.semiInvulnerable? || b.effects[PBEffects::SkyDrop]>=0
- next if nearOnly && !b.near?(user)
- newTarget = b
- end
- if newTarget!=nil
- targets.clear
- @battle.pbShowAbilitySplash(user)
- pbAddTarget(targets,user,newTarget,move,nearOnly)
- @battle.pbDisplay(_INTL("{1} targeted {2} instead because of its held {3}!",
- user.pbThis,newTarget.pbThis(true),newTarget.itemName))
- @battle.pbHideAbilitySplash(user)
- return targets
- end
- end
- end
- return targets
- end
- end
- #===============================================================================
- # Custom Ability #46 - Grizzly Guard
- #===============================================================================
- # Effect added to "module PBEffects"
- # Effect added to "def pbInitEffects"
- # Re-Targetting added to "def pbChangeTargets"
- BattleHandlers::AbilityOnSwitchIn.add(:GRIZZLYGUARD,
- proc { |ability,battler,battle|
- battle.eachSameSideBattler(battler.index) do |ally|
- next if !ally.near?(battler)
- if ally
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1} guards its allies!",battler.pbThis))
- battle.pbHideAbilitySplash(battler)
- break
- end
- end
- }
- )
- BattleHandlers::TargetAbilityOnHit.add(:GRIZZLYGUARD,
- proc { |ability,user,target,move,battle|
- if target.effects[PBEffects::GrizzlyGuard] &&
- target.pbCanRaiseStatStage?(PBStats::ATTACK,target)
- target.pbRaiseStatStage(PBStats::ATTACK,1,target)
- end
- target.effects[PBEffects::GrizzlyGuard] = false
- }
- )
- class PokeBattle_Battler
- def pbGrizzlyGuardTarget(move,user,targets,priority,nearOnly)
- if @battle.pbCheckOpposingAbility(:GRIZZLYGUARD,user.index,nearOnly) && !user.hasMoldBreaker?
- getID = pbGetMoveData(move.id,MOVE_FUNCTION_CODE)
- blacklist = ["0C9","0CA","0CB","0CC","0CD","0CE","14D"].include?(getID)
- usingmultiturn = (user.effects[PBEffects::TwoTurnAttack]!=0 && blacklist)
- if move.damagingMove? && targets.length==1 && !usingmultiturn
- newTarget = nil
- for oldTarget in targets
- next if oldTarget.semiInvulnerable?
- next if oldTarget.effects[PBEffects::Protect]
- next if oldTarget.effects[PBEffects::KingsShield]
- next if oldTarget.effects[PBEffects::SpikyShield]
- next if oldTarget.effects[PBEffects::BanefulBunker]
- next if oldTarget.effects[PBEffects::Obstruct]
- next if oldTarget.effects[PBEffects::SkyDrop]>=0
- next if oldTarget.effects[PBEffects::Substitute]>0
- next if oldTarget.pbOwnSide.effects[PBEffects::WideGuard]
- next if oldTarget.pbOwnSide.effects[PBEffects::QuickGuard]
- next if oldTarget.pbOwnSide.effects[PBEffects::MatBlock]
- next if defined?(oldTarget.dynamax?) && oldTarget.dynamax?
- priority.each do |b|
- next if !(b.opposes?(user.index) && b.hasActiveAbility?(:GRIZZLYGUARD))
- next if b.hp <= b.totalhp/4.floor
- next if b.level <= oldTarget.level-10
- next if b.index==oldTarget.index
- next if b.frozen? || b.asleep?
- next if b.effects[PBEffects::Protect]
- next if b.effects[PBEffects::KingsShield]
- next if b.effects[PBEffects::SpikyShield]
- next if b.effects[PBEffects::BanefulBunker]
- next if b.effects[PBEffects::Obstruct]
- next if b.effects[PBEffects::Substitute]>0
- next if b.semiInvulnerable? || b.effects[PBEffects::SkyDrop]>=0
- next if nearOnly && !b.near?(user)
- next if nearOnly && !b.near?(oldTarget)
- next if defined?(b.dynamax?) && b.dynamax?
- newTarget = b
- end
- if newTarget!=nil
- targets.clear
- pbAddTarget(targets,user,newTarget,move,nearOnly)
- @battle.pbShowAbilitySplash(newTarget)
- @battle.pbDisplay(_INTL("{1} takes attacks for its allies with {2}!",
- newTarget.pbThis,newTarget.abilityName))
- @battle.pbHideAbilitySplash(newTarget)
- newTarget.effects[PBEffects::GrizzlyGuard] = true
- return targets
- end
- end
- end
- end
- return targets
- end
- end
- #===============================================================================
- # Custom Ability #47 - Hive Mind
- #===============================================================================
- # Re-Targetting added to "pbChangeTargets"
- BattleHandlers::AbilityOnSwitchIn.add(:HIVEMIND,
- proc { |ability,battler,battle|
- battle.eachSameSideBattler(battler.index) do |ally|
- next if !ally.near?(battler)
- if ally
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1} commands its allies to shield it from harm!",battler.pbThis))
- battle.pbHideAbilitySplash(battler)
- break
- end
- end
- }
- )
- class PokeBattle_Battler
- def pbHiveMindTarget(move,user,targets,priority,nearOnly)
- if targets[0].hasActiveAbility?(:HIVEMIND) && !user.hasMoldBreaker?
- getID = pbGetMoveData(move.id,MOVE_FUNCTION_CODE)
- blacklist = ["0C9","0CA","0CB","0CC","0CD","0CE","14D"].include?(getID)
- usingmultiturn = (user.effects[PBEffects::TwoTurnAttack]!=0 && blacklist)
- if move.damagingMove? && targets.length==1 && !usingmultiturn
- newTarget = nil
- for oldTarget in targets
- next if oldTarget.semiInvulnerable?
- next if oldTarget.effects[PBEffects::Protect]
- next if oldTarget.effects[PBEffects::KingsShield]
- next if oldTarget.effects[PBEffects::SpikyShield]
- next if oldTarget.effects[PBEffects::BanefulBunker]
- next if oldTarget.effects[PBEffects::Obstruct]
- next if oldTarget.effects[PBEffects::SkyDrop]>=0
- next if oldTarget.effects[PBEffects::Substitute]>0
- next if oldTarget.pbOwnSide.effects[PBEffects::WideGuard]
- next if oldTarget.pbOwnSide.effects[PBEffects::QuickGuard]
- next if oldTarget.pbOwnSide.effects[PBEffects::MatBlock]
- next if defined?(oldTarget.dynamax?) && oldTarget.dynamax?
- priority.each do |b|
- next if !b.opposes?(user.index)
- next if b.index==oldTarget.index
- next if b.hp <= b.totalhp/4.floor
- next if b.level <= oldTarget.level-10
- next if b.frozen? || b.asleep?
- next if b.effects[PBEffects::Protect]
- next if b.effects[PBEffects::KingsShield]
- next if b.effects[PBEffects::SpikyShield]
- next if b.effects[PBEffects::BanefulBunker]
- next if b.effects[PBEffects::Obstruct]
- next if b.effects[PBEffects::Substitute]>0
- next if b.semiInvulnerable? || b.effects[PBEffects::SkyDrop]>=0
- next if nearOnly && !b.near?(user)
- next if nearOnly && !b.near?(oldTarget)
- next if defined?(b.dynamax?) && b.dynamax?
- newTarget = b
- end
- end
- if newTarget!=nil
- targets.clear
- @battle.pbShowAbilitySplash(oldTarget)
- pbAddTarget(targets,user,newTarget,move,nearOnly)
- @battle.pbDisplay(_INTL("{1} ordered {2} to take {3}'s attack!",
- oldTarget.pbThis,newTarget.pbThis(true),user.pbThis(true)))
- @battle.pbHideAbilitySplash(oldTarget)
- return targets
- end
- end
- end
- return targets
- end
- end
- #===============================================================================
- # Custom Ability #48 - Gambler
- #===============================================================================
- BattleHandlers::AbilityOnSwitchIn.add(:GAMBLER,
- proc { |ability,battler,battle|
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1} is ready to roll the dice!",battler.pbThis))
- battle.pbHideAbilitySplash(battler)
- }
- )
- BattleHandlers::EOREffectAbility.add(:GAMBLER,
- proc { |ability,battler,battle|
- next false if battler.asleep? || battler.frozen?
- rand = battle.pbRandom(11)
- battle.pbShowAbilitySplash(battler)
- # Roll 2 - Halves user's HP
- if rand==0
- battle.pbDisplay(_INTL("{1} rolled a 2!",battler.pbThis))
- battler.pbReduceHP(battler.hp/2,false)
- battle.pbDisplay(_INTL("{1}'s HP was cut by half!",battler.pbThis))
- # Roll 3 - Free Turn
- elsif rand==1
- battle.pbDisplay(_INTL("{1} rolled a 3!",battler.pbThis))
- battle.pbDisplay(_INTL("Free turn!"))
- # Roll 4 - Traps all Pokemon
- elsif rand==2
- battle.pbDisplay(_INTL("{1} rolled a 4!",battler.pbThis))
- battle.eachBattler do |b|
- if NEWEST_BATTLE_MECHANICS && b.pbHasType?(:GHOST)
- battle.pbDisplay(_INTL("{1} cannot be trapped!",b.pbThis))
- else
- b.effects[PBEffects::MeanLook] = battler.index
- if !battle.pbCanSwitch?(b.index) || battle.wildBattle?
- battle.pbDisplay(_INTL("{1} can no longer escape!",b.pbThis))
- end
- end
- end
- # Roll 5 - Curses user
- elsif rand==3
- battle.pbDisplay(_INTL("{1} rolled a 5!",battler.pbThis))
- if !battler.effects[PBEffects::Curse]
- battler.effects[PBEffects::Curse]=true
- battle.pbDisplay(_INTL("A curse was laid on {1}!",battler.pbThis))
- else
- battle.pbDisplay(_INTL("But it failed!",battler.pbThis))
- end
- # Roll 6 - Eliminates all stat changes
- elsif rand==4
- battle.pbDisplay(_INTL("{1} rolled a 6!",battler.pbThis))
- battle.eachBattler do |b|
- b.stages[PBStats::ATTACK] = 0
- b.stages[PBStats::DEFENSE] = 0
- b.stages[PBStats::SPEED] = 0
- b.stages[PBStats::SPATK] = 0
- b.stages[PBStats::SPDEF] = 0
- b.stages[PBStats::ACCURACY] = 0
- b.stages[PBStats::EVASION] = 0
- end
- battle.pbDisplay(_INTL("All stat changes were eliminated!"))
- # Roll 7 - Fully heals allies
- elsif rand==5
- battle.pbDisplay(_INTL("{1} rolled a 7!",battler.pbThis))
- battle.eachSameSideBattler(battler.index) do |b|
- b.effects[PBEffects::Curse]=false
- b.effects[PBEffects::Confusion]=0
- b.effects[PBEffects::Disable]= 0
- b.effects[PBEffects::DisableMove]= 0
- b.effects[PBEffects::Imprison]= false
- b.effects[PBEffects::MeanLook]=-1
- b.effects[PBEffects::Nightmare]=false
- b.effects[PBEffects::Taunt]=0
- b.effects[PBEffects::Torment]=false
- b.effects[PBEffects::GastroAcid]=false
- b.effects[PBEffects::LeechSeed]=-1
- b.effects[PBEffects::Toxic]=0
- b.effects[PBEffects::HealBlock]=0
- b.pbCureStatus(false)
- b.pbCureAttract
- b.pbRecoverHP(b.totalhp)
- end
- battle.pbDisplay(_INTL("{1} were fully restored!",battler.pbTeam))
- # Roll 8 - Puts all battlers to sleep & inflicts Nightmare
- elsif rand==6
- battle.pbDisplay(_INTL("{1} rolled an 8!",battler.pbThis))
- battle.eachBattler do |b|
- b.pbSleep if b.pbCanSleep?(nil,false)
- b.effects[PBEffects::Nightmare]=true if b.asleep?
- end
- battle.pbDisplay(_INTL("All sleeping Pokémon began having a nightmare!"))
- # Roll 9 - Reduces opponent's offense by 3 stages
- elsif rand==7
- battle.pbDisplay(_INTL("{1} rolled a 9!",battler.pbThis))
- battle.eachOtherSideBattler(battler.index) do |b|
- showAnim = true
- for i in [PBStats::ATTACK,PBStats::SPATK]
- if b.pbCanLowerStatStage?(i,battler,nil,true)
- b.pbLowerStatStage(i,3,battler,showAnim)
- showAnim = false
- end
- end
- end
- # Roll 10 - Gives opponents Truant
- elsif rand==8
- battle.pbDisplay(_INTL("{1} rolled a 10!",battler.pbThis))
- battle.eachOtherSideBattler(battler.index) do |b|
- if b.unstoppableAbility?
- battle.pbDisplay(_INTL("{1}'s ability could not be changed!",b.pbThis))
- elsif b.hasActiveAbility?(:TRUANT)
- battle.pbDisplay(_INTL("{1} already has the {2} ability!",b.pbThis,b.abilityName))
- else
- battle.pbShowAbilitySplash(b,true,false)
- oldAbil = b.ability
- b.ability = getConst(PBAbilities,:TRUANT) || 0
- battle.pbReplaceAbilitySplash(b)
- battle.pbDisplay(_INTL("{1} acquired {2}!",b.pbThis,b.abilityName))
- battle.pbHideAbilitySplash(b)
- b.pbOnAbilityChanged(oldAbil)
- b.pbEffectsOnSwitchIn
- end
- end
- # Roll 11 - Fully heals opponents
- elsif rand==9
- battle.pbDisplay(_INTL("{1} rolled an 11!",battler.pbThis))
- battle.eachOtherSideBattler(battler.index) do |b|
- b.effects[PBEffects::Curse]=false
- b.effects[PBEffects::Confusion]=0
- b.effects[PBEffects::Disable]= 0
- b.effects[PBEffects::DisableMove]= 0
- b.effects[PBEffects::Imprison]= false
- b.effects[PBEffects::MeanLook]=-1
- b.effects[PBEffects::Nightmare]=false
- b.effects[PBEffects::Taunt]=0
- b.effects[PBEffects::Torment]=false
- b.effects[PBEffects::GastroAcid]=false
- b.effects[PBEffects::LeechSeed]=-1
- b.effects[PBEffects::Toxic]=0
- b.effects[PBEffects::HealBlock]=0
- b.pbCureStatus(false)
- b.pbCureAttract
- b.pbRecoverHP(b.totalhp)
- end
- battle.pbDisplay(_INTL("{1} were fully restored!",battler.pbOpposingTeam))
- # Roll 12 - Raises users stats by 2 stages
- elsif rand==10
- battle.pbDisplay(_INTL("{1} rolled a 12!",battler.pbThis))
- showAnim=true
- for i in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPATK,
- PBStats::SPDEF,PBStats::SPEED]
- if battler.pbCanRaiseStatStage?(i,battler)
- battler.pbRaiseStatStage(i,2,battler,showAnim)
- showAnim=false
- end
- end
- end
- battle.pbHideAbilitySplash(battler)
- }
- )
- #===============================================================================
- # Custom Ability #49 - Lucky 7
- #===============================================================================
- # Start of round ability trigger added to "def pbAttackPhaseMoves"
- BattleHandlers::AbilityOnSwitchIn.add(:LUCKY7,
- proc { |ability,battler,battle|
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1} awaits for its luck to kick in!",battler.pbThis))
- battle.pbHideAbilitySplash(battler)
- }
- )
- BattleHandlers::SOREffectAbility.add(:LUCKY7,
- proc { |ability,battler,battle|
- if battler.turnCount%7==0
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1} is feelin' lucky!",battler.pbThis))
- battle.pbHideAbilitySplash(battler)
- if !battler.effects[PBEffects::Endure]
- battler.effects[PBEffects::Endure]=true
- end
- if battler.effects[PBEffects::LaserFocus]<=0
- battler.effects[PBEffects::LaserFocus]=2
- end
- if battler.pbOwnSide.effects[PBEffects::Rainbow]<=0
- battler.pbOwnSide.effects[PBEffects::Rainbow]=2
- end
- if battler.pbOwnSide.effects[PBEffects::LuckyChant]<=0
- battler.pbOwnSide.effects[PBEffects::LuckyChant]=2
- end
- if battle.positions[battler.index].effects[PBEffects::Wish]<=0
- battle.positions[battler.index].effects[PBEffects::Wish]=1
- battle.positions[battler.index].effects[PBEffects::WishAmount]= (battler.totalhp/2).round
- battle.positions[battler.index].effects[PBEffects::WishMaker]= battler.pokemonIndex
- battle.pbDisplay(_INTL("{1} made a wish!",battler.pbThis))
- end
- if battler.status>0
- battler.pbCureStatus(false)
- battler.pbCureAttract
- battler.pbCureConfusion
- battle.pbDisplay(_INTL("{1}'s status was miraculously cured!",battler.pbThis))
- end
- end
- }
- )
- BattleHandlers::AccuracyCalcUserAbility.add(:LUCKY7,
- proc { |ability,mods,user,target,move,type|
- mods[BASE_ACC] = 0 if user.turnCount%7==0
- }
- )
- BattleHandlers::EOREffectAbility.add(:LUCKY7,
- proc { |ability,battler,battle|
- if battler.turnCount%7==0
- battler.effects[PBEffects::LaserFocus]=0
- battler.pbOwnSide.effects[PBEffects::Rainbow]=0
- battler.pbOwnSide.effects[PBEffects::LuckyChant]=0
- battle.pbDisplay(_INTL("{1}'s luck ran out!",battler.pbThis))
- end
- }
- )
- #===============================================================================
- # Custom Ability #50 - Countdown
- #===============================================================================
- BattleHandlers::AbilityOnSwitchIn.add(:COUNTDOWN,
- proc { |ability,battler,battle|
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1}'s timer has been set!",battler.pbThis))
- battle.pbHideAbilitySplash(battler)
- }
- )
- BattleHandlers::EOREffectAbility.add(:COUNTDOWN,
- proc { |ability,battler,battle|
- if battler.turnCount==1
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1}'s {2} reached 3!",battler.pbThis,battler.abilityName))
- elsif battler.turnCount==2
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1}'s {2} reached 2!",battler.pbThis,battler.abilityName))
- elsif battler.turnCount==3
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1}'s {2} reached 1!",battler.pbThis,battler.abilityName))
- elsif battler.turnCount==4
- battle.pbShowAbilitySplash(battler)
- battle.pbDisplay(_INTL("{1}'s {2} reached 0!",battler.pbThis,battler.abilityName))
- bearer = battle.pbCheckGlobalAbility(:DAMP)
- if bearer!=nil
- battle.pbShowAbilitySplash(bearer)
- battle.pbDisplay(_INTL("{1}'s {2} prevents {3} from detonating!",
- bearer.pbThis,bearer.abilityName,battler.pbThis(true)))
- battle.pbHideAbilitySplash(bearer)
- else
- battle.pbDisplay(_INTL("{1} detonated with a devastating blast!",battler.pbThis))
- battle.pbHideAbilitySplash(battler)
- battle.scene.pbDamageAnimation(battler)
- battler.pbReduceHP(battler.totalhp)
- battler.pbFaint
- battle.eachBattler do |b|
- next if !b.near?(battler)
- next if b.semiInvulnerable?
- next if battler.effects[PBEffects::SkyDrop]>=0
- if b.effects[PBEffects::Protect] ||
- b.effects[PBEffects::KingsShield] ||
- b.effects[PBEffects::SpikyShield] ||
- b.effects[PBEffects::BanefulBunker] ||
- b.effects[PBEffects::Obstruct] ||
- (defined?(b.dynamax?) && b.effects[PBEffects::MaxGuard])
- battle.pbDisplay(_INTL("{1} protected itself!",b.pbThis))
- elsif b.pbOwnSide.effects[PBEffects::WideGuard] && b.opposes?
- battle.pbDisplay(_INTL("{1} was protected by Wide Guard!",b.pbThis))
- elsif b.pbOwnSide.effects[PBEffects::MatBlock] && b.opposes?
- battle.pbDisplay(_INTL("{1} was protected by the kicked-up mat!",b.pbThis))
- elsif b.effects[PBEffects::Substitute]>0
- battle.pbDisplay(_INTL("The substitute took damage for {1}!",b.pbThis(true)))
- b.effects[PBEffects::Substitute] = 0
- battle.pbDisplay(_INTL("{1}'s substitute faded!",b.pbThis))
- else
- oldHP = b.hp
- b.damageState.reset
- b.damageState.initialHP = b.hp
- ohkoMove = PokeBattle_Confusion.new(battle,nil)
- ohkoMove.calcType = ohkoMove.pbCalcType(battler)
- b.damageState.typeMod = ohkoMove.pbCalcTypeMod(ohkoMove.calcType,battler,b)
- ohkoMove.pbCalcDamage(battler,b)
- b.damageState.calcDamage = b.hp
- ohkoMove.pbReduceDamage(battler,b)
- b.hp -= b.damageState.hpLost
- ohkoMove.pbAnimateHitAndHPLost(battler,[b])
- ohkoMove.pbEndureKOMessage(b)
- b.pbItemHPHealCheck
- b.pbAbilitiesOnDamageTaken(oldHP)
- b.pbFaint if b.fainted?
- end
- end
- end
- end
- battle.pbHideAbilitySplash(battler)
- }
- )
Add Comment
Please, Sign In to add comment