From d4db99719bb75d0a4eb81983a0b330c578b5b6f9 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sat, 12 Sep 2020 22:00:25 +0100 Subject: [PATCH] Grouped all ability blacklists together --- .../001_Battler/001_PokeBattle_Battler.rb | 63 +++-- .../001_Battler/002_Battler_Initialize.rb | 2 +- .../001_Battler/006_Battler_AbilityAndItem.rb | 39 +-- .../002_Move/005_Move_Effects_000-07F.rb | 240 ++---------------- .../002_Move/007_Move_Effects_100-17F.rb | 24 +- .../007_BattleHandlers_Abilities.rb | 65 +---- 6 files changed, 85 insertions(+), 348 deletions(-) diff --git a/Data/Scripts/012_Battle/001_Battler/001_PokeBattle_Battler.rb b/Data/Scripts/012_Battle/001_Battler/001_PokeBattle_Battler.rb index d08e6305c..03a58e2f2 100644 --- a/Data/Scripts/012_Battle/001_Battler/001_PokeBattle_Battler.rb +++ b/Data/Scripts/012_Battle/001_Battler/001_PokeBattle_Battler.rb @@ -338,25 +338,54 @@ class PokeBattle_Battler end alias hasWorkingAbility hasActiveAbility? - def nonNegatableAbility? + # Applies to both losing self's ability (i.e. being replaced by another) and + # having self's ability be negated. + def unstoppableAbility? abilityBlacklist = [ - # Form-changing abilities - :BATTLEBOND, - :DISGUISE, -# :FLOWERGIFT, # This can be negated -# :FORECAST, # This can be negated - :MULTITYPE, - :POWERCONSTRUCT, - :SCHOOLING, - :SHIELDSDOWN, - :STANCECHANGE, - :ZENMODE, - # Abilities intended to be inherent properties of a certain species - :COMATOSE, - :RKSSYSTEM + # Form-changing abilities + :BATTLEBOND, + :DISGUISE, +# :FLOWERGIFT, # This can be stopped +# :FORECAST, # This can be stopped + :MULTITYPE, + :POWERCONSTRUCT, + :SCHOOLING, + :SHIELDSDOWN, + :STANCECHANGE, + :ZENMODE, + # Abilities intended to be inherent properties of a certain species + :COMATOSE, + :RKSSYSTEM ] - abilityBlacklist.each do |abil| - return true if isConst?(@ability,PBAbilities,abil) + abilityBlacklist.each do |a| + return true if isConst?(@ability, PBAbilities, a) + end + return false + end + + # Applies to gaining the ability. + def ungainableAbility?(abil) + abilityBlacklist = [ + # Form-changing abilities + :BATTLEBOND, + :DISGUISE, + :FLOWERGIFT, + :FORECAST, + :MULTITYPE, + :POWERCONSTRUCT, + :SCHOOLING, + :SHIELDSDOWN, + :STANCECHANGE, + :ZENMODE, + # Appearance-changing abilities + :ILLUSION, + :IMPOSTER, + # Abilities intended to be inherent properties of a certain species + :COMATOSE, + :RKSSYSTEM + ] + abilityBlacklist.each do |a| + return true if isConst?(abil, PBAbilities, a) end return false end diff --git a/Data/Scripts/012_Battle/001_Battler/002_Battler_Initialize.rb b/Data/Scripts/012_Battle/001_Battler/002_Battler_Initialize.rb index 8d95feaae..663fde76e 100644 --- a/Data/Scripts/012_Battle/001_Battler/002_Battler_Initialize.rb +++ b/Data/Scripts/012_Battle/001_Battler/002_Battler_Initialize.rb @@ -109,7 +109,7 @@ class PokeBattle_Battler # These effects are passed on if Baton Pass is used, but they need to be # cancelled in certain circumstances anyway @effects[PBEffects::Telekinesis] = 0 if isSpecies?(:GENGAR) && mega? - @effects[PBEffects::GastroAcid] = false if nonNegatableAbility? + @effects[PBEffects::GastroAcid] = false if unstoppableAbility? else # These effects are passed on if Baton Pass is used @stages[PBStats::ATTACK] = 0 diff --git a/Data/Scripts/012_Battle/001_Battler/006_Battler_AbilityAndItem.rb b/Data/Scripts/012_Battle/001_Battler/006_Battler_AbilityAndItem.rb index cc292fc4a..e23b034b4 100644 --- a/Data/Scripts/012_Battle/001_Battler/006_Battler_AbilityAndItem.rb +++ b/Data/Scripts/012_Battle/001_Battler/006_Battler_AbilityAndItem.rb @@ -10,7 +10,7 @@ class PokeBattle_Battler # Ending primordial weather, checking Trace pbContinualAbilityChecks(true) # Abilities that trigger upon switching in - if (!fainted? && nonNegatableAbility?) || abilityActive? + if (!fainted? && unstoppableAbility?) || abilityActive? BattleHandlers.triggerAbilityOnSwitchIn(@ability,self,@battle) end # Check for end of primordial weather @@ -72,36 +72,13 @@ class PokeBattle_Battler # in and not at any later times, even if a traceable ability turns # up later. Essentials ignores this, and allows Trace to trigger # whenever it can even in the old battle mechanics. - abilityBlacklist = [ - # Replaces self with another ability - :POWEROFALCHEMY, - :RECEIVER, - :TRACE, - # Form-changing abilities - :BATTLEBOND, - :DISGUISE, - :FLOWERGIFT, - :FORECAST, - :MULTITYPE, - :POWERCONSTRUCT, - :SCHOOLING, - :SHIELDSDOWN, - :STANCECHANGE, - :ZENMODE, - # Appearance-changing abilities - :ILLUSION, - :IMPOSTER, - # Abilities intended to be inherent properties of a certain species - :COMATOSE, - :RKSSYSTEM - ] choices = [] @battle.eachOtherSideBattler(@index) do |b| - abilityBlacklist.each do |abil| - next if !isConst?(b.ability,PBAbilities,abil) - choices.push(b) - break - end + next if b.ungainableAbility? || + isConst?(b.ability, PBAbilities, :POWEROFALCHEMY) || + isConst?(b.ability, PBAbilities, :RECEIVER) || + isConst?(b.ability, PBAbilities, :TRACE) + choices.push(b) end if choices.length>0 choice = choices[@battle.pbRandom(choices.length)] @@ -109,7 +86,7 @@ class PokeBattle_Battler @ability = choice.ability @battle.pbDisplay(_INTL("{1} traced {2}'s {3}!",pbThis,choice.pbThis(true),choice.abilityName)) @battle.pbHideAbilitySplash(self) - if !onSwitchIn && (nonNegatableAbility? || abilityActive?) + if !onSwitchIn && (unstoppableAbility? || abilityActive?) BattleHandlers.triggerAbilityOnSwitchIn(@ability,self,@battle) end end @@ -138,7 +115,7 @@ class PokeBattle_Battler @battle.pbSetSeen(self) end end - @effects[PBEffects::GastroAcid] = false if nonNegatableAbility? + @effects[PBEffects::GastroAcid] = false if unstoppableAbility? @effects[PBEffects::SlowStart] = 0 if !isConst?(@ability,PBAbilities,:SLOWSTART) # Revert form if Flower Gift/Forecast was lost pbCheckFormOnWeatherChange diff --git a/Data/Scripts/012_Battle/002_Move/005_Move_Effects_000-07F.rb b/Data/Scripts/012_Battle/002_Move/005_Move_Effects_000-07F.rb index 29948b1f0..2e474c441 100644 --- a/Data/Scripts/012_Battle/002_Move/005_Move_Effects_000-07F.rb +++ b/Data/Scripts/012_Battle/002_Move/005_Move_Effects_000-07F.rb @@ -1996,29 +1996,6 @@ end # Target's ability becomes Simple. (Simple Beam) #=============================================================================== class PokeBattle_Move_063 < PokeBattle_Move - def initialize(battle,move) - super - @abilityBlacklist = [ - :TRUANT, - # This ability - :SIMPLE, - # Form-changing abilities - :BATTLEBOND, - :DISGUISE, -# :FLOWERGIFT, # This can be replaced -# :FORECAST, # This can be replaced - :MULTITYPE, - :POWERCONSTRUCT, - :SCHOOLING, - :SHIELDSDOWN, - :STANCECHANGE, - :ZENMODE, - # Abilities intended to be inherent properties of a certain species - :COMATOSE, - :RKSSYSTEM - ] - end - def pbMoveFailed?(user,targets) if !hasConst?(PBAbilities,:SIMPLE) # Ability isn't defined @battle.pbDisplay(_INTL("But it failed!")) @@ -2028,8 +2005,9 @@ class PokeBattle_Move_063 < PokeBattle_Move end def pbFailsAgainstTarget?(user,target) - @abilityBlacklist.each do |abil| - next if !isConst?(target.ability,PBAbilities,abil) + if target.unstoppableAbility? || + isConst?(target.ability, PBAbilities, :TRUANT) || # For some reason + isConst?(target.ability, PBAbilities, :SIMPLE) @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -2053,29 +2031,6 @@ end # Target's ability becomes Insomnia. (Worry Seed) #=============================================================================== class PokeBattle_Move_064 < PokeBattle_Move - def initialize(battle,move) - super - @abilityBlacklist = [ - :TRUANT, - # This ability - :INSOMNIA, - # Form-changing abilities - :BATTLEBOND, - :DISGUISE, -# :FLOWERGIFT, # This can be replaced -# :FORECAST, # This can be replaced - :MULTITYPE, - :POWERCONSTRUCT, - :SCHOOLING, - :SHIELDSDOWN, - :STANCECHANGE, - :ZENMODE, - # Abilities intended to be inherent properties of a certain species - :COMATOSE, - :RKSSYSTEM - ] - end - def pbMoveFailed?(user,targets) if !hasConst?(PBAbilities,:INSOMNIA) # Ability isn't defined @battle.pbDisplay(_INTL("But it failed!")) @@ -2085,8 +2040,9 @@ class PokeBattle_Move_064 < PokeBattle_Move end def pbFailsAgainstTarget?(user,target) - @abilityBlacklist.each do |abil| - next if !isConst?(target.ability,PBAbilities,abil) + if target.unstoppableAbility? || + isConst?(target.ability, PBAbilities, :TRUANT) || # For some reason + isConst?(target.ability, PBAbilities, :INSOMNIA) @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -2112,54 +2068,8 @@ end class PokeBattle_Move_065 < PokeBattle_Move def ignoresSubstitute?(user); return true; end - def initialize(battle,move) - super - @abilityBlacklistUnlosable = [ - # Form-changing abilities - :BATTLEBOND, - :DISGUISE, -# :FLOWERGIFT, # This can be lost -# :FORECAST, # This can be lost - :MULTITYPE, - :POWERCONSTRUCT, - :SCHOOLING, - :SHIELDSDOWN, - :STANCECHANGE, - :ZENMODE, - # Abilities intended to be inherent properties of a certain species - :COMATOSE, - :RKSSYSTEM - ] - @abilityBlacklistUngainable = [ - # Replaces self with another ability - :POWEROFALCHEMY, - :RECEIVER, - :TRACE, - # Form-changing abilities - :BATTLEBOND, - :DISGUISE, - :FLOWERGIFT, - :FORECAST, - :MULTITYPE, - :POWERCONSTRUCT, - :SCHOOLING, - :SHIELDSDOWN, - :STANCECHANGE, - :ZENMODE, - # Appearance-changing abilities - :ILLUSION, - :IMPOSTER, - # Abilities intended to be inherent properties of a certain species - :COMATOSE, - :RKSSYSTEM, - # Abilities that would be overpowered if allowed to be transferred - :WONDERGUARD - ] - end - def pbMoveFailed?(user,targets) - @abilityBlacklistUnlosable.each do |abil| - next if !isConst?(user.ability,PBAbilities,abil) + if user.unstoppableAbility? @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -2171,8 +2081,11 @@ class PokeBattle_Move_065 < PokeBattle_Move @battle.pbDisplay(_INTL("But it failed!")) return true end - @abilityBlacklistUngainable.each do |abil| - next if !isConst?(target.ability,PBAbilities,abil) + if target.ungainableAbility? || + isConst?(target.ability, PBAbilities, :POWEROFALCHEMY) || + isConst?(target.ability, PBAbilities, :RECEIVER) || + isConst?(target.ability, PBAbilities, :TRACE) || + isConst?(target.ability, PBAbilities, :WONDERGUARD) @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -2198,57 +2111,15 @@ end # Target copies user's ability. (Entrainment) #=============================================================================== class PokeBattle_Move_066 < PokeBattle_Move - def initialize(battle,move) - super - @abilityBlacklistUnlosable = [ - :TRUANT, - # Form-changing abilities - :BATTLEBOND, - :DISGUISE, -# :FLOWERGIFT, # This can be lost -# :FORECAST, # This can be lost - :MULTITYPE, - :POWERCONSTRUCT, - :SCHOOLING, - :SHIELDSDOWN, - :STANCECHANGE, - :ZENMODE, - # Abilities intended to be inherent properties of a certain species - :COMATOSE, - :RKSSYSTEM - ] - @abilityBlacklistUngainable = [ - # Replaces self with another ability - :POWEROFALCHEMY, - :RECEIVER, - :TRACE, - # Form-changing abilities - :BATTLEBOND, - :DISGUISE, - :FLOWERGIFT, - :FORECAST, - :MULTITYPE, - :POWERCONSTRUCT, - :SCHOOLING, - :SHIELDSDOWN, - :STANCECHANGE, - :ZENMODE, - # Appearance-changing abilities - :ILLUSION, - :IMPOSTER, - # Abilities intended to be inherent properties of a certain species - :COMATOSE, - :RKSSYSTEM - ] - end - def pbMoveFailed?(user,targets) if user.ability==0 @battle.pbDisplay(_INTL("But it failed!")) return true end - @abilityBlacklistUngainable.each do |abil| - next if !isConst?(user.ability,PBAbilities,abil) + if user.ungainableAbility? || + isConst?(user.ability, PBAbilities, :POWEROFALCHEMY) || + isConst?(user.ability, PBAbilities, :RECEIVER) || + isConst?(user.ability, PBAbilities, :TRACE) @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -2256,8 +2127,7 @@ class PokeBattle_Move_066 < PokeBattle_Move end def pbFailsAgainstTarget?(user,target) - @abilityBlacklistUnlosable.each do |abil| - next if !isConst?(target.ability,PBAbilities,abil) + if target.unstoppableAbility? || isConst?(target.ability, PBAbilities, :TRUANT) @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -2284,59 +2154,16 @@ end class PokeBattle_Move_067 < PokeBattle_Move def ignoresSubstitute?(user); return true; end - def initialize(battle,move) - super - @abilityBlacklistUnlosable = [ - # Form-changing abilities - :BATTLEBOND, - :DISGUISE, -# :FLOWERGIFT, # This can be lost -# :FORECAST, # This can be lost - :MULTITYPE, - :POWERCONSTRUCT, - :SCHOOLING, - :SHIELDSDOWN, - :STANCECHANGE, - :ZENMODE, - # Abilities intended to be inherent properties of a certain species - :COMATOSE, - :RKSSYSTEM - ] - @abilityBlacklistUngainable = [ - # Form-changing abilities - :BATTLEBOND, - :DISGUISE, - :FLOWERGIFT, - :FORECAST, - :MULTITYPE, - :POWERCONSTRUCT, - :SCHOOLING, - :SHIELDSDOWN, - :STANCECHANGE, - :ZENMODE, - # Appearance-changing abilities - :ILLUSION, - :IMPOSTER, - # Abilities intended to be inherent properties of a certain species - :COMATOSE, - :RKSSYSTEM, - # Abilities that would be overpowered if allowed to be transferred - :WONDERGUARD - ] - end - def pbMoveFailed?(user,targets) if user.ability==0 @battle.pbDisplay(_INTL("But it failed!")) return true end - @abilityBlacklistUnlosable.each do |abil| - next if !isConst?(user.ability,PBAbilities,abil) + if user.unstoppableAbility? @battle.pbDisplay(_INTL("But it failed!")) return true end - @abilityBlacklistUngainable.each do |abil| - next if !isConst?(user.ability,PBAbilities,abil) + if user.ungainableAbility? || isConst?(user.ability, PBAbilities, :WONDERGUARD) @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -2349,13 +2176,11 @@ class PokeBattle_Move_067 < PokeBattle_Move @battle.pbDisplay(_INTL("But it failed!")) return true end - @abilityBlacklistUnlosable.each do |abil| - next if !isConst?(target.ability,PBAbilities,abil) + if target.unstoppableAbility? @battle.pbDisplay(_INTL("But it failed!")) return true end - @abilityBlacklistUngainable.each do |abil| - next if !isConst?(target.ability,PBAbilities,abil) + if target.ungainableAbility? || isConst?(target.ability, PBAbilities, :WONDERGUARD) @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -2398,29 +2223,8 @@ end # Target's ability is negated. (Gastro Acid) #=============================================================================== class PokeBattle_Move_068 < PokeBattle_Move - def initialize(battle,move) - super - @abilityBlacklist = [ - # Form-changing abilities - :BATTLEBOND, - :DISGUISE, -# :FLOWERGIFT, # This can be negated -# :FORECAST, # This can be negated - :MULTITYPE, - :POWERCONSTRUCT, - :SCHOOLING, - :SHIELDSDOWN, - :STANCECHANGE, - :ZENMODE, - # Abilities intended to be inherent properties of a certain species - :COMATOSE, - :RKSSYSTEM - ] - end - def pbFailsAgainstTarget?(user,target) - @abilityBlacklist.each do |abil| - next if !isConst?(target.ability,PBAbilities,abil) + if target.unstoppableAbility? @battle.pbDisplay(_INTL("But it failed!")) return true end diff --git a/Data/Scripts/012_Battle/002_Move/007_Move_Effects_100-17F.rb b/Data/Scripts/012_Battle/002_Move/007_Move_Effects_100-17F.rb index e9eb923ac..e8fbadf2e 100644 --- a/Data/Scripts/012_Battle/002_Move/007_Move_Effects_100-17F.rb +++ b/Data/Scripts/012_Battle/002_Move/007_Move_Effects_100-17F.rb @@ -2178,31 +2178,9 @@ end # performed its action this round. (Core Enforcer) #=============================================================================== class PokeBattle_Move_165 < PokeBattle_Move - def initialize(battle,move) - super - @abilityBlacklist = [ - # Form-changing abilities - :BATTLEBOND, - :DISGUISE, -# :FLOWERGIFT, # This can be negated -# :FORECAST, # This can be negated - :MULTITYPE, - :POWERCONSTRUCT, - :SCHOOLING, - :SHIELDSDOWN, - :STANCECHANGE, - :ZENMODE, - # Abilities intended to be inherent properties of a certain species - :COMATOSE, - :RKSSYSTEM - ] - end - def pbEffectAgainstTarget(user,target) return if target.damageState.substitute || target.effects[PBEffects::GastroAcid] - @abilityBlacklist.each do |abil| - return if isConst?(target.ability,PBAbilities,abil) - end + return if target.unstoppableAbility? return if @battle.choices[target.index][0]!=:UseItem && !((@battle.choices[target.index][0]==:UseMove || @battle.choices[target.index][0]==:Shift) && target.movedThisRound?) diff --git a/Data/Scripts/012_Battle/007_BattleHandlers_Abilities.rb b/Data/Scripts/012_Battle/007_BattleHandlers_Abilities.rb index d82f1d0de..031aab5f7 100644 --- a/Data/Scripts/012_Battle/007_BattleHandlers_Abilities.rb +++ b/Data/Scripts/012_Battle/007_BattleHandlers_Abilities.rb @@ -1532,37 +1532,13 @@ BattleHandlers::TargetAbilityOnHit.add(:MUMMY, proc { |ability,user,target,move,battle| next if !move.pbContactMove?(user) next if user.fainted? - abilityBlacklist = [ - # This ability - :MUMMY, - # Form-changing abilities - :BATTLEBOND, - :DISGUISE, -# :FLOWERGIFT, # This can be replaced -# :FORECAST, # This can be replaced - :MULTITYPE, - :POWERCONSTRUCT, - :SCHOOLING, - :SHIELDSDOWN, - :STANCECHANGE, - :ZENMODE, - # Abilities intended to be inherent properties of a certain species - :COMATOSE, - :RKSSYSTEM, - ] - failed = false - abilityBlacklist.each do |abil| - next if !isConst?(user.ability,PBAbilities,abil) - failed = true - break - end - next if failed + next if user.unstoppableAbility? || user.ability == ability oldAbil = -1 battle.pbShowAbilitySplash(target) if user.opposes?(target) if user.affectedByContactEffect?(PokeBattle_SceneConstants::USE_ABILITY_SPLASH) oldAbil = user.ability battle.pbShowAbilitySplash(user,true,false) if user.opposes?(target) - user.ability = getConst(PBAbilities,:MUMMY) + user.ability = ability battle.pbReplaceAbilitySplash(user) if user.opposes?(target) if PokeBattle_SceneConstants::USE_ABILITY_SPLASH battle.pbDisplay(_INTL("{1}'s Ability became {2}!",user.pbThis,user.abilityName)) @@ -2444,38 +2420,11 @@ BattleHandlers::AbilityOnSwitchOut.add(:REGENERATOR, BattleHandlers::AbilityChangeOnBattlerFainting.add(:POWEROFALCHEMY, proc { |ability,battler,fainted,battle| next if battler.opposes?(fainted) - abilityBlacklist = [ - # Replaces self with another ability - :POWEROFALCHEMY, - :RECEIVER, - :TRACE, - # Form-changing abilities - :BATTLEBOND, - :DISGUISE, - :FLOWERGIFT, - :FORECAST, - :MULTITYPE, - :POWERCONSTRUCT, - :SCHOOLING, - :SHIELDSDOWN, - :STANCECHANGE, - :ZENMODE, - # Appearance-changing abilities - :ILLUSION, - :IMPOSTER, - # Abilities intended to be inherent properties of a certain species - :COMATOSE, - :RKSSYSTEM, - # Abilities that would be overpowered if allowed to be transferred - :WONDERGUARD - ] - failed = false - abilityBlacklist.each do |abil| - next if !isConst?(fainted.ability,PBAbilities,abil) - failed = true - break - end - next if failed + next if fainted.ungainableAbility? || + isConst?(fainted.ability, PBAbilities, :POWEROFALCHEMY) || + isConst?(fainted.ability, PBAbilities, :RECEIVER) || + isConst?(fainted.ability, PBAbilities, :TRACE) || + isConst?(fainted.ability, PBAbilities, :WONDERGUARD) battle.pbShowAbilitySplash(battler,true) battler.ability = fainted.ability battle.pbReplaceAbilitySplash(battler)