diff --git a/Data/Scripts/011_Battle/001_Battler/001_PokeBattle_Battler.rb b/Data/Scripts/011_Battle/001_Battler/001_PokeBattle_Battler.rb index 83c8c91f7..6f807348f 100644 --- a/Data/Scripts/011_Battle/001_Battler/001_PokeBattle_Battler.rb +++ b/Data/Scripts/011_Battle/001_Battler/001_PokeBattle_Battler.rb @@ -39,10 +39,11 @@ class PokeBattle_Battler attr_accessor :movesUsed attr_accessor :currentMove # ID of multi-turn move currently being used attr_accessor :droppedBelowHalfHP # Used for Emergency Exit/Wimp Out + attr_accessor :statsDropped # Used for Eject Pack attr_accessor :tookDamageThisRound # Boolean for whether self took damage this round attr_accessor :tookPhysicalHit - attr_accessor :statsRaised # Boolean for whether self's stat(s) raised this round - attr_accessor :statsLowered # Boolean for whether self's stat(s) lowered this round + attr_accessor :statsRaisedThisRound # Boolean for whether self's stat(s) raised this round + attr_accessor :statsLoweredThisRound # Boolean for whether self's stat(s) lowered this round attr_accessor :canRestoreIceFace # Whether Hail started in the round attr_accessor :damageState diff --git a/Data/Scripts/011_Battle/001_Battler/002_Battler_Initialize.rb b/Data/Scripts/011_Battle/001_Battler/002_Battler_Initialize.rb index bb58e6157..c8a1a2211 100644 --- a/Data/Scripts/011_Battle/001_Battler/002_Battler_Initialize.rb +++ b/Data/Scripts/011_Battle/001_Battler/002_Battler_Initialize.rb @@ -148,10 +148,11 @@ class PokeBattle_Battler @lastHPLost = 0 @lastHPLostFromFoe = 0 @droppedBelowHalfHP = false + @statsDropped = false @tookDamageThisRound = false @tookPhysicalHit = false - @statsRaised = false - @statsLowered = false + @statsRaisedThisRound = false + @statsLoweredThisRound = false @canRestoreIceFace = false @lastMoveUsed = nil @lastMoveUsedType = nil 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 f6afb670c..a4932f820 100644 --- a/Data/Scripts/011_Battle/001_Battler/003_Battler_ChangeSelf.rb +++ b/Data/Scripts/011_Battle/001_Battler/003_Battler_ChangeSelf.rb @@ -51,11 +51,13 @@ class PokeBattle_Battler end def pbTakeEffectDamage(amt, show_anim = true) + @droppedBelowHalfHP = false hp_lost = pbReduceHP(amt, show_anim) yield hp_lost if block_given? # Show message pbItemHPHealCheck pbAbilitiesOnDamageTaken pbFaint if fainted? + @droppedBelowHalfHP = false end def pbFaint(showMessage=true) diff --git a/Data/Scripts/011_Battle/001_Battler/005_Battler_StatStages.rb b/Data/Scripts/011_Battle/001_Battler/005_Battler_StatStages.rb index 84afe1101..0b50f76b4 100644 --- a/Data/Scripts/011_Battle/001_Battler/005_Battler_StatStages.rb +++ b/Data/Scripts/011_Battle/001_Battler/005_Battler_StatStages.rb @@ -37,7 +37,7 @@ class PokeBattle_Battler new = @stages[stat]+increment PBDebug.log("[Stat change] #{pbThis}'s #{stat_name}: #{@stages[stat]} -> #{new} (+#{increment})") @stages[stat] += increment - @statsRaised = true + @statsRaisedThisRound = true end return increment end @@ -176,7 +176,8 @@ class PokeBattle_Battler new = @stages[stat]-increment PBDebug.log("[Stat change] #{pbThis}'s #{stat_name}: #{@stages[stat]} -> #{new} (-#{increment})") @stages[stat] -= increment - @statsLowered = true + @statsLoweredThisRound = true + @statsDropped = true end return increment end @@ -360,9 +361,10 @@ class PokeBattle_Battler def pbResetStatStages GameData::Stat.each_battle do |s| if @stages[s.id] > 0 - @statsLowered = true + @statsLoweredThisRound = true + @statsDropped = true elsif @stages[s.id] < 0 - @statsRaised = true + @statsRaisedThisRound = true end @stages[s.id] = 0 end 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 6e2f456c2..2887845a6 100644 --- a/Data/Scripts/011_Battle/001_Battler/006_Battler_AbilityAndItem.rb +++ b/Data/Scripts/011_Battle/001_Battler/006_Battler_AbilityAndItem.rb @@ -292,4 +292,11 @@ class PokeBattle_Battler pbHeldItemTriggered(self.item) end end + + # Used for Eject Pack. Returns whether self has switched out. + def pbItemOnStatDropped(move_user = nil) + return false if !@statsDropped + return false if !itemActive? + return BattleHandlers.triggerItemOnStatDropped(self.item, self, move_user, @battle) + end 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 14230ecd6..6f0032fa7 100644 --- a/Data/Scripts/011_Battle/001_Battler/007_Battler_UseMove.rb +++ b/Data/Scripts/011_Battle/001_Battler/007_Battler_UseMove.rb @@ -384,7 +384,10 @@ class PokeBattle_Battler user.lastMoveFailed = true else # We have targets, or move doesn't use targets # Reset whole damage state, perform various success checks (not accuracy) - @battle.eachBattler { |b| b.droppedBelowHalfHP = false } + @battle.eachBattler do |b| + b.droppedBelowHalfHP = false + b.statsDropped = false + end targets.each do |b| b.damageState.reset next if pbSuccessCheckAgainstTarget(move, user, b, targets) @@ -496,7 +499,10 @@ class PokeBattle_Battler user.pbFaint if user.fainted? # External/general effects after all hits. Eject Button, Shell Bell, etc. pbEffectsAfterMove(user,targets,move,realNumHits) - @battle.eachBattler { |b| b.droppedBelowHalfHP = false } + @battle.eachBattler do |b| + b.droppedBelowHalfHP = false + b.statsDropped = false + end end # End effect of Mold Breaker @battle.moldBreaker = false diff --git a/Data/Scripts/011_Battle/001_Battler/010_Battler_UseMove_TriggerEffects.rb b/Data/Scripts/011_Battle/001_Battler/010_Battler_UseMove_TriggerEffects.rb index f7b6c0c16..9f8ee4e21 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 @@ -138,12 +138,6 @@ class PokeBattle_Battler user.pbChangeForm((user.hp > user.totalhp / 2) ? 1 : 2, nil) end end - # Consume user's Gem - if user.effects[PBEffects::GemConsumed] - # NOTE: The consume animation and message for Gems are shown immediately - # after the move's animation, but the item is only consumed now. - user.pbConsumeItem - end # Room Service if move.function == "StartSlowerBattlersActFirst" && @battle.field.effects[PBEffects::TrickRoom] > 0 @battle.battlers.each do |b| @@ -154,6 +148,12 @@ class PokeBattle_Battler b.pbConsumeItem end end + # Consume user's Gem + if user.effects[PBEffects::GemConsumed] + # NOTE: The consume animation and message for Gems are shown immediately + # after the move's animation, but the item is only consumed now. + user.pbConsumeItem + end switched_battlers = [] # Indices of battlers that were switched out somehow # Target switching caused by Roar, Whirlwind, Circle Throw, Dragon Tail move.pbSwitchOutTargetEffect(user, targets, numHits, switched_battlers) @@ -180,10 +180,17 @@ class PokeBattle_Battler def pbEffectsAfterMove2(user, targets, move, numHits, switched_battlers) # Target's held item (Eject Button, Red Card, Eject Pack) @battle.pbPriority(true).each do |b| - next if !targets.any? { |targetB| targetB.index==b.index } - next if b.damageState.unaffected || b.damageState.calcDamage == 0 - next if !b.itemActive? - BattleHandlers.triggerTargetItemAfterMoveUse(b.item, b, user, move, switched_battlers, @battle) + if targets.any? { |targetB| targetB.index==b.index } + if !b.damageState.unaffected && b.damageState.calcDamage > 0 && b.itemActive? + BattleHandlers.triggerTargetItemAfterMoveUse(b.item, b, user, move, switched_battlers, @battle) + end + end + # Target's Eject Pack + if switched_battlers.empty? && b.index != user.index + if b.pbItemOnStatDropped(user) + switched_battlers.push(b.index) + end + end end # User's held item (Life Orb, Shell Bell, Throat Spray, Eject Pack) if !switched_battlers.include?(user.index) && user.itemActive? # Only if user hasn't switched out @@ -192,11 +199,11 @@ class PokeBattle_Battler # Target's ability (Berserk, Color Change, Emergency Exit, Pickpocket, Wimp Out) @battle.pbPriority(true).each do |b| if targets.any? { |targetB| targetB.index==b.index } - next if b.damageState.unaffected || switched_battlers.include?(b.index) - next if !b.abilityActive? - BattleHandlers.triggerTargetAbilityAfterMoveUse(b.ability, b, user, move, switched_battlers, @battle) + if !b.damageState.unaffected && !switched_battlers.include?(b.index) && b.abilityActive? + BattleHandlers.triggerTargetAbilityAfterMoveUse(b.ability, b, user, move, switched_battlers, @battle) + end end - # Emergency Exit, Wimp Out (including for Pokémon hurt by Flame Burst) + # Target's Emergency Exit, Wimp Out (including for Pokémon hurt by Flame Burst) if switched_battlers.empty? && move.damagingMove? && b.index != user.index if b.pbAbilitiesOnDamageTaken(user) switched_battlers.push(b.index) @@ -207,8 +214,12 @@ class PokeBattle_Battler # Everything in this method is negated by Sheer Force. def pbEffectsAfterMove3(user, targets, move, numHits, switched_battlers) - # TODO: User's Eject Pack. - + # User's held item that switches it out (Eject Pack) + if switched_battlers.empty? + if user.pbItemOnStatDropped(user) + switched_battlers.push(user.index) + end + end # User's ability (Emergency Exit, Wimp Out) if switched_battlers.empty? && move.damagingMove? if user.pbAbilitiesOnDamageTaken(user) diff --git a/Data/Scripts/011_Battle/002_BattleHandlers.rb b/Data/Scripts/011_Battle/002_BattleHandlers.rb index a82257267..bc3724791 100644 --- a/Data/Scripts/011_Battle/002_BattleHandlers.rb +++ b/Data/Scripts/011_Battle/002_BattleHandlers.rb @@ -5,9 +5,10 @@ module BattleHandlers # Battler's weight calculation WeightCalcAbility = AbilityHandlerHash.new WeightCalcItem = ItemHandlerHash.new # Float Stone - # Battler's HP changed + # Battler's HP/stat changed HPHealItem = ItemHandlerHash.new AbilityOnHPDroppedBelowHalf = AbilityHandlerHash.new + ItemOnStatDropped = ItemHandlerHash.new # Battler's status problem StatusCheckAbilityNonIgnorable = AbilityHandlerHash.new # Comatose StatusImmunityAbility = AbilityHandlerHash.new @@ -133,6 +134,11 @@ module BattleHandlers return (ret!=nil) ? ret : false end + def self.triggerItemOnStatDropped(item, user, move_user, battle) + ret = ItemOnStatDropped.trigger(item, user, move_user, battle) + return (ret != nil) ? ret : false + end + #============================================================================= def self.triggerStatusCheckAbilityNonIgnorable(ability,battler,status) diff --git a/Data/Scripts/011_Battle/002_Move/006_MoveEffects_BattlerStats.rb b/Data/Scripts/011_Battle/002_Move/006_MoveEffects_BattlerStats.rb index 52f3c3cde..51eabbc0f 100644 --- a/Data/Scripts/011_Battle/002_Move/006_MoveEffects_BattlerStats.rb +++ b/Data/Scripts/011_Battle/002_Move/006_MoveEffects_BattlerStats.rb @@ -62,12 +62,13 @@ class PokeBattle_Move_MaxUserAttackLoseHalfOfTotalHP < PokeBattle_Move user.pbReduceHP(hpLoss, false, false) if user.hasActiveAbility?(:CONTRARY) user.stages[:ATTACK] = -6 - user.statsLowered = true + user.statsLoweredThisRound = true + user.statsDropped = true @battle.pbCommonAnimation("StatDown",user) @battle.pbDisplay(_INTL("{1} cut its own HP and minimized its Attack!",user.pbThis)) else user.stages[:ATTACK] = 6 - user.statsRaised = true + user.statsRaisedThisRound = true @battle.pbCommonAnimation("StatUp",user) @battle.pbDisplay(_INTL("{1} cut its own HP and maximized its Attack!",user.pbThis)) end @@ -1616,11 +1617,13 @@ class PokeBattle_Move_UserTargetSwapAtkSpAtkStages < PokeBattle_Move def pbEffectAgainstTarget(user,target) [:ATTACK,:SPECIAL_ATTACK].each do |s| if user.stages[s] > target.stages[s] - user.statsLowered = true - target.statsRaised = true + user.statsLoweredThisRound = true + user.statsDropped = true + target.statsRaisedThisRound = true elsif user.stages[s] < target.stages[s] - user.statsRaised = true - target.statsLowered = true + user.statsRaisedThisRound = true + target.statsLoweredThisRound = true + target.statsDropped = true end user.stages[s],target.stages[s] = target.stages[s],user.stages[s] end @@ -1637,11 +1640,13 @@ class PokeBattle_Move_UserTargetSwapDefSpDefStages < PokeBattle_Move def pbEffectAgainstTarget(user,target) [:DEFENSE,:SPECIAL_DEFENSE].each do |s| if user.stages[s] > target.stages[s] - user.statsLowered = true - target.statsRaised = true + user.statsLoweredThisRound = true + user.statsDropped = true + target.statsRaisedThisRound = true elsif user.stages[s] < target.stages[s] - user.statsRaised = true - target.statsLowered = true + user.statsRaisedThisRound = true + target.statsLoweredThisRound = true + target.statsDropped = true end user.stages[s],target.stages[s] = target.stages[s],user.stages[s] end @@ -1658,11 +1663,13 @@ class PokeBattle_Move_UserTargetSwapStatStages < PokeBattle_Move def pbEffectAgainstTarget(user,target) GameData::Stat.each_battle do |s| if user.stages[s.id] > target.stages[s.id] - user.statsLowered = true - target.statsRaised = true + user.statsLoweredThisRound = true + user.statsDropped = true + target.statsRaisedThisRound = true elsif user.stages[s.id] < target.stages[s.id] - user.statsRaised = true - target.statsLowered = true + user.statsRaisedThisRound = true + target.statsLoweredThisRound = true + target.statsDropped = true end user.stages[s.id],target.stages[s.id] = target.stages[s.id],user.stages[s.id] end @@ -1679,9 +1686,10 @@ class PokeBattle_Move_UserCopyTargetStatStages < PokeBattle_Move def pbEffectAgainstTarget(user,target) GameData::Stat.each_battle do |s| if user.stages[s.id] > target.stages[s.id] - user.statsLowered = true + user.statsLoweredThisRound = true + user.statsDropped = true elsif user.stages[s.id] < target.stages[s.id] - user.statsRaised = true + user.statsRaisedThisRound = true end user.stages[s.id] = target.stages[s.id] end @@ -1713,7 +1721,8 @@ class PokeBattle_Move_UserStealTargetPositiveStatStages < PokeBattle_Move showAnim = false end end - target.statsLowered = true + target.statsLoweredThisRound = true + target.statsDropped = true target.stages[s.id] = 0 end end @@ -1738,9 +1747,10 @@ class PokeBattle_Move_InvertTargetStatStages < PokeBattle_Move def pbEffectAgainstTarget(user,target) GameData::Stat.each_battle do |s| if target.stages[s.id] > 0 - target.statsLowered = true + target.statsLoweredThisRound = true + target.statsDropped = true elsif target.stages[s.id] < 0 - target.statsRaised = true + target.statsRaisedThisRound = true end target.stages[s.id] *= -1 end diff --git a/Data/Scripts/011_Battle/002_Move/007_MoveEffects_BattlerOther.rb b/Data/Scripts/011_Battle/002_Move/007_MoveEffects_BattlerOther.rb index 1ebce538a..2c900b99d 100644 --- a/Data/Scripts/011_Battle/002_Move/007_MoveEffects_BattlerOther.rb +++ b/Data/Scripts/011_Battle/002_Move/007_MoveEffects_BattlerOther.rb @@ -175,7 +175,7 @@ end #=============================================================================== class PokeBattle_Move_BurnTargetIfTargetStatsRaisedThisTurn < PokeBattle_BurnMove def pbAdditionalEffect(user, target) - super if target.statsRaised + super if target.statsRaisedThisRound end end diff --git a/Data/Scripts/011_Battle/002_Move/008_MoveEffects_MoveAttributes.rb b/Data/Scripts/011_Battle/002_Move/008_MoveEffects_MoveAttributes.rb index 379e0573e..33e2d202c 100644 --- a/Data/Scripts/011_Battle/002_Move/008_MoveEffects_MoveAttributes.rb +++ b/Data/Scripts/011_Battle/002_Move/008_MoveEffects_MoveAttributes.rb @@ -605,7 +605,7 @@ end #=============================================================================== class PokeBattle_Move_DoublePowerIfUserStatsLoweredThisTurn < PokeBattle_Move def pbBaseDamage(baseDmg, user, target) - baseDmg *= 2 if user.statsLowered + baseDmg *= 2 if user.statsLoweredThisRound return baseDmg end end diff --git a/Data/Scripts/011_Battle/003_Battle/006_Battle_Action_Switching.rb b/Data/Scripts/011_Battle/003_Battle/006_Battle_Action_Switching.rb index 2db6f73e8..12ac6b558 100644 --- a/Data/Scripts/011_Battle/003_Battle/006_Battle_Action_Switching.rb +++ b/Data/Scripts/011_Battle/003_Battle/006_Battle_Action_Switching.rb @@ -316,8 +316,9 @@ class PokeBattle_Battle # in. def pbOnBattlerEnteringBattle(*battler_indices) battler_indices.flatten! - pbPriority(true).each do |b| + eachBattler do |b| b.droppedBelowHalfHP = false + b.statsDropped = false end # For each battler that entered battle, in speed order pbPriority(true).each do |b| @@ -355,10 +356,12 @@ class PokeBattle_Battle # Check for triggering of Emergency Exit/Wimp Out/Eject Pack (only one will # be triggered) pbPriority(true).each do |b| + break if b.pbItemOnStatDropped break if b.pbAbilitiesOnDamageTaken end - pbPriority(true).each do |b| + eachBattler do |b| b.droppedBelowHalfHP = false + b.statsDropped = false end end diff --git a/Data/Scripts/011_Battle/003_Battle/007_Battle_Action_UseItem.rb b/Data/Scripts/011_Battle/003_Battle/007_Battle_Action_UseItem.rb index 83ae74df9..5cede1216 100644 --- a/Data/Scripts/011_Battle/003_Battle/007_Battle_Action_UseItem.rb +++ b/Data/Scripts/011_Battle/003_Battle/007_Battle_Action_UseItem.rb @@ -103,6 +103,7 @@ class PokeBattle_Battle if ItemHandlers.triggerCanUseInBattle(item,battler.pokemon,battler,ch[3],true,self,@scene,false) ItemHandlers.triggerBattleUseOnBattler(item,battler,@scene) ch[1] = nil # Delete item from choice + battler.pbItemOnStatDropped return else pbDisplay(_INTL("But it had no effect!")) diff --git a/Data/Scripts/011_Battle/003_Battle/009_Battle_Action_Other.rb b/Data/Scripts/011_Battle/003_Battle/009_Battle_Action_Other.rb index b6d7fd636..87e4b059a 100644 --- a/Data/Scripts/011_Battle/003_Battle/009_Battle_Action_Other.rb +++ b/Data/Scripts/011_Battle/003_Battle/009_Battle_Action_Other.rb @@ -52,6 +52,7 @@ class PokeBattle_Battle battler.pbCureStatus elsif battler.pbCanRaiseStatStage?(:ACCURACY,battler) battler.pbRaiseStatStage(:ACCURACY,1,battler) + battler.pbItemOnStatDropped else pbDisplay(_INTL("But nothing happened!")) end diff --git a/Data/Scripts/011_Battle/003_Battle/012_Battle_Phase_EndOfRound.rb b/Data/Scripts/011_Battle/003_Battle/012_Battle_Phase_EndOfRound.rb index 29757a239..e7e2fb9d6 100644 --- a/Data/Scripts/011_Battle/003_Battle/012_Battle_Phase_EndOfRound.rb +++ b/Data/Scripts/011_Battle/003_Battle/012_Battle_Phase_EndOfRound.rb @@ -350,22 +350,26 @@ class PokeBattle_Battle pbHideAbilitySplash(b) end elsif b.takesIndirectDamage? + b.droppedBelowHalfHP = false dmg = (b.statusCount==0) ? b.totalhp/8 : b.totalhp*b.effects[PBEffects::Toxic]/16 b.pbContinueStatus { b.pbReduceHP(dmg,false) } b.pbItemHPHealCheck b.pbAbilitiesOnDamageTaken b.pbFaint if b.fainted? + b.droppedBelowHalfHP = false end end # Damage from burn priority.each do |b| next if b.status != :BURN || !b.takesIndirectDamage? + b.droppedBelowHalfHP = false dmg = (Settings::MECHANICS_GENERATION >= 7) ? b.totalhp/16 : b.totalhp/8 dmg = (dmg/2.0).round if b.hasActiveAbility?(:HEATPROOF) b.pbContinueStatus { b.pbReduceHP(dmg,false) } b.pbItemHPHealCheck b.pbAbilitiesOnDamageTaken b.pbFaint if b.fainted? + b.droppedBelowHalfHP = false end # Damage from sleep (Nightmare) priority.each do |b| @@ -418,6 +422,7 @@ class PokeBattle_Battle pbCommonAnimation("Octolock", b) b.pbLowerStatStage(:DEFENSE, 1, nil) if b.pbCanLowerStatStage?(:DEFENSE) b.pbLowerStatStage(:SPECIAL_DEFENSE, 1, nil) if b.pbCanLowerStatStage?(:SPECIAL_DEFENSE) + b.pbItemOnStatDropped end # Taunt pbEORCountDownBattlerEffect(priority,PBEffects::Taunt) { |battler| @@ -631,10 +636,11 @@ class PokeBattle_Battle b.lastHPLost = 0 b.lastHPLostFromFoe = 0 b.droppedBelowHalfHP = false + b.statsDropped = false b.tookDamageThisRound = false b.tookPhysicalHit = false - b.statsRaised = false - b.statsLowered = false + b.statsRaisedThisRound = false + b.statsLoweredThisRound = false b.canRestoreIceFace = false b.lastRoundMoveFailed = b.lastMoveFailed b.lastAttacker.clear diff --git a/Data/Scripts/011_Battle/003_BattleHandlers_Abilities.rb b/Data/Scripts/011_Battle/003_BattleHandlers_Abilities.rb index deb8aad16..66dcabc4a 100644 --- a/Data/Scripts/011_Battle/003_BattleHandlers_Abilities.rb +++ b/Data/Scripts/011_Battle/003_BattleHandlers_Abilities.rb @@ -1328,7 +1328,7 @@ BattleHandlers::TargetAbilityOnHit.add(:ANGERPOINT, next if !target.pbCanRaiseStatStage?(:ATTACK,target) battle.pbShowAbilitySplash(target) target.stages[:ATTACK] = 6 - target.statsRaised = true + target.statsRaisedThisRound = true battle.pbCommonAnimation("StatUp",target) if PokeBattle_SceneConstants::USE_ABILITY_SPLASH battle.pbDisplay(_INTL("{1} maxed its {2}!",target.pbThis,GameData::Stat.get(:ATTACK).name)) @@ -1976,6 +1976,7 @@ BattleHandlers::EOREffectAbility.add(:MOODY, end battle.pbHideAbilitySplash(battler) battler.pbItemStatRestoreCheck if randomDown.length>0 + battler.pbItemOnStatDropped } ) diff --git a/Data/Scripts/011_Battle/004_BattleHandlers_Items.rb b/Data/Scripts/011_Battle/004_BattleHandlers_Items.rb index 196e9d6b2..a79d06db5 100644 --- a/Data/Scripts/011_Battle/004_BattleHandlers_Items.rb +++ b/Data/Scripts/011_Battle/004_BattleHandlers_Items.rb @@ -1418,7 +1418,7 @@ BattleHandlers::EndOfMoveStatRestoreItem.add(:WHITEHERB, GameData::Stat.each_battle do |s| next if battler.stages[s.id] >= 0 battler.stages[s.id] = 0 - battler.statsRaised = true + battler.statsRaisedThisRound = true reducedStats = true end next false if !reducedStats diff --git a/Data/Scripts/013_Items/Gen 8 items.rb b/Data/Scripts/013_Items/Gen 8 items.rb index 3a6d575d8..45ca1a456 100644 --- a/Data/Scripts/013_Items/Gen 8 items.rb +++ b/Data/Scripts/013_Items/Gen 8 items.rb @@ -340,6 +340,33 @@ BattleHandlers::UserItemAfterMoveUse.add(:THROATSPRAY, } ) +BattleHandlers::ItemOnStatDropped.add(:EJECTPACK, + proc { |item, battler, move_user, battle| + next false if battler.effects[PBEffects::SkyDrop] >= 0 || + battler.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSkyTargetCannotAct") # Sky Drop + next false if battle.pbAllFainted?(battler.idxOpposingSide) + next false if battle.wildBattle? && battler.opposes? # Wild Pokémon can't eject + next false if !battle.pbCanSwitch?(battler.index) # Battler can't switch out + next false if !battle.pbCanChooseNonActive?(battler.index) # No Pokémon can switch in + battle.pbCommonAnimation("UseItem", battler) + battle.pbDisplay(_INTL("{1} is switched out by the {2}!", battler.pbThis, battler.itemName)) + battler.pbConsumeItem(true, false) + if battle.endOfRound # Just switch out + battle.scene.pbRecall(battler.index) if !battler.fainted? + battler.pbAbilitiesOnSwitchOut # Inc. primordial weather check + next true + end + newPkmn = battle.pbGetReplacementPokemonIndex(battler.index) # Owner chooses + next false if newPkmn < 0 # Shouldn't ever do this + battle.pbRecallAndReplace(battler.index, newPkmn) + battle.pbClearChoice(battler.index) # Replacement Pokémon does nothing this round + battle.moldBreaker = false if move_user && battler.index == move_user.index + battle.pbOnBattlerEnteringBattle(battler.index) + next true + } +) + + BattleHandlers::ItemOnSwitchIn.add(:ROOMSERVICE, proc { |item, battler, battle| next if battle.field.effects[PBEffects::TrickRoom] == 0 @@ -377,15 +404,3 @@ ItemHandlers::UseOnPokemon.add(:ZYGARDECUBE, proc { |item, pkmn, scene| end next false }) - - -=begin - -#=============================================================================== - -Eject Pack -When holder's stat(s) is lowered, consume item and holder switches out. Not -triggered by Parting Shot, or if a faster mon's Eject Button/Eject Pack -triggers. - -=end