From c360c4ddd2e7e9e3c602886c702195f9606345b4 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sat, 7 Aug 2021 20:56:43 +0100 Subject: [PATCH] Added effects of Ripen/Gorilla Tactics/Steam Engine, fixed SE move-weakening berries working on normal effectiveness moves as well --- .../001_Battler/006_Battler_AbilityAndItem.rb | 2 +- .../001_Battler/007_Battler_UseMove.rb | 14 ++- .../009_Battler_UseMove_SuccessChecks.rb | 28 +++--- Data/Scripts/011_Battle/002_BattleHandlers.rb | 36 ++++++-- .../002_Move/006_Move_Effects_080-0FF.rb | 4 +- .../011_Battle/004_BattleHandlers_Items.rb | 92 +++++++++++++++---- Data/Scripts/011_Battle/Gen 8 abilities.rb | 17 +--- 7 files changed, 140 insertions(+), 53 deletions(-) diff --git a/Data/Scripts/011_Battle/001_Battler/006_Battler_AbilityAndItem.rb b/Data/Scripts/011_Battle/001_Battler/006_Battler_AbilityAndItem.rb index 16afbb75e..bfba1d46d 100644 --- a/Data/Scripts/011_Battle/001_Battler/006_Battler_AbilityAndItem.rb +++ b/Data/Scripts/011_Battle/001_Battler/006_Battler_AbilityAndItem.rb @@ -145,7 +145,7 @@ class PokeBattle_Battler # permanent is whether the item is lost even after battle. Is false for Knock # Off. def pbRemoveItem(permanent = true) - @effects[PBEffects::ChoiceBand] = nil + @effects[PBEffects::ChoiceBand] = nil if ability_id != :GORILLATACTICS @effects[PBEffects::Unburden] = true if self.item setInitialItem(nil) if permanent && self.item == self.initialItem self.item = nil diff --git a/Data/Scripts/011_Battle/001_Battler/007_Battler_UseMove.rb b/Data/Scripts/011_Battle/001_Battler/007_Battler_UseMove.rb index 9dede31bb..e2637f0ba 100644 --- a/Data/Scripts/011_Battle/001_Battler/007_Battler_UseMove.rb +++ b/Data/Scripts/011_Battle/001_Battler/007_Battler_UseMove.rb @@ -108,7 +108,8 @@ class PokeBattle_Battler def pbEndTurn(_choice) @lastRoundMoved = @battle.turnCount # Done something this round if !@effects[PBEffects::ChoiceBand] && - hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF]) + (hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF]) || + hasActiveAbility?(:GORILLATACTICS)) if @lastMoveUsed && pbHasMove?(@lastMoveUsed) @effects[PBEffects::ChoiceBand] = @lastMoveUsed elsif @lastRegularMoveUsed && pbHasMove?(@lastRegularMoveUsed) @@ -726,6 +727,17 @@ class PokeBattle_Battler @battle.pbDisplay(_INTL("The {1} weakened the damage to {2}!",b.itemName,b.pbThis(true))) b.pbConsumeItem end + # Steam Engine (goes here because it should be after stat changes caused by + # the move) + if [:FIRE, :WATER].include?(move.calcType) + targets.each do |b| + next if b.damageState.unaffected + next if b.damageState.calcDamage == 0 || b.damageState.substitute + next if !b.hasActiveAbility?(:STEAMENGINE) + b.pbRaiseStatStageByAbility(:SPEED, 6, b) if b.pbCanRaiseStatStage?(:SPEED, b) + end + end + # Fainting targets.each { |b| b.pbFaint if b && b.fainted? } user.pbFaint if user.fainted? return true 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 91768c710..02046fd1a 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 @@ -40,20 +40,22 @@ class PokeBattle_Battler end return false end - # Choice Band - if @effects[PBEffects::ChoiceBand] - if hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF]) && - pbHasMove?(@effects[PBEffects::ChoiceBand]) - if move.id!=@effects[PBEffects::ChoiceBand] - if showMessages - msg = _INTL("{1} allows the use of only {2}!",itemName, - GameData::Move.get(@effects[PBEffects::ChoiceBand]).name) - (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) - end - return false + # Choice Band/Gorilla Tactics + @effects[PBEffects::ChoiceBand] = nil if !pbHasMove?(@effects[PBEffects::ChoiceBand]) + if @effects[PBEffects::ChoiceBand] && move.id != @effects[PBEffects::ChoiceBand] + choiced_move_name = GameData::Move.get(@effects[PBEffects::ChoiceBand]).name + if hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF]) + if showMessages + msg = _INTL("The {1} only allows the use of {2}!",itemName, choiced_move_name) + (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) end - else - @effects[PBEffects::ChoiceBand] = nil + return false + elsif hasActiveAbility?(:GORILLATACTICS) + if showMessages + msg = _INTL("{1} can only use {2}!", pbThis, choiced_move_name) + (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) + end + return false end end # Taunt diff --git a/Data/Scripts/011_Battle/002_BattleHandlers.rb b/Data/Scripts/011_Battle/002_BattleHandlers.rb index a39d3ad09..eae61c497 100644 --- a/Data/Scripts/011_Battle/002_BattleHandlers.rb +++ b/Data/Scripts/011_Battle/002_BattleHandlers.rb @@ -487,12 +487,20 @@ def pbBattleConfusionBerry(battler,battle,item,forced,flavor,confuseMsg) return false if !forced && !battler.canHeal? return false if !forced && !battler.canConsumePinchBerry?(Settings::MECHANICS_GENERATION >= 7) itemName = GameData::Item.get(item).name - battle.pbCommonAnimation("EatBerry",battler) if !forced fraction_to_heal = 8 # Gens 6 and lower if Settings::MECHANICS_GENERATION == 7; fraction_to_heal = 2 elsif Settings::MECHANICS_GENERATION >= 8; fraction_to_heal = 3 end - amt = battler.pbRecoverHP(battler.totalhp / fraction_to_heal) + amt = battler.totalhp / fraction_to_heal + ripening = false + if battler.hasActiveAbility?(:RIPEN) + battle.pbShowAbilitySplash(battler, forced) + amt *= 2 + ripening = true + end + battle.pbCommonAnimation("EatBerry", battler) if !forced + battle.pbHideAbilitySplash(battler) if ripening + amt = battler.pbRecoverHP(amt) if amt>0 if forced PBDebug.log("[Item triggered] Forced consuming of #{itemName}") @@ -515,12 +523,17 @@ def pbBattleStatIncreasingBerry(battler,battle,item,forced,stat,increment=1) return false if !forced && !battler.canConsumePinchBerry? return false if !battler.pbCanRaiseStatStage?(stat,battler) itemName = GameData::Item.get(item).name - if forced - PBDebug.log("[Item triggered] Forced consuming of #{itemName}") - return battler.pbRaiseStatStage(stat,increment,battler) + ripening = false + if battler.hasActiveAbility?(:RIPEN) + battle.pbShowAbilitySplash(battler, forced) + increment *= 2 + ripening = true end - battle.pbCommonAnimation("EatBerry",battler) - return battler.pbRaiseStatStageByCause(stat,increment,battler,itemName) + battle.pbCommonAnimation("EatBerry", battler) if !forced + battle.pbHideAbilitySplash(battler) if ripening + return battler.pbRaiseStatStageByCause(stat, increment, battler, itemName) if !forced + PBDebug.log("[Item triggered] Forced consuming of #{itemName}") + return battler.pbRaiseStatStage(stat, increment, battler) end # For abilities that grant immunity to moves of a particular type, and raises @@ -585,10 +598,17 @@ end def pbBattleTypeWeakingBerry(type,moveType,target,mults) return if moveType != type - return if Effectiveness.resistant?(target.damageState.typeMod) && moveType != :NORMAL + return if !Effectiveness.super_effective?(target.damageState.typeMod) && moveType != :NORMAL mults[:final_damage_multiplier] /= 2 target.damageState.berryWeakened = true + ripening = false + if target.hasActiveAbility?(:RIPEN) + target.battle.pbShowAbilitySplash(target) + mults[:final_damage_multiplier] /= 2 + ripening = true + end target.battle.pbCommonAnimation("EatBerry",target) + target.battle.pbHideAbilitySplash(target) if ripening end def pbBattleWeatherAbility(weather,battler,battle,ignorePrimal=false) diff --git a/Data/Scripts/011_Battle/002_Move/006_Move_Effects_080-0FF.rb b/Data/Scripts/011_Battle/002_Move/006_Move_Effects_080-0FF.rb index 94758c7ca..4c8dd418f 100644 --- a/Data/Scripts/011_Battle/002_Move/006_Move_Effects_080-0FF.rb +++ b/Data/Scripts/011_Battle/002_Move/006_Move_Effects_080-0FF.rb @@ -3342,10 +3342,10 @@ class PokeBattle_Move_0F2 < PokeBattle_Move oldUserItem = user.item; oldUserItemName = user.itemName oldTargetItem = target.item; oldTargetItemName = target.itemName user.item = oldTargetItem - user.effects[PBEffects::ChoiceBand] = nil + user.effects[PBEffects::ChoiceBand] = nil if user.ability_id != :GORILLATACTICS user.effects[PBEffects::Unburden] = (!user.item && oldUserItem) target.item = oldUserItem - target.effects[PBEffects::ChoiceBand] = nil + target.effects[PBEffects::ChoiceBand] = nil if target.ability_id != :GORILLATACTICS target.effects[PBEffects::Unburden] = (!target.item && oldTargetItem) # Permanently steal the item from wild Pokémon if @battle.wildBattle? && target.opposes? && !user.initialItem && diff --git a/Data/Scripts/011_Battle/004_BattleHandlers_Items.rb b/Data/Scripts/011_Battle/004_BattleHandlers_Items.rb index 987dce228..84b321ec2 100644 --- a/Data/Scripts/011_Battle/004_BattleHandlers_Items.rb +++ b/Data/Scripts/011_Battle/004_BattleHandlers_Items.rb @@ -146,8 +146,16 @@ BattleHandlers::HPHealItem.add(:ORANBERRY, proc { |item,battler,battle,forced| next false if !battler.canHeal? next false if !forced && !battler.canConsumePinchBerry?(false) + amt = 10 + ripening = false + if battler.hasActiveAbility?(:RIPEN) + battle.pbShowAbilitySplash(battler, forced) + amt *= 2 + ripening = true + end battle.pbCommonAnimation("EatBerry",battler) if !forced - battler.pbRecoverHP(10) + battle.pbHideAbilitySplash(battler) if ripening + battler.pbRecoverHP(amt) itemName = GameData::Item.get(item).name if forced PBDebug.log("[Item triggered] Forced consuming of #{itemName}") @@ -175,8 +183,16 @@ BattleHandlers::HPHealItem.add(:SITRUSBERRY, proc { |item,battler,battle,forced| next false if !battler.canHeal? next false if !forced && !battler.canConsumePinchBerry?(false) + amt = battler.totalhp / 4 + ripening = false + if battler.hasActiveAbility?(:RIPEN) + battle.pbShowAbilitySplash(battler, forced) + amt *= 2 + ripening = true + end battle.pbCommonAnimation("EatBerry",battler) if !forced - battler.pbRecoverHP(battler.totalhp/4) + battle.pbHideAbilitySplash(battler) if ripening + battler.pbRecoverHP(amt) itemName = GameData::Item.get(item).name if forced PBDebug.log("[Item triggered] Forced consuming of #{itemName}") @@ -1037,9 +1053,17 @@ BattleHandlers::TargetItemOnHit.add(:JABOCABERRY, next if !target.canConsumeBerry? next if !move.physicalMove? next if !user.takesIndirectDamage? - battle.pbCommonAnimation("EatBerry",target) + amt = user.totalhp / 8 + ripening = false + if battler.hasActiveAbility?(:RIPEN) + battle.pbShowAbilitySplash(battler) + amt *= 2 + ripening = true + end + battle.pbCommonAnimation("EatBerry", target) + battle.pbHideAbilitySplash(battler) if ripening battle.scene.pbDamageAnimation(user) - user.pbReduceHP(user.totalhp/8,false) + user.pbReduceHP(amt, false) battle.pbDisplay(_INTL("{1} consumed its {2} and hurt {3}!",target.pbThis, target.itemName,user.pbThis(true))) target.pbHeldItemTriggered(item) @@ -1099,9 +1123,17 @@ BattleHandlers::TargetItemOnHit.add(:ROWAPBERRY, next if !target.canConsumeBerry? next if !move.specialMove? next if !user.takesIndirectDamage? - battle.pbCommonAnimation("EatBerry",target) + amt = user.totalhp / 8 + ripening = false + if battler.hasActiveAbility?(:RIPEN) + battle.pbShowAbilitySplash(battler) + amt *= 2 + ripening = true + end + battle.pbCommonAnimation("EatBerry", target) + battle.pbHideAbilitySplash(battler) if ripening battle.scene.pbDamageAnimation(user) - user.pbReduceHP(user.totalhp/8,false) + user.pbReduceHP(amt, false) battle.pbDisplay(_INTL("{1} consumed its {2} and hurt {3}!",target.pbThis, target.itemName,user.pbThis(true))) target.pbHeldItemTriggered(item) @@ -1167,8 +1199,16 @@ BattleHandlers::TargetItemOnHitPositiveBerry.add(:ENIGMABERRY, next false if !forced && !battler.canConsumeBerry? itemName = GameData::Item.get(item).name PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced + amt = battler.totalhp / 4 + ripening = false + if battler.hasActiveAbility?(:RIPEN) + battle.pbShowAbilitySplash(battler, forced) + amt *= 2 + ripening = true + end battle.pbCommonAnimation("EatBerry",battler) if !forced - battler.pbRecoverHP(battler.totalhp/4) + battle.pbHideAbilitySplash(battler) if ripening + battler.pbRecoverHP(amt) if forced battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) else @@ -1184,12 +1224,18 @@ BattleHandlers::TargetItemOnHitPositiveBerry.add(:KEEBERRY, next false if !forced && !battler.canConsumeBerry? next false if !battler.pbCanRaiseStatStage?(:DEFENSE,battler) itemName = GameData::Item.get(item).name - if !forced - battle.pbCommonAnimation("EatBerry",battler) - next battler.pbRaiseStatStageByCause(:DEFENSE,1,battler,itemName) + amt = 1 + ripening = false + if battler.hasActiveAbility?(:RIPEN) + battle.pbShowAbilitySplash(battler, forced) + amt *= 2 + ripening = true end + battle.pbCommonAnimation("EatBerry", battler) if !forced + battle.pbHideAbilitySplash(battler) if ripening + next battler.pbRaiseStatStageByCause(:DEFENSE, amt, battler, itemName) if !forced PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") - next battler.pbRaiseStatStage(:DEFENSE,1,battler) + next battler.pbRaiseStatStage(:DEFENSE, amt, battler) } ) @@ -1198,12 +1244,18 @@ BattleHandlers::TargetItemOnHitPositiveBerry.add(:MARANGABERRY, next false if !forced && !battler.canConsumeBerry? next false if !battler.pbCanRaiseStatStage?(:SPECIAL_DEFENSE,battler) itemName = GameData::Item.get(item).name - if !forced - battle.pbCommonAnimation("EatBerry",battler) - next battler.pbRaiseStatStageByCause(:SPECIAL_DEFENSE,1,battler,itemName) + amt = 1 + ripening = false + if battler.hasActiveAbility?(:RIPEN) + battle.pbShowAbilitySplash(battler, forced) + amt *= 2 + ripening = true end + battle.pbCommonAnimation("EatBerry", battler) if !forced + battle.pbHideAbilitySplash(battler) if ripening + next battler.pbRaiseStatStageByCause(:SPECIAL_DEFENSE, amt, battler, itemName) if !forced PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") - next battler.pbRaiseStatStage(:SPECIAL_DEFENSE,1,battler) + next battler.pbRaiseStatStage(:SPECIAL_DEFENSE, amt, battler) } ) @@ -1292,11 +1344,19 @@ BattleHandlers::EndOfMoveItem.add(:LEPPABERRY, next false if found_empty_moves.empty? && (!forced || found_partial_moves.empty?) itemName = GameData::Item.get(item).name PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced + amt = 10 + ripening = false + if battler.hasActiveAbility?(:RIPEN) + battle.pbShowAbilitySplash(battler, forced) + amt *= 2 + ripening = true + end battle.pbCommonAnimation("EatBerry", battler) if !forced + battle.pbHideAbilitySplash(battler) if ripening choice = found_empty_moves.first choice = found_partial_moves.first if forced && choice.nil? pkmnMove = battler.pokemon.moves[choice] - pkmnMove.pp += 10 + pkmnMove.pp += amt pkmnMove.pp = pkmnMove.total_pp if pkmnMove.pp > pkmnMove.total_pp battler.moves[choice].pp = pkmnMove.pp moveName = pkmnMove.name diff --git a/Data/Scripts/011_Battle/Gen 8 abilities.rb b/Data/Scripts/011_Battle/Gen 8 abilities.rb index e91c5a27b..f02c098e3 100644 --- a/Data/Scripts/011_Battle/Gen 8 abilities.rb +++ b/Data/Scripts/011_Battle/Gen 8 abilities.rb @@ -324,27 +324,20 @@ BattleHandlers::EORWeatherAbility.add(:ICEFACE, } ) +BattleHandlers::DamageCalcUserAbility.add(:GORILLATACTICS, + proc { |ability, user, target, move, mults, baseDmg, type| + mults[:attack_multiplier] *= 1.5 + } +) =begin #=============================================================================== -Steam Engine -When bearer is hit by a Fire- or Water-type move, bearer gets +6 Speed (after -the effect of that move is applied). Outside of battle, makes eggs hatch twice -as fast (doesn't stack with other such abilities). - -Gorilla Tactics -Boosts bearer's Attack by 50%, but restricts bearer to one move (cf. Choice -Band). Power boost stacks with Choice Band. - Mirror Armor If a move/ability tries to lower the bearer's stat(s), the effect is reflected back at the causer. -Ripen -Doubles the effects of the bearer's held berries. - Neutralizing Gas Suppresses all other abilities. Once this ability stops applying, triggers all abilities that activate when gained (if this happens because bearer switches