diff --git a/Data/Scripts/010_Data/002_PBS data/005_Move.rb b/Data/Scripts/010_Data/002_PBS data/005_Move.rb index 675f29773..b0f608ce6 100644 --- a/Data/Scripts/010_Data/002_PBS data/005_Move.rb +++ b/Data/Scripts/010_Data/002_PBS data/005_Move.rb @@ -222,7 +222,7 @@ module GameData when "06F" then new_code = "FixedDamageUserLevelRandom" when "070" if data[:id] == :FISSURE - new_code = "OHKOHitsTargetUnderground" + new_code = "OHKOHitsUndergroundTarget" elsif data[:id] == :SHEERCOLD && Settings::MECHANICS_GENERATION >= 7 new_code = "OHKOIce" else diff --git a/Data/Scripts/011_Battle/001_Battler/005_Battler_StatStages.rb b/Data/Scripts/011_Battle/001_Battler/005_Battler_StatStages.rb index 11cff8ae0..84afe1101 100644 --- a/Data/Scripts/011_Battle/001_Battler/005_Battler_StatStages.rb +++ b/Data/Scripts/011_Battle/001_Battler/005_Battler_StatStages.rb @@ -115,14 +115,20 @@ class PokeBattle_Battler return @stages[stat]<=-6 end - def pbCanLowerStatStage?(stat,user=nil,move=nil,showFailMsg=false,ignoreContrary=false) + def pbCanLowerStatStage?(stat, user = nil, move = nil, showFailMsg = false, ignoreContrary = false, ignoreMirrorArmor = false) return false if fainted? - # Contrary - if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker - return pbCanRaiseStatStage?(stat,user,move,showFailMsg,true) + if !@battle.moldBreaker + # Contrary + if hasActiveAbility?(:CONTRARY) && !ignoreContrary + return pbCanRaiseStatStage?(stat, user, move, showFailMsg, true) + end + # Mirror Armor + if hasActiveAbility?(:MIRRORARMOR) && !ignoreMirrorArmor && user && user.index != @index + return true if !statStageAtMin?(stat) + end end if !user || user.index!=@index # Not self-inflicted - if @effects[PBEffects::Substitute]>0 && !(move && move.ignoresSubstitute?(user)) + if @effects[PBEffects::Substitute]>0 && (ignoreMirrorArmor || !(move && move.ignoresSubstitute?(user))) @battle.pbDisplay(_INTL("{1} is protected by its substitute!",pbThis)) if showFailMsg return false end @@ -175,10 +181,29 @@ class PokeBattle_Battler return increment end - def pbLowerStatStage(stat,increment,user,showAnim=true,ignoreContrary=false) - # Contrary - if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker - return pbRaiseStatStage(stat,increment,user,showAnim,true) + def pbLowerStatStage(stat, increment, user, showAnim = true, ignoreContrary = false, + mirrorArmorSplash = 0, ignoreMirrorArmor = false) + if !@battle.moldBreaker + # Contrary + if hasActiveAbility?(:CONTRARY) && !ignoreContrary + return pbRaiseStatStage(stat, increment, user, showAnim, true) + end + # Mirror Armor + if hasActiveAbility?(:MIRRORARMOR) && !ignoreMirrorArmor && + user && user.index != @index && !statStageAtMin?(stat) + if mirrorArmorSplash < 2 + @battle.pbShowAbilitySplash(self) + if !PokeBattle_SceneConstants::USE_ABILITY_SPLASH + @battle.pbDisplay(_INTL("{1}'s {2} activated!", pbThis, abilityName)) + end + end + ret = false + if user.pbCanLowerStatStage?(stat, self, nil, true, ignoreContrary, true) + ret = user.pbLowerStatStage(stat, increment, self, showAnim, ignoreContrary, mirrorArmorSplash, true) + end + @battle.pbHideAbilitySplash(self) if mirrorArmorSplash.even? # i.e. not 1 or 3 + return ret + end end # Perform the stat stage change increment = pbLowerStatStageBasic(stat,increment,ignoreContrary) @@ -197,10 +222,27 @@ class PokeBattle_Battler return true end - def pbLowerStatStageByCause(stat,increment,user,cause,showAnim=true,ignoreContrary=false) - # Contrary - if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker - return pbRaiseStatStageByCause(stat,increment,user,cause,showAnim,true) + def pbLowerStatStageByCause(stat, increment, user, cause, showAnim = true, + ignoreContrary = false, ignoreMirrorArmor = false) + if !@battle.moldBreaker + # Contrary + if hasActiveAbility?(:CONTRARY) && !ignoreContrary + return pbRaiseStatStageByCause(stat, increment, user, cause, showAnim, true) + end + # Mirror Armor + if hasActiveAbility?(:MIRRORARMOR) && !ignoreMirrorArmor && + user && user.index != @index && !statStageAtMin?(stat) + @battle.pbShowAbilitySplash(self) + if !PokeBattle_SceneConstants::USE_ABILITY_SPLASH + @battle.pbDisplay(_INTL("{1}'s {2} activated!", pbThis, abilityName)) + end + ret = false + if user.pbCanLowerStatStage?(stat, self, nil, true, ignoreContrary, true) + ret = user.pbLowerStatStageByCause(stat, increment, self, abilityName, showAnim, ignoreContrary, true) + end + @battle.pbHideAbilitySplash(self) + return ret + end end # Perform the stat stage change increment = pbLowerStatStageBasic(stat,increment,ignoreContrary) diff --git a/Data/Scripts/011_Battle/001_Battler/009_Battler_UseMove_SuccessChecks.rb b/Data/Scripts/011_Battle/001_Battler/009_Battler_UseMove_SuccessChecks.rb index cbeaf7cc0..a881139ca 100644 --- a/Data/Scripts/011_Battle/001_Battler/009_Battler_UseMove_SuccessChecks.rb +++ b/Data/Scripts/011_Battle/001_Battler/009_Battler_UseMove_SuccessChecks.rb @@ -361,8 +361,8 @@ class PokeBattle_Battler target.damageState.protected = true @battle.successStates[user.index].protected = true if move.pbContactMove?(user) && user.affectedByContactEffect? - if user.pbCanLowerStatStage?(:ATTACK) - user.pbLowerStatStage(:ATTACK, (Settings::MECHANICS_GENERATION >= 8) ? 1 : 2, nil) + if user.pbCanLowerStatStage?(:ATTACK, target) + user.pbLowerStatStage(:ATTACK, (Settings::MECHANICS_GENERATION >= 8) ? 1 : 2, target) end end return false @@ -405,8 +405,8 @@ class PokeBattle_Battler target.damageState.protected = true @battle.successStates[user.index].protected = true if move.pbContactMove?(user) && user.affectedByContactEffect? - if user.pbCanLowerStatStage?(:DEFENSE) - user.pbLowerStatStage(:DEFENSE, 2, nil) + if user.pbCanLowerStatStage?(:DEFENSE, target) + user.pbLowerStatStage(:DEFENSE, 2, target) end end return false diff --git a/Data/Scripts/011_Battle/001_Battler/010_Battler_UseMove_TriggerEffects.rb b/Data/Scripts/011_Battle/001_Battler/010_Battler_UseMove_TriggerEffects.rb index 24308d5b2..71aee89db 100644 --- a/Data/Scripts/011_Battle/001_Battler/010_Battler_UseMove_TriggerEffects.rb +++ b/Data/Scripts/011_Battle/001_Battler/010_Battler_UseMove_TriggerEffects.rb @@ -148,9 +148,9 @@ class PokeBattle_Battler if move.function == "StartSlowerBattlersActFirst" && @battle.field.effects[PBEffects::TrickRoom] > 0 @battle.battlers.each do |b| next if !b.hasActiveItem?(:ROOMSERVICE) - next if !b.pbCanLowerStatStage?(:SPEED, b) + next if !b.pbCanLowerStatStage?(:SPEED) @battle.pbCommonAnimation("UseItem", b) - b.pbLowerStatStage(:SPEED, 1, b) + b.pbLowerStatStage(:SPEED, 1, nil) b.pbConsumeItem end end diff --git a/Data/Scripts/011_Battle/002_Move/004_Move_BaseEffects.rb b/Data/Scripts/011_Battle/002_Move/004_Move_BaseEffects.rb index 1ecd10d9b..bec1fd97d 100644 --- a/Data/Scripts/011_Battle/002_Move/004_Move_BaseEffects.rb +++ b/Data/Scripts/011_Battle/002_Move/004_Move_BaseEffects.rb @@ -383,26 +383,49 @@ class PokeBattle_TargetMultiStatDownMove < PokeBattle_Move return false end - def pbEffectAgainstTarget(user,target) - return if damagingMove? - showAnim = true - for i in 0...@statDown.length/2 - next if !target.pbCanLowerStatStage?(@statDown[i*2],user,self) - if target.pbLowerStatStage(@statDown[i*2],@statDown[i*2+1],user,showAnim) - showAnim = false + def pbCheckForMirrorArmor(user, target) + if target.hasActiveAbility?(:MIRRORARMOR) && user.index != target.index + failed = true + for i in 0...@statDown.length / 2 + next if target.statStageAtMin?(@statDown[i * 2]) + next if !user.pbCanLowerStatStage?(@statDown[i * 2], target, self, false, false, true) + failed = false + break + end + if failed + @battle.pbShowAbilitySplash(target) + if !PokeBattle_SceneConstants::USE_ABILITY_SPLASH + @battle.pbDisplay(_INTL("{1}'s {2} activated!", target.pbThis, target.abilityName)) + end + user.pbCanLowerStatStage?(@statDown[0], target, self, true, false, true) # Show fail message + @battle.pbHideAbilitySplash(target) + return false end end + return true + end + + def pbLowerTargetMultipleStats(user, target) + return if !pbCheckForMirrorArmor(user, target) + showAnim = true + showMirrorArmorSplash = true + for i in 0...@statDown.length / 2 + next if !target.pbCanLowerStatStage?(@statDown[i * 2], user, self) + if target.pbLowerStatStage(@statDown[i * 2], @statDown[i * 2 + 1], user, + showAnim, false, (showMirrorArmorSplash) ? 1 : 3) + showAnim = false + end + showMirrorArmorSplash = false + end + @battle.pbHideAbilitySplash(target) # To hide target's Mirror Armor splash + end + + def pbEffectAgainstTarget(user,target) + pbLowerTargetMultipleStats(user, target) if !damagingMove? end def pbAdditionalEffect(user,target) - return if target.damageState.substitute - showAnim = true - for i in 0...@statDown.length/2 - next if !target.pbCanLowerStatStage?(@statDown[i*2],user,self) - if target.pbLowerStatStage(@statDown[i*2],@statDown[i*2+1],user,showAnim) - showAnim = false - end - end + pbLowerTargetMultipleStats(user, target) if !target.damageState.substitute end end diff --git a/Data/Scripts/011_Battle/002_Move/006_MoveEffects_BattlerStats.rb b/Data/Scripts/011_Battle/002_Move/006_MoveEffects_BattlerStats.rb index b92b78cb4..62291b5cd 100644 --- a/Data/Scripts/011_Battle/002_Move/006_MoveEffects_BattlerStats.rb +++ b/Data/Scripts/011_Battle/002_Move/006_MoveEffects_BattlerStats.rb @@ -1321,6 +1321,11 @@ end class PokeBattle_Move_LowerPoisonedTargetAtkSpAtkSpd1 < PokeBattle_Move def canMagicCoat?; return true; end + def initialize(battle,move) + super + @statDown = [:ATTACK, 1, :SPECIAL_ATTACK, 1, :SPEED, 1] + end + def pbMoveFailed?(user,targets) @validTargets = [] targets.each do |b| @@ -1338,15 +1343,42 @@ class PokeBattle_Move_LowerPoisonedTargetAtkSpAtkSpd1 < PokeBattle_Move return false end - def pbEffectAgainstTarget(user,target) - return if !@validTargets.include?(target.index) - showAnim = true - [:ATTACK,:SPECIAL_ATTACK,:SPEED].each do |s| - next if !target.pbCanLowerStatStage?(s,user,self) - if target.pbLowerStatStage(s,1,user,showAnim) - showAnim = false + def pbCheckForMirrorArmor(user, target) + if target.hasActiveAbility?(:MIRRORARMOR) && user.index != target.index + failed = true + for i in 0...@statDown.length / 2 + next if target.statStageAtMin?(@statDown[i * 2]) + next if !user.pbCanLowerStatStage?(@statDown[i * 2], target, self, false, false, true) + failed = false + break + end + if failed + @battle.pbShowAbilitySplash(target) + if !PokeBattle_SceneConstants::USE_ABILITY_SPLASH + @battle.pbDisplay(_INTL("{1}'s {2} activated!", target.pbThis, target.abilityName)) + end + user.pbCanLowerStatStage?(@statDown[0], target, self, true, false, true) # Show fail message + @battle.pbHideAbilitySplash(target) + return false end end + return true + end + + def pbEffectAgainstTarget(user,target) + return if !@validTargets.include?(target.index) + return if !pbCheckForMirrorArmor(user, target) + showAnim = true + showMirrorArmorSplash = true + for i in 0...@statDown.length / 2 + next if !target.pbCanLowerStatStage?(@statDown[i * 2], user, self) + if target.pbLowerStatStage(@statDown[i * 2], @statDown[i * 2 + 1], user, + showAnim, false, (showMirrorArmorSplash) ? 1 : 3) + showAnim = false + end + showMirrorArmorSplash = false + end + @battle.pbHideAbilitySplash(target) # To hide target's Mirror Armor splash end end diff --git a/Data/Scripts/011_Battle/002_Move/008_MoveEffects_MoveAttributes.rb b/Data/Scripts/011_Battle/002_Move/008_MoveEffects_MoveAttributes.rb index c70db3ecb..b19c7fb1d 100644 --- a/Data/Scripts/011_Battle/002_Move/008_MoveEffects_MoveAttributes.rb +++ b/Data/Scripts/011_Battle/002_Move/008_MoveEffects_MoveAttributes.rb @@ -131,7 +131,7 @@ end # OHKO. Accuracy increases by difference between levels of user and target. Hits # targets that are semi-invulnerable underground. (Fissure) #=============================================================================== -class PokeBattle_Move_OHKOHitsTargetUnderground < PokeBattle_Move_OHKO +class PokeBattle_Move_OHKOHitsUndergroundTarget < PokeBattle_Move_OHKO def hitsDiggingTargets?; return true; end end diff --git a/Data/Scripts/011_Battle/003_BattleHandlers_Abilities.rb b/Data/Scripts/011_Battle/003_BattleHandlers_Abilities.rb index f32f4758a..db512f457 100644 --- a/Data/Scripts/011_Battle/003_BattleHandlers_Abilities.rb +++ b/Data/Scripts/011_Battle/003_BattleHandlers_Abilities.rb @@ -2104,9 +2104,9 @@ BattleHandlers::AbilityOnSwitchIn.add(:ANTICIPATION, eff = Effectiveness.calculate(moveType,type1,type2,type3) next if Effectiveness.ineffective?(eff) next if !Effectiveness.super_effective?(eff) && - !["OHKO", "OHKOIce", "OHKOHitsTargetUnderground"].include?(m.function) + !["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function) else - next if !["OHKO", "OHKOIce", "OHKOHitsTargetUnderground"].include?(m.function) + next if !["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function) end found = true break @@ -2206,7 +2206,7 @@ BattleHandlers::AbilityOnSwitchIn.add(:FOREWARN, battle.eachOtherSideBattler(battler.index) do |b| b.eachMove do |m| power = m.baseDamage - power = 160 if ["OHKO", "OHKOIce", "OHKOHitsTargetUnderground"].include?(m.function) + power = 160 if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function) power = 150 if ["PowerHigherWithUserHP"].include?(m.function) # Eruption # Counter, Mirror Coat, Metal Burst power = 120 if ["CounterPhysicalDamage", diff --git a/Data/Scripts/011_Battle/004_AI/005_AI_Move_EffectScores.rb b/Data/Scripts/011_Battle/004_AI/005_AI_Move_EffectScores.rb index 0da14e8bb..f157ab473 100644 --- a/Data/Scripts/011_Battle/004_AI/005_AI_Move_EffectScores.rb +++ b/Data/Scripts/011_Battle/004_AI/005_AI_Move_EffectScores.rb @@ -1547,7 +1547,7 @@ class PokeBattle_AI when "FixedDamageUserLevelRandom" score += 30 if target.hp<=user.level #--------------------------------------------------------------------------- - when "OHKO", "OHKOIce", "OHKOHitsTargetUnderground" + when "OHKO", "OHKOIce", "OHKOHitsUndergroundTarget" score -= 90 if target.hasActiveAbility?(:STURDY) score -= 90 if target.level>user.level #--------------------------------------------------------------------------- diff --git a/Data/Scripts/011_Battle/004_AI/006_AI_Move_Utilities.rb b/Data/Scripts/011_Battle/004_AI/006_AI_Move_Utilities.rb index 628fc78fc..6760acefd 100644 --- a/Data/Scripts/011_Battle/004_AI/006_AI_Move_Utilities.rb +++ b/Data/Scripts/011_Battle/004_AI/006_AI_Move_Utilities.rb @@ -180,7 +180,7 @@ class PokeBattle_AI baseDmg = move.pbFixedDamage(user,target) when "FixedDamageUserLevelRandom" # Psywave baseDmg = user.level - when "OHKO", "OHKOIce", "OHKOHitsTargetUnderground" + when "OHKO", "OHKOIce", "OHKOHitsUndergroundTarget" baseDmg = 200 when "CounterPhysicalDamage", "CounterSpecialDamage", "CounterDamagePlusHalf" baseDmg = 60 @@ -692,7 +692,7 @@ class PokeBattle_AI modifiers[:base_accuracy] = 0 if Settings::MORE_TYPE_EFFECTS && move.statusMove? && user.pbHasType?(:POISON) end - if ["OHKO", "OHKOIce", "OHKOHitsTargetUnderground"].include?(move.function) + if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(move.function) modifiers[:base_accuracy] = move.accuracy + user.level - target.level modifiers[:accuracy_multiplier] = 0 if target.level > user.level if skill>=PBTrainerAI.bestSkill diff --git a/Data/Scripts/011_Battle/006_Other battle types/009_PokeBattle_Clauses.rb b/Data/Scripts/011_Battle/006_Other battle types/009_PokeBattle_Clauses.rb index 9fd8647af..e255c92f5 100644 --- a/Data/Scripts/011_Battle/006_Other battle types/009_PokeBattle_Clauses.rb +++ b/Data/Scripts/011_Battle/006_Other battle types/009_PokeBattle_Clauses.rb @@ -200,7 +200,7 @@ end -class PokeBattle_Move_OHKOHitsTargetUnderground +class PokeBattle_Move_OHKOHitsUndergroundTarget alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget? def pbFailsAgainstTarget?(user, target, show_message) diff --git a/Data/Scripts/011_Battle/Gen 8 abilities.rb b/Data/Scripts/011_Battle/Gen 8 abilities.rb index 9172f804c..eb9f90737 100644 --- a/Data/Scripts/011_Battle/Gen 8 abilities.rb +++ b/Data/Scripts/011_Battle/Gen 8 abilities.rb @@ -342,10 +342,6 @@ BattleHandlers::AbilityOnSwitchIn.add(:MIMICRY, #=============================================================================== -Mirror Armor -If a move/ability tries to lower the bearer's stat(s), the effect is reflected -back at the causer. - Neutralizing Gas Suppresses all other abilities. Once this ability stops applying, triggers all abilities that activate when gained (if this happens because bearer switches diff --git a/Data/Scripts/013_Items/Gen 8 items.rb b/Data/Scripts/013_Items/Gen 8 items.rb index 41ee15d2e..733c4cc68 100644 --- a/Data/Scripts/013_Items/Gen 8 items.rb +++ b/Data/Scripts/013_Items/Gen 8 items.rb @@ -343,9 +343,9 @@ BattleHandlers::UserItemAfterMoveUse.add(:THROATSPRAY, BattleHandlers::ItemOnSwitchIn.add(:ROOMSERVICE, proc { |item, battler, battle| next if battle.field.effects[PBEffects::TrickRoom] == 0 - next if !battler.pbCanLowerStatStage?(:SPEED, battler) + next if !battler.pbCanLowerStatStage?(:SPEED) battle.pbCommonAnimation("UseItem", battler) - battler.pbLowerStatStage(:SPEED, 1, battler) + battler.pbLowerStatStage(:SPEED, 1, nil) battler.pbConsumeItem } ) diff --git a/PBS/Gen 5/moves.txt b/PBS/Gen 5/moves.txt index a34ccf6a3..8d8efdfba 100644 --- a/PBS/Gen 5/moves.txt +++ b/PBS/Gen 5/moves.txt @@ -2825,7 +2825,7 @@ BaseDamage = 1 Accuracy = 30 TotalPP = 5 Target = NearOther -FunctionCode = OHKOHitsTargetUnderground +FunctionCode = OHKOHitsUndergroundTarget Flags = CanProtect,CanMirrorMove Description = The user opens up a fissure in the ground and drops the foe in. The target instantly faints if it hits. #------------------------------- diff --git a/PBS/Gen 7/moves.txt b/PBS/Gen 7/moves.txt index d35122acc..51c1545cd 100644 --- a/PBS/Gen 7/moves.txt +++ b/PBS/Gen 7/moves.txt @@ -3728,7 +3728,7 @@ BaseDamage = 1 Accuracy = 30 TotalPP = 5 Target = NearOther -FunctionCode = OHKOHitsTargetUnderground +FunctionCode = OHKOHitsUndergroundTarget Flags = CanProtect,CanMirrorMove Description = The user opens up a fissure in the ground and drops the foe in. The target instantly faints if it hits. #------------------------------- diff --git a/PBS/Gen 8/moves.txt b/PBS/Gen 8/moves.txt index 4ee6e4fbd..87f872b2d 100644 --- a/PBS/Gen 8/moves.txt +++ b/PBS/Gen 8/moves.txt @@ -4234,7 +4234,7 @@ BaseDamage = 1 Accuracy = 30 TotalPP = 5 Target = NearOther -FunctionCode = OHKOHitsTargetUnderground +FunctionCode = OHKOHitsUndergroundTarget Flags = CanProtect,CanMirrorMove Description = The user opens up a fissure in the ground and drops the foe in. The target instantly faints if it hits. #------------------------------- diff --git a/PBS/moves.txt b/PBS/moves.txt index 4ee6e4fbd..87f872b2d 100644 --- a/PBS/moves.txt +++ b/PBS/moves.txt @@ -4234,7 +4234,7 @@ BaseDamage = 1 Accuracy = 30 TotalPP = 5 Target = NearOther -FunctionCode = OHKOHitsTargetUnderground +FunctionCode = OHKOHitsUndergroundTarget Flags = CanProtect,CanMirrorMove Description = The user opens up a fissure in the ground and drops the foe in. The target instantly faints if it hits. #-------------------------------