From 22b33ca6c270d57956d57157e1c727fefd2b7824 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sat, 15 Jun 2024 15:58:31 +0100 Subject: [PATCH] Coded some Gen 9 ability/item/move effects --- .../Scripts/010_Data/002_PBS data/006_Item.rb | 5 +- .../011_Battle/001_Battle/001_Battle.rb | 13 +- .../002_Battler/001_Battle_Battler.rb | 15 +- .../002_Battler/004_Battler_Statuses.rb | 61 ++++--- .../002_Battler/005_Battler_StatStages.rb | 41 +++-- .../002_Battler/007_Battler_UseMove.rb | 2 +- .../009_Battler_UseMoveSuccessChecks.rb | 8 +- .../011_Battle/003_Move/001_Battle_Move.rb | 2 + .../011_Battle/003_Move/002_Move_Usage.rb | 15 +- .../003_Move/003_Move_UsageCalculations.rb | 86 ++++++---- .../003_Move/004_Move_BaseEffects.rb | 2 +- .../003_Move/005_MoveEffects_Misc.rb | 31 ++-- .../003_Move/006_MoveEffects_BattlerStats.rb | 28 ++- .../003_Move/007_MoveEffects_BattlerOther.rb | 20 +++ .../008_MoveEffects_MoveAttributes.rb | 39 ++++- .../003_Move/009_MoveEffects_MultiHit.rb | 3 +- .../003_Move/010_MoveEffects_Healing.rb | 46 +++-- .../003_Move/011_MoveEffects_Items.rb | 14 +- .../013_MoveEffects_SwitchingActing.rb | 8 +- .../006_AI_ChooseMove_GenericEffects.rb | 8 +- .../005_AI/007_AI_ChooseMove_OtherScores.rb | 6 +- .../011_Battle/005_AI/010_AIBattler.rb | 4 + Data/Scripts/011_Battle/005_AI/011_AIMove.rb | 54 +++--- .../001_AI_MoveEffects_Misc.rb | 16 +- .../002_AI_MoveEffects_BattlerStats.rb | 8 +- .../003_AI_MoveEffects_BattlerOther.rb | 2 +- .../004_AI_MoveEffects_MoveAttributes.rb | 5 +- .../006_AI_MoveEffects_Healing.rb | 4 +- .../007_AI_MoveEffects_Items.rb | 10 +- .../009_AI_MoveEffects_SwitchingActing.rb | 4 +- .../008_Battle_AbilityEffects.rb | 161 +++++++++++++++--- .../009_Battle_ItemEffects.rb | 42 ++++- Data/Scripts/013_Items/002_Item_Effects.rb | 48 +++++- .../001_Pokemon-related/001_FormHandlers.rb | 13 ++ PBS/moves.txt | 6 +- 35 files changed, 596 insertions(+), 234 deletions(-) diff --git a/Data/Scripts/010_Data/002_PBS data/006_Item.rb b/Data/Scripts/010_Data/002_PBS data/006_Item.rb index 1c5576072..d0e5b03d1 100644 --- a/Data/Scripts/010_Data/002_PBS data/006_Item.rb +++ b/Data/Scripts/010_Data/002_PBS data/006_Item.rb @@ -239,7 +239,9 @@ module GameData :DRAGONMEMORY, :DARKMEMORY, :FAIRYMEMORY], - :GIRATINA => [:GRISEOUSORB], + :DIALGA => [:ADAMANTCRYSTAL], + :PALKIA => [:LUSTROUSGLOBE], + :GIRATINA => [:GRISEOUSORB, :GRISEOUSCORE], :GENESECT => [:BURNDRIVE, :CHILLDRIVE, :DOUSEDRIVE, :SHOCKDRIVE], :KYOGRE => [:BLUEORB], :GROUDON => [:REDORB], @@ -247,6 +249,7 @@ module GameData :ZAMAZENTA => [:RUSTEDSHIELD], :OGERPON => [:WELLSPRINGMASK, :HEARTHFLAMEMASK, :CORNERSTONEMASK] } + combos[:GIRATINA].delete(:GRISEOUSORB) if Settings::MECHANICS_GENERATION >= 9 return combos[species]&.include?(@id) end diff --git a/Data/Scripts/011_Battle/001_Battle/001_Battle.rb b/Data/Scripts/011_Battle/001_Battle/001_Battle.rb index ce89d4307..edcf2cd5b 100644 --- a/Data/Scripts/011_Battle/001_Battle/001_Battle.rb +++ b/Data/Scripts/011_Battle/001_Battle/001_Battle.rb @@ -484,8 +484,10 @@ class Battle return allSameSideBattlers.select { |b| b.pbOwnedByPlayer? }.length end - def pbCheckGlobalAbility(abil) - allBattlers.each { |b| return b if b.hasActiveAbility?(abil) } + def pbCheckGlobalAbility(abil, check_mold_breaker = false) + allBattlers.each do |b| + return b if b.hasActiveAbility?(abil) && (!check_mold_breaker || !b.beingMoldBroken?) + end return nil end @@ -497,6 +499,13 @@ class Battle return nil end + # Returns an array containing the IDs of all active abilities. + def pbAllActiveAbilities + ret = [] + allBattlers.each { |b| ret.push(b.ability_id) if b.abilityActive? } + return ret + end + # Given a battler index, and using battle side sizes, returns an array of # battler indices from the opposing side that are in order of most "opposite". # Used when choosing a target and pressing up/down to move the cursor to the diff --git a/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb b/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb index dfea2bb1c..37713c94a 100644 --- a/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb +++ b/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb @@ -278,7 +278,7 @@ class Battle::Battler ret = (@pokemon) ? @pokemon.weight : 500 ret += @effects[PBEffects::WeightChange] ret = 1 if ret < 1 - if abilityActive? && !@battle.moldBreaker + if abilityActive? && !beingMoldBroken? ret = Battle::AbilityEffects.triggerWeightCalc(self.ability, self, ret) end if itemActive? @@ -382,7 +382,9 @@ class Battle::Battler :COMATOSE, :RKSSYSTEM ] - return ability_blacklist.include?(abil.id) + return true if ability_blacklist.include?(abil.id) + return true if hasActiveItem?(:ABILITYSHIELD) + return false end # Applies to gaining the ability. @@ -492,6 +494,11 @@ class Battle::Battler return hasActiveAbility?([:MOLDBREAKER, :TERAVOLT, :TURBOBLAZE]) end + def beingMoldBroken? + return false if hasActiveItem?(:ABILITYSHIELD) + return @battle.moldBreaker + end + def canChangeType? return ![:MULTITYPE, :RKSSYSTEM].include?(@ability_id) end @@ -502,7 +509,7 @@ class Battle::Battler return false if @effects[PBEffects::SmackDown] return false if @battle.field.effects[PBEffects::Gravity] > 0 return true if pbHasType?(:FLYING) - return true if hasActiveAbility?(:LEVITATE) && !@battle.moldBreaker + return true if hasActiveAbility?(:LEVITATE) && !beingMoldBroken? return true if hasActiveItem?(:AIRBALLOON) return true if @effects[PBEffects::MagnetRise] > 0 return true if @effects[PBEffects::Telekinesis] > 0 @@ -571,7 +578,7 @@ class Battle::Battler return false end if Settings::MECHANICS_GENERATION >= 6 - if hasActiveAbility?(:OVERCOAT) && !@battle.moldBreaker + if hasActiveAbility?(:OVERCOAT) && !beingMoldBroken? if showMsg @battle.pbShowAbilitySplash(self) if Battle::Scene::USE_ABILITY_SPLASH diff --git a/Data/Scripts/011_Battle/002_Battler/004_Battler_Statuses.rb b/Data/Scripts/011_Battle/002_Battler/004_Battler_Statuses.rb index 5cba43ffc..cc9735d47 100644 --- a/Data/Scripts/011_Battle/002_Battler/004_Battler_Statuses.rb +++ b/Data/Scripts/011_Battle/002_Battler/004_Battler_Statuses.rb @@ -72,7 +72,7 @@ class Battle::Battler end end # Uproar immunity - if newStatus == :SLEEP && !(hasActiveAbility?(:SOUNDPROOF) && !@battle.moldBreaker) + if newStatus == :SLEEP && !(hasActiveAbility?(:SOUNDPROOF) && !beingMoldBroken?) @battle.allBattlers.each do |b| next if b.effects[PBEffects::Uproar] == 0 @battle.pbDisplay(_INTL("But the uproar kept {1} awake!", pbThis(true))) if showMessages @@ -105,17 +105,16 @@ class Battle::Battler immAlly = nil if Battle::AbilityEffects.triggerStatusImmunityNonIgnorable(self.ability, self, newStatus) immuneByAbility = true - elsif self_inflicted || !@battle.moldBreaker - if abilityActive? && Battle::AbilityEffects.triggerStatusImmunity(self.ability, self, newStatus) + elsif abilityActive? && (self_inflicted || !beingMoldBroken?) && + Battle::AbilityEffects.triggerStatusImmunity(self.ability, self, newStatus) + immuneByAbility = true + else + allAllies.each do |b| + next if !b.abilityActive? || (!self_inflicted && b.beingMoldBroken?) + next if !Battle::AbilityEffects.triggerStatusImmunityFromAlly(b.ability, self, newStatus) immuneByAbility = true - else - allAllies.each do |b| - next if !b.abilityActive? - next if !Battle::AbilityEffects.triggerStatusImmunityFromAlly(b.ability, self, newStatus) - immuneByAbility = true - immAlly = b - break - end + immAlly = b + break end end if immuneByAbility @@ -456,7 +455,7 @@ class Battle::Battler @battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!", pbThis(true))) if showMessages return false end - if (selfInflicted || !@battle.moldBreaker) && hasActiveAbility?(:OWNTEMPO) + if (selfInflicted || !beingMoldBroken?) && hasActiveAbility?(:OWNTEMPO) if showMessages @battle.pbShowAbilitySplash(self) if Battle::Scene::USE_ABILITY_SPLASH @@ -516,32 +515,30 @@ class Battle::Battler @battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) if showMessages return false end - if !@battle.moldBreaker - if hasActiveAbility?([:AROMAVEIL, :OBLIVIOUS]) + if hasActiveAbility?([:AROMAVEIL, :OBLIVIOUS]) && !beingMoldBroken? + if showMessages + @battle.pbShowAbilitySplash(self) + if Battle::Scene::USE_ABILITY_SPLASH + @battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) + else + @battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", pbThis, abilityName)) + end + @battle.pbHideAbilitySplash(self) + end + return false + else + allAllies.each do |b| + next if !b.hasActiveAbility?(:AROMAVEIL) || b.beingMoldBroken? if showMessages - @battle.pbShowAbilitySplash(self) + @battle.pbShowAbilitySplash(b) if Battle::Scene::USE_ABILITY_SPLASH @battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) else - @battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", pbThis, abilityName)) + @battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", b.pbThis, b.abilityName)) end - @battle.pbHideAbilitySplash(self) + @battle.pbHideAbilitySplash(b) end return false - else - allAllies.each do |b| - next if !b.hasActiveAbility?(:AROMAVEIL) - if showMessages - @battle.pbShowAbilitySplash(b) - if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) - else - @battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", b.pbThis, b.abilityName)) - end - @battle.pbHideAbilitySplash(b) - end - return false - end end end return true @@ -569,7 +566,7 @@ class Battle::Battler # Flinching #============================================================================= def pbFlinch(_user = nil) - return if hasActiveAbility?(:INNERFOCUS) && !@battle.moldBreaker + return if hasActiveAbility?(:INNERFOCUS) && !beingMoldBroken? @effects[PBEffects::Flinch] = true end end diff --git a/Data/Scripts/011_Battle/002_Battler/005_Battler_StatStages.rb b/Data/Scripts/011_Battle/002_Battler/005_Battler_StatStages.rb index 134f56f00..5d8ed9661 100644 --- a/Data/Scripts/011_Battle/002_Battler/005_Battler_StatStages.rb +++ b/Data/Scripts/011_Battle/002_Battler/005_Battler_StatStages.rb @@ -9,7 +9,7 @@ class Battle::Battler def pbCanRaiseStatStage?(stat, user = nil, move = nil, showFailMsg = false, ignoreContrary = false) return false if fainted? # Contrary - if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker + if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !beingMoldBroken? return pbCanLowerStatStage?(stat, user, move, showFailMsg, true) end # Check the stat stage @@ -24,7 +24,7 @@ class Battle::Battler end def pbRaiseStatStageBasic(stat, increment, ignoreContrary = false) - if !@battle.moldBreaker + if !beingMoldBroken? # Contrary if hasActiveAbility?(:CONTRARY) && !ignoreContrary return pbLowerStatStageBasic(stat, increment, true) @@ -46,7 +46,7 @@ class Battle::Battler def pbRaiseStatStage(stat, increment, user, showAnim = true, ignoreContrary = false) # Contrary - if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker + if hasActiveAbility?(:CONTRARY) && !beingMoldBroken? && !ignoreContrary return pbLowerStatStage(stat, increment, user, showAnim, true) end # Perform the stat stage change @@ -69,7 +69,7 @@ class Battle::Battler def pbRaiseStatStageByCause(stat, increment, user, cause, showAnim = true, ignoreContrary = false) # Contrary - if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker + if hasActiveAbility?(:CONTRARY) && !beingMoldBroken? && !ignoreContrary return pbLowerStatStageByCause(stat, increment, user, cause, showAnim, true) end # Perform the stat stage change @@ -123,7 +123,7 @@ class Battle::Battler def pbCanLowerStatStage?(stat, user = nil, move = nil, showFailMsg = false, ignoreContrary = false, ignoreMirrorArmor = false) return false if fainted? - if !@battle.moldBreaker + if !beingMoldBroken? # Contrary if hasActiveAbility?(:CONTRARY) && !ignoreContrary return pbCanRaiseStatStage?(stat, user, move, showFailMsg, true) @@ -146,22 +146,25 @@ class Battle::Battler return false end if abilityActive? - return false if !@battle.moldBreaker && Battle::AbilityEffects.triggerStatLossImmunity( + return false if !beingMoldBroken? && Battle::AbilityEffects.triggerStatLossImmunity( self.ability, self, stat, @battle, showFailMsg ) return false if Battle::AbilityEffects.triggerStatLossImmunityNonIgnorable( self.ability, self, stat, @battle, showFailMsg ) end - if !@battle.moldBreaker - allAllies.each do |b| - next if !b.abilityActive? - return false if Battle::AbilityEffects.triggerStatLossImmunityFromAlly( - b.ability, b, self, stat, @battle, showFailMsg - ) - end + allAllies.each do |b| + next if !b.abilityActive? || b.beingMoldBroken? + return false if Battle::AbilityEffects.triggerStatLossImmunityFromAlly( + b.ability, b, self, stat, @battle, showFailMsg + ) end end + if user && user.index != @index # Only protects against moves/abilities of non-self + return false if itemActive? && Battle::ItemEffects.triggerStatLossImmunity( + self.item, self, stat, @battle, showFailMsg + ) + end # Check the stat stage if statStageAtMin?(stat) if showFailMsg @@ -174,7 +177,7 @@ class Battle::Battler end def pbLowerStatStageBasic(stat, increment, ignoreContrary = false) - if !@battle.moldBreaker + if !beingMoldBroken? # Contrary if hasActiveAbility?(:CONTRARY) && !ignoreContrary return pbRaiseStatStageBasic(stat, increment, true) @@ -197,7 +200,7 @@ class Battle::Battler def pbLowerStatStage(stat, increment, user, showAnim = true, ignoreContrary = false, mirrorArmorSplash = 0, ignoreMirrorArmor = false) - if !@battle.moldBreaker + if !beingMoldBroken? # Contrary if hasActiveAbility?(:CONTRARY) && !ignoreContrary return pbRaiseStatStage(stat, increment, user, showAnim, true) @@ -239,7 +242,7 @@ class Battle::Battler def pbLowerStatStageByCause(stat, increment, user, cause, showAnim = true, ignoreContrary = false, ignoreMirrorArmor = false) - if !@battle.moldBreaker + if !beingMoldBroken? # Contrary if hasActiveAbility?(:CONTRARY) && !ignoreContrary return pbRaiseStatStageByCause(stat, increment, user, cause, showAnim, true) @@ -350,6 +353,12 @@ class Battle::Battler return false end end + if itemActive? && + Battle::ItemEffects.triggerStatLossImmunity(self.item, self, :ATTACK, @battle, false) + @battle.pbDisplay(_INTL("{1}'s {2} prevented {3}'s {4} from working!", + pbThis, itemName, user.pbThis(true), user.abilityName)) + return false + end end return false if !pbCanLowerStatStage?(:ATTACK, user) return pbLowerStatStageByCause(:ATTACK, 1, user, user.abilityName) diff --git a/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb b/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb index 1e92403f7..66119240b 100644 --- a/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb +++ b/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb @@ -395,7 +395,7 @@ class Battle::Battler magicCoater = b.index b.effects[PBEffects::MagicCoat] = false break - elsif b.hasActiveAbility?(:MAGICBOUNCE) && !@battle.moldBreaker && + elsif b.hasActiveAbility?(:MAGICBOUNCE) && !b.beingMoldBroken? && !b.effects[PBEffects::MagicBounce] magicBouncer = b.index b.effects[PBEffects::MagicBounce] = true diff --git a/Data/Scripts/011_Battle/002_Battler/009_Battler_UseMoveSuccessChecks.rb b/Data/Scripts/011_Battle/002_Battler/009_Battler_UseMoveSuccessChecks.rb index 66686e67c..642687e38 100644 --- a/Data/Scripts/011_Battle/002_Battler/009_Battler_UseMoveSuccessChecks.rb +++ b/Data/Scripts/011_Battle/002_Battler/009_Battler_UseMoveSuccessChecks.rb @@ -334,7 +334,7 @@ class Battle::Battler @battle.successStates[user.index].protected = true return false end - if !(user.hasActiveAbility?(:UNSEENFIST) && move.contactMove?) + if !(user.hasActiveAbility?(:UNSEENFIST) && move.pbContactMove?(user)) # Wide Guard if target.pbOwnSide.effects[PBEffects::WideGuard] && user.index != target.index && move.pbTarget(user).num_targets > 1 && @@ -444,7 +444,7 @@ class Battle::Battler target.effects[PBEffects::MagicCoat] = false return false end - if target.hasActiveAbility?(:MAGICBOUNCE) && !@battle.moldBreaker && + if target.hasActiveAbility?(:MAGICBOUNCE) && !target.beingMoldBroken? && !target.effects[PBEffects::MagicBounce] target.damageState.magicBounce = true target.effects[PBEffects::MagicBounce] = true @@ -469,7 +469,7 @@ class Battle::Battler # Airborne-based immunity to Ground moves if move.damagingMove? && move.calcType == :GROUND && target.airborne? && !move.hitsFlyingTargets? - if target.hasActiveAbility?(:LEVITATE) && !@battle.moldBreaker + if target.hasActiveAbility?(:LEVITATE) && !target.beingMoldBroken? if show_message @battle.pbShowAbilitySplash(target) if Battle::Scene::USE_ABILITY_SPLASH @@ -502,7 +502,7 @@ class Battle::Battler return false end if Settings::MECHANICS_GENERATION >= 6 - if target.hasActiveAbility?(:OVERCOAT) && !@battle.moldBreaker + if target.hasActiveAbility?(:OVERCOAT) && !target.beingMoldBroken? if show_message @battle.pbShowAbilitySplash(target) if Battle::Scene::USE_ABILITY_SPLASH diff --git a/Data/Scripts/011_Battle/003_Move/001_Battle_Move.rb b/Data/Scripts/011_Battle/003_Move/001_Battle_Move.rb index f59849cee..1bc3a4117 100644 --- a/Data/Scripts/011_Battle/003_Move/001_Battle_Move.rb +++ b/Data/Scripts/011_Battle/003_Move/001_Battle_Move.rb @@ -139,6 +139,8 @@ class Battle::Move def pulseMove?; return @flags.any? { |f| f[/^Pulse$/i] }; end def bombMove?; return @flags.any? { |f| f[/^Bomb$/i] }; end def danceMove?; return @flags.any? { |f| f[/^Dance$/i] }; end + def slicingMove?; return @flags.any? { |f| f[/^Slicing$/i] }; end + def windMove?; return @flags.any? { |f| f[/^Wind$/i] }; end # Causes perfect accuracy and double damage if target used Minimize. Perfect accuracy only with Gen 6+ mechanics. def tramplesMinimize?; return @flags.any? { |f| f[/^TramplesMinimize$/i] }; end diff --git a/Data/Scripts/011_Battle/003_Move/002_Move_Usage.rb b/Data/Scripts/011_Battle/003_Move/002_Move_Usage.rb index 33b13e68d..62b71fdea 100644 --- a/Data/Scripts/011_Battle/003_Move/002_Move_Usage.rb +++ b/Data/Scripts/011_Battle/003_Move/002_Move_Usage.rb @@ -37,6 +37,7 @@ class Battle::Move def pbContactMove?(user) return false if user.hasActiveAbility?(:LONGREACH) + return false if punchingMove? && user.hasActiveItem?(:PUNCHINGGLOVE) return contactMove? end @@ -86,9 +87,8 @@ class Battle::Move # Check if target is immune to the move because of its ability #============================================================================= def pbImmunityByAbility(user, target, show_message) - return false if @battle.moldBreaker ret = false - if target.abilityActive? + if target.abilityActive? && !target.beingMoldBroken? ret = Battle::AbilityEffects.triggerMoveImmunity(target.ability, user, target, self, @calcType, @battle, show_message) end @@ -126,8 +126,7 @@ class Battle::Move end def pbMoveFailedAromaVeil?(user, target, showMessage = true) - return false if @battle.moldBreaker - if target.hasActiveAbility?(:AROMAVEIL) + if target.hasActiveAbility?(:AROMAVEIL) && !target.beingMoldBroken? if showMessage @battle.pbShowAbilitySplash(target) if Battle::Scene::USE_ABILITY_SPLASH @@ -141,7 +140,7 @@ class Battle::Move return true end target.allAllies.each do |b| - next if !b.hasActiveAbility?(:AROMAVEIL) + next if !b.hasActiveAbility?(:AROMAVEIL) || b.beingMoldBroken? if showMessage @battle.pbShowAbilitySplash(b) if Battle::Scene::USE_ABILITY_SPLASH @@ -168,13 +167,13 @@ class Battle::Move return end # Ice Face will take the damage - if !@battle.moldBreaker && target.isSpecies?(:EISCUE) && + if !target.beingMoldBroken? && target.isSpecies?(:EISCUE) && target.form == 0 && target.ability == :ICEFACE && physicalMove? target.damageState.iceFace = true return end # Disguise will take the damage - if !@battle.moldBreaker && target.isSpecies?(:MIMIKYU) && + if !target.beingMoldBroken? && target.isSpecies?(:MIMIKYU) && target.form == 0 && target.ability == :DISGUISE target.damageState.disguise = true return @@ -202,7 +201,7 @@ class Battle::Move target.damageState.endured = true damage -= 1 elsif damage == target.totalhp - if target.hasActiveAbility?(:STURDY) && !@battle.moldBreaker + if target.hasActiveAbility?(:STURDY) && !target.beingMoldBroken? target.damageState.sturdy = true damage -= 1 elsif target.hasActiveItem?(:FOCUSSASH) && target.hp == target.totalhp diff --git a/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb b/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb index 342abdfb6..0148e2efe 100644 --- a/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb +++ b/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb @@ -37,8 +37,8 @@ class Battle::Move ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER end # Foresight - if (user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]) && - defType == :GHOST + if (user.hasActiveAbility?(:SCRAPPY) || user.hasActiveAbility?(:MINDSEYE) || + target.effects[PBEffects::Foresight]) && defType == :GHOST ret = Effectiveness::NORMAL_EFFECTIVE_MULTIPLIER end # Miracle Eye @@ -136,7 +136,7 @@ class Battle::Move b.ability, modifiers, user, target, self, @calcType ) end - if target.abilityActive? && !@battle.moldBreaker + if target.abilityActive? && !target.beingMoldBroken? Battle::AbilityEffects.triggerAccuracyCalcFromTarget( target.ability, modifiers, user, target, self, @calcType ) @@ -163,6 +163,7 @@ class Battle::Move end modifiers[:evasion_stage] = 0 if target.effects[PBEffects::Foresight] && modifiers[:evasion_stage] > 0 modifiers[:evasion_stage] = 0 if target.effects[PBEffects::MiracleEye] && modifiers[:evasion_stage] > 0 + modifiers[:evasion_stage] = 0 if user.hasActiveAbility?(:MINDSEYE) end #============================================================================= @@ -182,7 +183,7 @@ class Battle::Move if c >= 0 && user.abilityActive? c = Battle::AbilityEffects.triggerCriticalCalcFromUser(user.ability, user, target, c) end - if c >= 0 && target.abilityActive? && !@battle.moldBreaker + if c >= 0 && target.abilityActive? && !target.beingMoldBroken? c = Battle::AbilityEffects.triggerCriticalCalcFromTarget(target.ability, user, target, c) end # Item effects that alter critical hit rate @@ -253,7 +254,7 @@ class Battle::Move baseDmg = pbBaseDamage(@power, user, target) # Calculate user's attack stat atk, atkStage = pbGetAttackStats(user, target) - if !target.hasActiveAbility?(:UNAWARE) || @battle.moldBreaker + if !target.hasActiveAbility?(:UNAWARE) || target.beingMoldBroken? atkStage = max_stage if target.damageState.critical && atkStage < max_stage atk = (atk.to_f * stageMul[atkStage] / stageDiv[atkStage]).floor end @@ -282,48 +283,65 @@ class Battle::Move def pbCalcDamageMultipliers(user, target, numTargets, type, baseDmg, multipliers) # Global abilities - if (@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) || - (@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY) - if @battle.pbCheckGlobalAbility(:AURABREAK) + all_abilities = @battle.pbAllActiveAbilities + if (all_abilities.include?(:DARKAURA) && type == :DARK) || + (all_abilities.include?(:FAIRYAURA) && type == :FAIRY) + if all_abilities.include?(:AURABREAK) multipliers[:power_multiplier] *= 3 / 4.0 else multipliers[:power_multiplier] *= 4 / 3.0 end end + if all_abilities.include?(:TABLETSOFRUIN) && user.ability_id != :TABLETSOFRUIN + multipliers[:power_multiplier] *= 3 / 4.0 if physicalMove? + end + if all_abilities.include?(:VESSELOFRUIN) && user.ability_id != :VESSELOFRUIN + multipliers[:power_multiplier] *= 3 / 4.0 if specialMove? + end + if all_abilities.include?(:SWORDOFRUIN) && user.ability_id != :SWORDOFRUIN + if @battle.field.effects[PBEffects::WonderRoom] > 0 + multipliers[:defense_multiplier] *= 3 / 4.0 if specialMove? + else + multipliers[:defense_multiplier] *= 3 / 4.0 if physicalMove? + end + end + if all_abilities.include?(:BEADSOFRUIN) && user.ability_id != :BEADSOFRUIN + if @battle.field.effects[PBEffects::WonderRoom] > 0 + multipliers[:defense_multiplier] *= 3 / 4.0 if physicalMove? + else + multipliers[:defense_multiplier] *= 3 / 4.0 if specialMove? + end + end # Ability effects that alter damage if user.abilityActive? Battle::AbilityEffects.triggerDamageCalcFromUser( user.ability, user, target, self, multipliers, baseDmg, type ) end - if !@battle.moldBreaker - # NOTE: It's odd that the user's Mold Breaker prevents its partner's - # beneficial abilities (i.e. Flower Gift boosting Atk), but that's - # how it works. - user.allAllies.each do |b| - next if !b.abilityActive? - Battle::AbilityEffects.triggerDamageCalcFromAlly( - b.ability, user, target, self, multipliers, baseDmg, type - ) - end - if target.abilityActive? + # NOTE: It's odd that the user's Mold Breaker prevents its partner's + # beneficial abilities (i.e. Flower Gift boosting Atk), but that's + # how it works. + user.allAllies.each do |b| + next if !b.abilityActive? || b.beingMoldBroken? + Battle::AbilityEffects.triggerDamageCalcFromAlly( + b.ability, user, target, self, multipliers, baseDmg, type + ) + end + if target.abilityActive? + if !target.beingMoldBroken? Battle::AbilityEffects.triggerDamageCalcFromTarget( target.ability, user, target, self, multipliers, baseDmg, type ) end - end - if target.abilityActive? Battle::AbilityEffects.triggerDamageCalcFromTargetNonIgnorable( target.ability, user, target, self, multipliers, baseDmg, type ) end - if !@battle.moldBreaker - target.allAllies.each do |b| - next if !b.abilityActive? - Battle::AbilityEffects.triggerDamageCalcFromTargetAlly( - b.ability, user, target, self, multipliers, baseDmg, type - ) - end + target.allAllies.each do |b| + next if !b.abilityActive? || b.beingMoldBroken? + Battle::AbilityEffects.triggerDamageCalcFromTargetAlly( + b.ability, user, target, self, multipliers, baseDmg, type + ) end # Item effects that alter damage if user.itemActive? @@ -400,13 +418,17 @@ class Battle::Move # Multi-targeting attacks multipliers[:final_damage_multiplier] *= 0.75 if numTargets > 1 # Weather - case user.effectiveWeather + case target.effectiveWeather when :Sun, :HarshSun case type when :FIRE multipliers[:final_damage_multiplier] *= 1.5 when :WATER - multipliers[:final_damage_multiplier] /= 2 + if @function_code == "IncreasePowerInSun" && [:Sun, :HarshSun].include?(user.effectiveWeather) + multipliers[:final_damage_multiplier] *= 1.5 + else + multipliers[:final_damage_multiplier] /= 2 + end end when :Rain, :HeavyRain case type @@ -487,7 +509,7 @@ class Battle::Move # Additional effect chance #============================================================================= def pbAdditionalEffectChance(user, target, effectChance = 0) - return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker + return 0 if target.hasActiveAbility?(:SHIELDDUST) && !target.beingMoldBroken? ret = (effectChance > 0) ? effectChance : @addlEffect return ret if ret > 100 if (Settings::MECHANICS_GENERATION >= 6 || @function_code != "EffectDependsOnEnvironment") && @@ -502,7 +524,7 @@ class Battle::Move # not here. def pbFlinchChance(user, target) return 0 if flinchingMove? - return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker + return 0 if target.hasActiveAbility?(:SHIELDDUST) && !target.beingMoldBroken? ret = 0 if user.hasActiveAbility?(:STENCH, true) || user.hasActiveItem?([:KINGSROCK, :RAZORFANG], true) diff --git a/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb b/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb index a7e9afb00..6455c2f7e 100644 --- a/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb +++ b/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb @@ -212,7 +212,7 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move # NOTE: It's a bit of a faff to make sure the appropriate failure message # is shown here, I know. canLower = false - if target.hasActiveAbility?(:CONTRARY) && !@battle.moldBreaker + if target.hasActiveAbility?(:CONTRARY) && !target.beingMoldBroken? (@statDown.length / 2).times do |i| next if target.statStageAtMax?(@statDown[i * 2]) canLower = true diff --git a/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb b/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb index fd0968291..a6337a30a 100644 --- a/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb +++ b/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb @@ -342,19 +342,16 @@ class Battle::Move::StartPsychicTerrain < Battle::Move end #=============================================================================== -# Removes the current terrain. Fails if there is no terrain in effect. -# (Steel Roller) +# Removes the current terrain. (Ice Spinner) #=============================================================================== class Battle::Move::RemoveTerrain < Battle::Move - def pbMoveFailed?(user, targets) - if @battle.field.terrain == :None - @battle.pbDisplay(_INTL("But it failed!")) - return true - end - return false - end - + # NOTE: Bulbapedia claims that Ice Spinner shouldn't remove terrain if the + # user faints because of its Life Orb or is switched out by Red Card. + # I can't find any evidence of this. Also, those items trigger at the + # very end of a move's use, way after move effects usually happen. I'm + # treating Bulbapedia's claim as a mistake and ignoring it. def pbEffectGeneral(user) + return if user.fainted? case @battle.field.terrain when :Electric @battle.pbDisplay(_INTL("The electricity disappeared from the battlefield.")) @@ -369,6 +366,20 @@ class Battle::Move::RemoveTerrain < Battle::Move end end +#=============================================================================== +# Removes the current terrain. Fails if there is no terrain in effect. +# (Steel Roller) +#=============================================================================== +class Battle::Move::RemoveTerrainFailsIfNoTerrain < Battle::Move::RemoveTerrain + def pbMoveFailed?(user, targets) + if @battle.field.terrain == :None + @battle.pbDisplay(_INTL("But it failed!")) + return true + end + return false + end +end + #=============================================================================== # Entry hazard. Lays spikes on the opposing side (max. 3 layers). (Spikes) #=============================================================================== diff --git a/Data/Scripts/011_Battle/003_Move/006_MoveEffects_BattlerStats.rb b/Data/Scripts/011_Battle/003_Move/006_MoveEffects_BattlerStats.rb index ec09b37ec..f5101bab0 100644 --- a/Data/Scripts/011_Battle/003_Move/006_MoveEffects_BattlerStats.rb +++ b/Data/Scripts/011_Battle/003_Move/006_MoveEffects_BattlerStats.rb @@ -387,6 +387,16 @@ class Battle::Move::RaiseUserAtkDef1 < Battle::Move::MultiStatUpMove end end +#=============================================================================== +# Increases the user's Attack, Defense and Speed by 1 stage each. (Victory Dance) +#=============================================================================== +class Battle::Move::RaiseUserAtkDefSpd1 < Battle::Move::MultiStatUpMove + def initialize(battle, move) + super + @statUp = [:ATTACK, 1, :DEFENSE, 1, :SPEED, 1] + end +end + #=============================================================================== # Increases the user's Attack, Defense and accuracy by 1 stage each. (Coil) #=============================================================================== @@ -1037,7 +1047,7 @@ class Battle::Move::LowerTargetSpAtk2IfCanAttract < Battle::Move::TargetStatDown @battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) if show_message return true end - if target.hasActiveAbility?(:OBLIVIOUS) && !@battle.moldBreaker + if target.hasActiveAbility?(:OBLIVIOUS) && !target.beingMoldBroken? if show_message @battle.pbShowAbilitySplash(target) if Battle::Scene::USE_ABILITY_SPLASH @@ -1054,7 +1064,7 @@ class Battle::Move::LowerTargetSpAtk2IfCanAttract < Battle::Move::TargetStatDown def pbAdditionalEffect(user, target) return if user.gender == 2 || target.gender == 2 || user.gender == target.gender - return if target.hasActiveAbility?(:OBLIVIOUS) && !@battle.moldBreaker + return if target.hasActiveAbility?(:OBLIVIOUS) && !target.beingMoldBroken? super end end @@ -1109,6 +1119,17 @@ class Battle::Move::LowerTargetSpeed1 < Battle::Move::TargetStatDownMove end end +#=============================================================================== +# Decreases the target's Speed by 1 stage. Accuracy perfect in rain. +# (Bleakwind Storm) +#=============================================================================== +class Battle::Move::LowerTargetSpeed1AlwaysHitsInRain < Battle::Move::LowerTargetSpeed1 + def pbBaseAccuracy(user, target) + return 0 if [:Rain, :HeavyRain].include?(target.effectiveWeather) + return super + end +end + #=============================================================================== # Decreases the target's Speed by 1 stage. Power is halved in Grassy Terrain. # (Bulldoze) @@ -1932,6 +1953,9 @@ class Battle::Move::StartUserSideDoubleSpeed < Battle::Move def pbEffectGeneral(user) user.pbOwnSide.effects[PBEffects::Tailwind] = 4 @battle.pbDisplay(_INTL("The Tailwind blew from behind {1}!", user.pbTeam(true))) + @battle.allSameSideBattlers(user).each do |b| + pbRaiseStatStageByAbility(:ATTACK, 1, b) if b.hasActiveAbility?(:WINDRIDER) + end end end diff --git a/Data/Scripts/011_Battle/003_Move/007_MoveEffects_BattlerOther.rb b/Data/Scripts/011_Battle/003_Move/007_MoveEffects_BattlerOther.rb index fd2a795f9..d863c6774 100644 --- a/Data/Scripts/011_Battle/003_Move/007_MoveEffects_BattlerOther.rb +++ b/Data/Scripts/011_Battle/003_Move/007_MoveEffects_BattlerOther.rb @@ -176,6 +176,16 @@ class Battle::Move::ParalyzeTargetIfNotTypeImmune < Battle::Move::ParalyzeTarget end end +#=============================================================================== +# Paralyzes the target. Accuracy perfect in rain. (Wildbolt Storm) +#=============================================================================== +class Battle::Move::ParalyzeTargetAlwaysHitsInRain < Battle::Move::ParalyzeTarget + def pbBaseAccuracy(user, target) + return 0 if [:Rain, :HeavyRain].include?(target.effectiveWeather) + return super + end +end + #=============================================================================== # Paralyzes the target. Accuracy perfect in rain, 50% in sunshine. Hits some # semi-invulnerable targets. (Thunder) @@ -233,6 +243,16 @@ class Battle::Move::BurnTarget < Battle::Move end end +#=============================================================================== +# Burns the target. Accuracy perfect in rain. (Sandsear Storm) +#=============================================================================== +class Battle::Move::BurnTargetAlwaysHitsInRain < Battle::Move::BurnTarget + def pbBaseAccuracy(user, target) + return 0 if [:Rain, :HeavyRain].include?(target.effectiveWeather) + return super + end +end + #=============================================================================== # Burns the target if any of its stats were increased this round. # (Burning Jealousy) diff --git a/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb b/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb index 8cd3b428b..b30e327e7 100644 --- a/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb +++ b/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb @@ -73,7 +73,7 @@ class Battle::Move::OHKO < Battle::Move::FixedDamageMove @battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) if show_message return true end - if target.hasActiveAbility?(:STURDY) && !@battle.moldBreaker + if target.hasActiveAbility?(:STURDY) && !target.beingMoldBroken? if show_message @battle.pbShowAbilitySplash(target) if Battle::Scene::USE_ABILITY_SPLASH @@ -190,10 +190,19 @@ class Battle::Move::PowerLowerWithUserHP < Battle::Move end end +#=============================================================================== +# Power increases with the target's HP. (Hard Press) +#=============================================================================== +class Battle::Move::PowerHigherWithTargetHP100 < Battle::Move + def pbBaseDamage(baseDmg, user, target) + return [100 * target.hp / target.totalhp, 1].max + end +end + #=============================================================================== # Power increases with the target's HP. (Crush Grip, Wring Out) #=============================================================================== -class Battle::Move::PowerHigherWithTargetHP < Battle::Move +class Battle::Move::PowerHigherWithTargetHP120 < Battle::Move def pbBaseDamage(baseDmg, user, target) return [120 * target.hp / target.totalhp, 1].max end @@ -395,6 +404,23 @@ class Battle::Move::RandomPowerDoublePowerIfTargetUnderground < Battle::Move end end +#=============================================================================== +# Power is increased by 50% in sunny weather. (Hydro Steam) +#=============================================================================== +class Battle::Move::IncreasePowerInSun < Battle::Move + # NOTE: No code needed here. Effect is coded in def pbCalcDamageMultipliers. +end + +#=============================================================================== +# Power is increased by 50% if Electric Terrain applies. (Psyblade) +#=============================================================================== +class Battle::Move::IncreasePowerInElectricTerrain < Battle::Move + def pbBaseDamage(baseDmg, user, target) + baseDmg = (baseDmg * 1.5).floor if @battle.field.terrain == :Electric && target.affectedByTerrain? + return baseDmg + end +end + #=============================================================================== # Power is doubled if the target's HP is down to 1/2 or less. (Brine) #=============================================================================== @@ -1090,6 +1116,15 @@ class Battle::Move::RecoilHalfOfDamageDealt < Battle::Move::RecoilMove end end +#=============================================================================== +# User takes recoil damage equal to 1/2 of is maximum HP. (Chloroblast) +#=============================================================================== +class Battle::Move::RecoilHalfOfTotalHP < Battle::Move::RecoilMove + def pbRecoilDamage(user, target) + return (user.totalhp / 2.0).round + end +end + #=============================================================================== # Type effectiveness is multiplied by the Flying-type's effectiveness against # the target. (Flying Press) diff --git a/Data/Scripts/011_Battle/003_Move/009_MoveEffects_MultiHit.rb b/Data/Scripts/011_Battle/003_Move/009_MoveEffects_MultiHit.rb index 2e4ef4cc0..1d02d825a 100644 --- a/Data/Scripts/011_Battle/003_Move/009_MoveEffects_MultiHit.rb +++ b/Data/Scripts/011_Battle/003_Move/009_MoveEffects_MultiHit.rb @@ -76,7 +76,7 @@ class Battle::Move::HitThreeTimesPowersUpWithEachHit < Battle::Move def pbOnStartUse(user, targets) @calcBaseDmg = 0 - @accCheckPerHit = !user.hasActiveAbility?(:SKILLLINK) + @accCheckPerHit = !user.hasActiveAbility?(:SKILLLINK) && !user.hasActiveItem?(:LOADEDDICE) end def pbBaseDamage(baseDmg, user, target) @@ -110,6 +110,7 @@ class Battle::Move::HitTwoToFiveTimes < Battle::Move ] r = @battle.pbRandom(hitChances.length) r = hitChances.length - 1 if user.hasActiveAbility?(:SKILLLINK) + r = 4 if r < 4 && user.hasActiveItem?(:LOADEDDICE) return hitChances[r] end end diff --git a/Data/Scripts/011_Battle/003_Move/010_MoveEffects_Healing.rb b/Data/Scripts/011_Battle/003_Move/010_MoveEffects_Healing.rb index 5e1de0c7a..4ac5cd24e 100644 --- a/Data/Scripts/011_Battle/003_Move/010_MoveEffects_Healing.rb +++ b/Data/Scripts/011_Battle/003_Move/010_MoveEffects_Healing.rb @@ -125,7 +125,7 @@ class Battle::Move::HealUserByTargetAttackLowerTargetAttack1 < Battle::Move # has Contrary and is at +6" check too for symmetry. This move still # works even if the stat stage cannot be changed due to an ability or # other effect. - if !@battle.moldBreaker && target.hasActiveAbility?(:CONTRARY) + if target.hasActiveAbility?(:CONTRARY) && !target.beingMoldBroken? if target.statStageAtMax?(@statDown[0]) @battle.pbDisplay(_INTL("But it failed!")) if show_message return true @@ -469,19 +469,17 @@ class Battle::Move::UserLosesHalfOfTotalHPExplosive < Battle::Move def worksWithNoTargets?; return true; end def pbMoveFailed?(user, targets) - if !@battle.moldBreaker - bearer = @battle.pbCheckGlobalAbility(:DAMP) - if bearer - @battle.pbShowAbilitySplash(bearer) - if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, @name)) - else - @battle.pbDisplay(_INTL("{1} cannot use {2} because of {3}'s {4}!", - user.pbThis, @name, bearer.pbThis(true), bearer.abilityName)) - end - @battle.pbHideAbilitySplash(bearer) - return true + bearer = @battle.pbCheckGlobalAbility(:DAMP, true) + if bearer + @battle.pbShowAbilitySplash(bearer) + if Battle::Scene::USE_ABILITY_SPLASH + @battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, @name)) + else + @battle.pbDisplay(_INTL("{1} cannot use {2} because of {3}'s {4}!", + user.pbThis, @name, bearer.pbThis(true), bearer.abilityName)) end + @battle.pbHideAbilitySplash(bearer) + return true end return false end @@ -501,19 +499,17 @@ class Battle::Move::UserFaintsExplosive < Battle::Move def pbNumHits(user, targets); return 1; end def pbMoveFailed?(user, targets) - if !@battle.moldBreaker - bearer = @battle.pbCheckGlobalAbility(:DAMP) - if bearer - @battle.pbShowAbilitySplash(bearer) - if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, @name)) - else - @battle.pbDisplay(_INTL("{1} cannot use {2} because of {3}'s {4}!", - user.pbThis, @name, bearer.pbThis(true), bearer.abilityName)) - end - @battle.pbHideAbilitySplash(bearer) - return true + bearer = @battle.pbCheckGlobalAbility(:DAMP, true) + if bearer + @battle.pbShowAbilitySplash(bearer) + if Battle::Scene::USE_ABILITY_SPLASH + @battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, @name)) + else + @battle.pbDisplay(_INTL("{1} cannot use {2} because of {3}'s {4}!", + user.pbThis, @name, bearer.pbThis(true), bearer.abilityName)) end + @battle.pbHideAbilitySplash(bearer) + return true end return false end diff --git a/Data/Scripts/011_Battle/003_Move/011_MoveEffects_Items.rb b/Data/Scripts/011_Battle/003_Move/011_MoveEffects_Items.rb index 92fa820e0..3f71eeed4 100644 --- a/Data/Scripts/011_Battle/003_Move/011_MoveEffects_Items.rb +++ b/Data/Scripts/011_Battle/003_Move/011_MoveEffects_Items.rb @@ -10,7 +10,7 @@ class Battle::Move::UserTakesTargetItem < Battle::Move return if !target.item || user.item return if target.unlosableItem?(target.item) return if user.unlosableItem?(target.item) - return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker + return if target.hasActiveAbility?(:STICKYHOLD) && !target.beingMoldBroken? itemName = target.itemName user.item = target.item # Permanently steal the item from wild Pokémon @@ -91,7 +91,7 @@ class Battle::Move::UserTargetSwapItems < Battle::Move @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end - if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker + if target.hasActiveAbility?(:STICKYHOLD) && !target.beingMoldBroken? if show_message @battle.pbShowAbilitySplash(target) if Battle::Scene::USE_ABILITY_SPLASH @@ -181,7 +181,7 @@ class Battle::Move::RemoveTargetItem < Battle::Move return if user.fainted? return if target.damageState.unaffected || target.damageState.substitute return if !target.item || target.unlosableItem?(target.item) - return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker + return if target.hasActiveAbility?(:STICKYHOLD) && !target.beingMoldBroken? itemName = target.itemName target.pbRemoveItem(false) @battle.pbDisplay(_INTL("{1} dropped its {2}!", target.pbThis, itemName)) @@ -197,7 +197,7 @@ class Battle::Move::DestroyTargetBerryOrGem < Battle::Move return if !target.item || (!target.item.is_berry? && !(Settings::MECHANICS_GENERATION >= 6 && target.item.is_gem?)) return if target.unlosableItem?(target.item) - return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker + return if target.hasActiveAbility?(:STICKYHOLD) && !target.beingMoldBroken? item_name = target.itemName target.pbRemoveItem @battle.pbDisplay(_INTL("{1}'s {2} was incinerated!", target.pbThis, item_name)) @@ -219,7 +219,7 @@ class Battle::Move::CorrodeTargetItem < Battle::Move @battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) if show_message return true end - if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker + if target.hasActiveAbility?(:STICKYHOLD) && !target.beingMoldBroken? if show_message @battle.pbShowAbilitySplash(target) if Battle::Scene::USE_ABILITY_SPLASH @@ -386,7 +386,7 @@ class Battle::Move::UserConsumeTargetBerry < Battle::Move return if user.fainted? || target.fainted? return if target.damageState.unaffected || target.damageState.substitute return if !target.item || !target.item.is_berry? || target.unlosableItem?(target.item) - return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker + return if target.hasActiveAbility?(:STICKYHOLD) && !target.beingMoldBroken? item = target.item itemName = target.itemName user.setBelched @@ -438,7 +438,7 @@ class Battle::Move::ThrowUserItemAtTarget < Battle::Move def pbEffectAgainstTarget(user, target) return if target.damageState.substitute - return if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker + return if target.hasActiveAbility?(:SHIELDDUST) && !target.beingMoldBroken? case user.item_id when :POISONBARB target.pbPoison(user) if target.pbCanPoison?(user, false, self) diff --git a/Data/Scripts/011_Battle/003_Move/013_MoveEffects_SwitchingActing.rb b/Data/Scripts/011_Battle/003_Move/013_MoveEffects_SwitchingActing.rb index df0a078ed..25838d755 100644 --- a/Data/Scripts/011_Battle/003_Move/013_MoveEffects_SwitchingActing.rb +++ b/Data/Scripts/011_Battle/003_Move/013_MoveEffects_SwitchingActing.rb @@ -155,7 +155,7 @@ class Battle::Move::SwitchOutTargetStatusMove < Battle::Move def canMagicCoat?; return true; end def pbFailsAgainstTarget?(user, target, show_message) - if target.hasActiveAbility?(:SUCTIONCUPS) && !@battle.moldBreaker + if target.hasActiveAbility?(:SUCTIONCUPS) && !target.beingMoldBroken? if show_message @battle.pbShowAbilitySplash(target) if Battle::Scene::USE_ABILITY_SPLASH @@ -206,7 +206,7 @@ class Battle::Move::SwitchOutTargetStatusMove < Battle::Move next if b.fainted? || b.damageState.unaffected next if b.wild? next if b.effects[PBEffects::Ingrain] - next if b.hasActiveAbility?(:SUCTIONCUPS) && !@battle.moldBreaker + next if b.hasActiveAbility?(:SUCTIONCUPS) && !b.beingMoldBroken? newPkmn = @battle.pbGetReplacementPokemonIndex(b.index, true) # Random next if newPkmn < 0 @battle.pbRecallAndReplace(b.index, newPkmn, true) @@ -241,7 +241,7 @@ class Battle::Move::SwitchOutTargetDamagingMove < Battle::Move next if b.fainted? || b.damageState.unaffected || b.damageState.substitute next if b.wild? next if b.effects[PBEffects::Ingrain] - next if b.hasActiveAbility?(:SUCTIONCUPS) && !@battle.moldBreaker + next if b.hasActiveAbility?(:SUCTIONCUPS) && !b.beingMoldBroken? newPkmn = @battle.pbGetReplacementPokemonIndex(b.index, true) # Random next if newPkmn < 0 @battle.pbRecallAndReplace(b.index, newPkmn, true) @@ -868,7 +868,7 @@ class Battle::Move::DisableTargetStatusMoves < Battle::Move end return true if pbMoveFailedAromaVeil?(user, target, show_message) if Settings::MECHANICS_GENERATION >= 6 && target.hasActiveAbility?(:OBLIVIOUS) && - !@battle.moldBreaker + !target.beingMoldBroken? if show_message @battle.pbShowAbilitySplash(target) if Battle::Scene::USE_ABILITY_SPLASH diff --git a/Data/Scripts/011_Battle/005_AI/006_AI_ChooseMove_GenericEffects.rb b/Data/Scripts/011_Battle/005_AI/006_AI_ChooseMove_GenericEffects.rb index 2f0bbfa83..794e503b1 100644 --- a/Data/Scripts/011_Battle/005_AI/006_AI_ChooseMove_GenericEffects.rb +++ b/Data/Scripts/011_Battle/005_AI/006_AI_ChooseMove_GenericEffects.rb @@ -18,7 +18,7 @@ class Battle::AI desire_mult = -1 end # If target has Contrary, use different calculations to score the stat change - if !ignore_contrary && !fixed_change && !@battle.moldBreaker && target.has_active_ability?(:CONTRARY) + if !ignore_contrary && !fixed_change && target.has_active_ability?(:CONTRARY) && !target.being_mold_broken? if desire_mult > 0 && whole_effect PBDebug.log_score_change(MOVE_USELESS_SCORE - score, "don't prefer raising target's stats (it has Contrary)") return MOVE_USELESS_SCORE @@ -62,7 +62,7 @@ class Battle::AI end # Calculate amount that stat will be raised by increment = stat_changes[idx + 1] - increment *= 2 if !fixed_change && !@battle.moldBreaker && target.has_active_ability?(:SIMPLE) + increment *= 2 if !fixed_change && target.has_active_ability?(:SIMPLE) && !target.being_mold_broken? increment = [increment, Battle::Battler::STAT_STAGE_MAXIMUM - target.stages[stat]].min # The actual stages gained # Count this as a valid stat raise real_stat_changes.push([stat, increment]) if increment > 0 @@ -324,7 +324,7 @@ class Battle::AI desire_mult = 1 end # If target has Contrary, use different calculations to score the stat change - if !ignore_contrary && !fixed_change && !@battle.moldBreaker && target.has_active_ability?(:CONTRARY) + if !ignore_contrary && !fixed_change && target.has_active_ability?(:CONTRARY) && !target.being_mold_broken? if desire_mult > 0 && whole_effect PBDebug.log_score_change(MOVE_USELESS_SCORE - score, "don't prefer lowering target's stats (it has Contrary)") return MOVE_USELESS_SCORE @@ -366,7 +366,7 @@ class Battle::AI end # Calculate amount that stat will be lowered by decrement = stat_changes[idx + 1] - decrement *= 2 if !fixed_change && !@battle.moldBreaker && target.has_active_ability?(:SIMPLE) + decrement *= 2 if !fixed_change && target.has_active_ability?(:SIMPLE) && !target.being_mold_broken? decrement = [decrement, Battle::Battler::STAT_STAGE_MAXIMUM + target.stages[stat]].min # The actual stages lost # Count this as a valid stat drop real_stat_changes.push([stat, decrement]) if decrement > 0 diff --git a/Data/Scripts/011_Battle/005_AI/007_AI_ChooseMove_OtherScores.rb b/Data/Scripts/011_Battle/005_AI/007_AI_ChooseMove_OtherScores.rb index f301b814c..5108b5296 100644 --- a/Data/Scripts/011_Battle/005_AI/007_AI_ChooseMove_OtherScores.rb +++ b/Data/Scripts/011_Battle/005_AI/007_AI_ChooseMove_OtherScores.rb @@ -89,7 +89,7 @@ Battle::AI::Handlers::GeneralMoveAgainstTargetScore.add(:target_can_Magic_Coat_o if move.statusMove? && move.move.canMagicCoat? && target.opposes?(user) && (target.faster_than?(user) || !target.battler.semiInvulnerable?) old_score = score - if !battle.moldBreaker && target.has_active_ability?(:MAGICBOUNCE) + if target.has_active_ability?(:MAGICBOUNCE) && !target.being_mold_broken? score = Battle::AI::MOVE_USELESS_SCORE PBDebug.log_score_change(score - old_score, "useless because target will Magic Bounce it") elsif target.has_move_with_function?("BounceBackProblemCausingStatusMoves") && @@ -108,7 +108,7 @@ Battle::AI::Handlers::GeneralMoveScore.add(:any_foe_can_Magic_Coat_or_Bounce_mov old_score = score ai.each_foe_battler(user.side) do |b, i| next if user.faster_than?(b) && b.battler.semiInvulnerable? - if b.has_active_ability?(:MAGICBOUNCE) && !battle.moldBreaker + if b.has_active_ability?(:MAGICBOUNCE) && !b.being_mold_broken? score = Battle::AI::MOVE_USELESS_SCORE PBDebug.log_score_change(score - old_score, "useless because a foe will Magic Bounce it") break @@ -336,7 +336,7 @@ Battle::AI::Handlers::GeneralMoveAgainstTargetScore.add(:external_flinching_effe user.faster_than?(target) && target.effects[PBEffects::Substitute] == 0 if user.has_active_item?([:KINGSROCK, :RAZORFANG]) || user.has_active_ability?(:STENCH) - if battle.moldBreaker || !target.has_active_ability?([:INNERFOCUS, :SHIELDDUST]) + if !target.has_active_ability?([:INNERFOCUS, :SHIELDDUST]) || target.being_mold_broken? old_score = score score += 8 score += 5 if move.move.multiHitMove? diff --git a/Data/Scripts/011_Battle/005_AI/010_AIBattler.rb b/Data/Scripts/011_Battle/005_AI/010_AIBattler.rb index 3ad1eef72..fb641bd2e 100644 --- a/Data/Scripts/011_Battle/005_AI/010_AIBattler.rb +++ b/Data/Scripts/011_Battle/005_AI/010_AIBattler.rb @@ -274,6 +274,10 @@ class Battle::AI::AIBattler return battler.hasMoldBreaker? end + def being_mold_broken? + return battler.beingMoldBroken? + end + #----------------------------------------------------------------------------- def item_id; return battler.item_id; end diff --git a/Data/Scripts/011_Battle/005_AI/011_AIMove.rb b/Data/Scripts/011_Battle/005_AI/011_AIMove.rb index 3b10b9d28..f06e52da6 100644 --- a/Data/Scripts/011_Battle/005_AI/011_AIMove.rb +++ b/Data/Scripts/011_Battle/005_AI/011_AIMove.rb @@ -110,13 +110,13 @@ class Battle::AI::AIMove @move.pbOnStartUse(user.battler, [target.battler]) # Calculate category end atk, atk_stage = @move.pbGetAttackStats(user.battler, target.battler) - if !target.has_active_ability?(:UNAWARE) || @ai.battle.moldBreaker + if !target.has_active_ability?(:UNAWARE) || target.being_mold_broken? atk_stage = max_stage if is_critical && atk_stage < max_stage atk = (atk.to_f * stage_mul[atk_stage] / stage_div[atk_stage]).floor end ##### Calculate target's defense stat ##### defense, def_stage = @move.pbGetDefenseStats(user.battler, target.battler) - if !user.has_active_ability?(:UNAWARE) || @ai.battle.moldBreaker + if !user.has_active_ability?(:UNAWARE) || user.being_mold_broken? def_stage = max_stage if is_critical && def_stage > max_stage defense = (defense.to_f * stage_mul[def_stage] / stage_div[def_stage]).floor end @@ -171,24 +171,22 @@ class Battle::AI::AIMove ) end end - if !@ai.battle.moldBreaker - user_battler.allAllies.each do |b| - next if !b.abilityActive? - Battle::AbilityEffects.triggerDamageCalcFromAlly( - b.ability, user_battler, target_battler, @move, multipliers, base_dmg, calc_type - ) - end - if target.ability_active? - case target.ability_id - when :FILTER, :SOLIDROCK - if Effectiveness.super_effective_type?(calc_type, *target.pbTypes(true)) - multipliers[:final_damage_multiplier] *= 0.75 - end - else - Battle::AbilityEffects.triggerDamageCalcFromTarget( - target.ability, user_battler, target_battler, @move, multipliers, base_dmg, calc_type - ) + user_battler.allAllies.each do |b| + next if !b.abilityActive? || b.beingMoldBroken? + Battle::AbilityEffects.triggerDamageCalcFromAlly( + b.ability, user_battler, target_battler, @move, multipliers, base_dmg, calc_type + ) + end + if target.ability_active? && !target.being_mold_broken? + case target.ability_id + when :FILTER, :SOLIDROCK + if Effectiveness.super_effective_type?(calc_type, *target.pbTypes(true)) + multipliers[:final_damage_multiplier] *= 0.75 end + else + Battle::AbilityEffects.triggerDamageCalcFromTarget( + target.ability, user_battler, target_battler, @move, multipliers, base_dmg, calc_type + ) end end if target.ability_active? @@ -196,13 +194,11 @@ class Battle::AI::AIMove target.ability, user_battler, target_battler, @move, multipliers, base_dmg, calc_type ) end - if !@ai.battle.moldBreaker - target_battler.allAllies.each do |b| - next if !b.abilityActive? - Battle::AbilityEffects.triggerDamageCalcFromTargetAlly( - b.ability, user_battler, target_battler, @move, multipliers, base_dmg, calc_type - ) - end + target_battler.allAllies.each do |b| + next if !b.abilityActive? || b.beingMoldBroken? + Battle::AbilityEffects.triggerDamageCalcFromTargetAlly( + b.ability, user_battler, target_battler, @move, multipliers, base_dmg, calc_type + ) end # Item effects that alter damage if user.item_active? @@ -445,7 +441,7 @@ class Battle::AI::AIMove b.ability, modifiers, user_battler, target_battler, @move, calc_type ) end - if !@ai.battle.moldBreaker && target.ability_active? + if target.ability_active? && !target.being_mold_broken? Battle::AbilityEffects.triggerAccuracyCalcFromTarget( target.ability, modifiers, user_battler, target_battler, @move, calc_type ) @@ -510,7 +506,7 @@ class Battle::AI::AIMove user_battler, target_battler, crit_stage) return -1 if crit_stage < 0 end - if !@ai.battle.moldBreaker && target.ability_active? + if target.ability_active? && !target.being_mold_broken? crit_stage = Battle::AbilityEffects.triggerCriticalCalcFromTarget(target_battler.ability, user_battler, target_battler, crit_stage) return -1 if crit_stage < 0 @@ -556,7 +552,7 @@ class Battle::AI::AIMove # Additional effect will be negated return -999 if user.has_active_ability?(:SHEERFORCE) return -999 if target && user.index != target.index && - target.has_active_ability?(:SHIELDDUST) && !@ai.battle.moldBreaker + target.has_active_ability?(:SHIELDDUST) && !target.being_mold_broken? # Additional effect will always trigger return 0 if chance > 100 # Calculate the chance diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/001_AI_MoveEffects_Misc.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/001_AI_MoveEffects_Misc.rb index 876e2c952..65ac96e83 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/001_AI_MoveEffects_Misc.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/001_AI_MoveEffects_Misc.rb @@ -341,17 +341,23 @@ Battle::AI::Handlers::MoveEffectScore.add("StartPsychicTerrain", #=============================================================================== # #=============================================================================== -Battle::AI::Handlers::MoveFailureCheck.add("RemoveTerrain", - proc { |move, user, ai, battle| - next battle.field.terrain == :None - } -) Battle::AI::Handlers::MoveEffectScore.add("RemoveTerrain", proc { |score, move, user, ai, battle| next score - ai.get_score_for_terrain(battle.field.terrain, user) } ) +#=============================================================================== +# +#=============================================================================== +Battle::AI::Handlers::MoveFailureCheck.add("RemoveTerrainFailsIfNoTerrain", + proc { |move, user, ai, battle| + next battle.field.terrain == :None + } +) +Battle::AI::Handlers::MoveEffectScore.copy("RemoveTerrain", + "RemoveTerrainFailsIfNoTerrain") + #=============================================================================== # #=============================================================================== diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/002_AI_MoveEffects_BattlerStats.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/002_AI_MoveEffects_BattlerStats.rb index 70afbeb5c..d322d7d02 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/002_AI_MoveEffects_BattlerStats.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/002_AI_MoveEffects_BattlerStats.rb @@ -628,7 +628,7 @@ Battle::AI::Handlers::MoveFailureAgainstTargetCheck.add("RaiseTargetAttack2Confu ) Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("RaiseTargetAttack2ConfuseTarget", proc { |score, move, user, target, ai, battle| - if !target.has_active_ability?(:CONTRARY) || battle.moldBreaker + if !target.has_active_ability?(:CONTRARY) || target.being_mold_broken? next Battle::AI::MOVE_USELESS_SCORE if !target.battler.pbCanConfuse?(user.battler, false, move.move) end # Score for stat raise @@ -650,7 +650,7 @@ Battle::AI::Handlers::MoveFailureAgainstTargetCheck.add("RaiseTargetSpAtk1Confus ) Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("RaiseTargetSpAtk1ConfuseTarget", proc { |score, move, user, target, ai, battle| - if !target.has_active_ability?(:CONTRARY) || battle.moldBreaker + if !target.has_active_ability?(:CONTRARY) || target.being_mold_broken? next Battle::AI::MOVE_USELESS_SCORE if !target.battler.pbCanConfuse?(user.battler, false, move.move) end # Score for stat raise @@ -690,7 +690,7 @@ Battle::AI::Handlers::MoveFailureAgainstTargetCheck.add("RaiseTargetRandomStat2" ) Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("RaiseTargetRandomStat2", proc { |score, move, user, target, ai, battle| - next Battle::AI::MOVE_USELESS_SCORE if !battle.moldBreaker && target.has_active_ability?(:CONTRARY) + next Battle::AI::MOVE_USELESS_SCORE if target.has_active_ability?(:CONTRARY) && !target.being_mold_broken? next Battle::AI::MOVE_USELESS_SCORE if target.rough_end_of_round_damage >= target.hp score -= 7 if target.index != user.index # Less likely to use on ally score += 10 if target.has_active_ability?(:SIMPLE) @@ -831,7 +831,7 @@ Battle::AI::Handlers::MoveFailureAgainstTargetCheck.add("LowerTargetSpAtk2IfCanA next true if move.statusMove? && !target.battler.pbCanLowerStatStage?(move.move.statDown[0], user.battler, move.move) next true if user.gender == 2 || target.gender == 2 || user.gender == target.gender - next true if !battle.moldBreaker && target.has_active_ability?(:OBLIVIOUS) + next true if target.has_active_ability?(:OBLIVIOUS) && !target.being_mold_broken? next false } ) diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/003_AI_MoveEffects_BattlerOther.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/003_AI_MoveEffects_BattlerOther.rb index d00d0943b..c400a7666 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/003_AI_MoveEffects_BattlerOther.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/003_AI_MoveEffects_BattlerOther.rb @@ -576,7 +576,7 @@ Battle::AI::Handlers::MoveEffectScore.add("StartUserSideImmunityToInflictedStatu Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("FlinchTarget", proc { |score, move, user, target, ai, battle| next score if target.faster_than?(user) || target.effects[PBEffects::Substitute] > 0 - next score if target.has_active_ability?(:INNERFOCUS) && !battle.moldBreaker + next score if target.has_active_ability?(:INNERFOCUS) && !target.being_mold_broken? add_effect = move.get_score_change_for_additional_effect(user, target) next score if add_effect == -999 # Additional effect will be negated score += add_effect diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/004_AI_MoveEffects_MoveAttributes.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/004_AI_MoveEffects_MoveAttributes.rb index c41f37f63..3e5e49233 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/004_AI_MoveEffects_MoveAttributes.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/004_AI_MoveEffects_MoveAttributes.rb @@ -63,7 +63,7 @@ Battle::AI::Handlers::MoveBasePower.add("LowerTargetHPToUserHP", Battle::AI::Handlers::MoveFailureAgainstTargetCheck.add("OHKO", proc { |move, user, target, ai, battle| next true if target.level > user.level - next true if !battle.moldBreaker && target.has_active_ability?(:STURDY) + next true if target.has_active_ability?(:STURDY) && !target.being_mold_broken? next false } ) @@ -144,7 +144,8 @@ Battle::AI::Handlers::MoveBasePower.copy("PowerHigherWithUserHP", # #=============================================================================== Battle::AI::Handlers::MoveBasePower.copy("PowerHigherWithUserHP", - "PowerHigherWithTargetHP") + "PowerHigherWithTargetHP100", + "PowerHigherWithTargetHP120") #=============================================================================== # diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/006_AI_MoveEffects_Healing.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/006_AI_MoveEffects_Healing.rb index 385dae654..63693bdfe 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/006_AI_MoveEffects_Healing.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/006_AI_MoveEffects_Healing.rb @@ -126,7 +126,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("CureTargetStatusHealUser #=============================================================================== Battle::AI::Handlers::MoveFailureAgainstTargetCheck.add("HealUserByTargetAttackLowerTargetAttack1", proc { |move, user, target, ai, battle| - if !battle.moldBreaker && target.has_active_ability?(:CONTRARY) + if target.has_active_ability?(:CONTRARY) && !target.being_mold_broken? next target.statStageAtMax?(:ATTACK) end next target.statStageAtMin?(:ATTACK) @@ -456,7 +456,7 @@ Battle::AI::Handlers::MoveEffectScore.add("UserLosesHalfOfTotalHP", #=============================================================================== Battle::AI::Handlers::MoveFailureCheck.add("UserLosesHalfOfTotalHPExplosive", proc { |move, user, ai, battle| - next !battle.moldBreaker && battle.pbCheckGlobalAbility(:DAMP) + next !battle.pbCheckGlobalAbility(:DAMP, true).nil? } ) Battle::AI::Handlers::MoveEffectScore.copy("UserLosesHalfOfTotalHP", diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/007_AI_MoveEffects_Items.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/007_AI_MoveEffects_Items.rb index f766fc574..7af377a10 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/007_AI_MoveEffects_Items.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/007_AI_MoveEffects_Items.rb @@ -7,7 +7,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("UserTakesTargetItem", next score if !target.item || target.battler.unlosableItem?(target.item) next score if user.battler.unlosableItem?(target.item) next score if target.effects[PBEffects::Substitute] > 0 - next score if target.has_active_ability?(:STICKYHOLD) && !battle.moldBreaker + next score if target.has_active_ability?(:STICKYHOLD) && !target.being_mold_broken? # User can steal the target's item; score it user_item_preference = user.wants_item?(target.item_id) user_no_item_preference = user.wants_item?(:NONE) @@ -58,7 +58,7 @@ Battle::AI::Handlers::MoveFailureAgainstTargetCheck.add("UserTargetSwapItems", next true if !user.item && !target.item next true if user.battler.unlosableItem?(user.item) || user.battler.unlosableItem?(target.item) next true if target.battler.unlosableItem?(target.item) || target.battler.unlosableItem?(user.item) - next true if target.has_active_ability?(:STICKYHOLD) && !battle.moldBreaker + next true if target.has_active_ability?(:STICKYHOLD) && !target.being_mold_broken? next false } ) @@ -113,7 +113,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("RemoveTargetItem", next score if user.wild? next score if !target.item || target.battler.unlosableItem?(target.item) next score if target.effects[PBEffects::Substitute] > 0 - next score if target.has_active_ability?(:STICKYHOLD) && !battle.moldBreaker + next score if target.has_active_ability?(:STICKYHOLD) && !target.being_mold_broken? next score if !target.item_active? # User can knock off the target's item; score it item_preference = target.wants_item?(target.item_id) @@ -132,7 +132,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("DestroyTargetBerryOrGem" !(Settings::MECHANICS_GENERATION >= 6 && target.item.is_gem?)) next score if user.battler.unlosableItem?(target.item) next score if target.effects[PBEffects::Substitute] > 0 - next score if target.has_active_ability?(:STICKYHOLD) && !battle.moldBreaker + next score if target.has_active_ability?(:STICKYHOLD) && !target.being_mold_broken? next score if !target.item_active? # User can incinerate the target's item; score it item_preference = target.wants_item?(target.item_id) @@ -302,7 +302,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("UserConsumeTargetBerry", next score if !target.item || !target.item.is_berry? next score if user.battler.unlosableItem?(target.item) next score if target.effects[PBEffects::Substitute] > 0 - next score if target.has_active_ability?(:STICKYHOLD) && !battle.moldBreaker + next score if target.has_active_ability?(:STICKYHOLD) && !target.being_mold_broken? # Score the user gaining the item's effect score += user.get_score_change_for_consuming_item(target.item_id) # Score for other results of consuming the berry diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/009_AI_MoveEffects_SwitchingActing.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/009_AI_MoveEffects_SwitchingActing.rb index 287c0d20d..76099ff5b 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/009_AI_MoveEffects_SwitchingActing.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/009_AI_MoveEffects_SwitchingActing.rb @@ -201,7 +201,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("SwitchOutTargetDamagingM proc { |score, move, user, target, ai, battle| next score if target.wild? # No score modification if the target can't be made to switch out - next score if !battle.moldBreaker && target.has_active_ability?(:SUCTIONCUPS) + next score if target.has_active_ability?(:SUCTIONCUPS) && !target.being_mold_broken? next score if target.effects[PBEffects::Ingrain] # No score modification if the target can't be replaced can_switch = false @@ -764,7 +764,7 @@ Battle::AI::Handlers::MoveFailureAgainstTargetCheck.add("DisableTargetStatusMove next true if target.effects[PBEffects::Taunt] > 0 next true if move.move.pbMoveFailedAromaVeil?(user.battler, target.battler, false) next true if Settings::MECHANICS_GENERATION >= 6 && - !battle.moldBreaker && target.has_active_ability?(:OBLIVIOUS) + target.has_active_ability?(:OBLIVIOUS) && !target.being_mold_broken? next false } ) diff --git a/Data/Scripts/011_Battle/007_Other battle code/008_Battle_AbilityEffects.rb b/Data/Scripts/011_Battle/007_Other battle code/008_Battle_AbilityEffects.rb index 6deff3758..9fdcb5807 100644 --- a/Data/Scripts/011_Battle/007_Other battle code/008_Battle_AbilityEffects.rb +++ b/Data/Scripts/011_Battle/007_Other battle code/008_Battle_AbilityEffects.rb @@ -462,13 +462,19 @@ Battle::AbilityEffects::StatusImmunity.add(:MAGMAARMOR, } ) +Battle::AbilityEffects::StatusImmunity.add(:PURIFYINGSALT, + proc { |ability, battler, status| + next true + } +) + Battle::AbilityEffects::StatusImmunity.add(:WATERVEIL, proc { |ability, battler, status| next true if status == :BURN } ) -Battle::AbilityEffects::StatusImmunity.copy(:WATERVEIL, :WATERBUBBLE) +Battle::AbilityEffects::StatusImmunity.copy(:WATERVEIL, :THERMALEXCHANGE, :WATERBUBBLE) #=============================================================================== # StatusImmunityNonIgnorable handlers @@ -661,7 +667,7 @@ Battle::AbilityEffects::StatusCure.add(:WATERVEIL, } ) -Battle::AbilityEffects::StatusCure.copy(:WATERVEIL, :WATERBUBBLE) +Battle::AbilityEffects::StatusCure.copy(:WATERVEIL, :THERMALEXCHANGE, :WATERBUBBLE) #=============================================================================== # StatLossImmunity handlers @@ -751,6 +757,8 @@ Battle::AbilityEffects::StatLossImmunity.add(:KEENEYE, } ) +Battle::AbilityEffects::StatLossImmunity.copy(:KEENEYE, :MINDSEYE) + #=============================================================================== # StatLossImmunityNonIgnorable handlers #=============================================================================== @@ -916,6 +924,12 @@ Battle::AbilityEffects::MoveImmunity.add(:BULLETPROOF, } ) +Battle::AbilityEffects::MoveImmunity.add(:EARTHEATER, + proc { |ability, user, target, move, type, battle, show_message| + next target.pbMoveImmunityHealingAbility(user, move, type, :GROUND, show_message) + } +) + Battle::AbilityEffects::MoveImmunity.add(:FLASHFIRE, proc { |ability, user, target, move, type, battle, show_message| next false if user.index == target.index @@ -1019,6 +1033,36 @@ Battle::AbilityEffects::MoveImmunity.add(:WATERABSORB, Battle::AbilityEffects::MoveImmunity.copy(:WATERABSORB, :DRYSKIN) +Battle::AbilityEffects::MoveImmunity.add(:WELLBAKEDBODY, + proc { |ability, user, target, move, type, battle, show_message| + next target.pbMoveImmunityStatRaisingAbility(user, move, type, + :FIRE, :DEFENSE, 2, show_message) + } +) + +Battle::AbilityEffects::MoveImmunity.add(:WINDRIDER, + proc { |ability, user, target, move, type, battle, show_message| + next false if user.index == target.index + next false if !move.windMove? + if show_message + battle.pbShowAbilitySplash(target) + if target.pbCanRaiseStatStage?(:ATTACK, target) + if Battle::Scene::USE_ABILITY_SPLASH + target.pbRaiseStatStage(:ATTACK, 1, target) + else + target.pbRaiseStatStageByCause(:ATTACK, 1, target, target.abilityName) + end + elsif Battle::Scene::USE_ABILITY_SPLASH + battle.pbDisplay(_INTL("It doesn't affect {1}...", target.pbThis(true))) + else + battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!", target.pbThis, target.abilityName, move.name)) + end + battle.pbHideAbilitySplash(target) + end + next true + } +) + Battle::AbilityEffects::MoveImmunity.add(:WONDERGUARD, proc { |ability, user, target, move, type, battle, show_message| next false if move.statusMove? @@ -1351,6 +1395,12 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:RIVALRY, } ) +Battle::AbilityEffects::DamageCalcFromUser.add(:ROCKYPAYLOAD, + proc { |ability, user, target, move, mults, power, type| + mults[:attack_multiplier] *= 1.5 if type == :ROCK + } +) + Battle::AbilityEffects::DamageCalcFromUser.add(:SANDFORCE, proc { |ability, user, target, move, mults, power, type| if user.effectiveWeather == :Sandstorm && @@ -1360,6 +1410,12 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:SANDFORCE, } ) +Battle::AbilityEffects::DamageCalcFromUser.add(:SHARPNESS, + proc { |ability, user, target, move, mults, power, type| + mults[:power_multiplier] *= 1.5 if move.slicingMove? + } +) + Battle::AbilityEffects::DamageCalcFromUser.add(:SHEERFORCE, proc { |ability, user, target, move, mults, power, type| mults[:power_multiplier] *= 1.3 if move.addlEffect > 0 @@ -1443,7 +1499,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:TORRENT, Battle::AbilityEffects::DamageCalcFromUser.add(:TOUGHCLAWS, proc { |ability, user, target, move, mults, power, type| - mults[:power_multiplier] *= 4 / 3.0 if move.contactMove? + mults[:power_multiplier] *= 4 / 3.0 if move.pbContactMove?(user) } ) @@ -1578,6 +1634,12 @@ Battle::AbilityEffects::DamageCalcFromTarget.add(:PUNKROCK, } ) +Battle::AbilityEffects::DamageCalcFromTarget.add(:PURIFYINGSALT, + proc { |ability, user, target, move, mults, power, type| + mults[:attack_multiplier] /= 2 if move.calcType == :GHOST + } +) + Battle::AbilityEffects::DamageCalcFromTarget.add(:THICKFAT, proc { |ability, user, target, move, mults, power, type| mults[:power_multiplier] /= 2 if [:FIRE, :ICE].include?(type) @@ -1663,20 +1725,18 @@ Battle::AbilityEffects::OnBeingHit.add(:AFTERMATH, next if !target.fainted? next if !move.pbContactMove?(user) battle.pbShowAbilitySplash(target) - if !battle.moldBreaker - dampBattler = battle.pbCheckGlobalAbility(:DAMP) - if dampBattler - battle.pbShowAbilitySplash(dampBattler) - if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1} cannot use {2}!", target.pbThis, target.abilityName)) - else - battle.pbDisplay(_INTL("{1} cannot use {2} because of {3}'s {4}!", - target.pbThis, target.abilityName, dampBattler.pbThis(true), dampBattler.abilityName)) - end - battle.pbHideAbilitySplash(dampBattler) - battle.pbHideAbilitySplash(target) - next + dampBattler = battle.pbCheckGlobalAbility(:DAMP, true) + if dampBattler + battle.pbShowAbilitySplash(dampBattler) + if Battle::Scene::USE_ABILITY_SPLASH + battle.pbDisplay(_INTL("{1} cannot use {2}!", target.pbThis, target.abilityName)) + else + battle.pbDisplay(_INTL("{1} cannot use {2} because of {3}'s {4}!", + target.pbThis, target.abilityName, dampBattler.pbThis(true), dampBattler.abilityName)) end + battle.pbHideAbilitySplash(dampBattler) + battle.pbHideAbilitySplash(target) + next end if user.takesIndirectDamage?(Battle::Scene::USE_ABILITY_SPLASH) && user.affectedByContactEffect?(Battle::Scene::USE_ABILITY_SPLASH) @@ -1922,6 +1982,8 @@ Battle::AbilityEffects::OnBeingHit.add(:MUMMY, } ) +Battle::AbilityEffects::OnBeingHit.copy(:MUMMY, :LINGERINGAROMA) + Battle::AbilityEffects::OnBeingHit.add(:PERISHBODY, proc { |ability, user, target, move, battle| next if !move.pbContactMove?(user) @@ -1980,6 +2042,15 @@ Battle::AbilityEffects::OnBeingHit.add(:STAMINA, } ) +Battle::AbilityEffects::OnBeingHit.add(:SEEDSOWER, + proc { |ability, user, target, move, battle| + next if battle.field.terrain == :Grassy + battle.pbShowAbilitySplash(target) + battle.pbStartTerrain(target, :Grassy) + # NOTE: The ability splash is hidden again in def pbStartTerrain. + } +) + Battle::AbilityEffects::OnBeingHit.add(:STATIC, proc { |ability, user, target, move, battle| next if !move.pbContactMove?(user) @@ -1998,6 +2069,30 @@ Battle::AbilityEffects::OnBeingHit.add(:STATIC, } ) +Battle::AbilityEffects::OnBeingHit.add(:THERMALEXCHANGE, + proc { |ability, user, target, move, battle| + next if move.calcType != :FIRE + target.pbRaiseStatStageByAbility(:ATTACK, 1, target) + } +) + +Battle::AbilityEffects::OnBeingHit.add(:TOXICDEBRIS, + proc { |ability, user, target, move, battle| + next if !move.physicalMove? + next if target.pbOpposingSide.effects[PBEffects::ToxicSpikes] >= 2 + battle.pbShowAbilitySplash(target) + target.pbOpposingSide.effects[PBEffects::ToxicSpikes] += 1 + if Battle::Scene::USE_ABILITY_SPLASH + battle.pbDisplay(_INTL("Poison spikes were scattered all around {1}'s feet!", + target.pbOpposingTeam(true))) + else + battle.pbDisplay(_INTL("{1}'s {2} scattered poison spikes all around {3}'s feet!", + target.pbThis, target.abilityName, target.pbOpposingTeam(true))) + end + battle.pbHideAbilitySplash(target) + } +) + Battle::AbilityEffects::OnBeingHit.add(:WANDERINGSPIRIT, proc { |ability, user, target, move, battle| next if !move.pbContactMove?(user) @@ -2060,10 +2155,10 @@ Battle::AbilityEffects::OnBeingHit.add(:WEAKARMOR, Battle::AbilityEffects::OnDealingHit.add(:POISONTOUCH, proc { |ability, user, target, move, battle| - next if !move.contactMove? + next if !move.pbContactMove?(user) next if battle.pbRandom(100) >= 30 battle.pbShowAbilitySplash(user) - if target.hasActiveAbility?(:SHIELDDUST) && !battle.moldBreaker + if target.hasActiveAbility?(:SHIELDDUST) && !target.being_mold_broken? battle.pbShowAbilitySplash(target) if !Battle::Scene::USE_ABILITY_SPLASH battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) @@ -2080,6 +2175,27 @@ Battle::AbilityEffects::OnDealingHit.add(:POISONTOUCH, } ) +Battle::AbilityEffects::OnDealingHit.add(:TOXICCHAIN, + proc { |ability, user, target, move, battle| + next if battle.pbRandom(100) >= 30 + battle.pbShowAbilitySplash(user) + if target.hasActiveAbility?(:SHIELDDUST) && !target.being_mold_broken? + battle.pbShowAbilitySplash(target) + if !Battle::Scene::USE_ABILITY_SPLASH + battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) + end + battle.pbHideAbilitySplash(target) + elsif target.pbCanPoison?(user, Battle::Scene::USE_ABILITY_SPLASH) + msg = nil + if !Battle::Scene::USE_ABILITY_SPLASH + msg = _INTL("{1}'s {2} badly poisoned {3}!", user.pbThis, user.abilityName, target.pbThis(true)) + end + target.pbPoison(user, msg, true) + end + battle.pbHideAbilitySplash(user) + } +) + #=============================================================================== # OnEndOfUsingMove handlers #=============================================================================== @@ -2215,7 +2331,7 @@ Battle::AbilityEffects::AfterMoveUseFromTarget.add(:PICKPOCKET, # sense, so this code doesn't do it. next if target.wild? next if switched_battlers.include?(user.index) # User was switched out - next if !move.contactMove? + next if !move.pbContactMove?(user) next if user.effects[PBEffects::Substitute] > 0 || target.damageState.substitute next if target.item || !user.item next if user.unlosableItem?(user.item) || target.unlosableItem?(user.item) @@ -3057,6 +3173,13 @@ Battle::AbilityEffects::OnSwitchIn.add(:UNNERVE, } ) +Battle::AbilityEffects::OnSwitchIn.add(:WINDRIDER, + proc { |ability, battler, battle, switch_in| + next if battler.pbOwnSide.effects[PBEffects::Tailwind] == 0 + battler.pbRaiseStatStageByAbility(:ATTACK, 1, battler) + } +) + #=============================================================================== # OnSwitchOut handlers #=============================================================================== diff --git a/Data/Scripts/011_Battle/007_Other battle code/009_Battle_ItemEffects.rb b/Data/Scripts/011_Battle/007_Other battle code/009_Battle_ItemEffects.rb index 1c48d50af..b50d624ce 100644 --- a/Data/Scripts/011_Battle/007_Other battle code/009_Battle_ItemEffects.rb +++ b/Data/Scripts/011_Battle/007_Other battle code/009_Battle_ItemEffects.rb @@ -9,6 +9,8 @@ module Battle::ItemEffects OnStatLoss = ItemHandlerHash.new # Battler's status problem StatusCure = ItemHandlerHash.new + # Battler's stat stages + StatLossImmunity = ItemHandlerHash.new # Priority and turn order PriorityBracketChange = ItemHandlerHash.new PriorityBracketUse = ItemHandlerHash.new @@ -83,6 +85,12 @@ module Battle::ItemEffects #============================================================================= + def self.triggerStatLossImmunity(item, battler, stat, battle, show_messages) + return trigger(StatLossImmunity, item, battler, stat, battle, show_messages) + end + + #============================================================================= + def self.triggerPriorityBracketChange(item, battler, battle) return trigger(PriorityBracketChange, item, battler, battle, ret: 0) end @@ -627,6 +635,18 @@ Battle::ItemEffects::StatusCure.add(:RAWSTBERRY, } ) +#=============================================================================== +# StatLossImmunity handlers +#=============================================================================== + +Battle::ItemEffects::StatLossImmunity.add(:CLEARAMULET, + proc { |item, battler, stat, battle, showMessages| + battle.pbDisplay(_INTL("The effects of {1}'s {2} prevent its stats from being lowered!", + battler.pbThis, GameData::Item.get(item).name)) if showMessages + next true + } +) + #=============================================================================== # PriorityBracketChange handlers #=============================================================================== @@ -730,6 +750,8 @@ Battle::ItemEffects::DamageCalcFromUser.add(:ADAMANTORB, } ) +Battle::ItemEffects::DamageCalcFromUser.copy(:ADAMANTORB, :ADAMANTCRYSTAL) + Battle::ItemEffects::DamageCalcFromUser.add(:BLACKBELT, proc { |item, user, target, move, mults, power, type| mults[:power_multiplier] *= 1.2 if type == :FIGHTING @@ -772,6 +794,14 @@ Battle::ItemEffects::DamageCalcFromUser.add(:CHOICESPECS, } ) +Battle::ItemEffects::DamageCalcFromUser.add(:CORNERSTONEMASK, + proc { |item, user, target, move, mults, power, type| + mults[:power_multiplier] *= 1.2 if user.isSpecies?(:OGERPON) + } +) + +Battle::ItemEffects::DamageCalcFromUser.copy(:CORNERSTONEMASK, :HEARTHFLAMEEMASK, :WELLSPRINGMASK) + Battle::ItemEffects::DamageCalcFromUser.add(:DARKGEM, proc { |item, user, target, move, mults, power, type| user.pbMoveTypePoweringUpGem(:DARK, move, type, mults) @@ -858,6 +888,8 @@ Battle::ItemEffects::DamageCalcFromUser.add(:GRISEOUSORB, } ) +Battle::ItemEffects::DamageCalcFromUser.copy(:GRISEOUSORB, :GRISEOUSCORE) + Battle::ItemEffects::DamageCalcFromUser.add(:GROUNDGEM, proc { |item, user, target, move, mults, power, type| user.pbMoveTypePoweringUpGem(:GROUND, move, type, mults) @@ -900,6 +932,8 @@ Battle::ItemEffects::DamageCalcFromUser.add(:LUSTROUSORB, } ) +Battle::ItemEffects::DamageCalcFromUser.copy(:LUSTROUSORB, :LUSTROUSGLOBE) + Battle::ItemEffects::DamageCalcFromUser.add(:MAGNET, proc { |item, user, target, move, mults, power, type| mults[:power_multiplier] *= 1.2 if type == :ELECTRIC @@ -987,6 +1021,12 @@ Battle::ItemEffects::DamageCalcFromUser.add(:PSYCHICGEM, } ) +Battle::ItemEffects::DamageCalcFromUser.add(:PUNCHINGGLOVE, + proc { |item, user, target, move, mults, power, type| + mults[:power_multiplier] *= 1.1 if move.punchingMove? + } +) + Battle::ItemEffects::DamageCalcFromUser.add(:ROCKGEM, proc { |item, user, target, move, mults, power, type| user.pbMoveTypePoweringUpGem(:ROCK, move, type, mults) @@ -1551,7 +1591,7 @@ Battle::ItemEffects::AfterMoveUseFromTarget.add(:REDCARD, battle.pbDisplay(_INTL("{1} held up its {2} against {3}!", battler.pbThis, battler.itemName, user.pbThis(true))) battler.pbConsumeItem - if user.hasActiveAbility?(:SUCTIONCUPS) && !battle.moldBreaker + if user.hasActiveAbility?(:SUCTIONCUPS) && !user.being_mold_broken? battle.pbShowAbilitySplash(user) if Battle::Scene::USE_ABILITY_SPLASH battle.pbDisplay(_INTL("{1} anchors itself!", user.pbThis)) diff --git a/Data/Scripts/013_Items/002_Item_Effects.rb b/Data/Scripts/013_Items/002_Item_Effects.rb index e8b95f497..3aa5741f3 100644 --- a/Data/Scripts/013_Items/002_Item_Effects.rb +++ b/Data/Scripts/013_Items/002_Item_Effects.rb @@ -409,6 +409,30 @@ ItemHandlers::UseOnPokemon.addIf(:evolution_stones, } ) +ItemHandlers::UseOnPokemon.add(:SCROLLOFWATERS, proc { |item, qty, pkmn, scene| + if pkmn.shadowPokemon? + scene.pbDisplay(_INTL("It won't have any effect.")) + next false + end + newspecies = pkmn.check_evolution_on_use_item(item) + if newspecies + pkmn.form = 1 # NOTE: This is the only difference to the generic evolution stone code. + pbFadeOutInWithMusic do + evo = PokemonEvolutionScene.new + evo.pbStartScreen(pkmn, newspecies) + evo.pbEvolution(false) + evo.pbEndScreen + if scene.is_a?(PokemonPartyScreen) + scene.pbRefreshAnnotations(proc { |p| !p.check_evolution_on_use_item(item).nil? }) + scene.pbRefresh + end + end + next true + end + scene.pbDisplay(_INTL("It won't have any effect.")) + next false +}) + ItemHandlers::UseOnPokemon.add(:POTION, proc { |item, qty, pkmn, scene| next pbHPItem(pkmn, 20, scene) }) @@ -1138,8 +1162,12 @@ ItemHandlers::UseOnPokemon.add(:ABILITYPATCH, proc { |item, qty, pkmn, scene| if scene.pbConfirm(_INTL("Do you want to change {1}'s Ability?", pkmn.name)) abils = pkmn.getAbilityList new_ability_id = nil - abils.each { |a| new_ability_id = a[0] if a[1] == 2 } - if !new_ability_id || pkmn.hasHiddenAbility? || pkmn.isSpecies?(:ZYGARDE) + if pkmn.hasHiddenAbility? + new_ability_id = 0 if Settings::MECHANICS_GENERATION >= 9 # First regular ability + else + abils.each { |a| new_ability_id = a[0] if a[1] == 2 } # Hidden ability + end + if !new_ability_id || pkmn.isSpecies?(:ZYGARDE) scene.pbDisplay(_INTL("It won't have any effect.")) next false end @@ -1153,6 +1181,22 @@ ItemHandlers::UseOnPokemon.add(:ABILITYPATCH, proc { |item, qty, pkmn, scene| next false }) +ItemHandlers::UseOnPokemon.add(:METEORITE, proc { |item, qty, pkmn, scene| + if !pkmn.isSpecies?(:DEOXYS) + scene.pbDisplay(_INTL("It had no effect.")) + next false + elsif pkmn.fainted? + scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) + next false + end + new_form = (pkmn.form + 1) % 4 # Normal, Attack, Defense, Speed + pkmn.setForm(new_form) do + scene.pbRefresh + scene.pbDisplay(_INTL("{1} transformed!", pkmn.name)) + end + next true +}) + ItemHandlers::UseOnPokemon.add(:GRACIDEA, proc { |item, qty, pkmn, scene| if !pkmn.isSpecies?(:SHAYMIN) || pkmn.form != 0 || pkmn.status == :FROZEN || PBDayNight.isNight? diff --git a/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb b/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb index 9704f69eb..855f3d83e 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb @@ -270,8 +270,21 @@ MultipleForms.register(:ROTOM, { } }) +MultipleForms.register(:DIALGA, { + "getForm" => proc { |pkmn| + next pkmn.hasItem?(:ADAMANTCRYSTAL) ? 1 : 0 + } +}) + +MultipleForms.register(:PALKIA, { + "getForm" => proc { |pkmn| + next pkmn.hasItem?(:LUSTROUSGLOBE) ? 1 : 0 + } +}) + MultipleForms.register(:GIRATINA, { "getForm" => proc { |pkmn| + next 1 if pkmn.hasItem?(:GRISEOUSCORE) next 1 if pkmn.hasItem?(:GRISEOUSORB) && Settings::MECHANICS_GENERATION <= 8 next 1 if $game_map&.metadata&.has_flag?("DistortionWorld") next 0 diff --git a/PBS/moves.txt b/PBS/moves.txt index f83e7e77c..0f669f116 100644 --- a/PBS/moves.txt +++ b/PBS/moves.txt @@ -6163,7 +6163,7 @@ Power = 1 Accuracy = 100 TotalPP = 5 Target = NearOther -FunctionCode = PowerHigherWithTargetHP +FunctionCode = PowerHigherWithTargetHP120 Flags = Contact,CanProtect,CanMirrorMove Description = The target is crushed with great force. The attack is more powerful the more HP the target has left. #------------------------------- @@ -6319,7 +6319,7 @@ Power = 1 Accuracy = 100 TotalPP = 5 Target = NearOther -FunctionCode = PowerHigherWithTargetHP +FunctionCode = PowerHigherWithTargetHP120 Flags = Contact,CanProtect,CanMirrorMove Description = The user powerfully wrings the foe. The more HP the foe has, the greater this attack's power. #------------------------------- @@ -8900,7 +8900,7 @@ Power = 130 Accuracy = 100 TotalPP = 5 Target = NearOther -FunctionCode = RemoveTerrain +FunctionCode = RemoveTerrainFailsIfNoTerrain Flags = Contact,CanProtect,CanMirrorMove Description = The user attacks while destroying the terrain. This move fails when the ground isn't a terrain. #-------------------------------