From 8d4015c903172ed56df5197c80b3869ebfe6be85 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Mon, 13 Jun 2022 21:23:51 +0100 Subject: [PATCH] Improvement to Scent items' in-battle effects --- .../002_ShadowPokemon_Other.rb | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb b/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb index 79ac93013..86a96c480 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb @@ -294,7 +294,7 @@ ItemHandlers::UseOnPokemon.add(:TIMEFLUTE, proc { |item, qty, pkmn, scene| }) ItemHandlers::CanUseInBattle.add(:JOYSCENT, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| - if !battler || !battler.shadowPokemon? || !battler.inHyperMode? + if !pokemon.shadowPokemon? || (pokemon.happiness == 255 && pokemon.heart_gauge == 0) scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false end @@ -303,24 +303,33 @@ ItemHandlers::CanUseInBattle.add(:JOYSCENT, proc { |item, pokemon, battler, move ItemHandlers::CanUseInBattle.copy(:JOYSCENT, :EXCITESCENT, :VIVIDSCENT) -ItemHandlers::BattleUseOnBattler.add(:JOYSCENT, proc { |item, battler, scene| - battler.pokemon.hyper_mode = false - battler.pokemon.change_heart_gauge("scent", 1) - scene.pbDisplay(_INTL("{1} came to its senses from the {2}!", battler.pbThis, GameData::Item.get(item).name)) +ItemHandlers::BattleUseOnPokemon.add(:JOYSCENT, proc { |item, pokemon, battler, choices, scene| + if pokemon.hyper_mode + pokemon.hyper_mode = false + scene.pbDisplay(_INTL("{1} came to its senses from the {2}!", + battler&.pbThis || pokemon.name, GameData::Item.get(item).name)) + end + pbRaiseHappinessAndReduceHeart(pokemon, scene, 1, false) next true }) -ItemHandlers::BattleUseOnBattler.add(:EXCITESCENT, proc { |item, battler, scene| - battler.pokemon.hyper_mode = false - battler.pokemon.change_heart_gauge("scent", 2) - scene.pbDisplay(_INTL("{1} came to its senses from the {2}!", battler.pbThis, GameData::Item.get(item).name)) +ItemHandlers::BattleUseOnPokemon.add(:EXCITESCENT, proc { |item, pokemon, battler, choices, scene| + if pokemon.hyper_mode + pokemon.hyper_mode = false + scene.pbDisplay(_INTL("{1} came to its senses from the {2}!", + battler&.pbThis || pokemon.name, GameData::Item.get(item).name)) + end + pbRaiseHappinessAndReduceHeart(pokemon, scene, 2, false) next true }) -ItemHandlers::BattleUseOnBattler.add(:VIVIDSCENT, proc { |item, battler, scene| - battler.pokemon.hyper_mode = false - battler.pokemon.change_heart_gauge("scent", 3) - scene.pbDisplay(_INTL("{1} came to its senses from the {2}!", battler.pbThis, GameData::Item.get(item).name)) +ItemHandlers::BattleUseOnPokemon.add(:VIVIDSCENT, proc { |item, pokemon, battler, choices, scene| + if pokemon.hyper_mode + pokemon.hyper_mode = false + scene.pbDisplay(_INTL("{1} came to its senses from the {2}!", + battler&.pbThis || pokemon.name, GameData::Item.get(item).name)) + end + pbRaiseHappinessAndReduceHeart(pokemon, scene, 3, false) next true })