From 2112cdba37574e7c0bf6dff8b7cf98e5cc9a3cdf Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sat, 14 Aug 2021 19:07:57 +0100 Subject: [PATCH] Added effects of Mimicry/Room Service/Catching Charm, tweaked Sinistea's form chances, fixed bug in Fling about TRs. --- .../001_Battler/003_Battler_ChangeSelf.rb | 8 ++++ .../001_Battler/006_Battler_AbilityAndItem.rb | 19 ++++++--- .../001_Battler/007_Battler_UseMove.rb | 2 +- .../010_Battler_UseMove_TriggerEffects.rb | 10 +++++ Data/Scripts/011_Battle/002_BattleHandlers.rb | 5 +++ .../002_Move/005_Move_Effects_000-07F.rb | 8 ++-- .../002_Move/006_Move_Effects_080-0FF.rb | 5 ++- .../002_Move/008_Move_Effects_Gen8.rb | 2 +- .../003_Battle/001_PokeBattle_BattleCommon.rb | 14 ++++--- .../003_Battle/002_PokeBattle_Battle.rb | 3 +- .../003_Battle/012_Battle_Phase_EndOfRound.rb | 7 +++- .../003_BattleHandlers_Abilities.rb | 41 ++++++++++++++++++- Data/Scripts/011_Battle/Gen 8 abilities.rb | 13 +++--- Data/Scripts/013_Items/Gen 8 items.rb | 18 ++++---- .../001_Pokemon-related/001_FormHandlers.rb | 2 +- 15 files changed, 120 insertions(+), 37 deletions(-) diff --git a/Data/Scripts/011_Battle/001_Battler/003_Battler_ChangeSelf.rb b/Data/Scripts/011_Battle/001_Battler/003_Battler_ChangeSelf.rb index 82aa53879..8ccb0921e 100644 --- a/Data/Scripts/011_Battle/001_Battler/003_Battler_ChangeSelf.rb +++ b/Data/Scripts/011_Battle/001_Battler/003_Battler_ChangeSelf.rb @@ -127,6 +127,14 @@ class PokeBattle_Battler @effects[PBEffects::Roost] = false end + def pbResetTypes + @type1 = @pokemon.type1 + @type2 = @pokemon.type2 + @effects[PBEffects::Type3] = nil + @effects[PBEffects::BurnUp] = false + @effects[PBEffects::Roost] = false + end + #============================================================================= # Forms #============================================================================= 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 601715c62..c3f5977da 100644 --- a/Data/Scripts/011_Battle/001_Battler/006_Battler_AbilityAndItem.rb +++ b/Data/Scripts/011_Battle/001_Battler/006_Battler_AbilityAndItem.rb @@ -61,6 +61,17 @@ class PokeBattle_Battler return ret # Whether self has switched out end + def pbAbilityOnTerrainChange(ability_changed = false) + return if !abilityActive? + BattleHandlers.triggerAbilityOnTerrainChange(self.ability, self, @battle, ability_changed) + end + + # Used for Rattled's Gen 8 effect. Called when Intimidate is triggered. + def pbAbilitiesOnIntimidated + return if !abilityActive? + BattleHandlers.triggerAbilityOnIntimidated(self.ability, self, @battle) + end + # Called when a Pokémon (self) enters battle, at the end of each move used, # and at the end of each round. def pbContinualAbilityChecks(onSwitchIn=false) @@ -91,12 +102,6 @@ class PokeBattle_Battler end end - # Used for Rattled's Gen 8 effect. Called when Intimidate is triggered. - def pbAbilitiesOnIntimidated - return if !abilityActive? - BattleHandlers.triggerAbilityOnIntimidated(self.ability, self, @battle) - end - #============================================================================= # Ability curing #============================================================================= @@ -123,6 +128,8 @@ class PokeBattle_Battler @effects[PBEffects::SlowStart] = 0 if self.ability != :SLOWSTART # Revert form if Flower Gift/Forecast was lost pbCheckFormOnWeatherChange(true) + # Abilities that trigger when the terrain changes + pbAbilityOnTerrainChange(true) # Check for end of primordial weather @battle.pbEndPrimordialWeather end 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 e2637f0ba..8607a08d6 100644 --- a/Data/Scripts/011_Battle/001_Battler/007_Battler_UseMove.rb +++ b/Data/Scripts/011_Battle/001_Battler/007_Battler_UseMove.rb @@ -366,7 +366,7 @@ class PokeBattle_Battler @battle.pbShowAbilitySplash(user) user.pbChangeTypes(move.calcType) typeName = GameData::Type.get(move.calcType).name - @battle.pbDisplay(_INTL("{1} transformed into the {2} type!",user.pbThis,typeName)) + @battle.pbDisplay(_INTL("{1}'s type changed to {2}!",user.pbThis,typeName)) @battle.pbHideAbilitySplash(user) # NOTE: The GF games say that if Curse is used by a non-Ghost-type # Pokémon which becomes Ghost-type because of Protean, it should diff --git a/Data/Scripts/011_Battle/001_Battler/010_Battler_UseMove_TriggerEffects.rb b/Data/Scripts/011_Battle/001_Battler/010_Battler_UseMove_TriggerEffects.rb index bc41b367c..8de9b3cca 100644 --- a/Data/Scripts/011_Battle/001_Battler/010_Battler_UseMove_TriggerEffects.rb +++ b/Data/Scripts/011_Battle/001_Battler/010_Battler_UseMove_TriggerEffects.rb @@ -144,6 +144,16 @@ class PokeBattle_Battler # after the move's animation, but the item is only consumed now. user.pbConsumeItem end + # Room Service + if move.function == "11F" && @battle.field.effects[PBEffects::TrickRoom] > 0 # Trick Room + @battle.battlers.each do |b| + next if !b.hasActiveItem?(:ROOMSERVICE) + next if !b.pbCanLowerStatStage?(:SPEED, b) + @battle.pbCommonAnimation("UseItem", b) + b.pbLowerStatStage(:SPEED, 1, b) + b.pbConsumeItem + end + end # Pokémon switching caused by Roar, Whirlwind, Circle Throw, Dragon Tail switchedBattlers = [] move.pbSwitchOutTargetsEffect(user,targets,numHits,switchedBattlers) diff --git a/Data/Scripts/011_Battle/002_BattleHandlers.rb b/Data/Scripts/011_Battle/002_BattleHandlers.rb index eae61c497..778a3f486 100644 --- a/Data/Scripts/011_Battle/002_BattleHandlers.rb +++ b/Data/Scripts/011_Battle/002_BattleHandlers.rb @@ -90,6 +90,7 @@ module BattleHandlers AbilityOnSwitchOut = AbilityHandlerHash.new AbilityChangeOnBattlerFainting = AbilityHandlerHash.new AbilityOnBattlerFainting = AbilityHandlerHash.new # Soul-Heart + AbilityOnTerrainChange = AbilityHandlerHash.new # Mimicry AbilityOnIntimidated = AbilityHandlerHash.new # Rattled (Gen 8) # Running from battle RunFromBattleAbility = AbilityHandlerHash.new # Run Away @@ -464,6 +465,10 @@ module BattleHandlers AbilityOnBattlerFainting.trigger(ability,battler,fainted,battle) end + def self.triggerAbilityOnTerrainChange(ability, battler, battle, ability_changed) + AbilityOnTerrainChange.trigger(ability, battler, battle, ability_changed) + end + def self.triggerAbilityOnIntimidated(ability,battler,battle) AbilityOnIntimidated.trigger(ability,battler,battle) end diff --git a/Data/Scripts/011_Battle/002_Move/005_Move_Effects_000-07F.rb b/Data/Scripts/011_Battle/002_Move/005_Move_Effects_000-07F.rb index 032a62f01..81543ff75 100644 --- a/Data/Scripts/011_Battle/002_Move/005_Move_Effects_000-07F.rb +++ b/Data/Scripts/011_Battle/002_Move/005_Move_Effects_000-07F.rb @@ -1860,7 +1860,7 @@ class PokeBattle_Move_05E < PokeBattle_Move newType = @newTypes[@battle.pbRandom(@newTypes.length)] user.pbChangeTypes(newType) typeName = GameData::Type.get(newType).name - @battle.pbDisplay(_INTL("{1} transformed into the {2} type!",user.pbThis,typeName)) + @battle.pbDisplay(_INTL("{1}'s type changed to {2}!",user.pbThis,typeName)) end end @@ -1904,7 +1904,7 @@ class PokeBattle_Move_05F < PokeBattle_Move newType = @newTypes[@battle.pbRandom(@newTypes.length)] user.pbChangeTypes(newType) typeName = GameData::Type.get(newType).name - @battle.pbDisplay(_INTL("{1} transformed into the {2} type!", user.pbThis, typeName)) + @battle.pbDisplay(_INTL("{1}'s type changed to {2}!", user.pbThis, typeName)) end end @@ -1982,7 +1982,7 @@ class PokeBattle_Move_060 < PokeBattle_Move def pbEffectGeneral(user) user.pbChangeTypes(@newType) typeName = GameData::Type.get(@newType).name - @battle.pbDisplay(_INTL("{1} transformed into the {2} type!",user.pbThis,typeName)) + @battle.pbDisplay(_INTL("{1}'s type changed to {2}!",user.pbThis,typeName)) end end @@ -2006,7 +2006,7 @@ class PokeBattle_Move_061 < PokeBattle_Move def pbEffectAgainstTarget(user,target) target.pbChangeTypes(:WATER) typeName = GameData::Type.get(:WATER).name - @battle.pbDisplay(_INTL("{1} transformed into the {2} type!",target.pbThis,typeName)) + @battle.pbDisplay(_INTL("{1}'s type changed to {2}!",target.pbThis,typeName)) end end 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 34bfbd097..36e8d7bd3 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 @@ -3644,8 +3644,9 @@ class PokeBattle_Move_0F7 < PokeBattle_Move def pbNumHits(user,targets); return 1; end def pbBaseDamage(baseDmg,user,target) - return 10 if user.item && user.item.is_berry? - return 80 if user.item && user.item.is_mega_stone? + return 0 if !user.item + return 10 if user.item.is_berry? + return 80 if user.item.is_mega_stone? if user.item.is_TR? ret = GameData::Move.get(user.item.move).base_damage ret = 10 if ret < 10 diff --git a/Data/Scripts/011_Battle/002_Move/008_Move_Effects_Gen8.rb b/Data/Scripts/011_Battle/002_Move/008_Move_Effects_Gen8.rb index c7ea2ca73..62a1a0f41 100644 --- a/Data/Scripts/011_Battle/002_Move/008_Move_Effects_Gen8.rb +++ b/Data/Scripts/011_Battle/002_Move/008_Move_Effects_Gen8.rb @@ -255,7 +255,7 @@ class PokeBattle_Move_17F < PokeBattle_Move def pbEffectAgainstTarget(user, target) target.pbChangeTypes(:PSYCHIC) typeName = GameData::Type.get(:PSYCHIC).name - @battle.pbDisplay(_INTL("{1} transformed into the {2} type!", target.pbThis, typeName)) + @battle.pbDisplay(_INTL("{1}'s type changed to {2}!", target.pbThis, typeName)) end end diff --git a/Data/Scripts/011_Battle/003_Battle/001_PokeBattle_BattleCommon.rb b/Data/Scripts/011_Battle/003_Battle/001_PokeBattle_BattleCommon.rb index e407d753d..0898bb1d7 100644 --- a/Data/Scripts/011_Battle/003_Battle/001_PokeBattle_BattleCommon.rb +++ b/Data/Scripts/011_Battle/003_Battle/001_PokeBattle_BattleCommon.rb @@ -193,14 +193,16 @@ module PokeBattle_BattleCommon y = ( 65536 / ((255.0/x)**0.1875) ).floor # Critical capture check if Settings::ENABLE_CRITICAL_CAPTURES - c = 0 + dex_modifier = 0 numOwned = $Trainer.pokedex.owned_count - if numOwned>600; c = x*5/12 - elsif numOwned>450; c = x*4/12 - elsif numOwned>300; c = x*3/12 - elsif numOwned>150; c = x*2/12 - elsif numOwned>30; c = x/12 + if numOwned>600; dex_modifier = 5 + elsif numOwned>450; dex_modifier = 4 + elsif numOwned>300; dex_modifier = 3 + elsif numOwned>150; dex_modifier = 2 + elsif numOwned>30; dex_modifier = 1 end + dex_modifier *= 2 if $PokemonBag.pbHasItem?(:CATCHINGCHARM) + c = x * dex_modifier / 12 # Calculate the number of shakes if c>0 && pbRandom(256) :ELECTRIC, + :Grassy => :GRASS, + :Misty => :FAIRY, + :Psychic => :PSYCHIC + } + new_type = terrain_hash[battle.field.terrain] + new_type_name = nil + if new_type + type_data = GameData::Type.try_get(new_type) + new_type = nil if !type_data + new_type_name = type_data.name if type_data + end + if new_type + battle.pbShowAbilitySplash(battler) + battler.pbChangeTypes(new_type) + battle.pbDisplay(_INTL("{1}'s type changed to {2}!", battler.pbThis, new_type_name)) + battle.pbHideAbilitySplash(battler) + end + end + } +) + #=============================================================================== # AbilityOnIntimidated handlers #=============================================================================== diff --git a/Data/Scripts/011_Battle/Gen 8 abilities.rb b/Data/Scripts/011_Battle/Gen 8 abilities.rb index f02c098e3..9172f804c 100644 --- a/Data/Scripts/011_Battle/Gen 8 abilities.rb +++ b/Data/Scripts/011_Battle/Gen 8 abilities.rb @@ -330,6 +330,14 @@ BattleHandlers::DamageCalcUserAbility.add(:GORILLATACTICS, } ) +BattleHandlers::AbilityOnSwitchIn.add(:MIMICRY, + proc { |ability, battler, battle| + next if battle.field.terrain == :None + BattleHandlers.triggerAbilityOnTerrainChange(ability, battler, battle, false) + } +) + + =begin #=============================================================================== @@ -343,9 +351,4 @@ Suppresses all other abilities. Once this ability stops applying, triggers all abilities that activate when gained (if this happens because bearer switches out, abilities trigger before the replacement switches in). -Mimicry -The bearer's type changes depending on the terrain. Triggers upon entering -battle and when terrain changes (and not when bearer's type is changed, e.g. -with Soak). - =end diff --git a/Data/Scripts/013_Items/Gen 8 items.rb b/Data/Scripts/013_Items/Gen 8 items.rb index 05ad76480..54482096a 100644 --- a/Data/Scripts/013_Items/Gen 8 items.rb +++ b/Data/Scripts/013_Items/Gen 8 items.rb @@ -324,11 +324,22 @@ BattleHandlers::UserItemAfterMoveUse.add(:THROATSPRAY, battle.pbAllFainted?(user.idxOpposingSide) next if !move.soundMove? || numHits == 0 next if !user.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user) + battle.pbCommonAnimation("UseItem", user) user.pbRaiseStatStage(:SPECIAL_ATTACK, 1, user) user.pbConsumeItem } ) +BattleHandlers::ItemOnSwitchIn.add(:ROOMSERVICE, + proc { |item, battler, battle| + next if battle.field.effects[PBEffects::TrickRoom] == 0 + next if !battler.pbCanLowerStatStage?(:SPEED, battler) + battle.pbCommonAnimation("UseItem", battler) + battler.pbLowerStatStage(:SPEED, 1, battler) + battler.pbConsumeItem + } +) + =begin @@ -344,16 +355,9 @@ If holder's move fails its accuracy check, consume item and holder gets +2 Speed. Doesn't trigger if move was an OHKO move, or Triple Kick that hit at least once. -Room Service -If Trick Room is used, or if holder switches in while Trick Room applies, -consume item and holder gets -1 Speed. - Pokémon Box Link Key item, unusable. Enables pressing a button while in the party screen to open the "Organise Boxes" mode of Pokémon storage. This is disabled at certain times, perhaps when a Game Switch is on. -Catching Charm -Increases the chance of a critical catch. By how much? - =end 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 546672b06..0d477261a 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb @@ -603,7 +603,7 @@ MultipleForms.copy(:TOXEL, :TOXTRICITY) MultipleForms.register(:SINISTEA, { "getFormOnCreation" => proc { |pkmn| - next 1 if rand(100) == 0 + next 1 if rand(100) < 50 next 0 } })