From e93b08a87b17d9830601385913127c4308af61d0 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sat, 26 Jun 2021 22:12:47 +0100 Subject: [PATCH] Added some more Gen 8 move effects --- .../001_Battler/001_PokeBattle_Battler.rb | 14 ++ .../001_Battler/002_Battler_Initialize.rb | 6 + .../001_Battler/005_Battler_StatStages.rb | 11 +- .../002_Move/005_Move_Effects_000-07F.rb | 32 ++++- .../002_Move/007_Move_Effects_100-17F.rb | 18 +-- .../002_Move/008_Move_Effects_Gen8.rb | 128 ++++++++++++++++-- .../003_Battle/002_PokeBattle_Battle.rb | 3 + .../003_Battle/006_Battle_Action_Switching.rb | 7 +- .../003_Battle/008_Battle_Action_Running.rb | 14 +- .../003_Battle/012_Battle_Phase_EndOfRound.rb | 2 + .../003_BattleHandlers_Abilities.rb | 1 + .../011_Battle/004_BattleHandlers_Items.rb | 1 + 12 files changed, 197 insertions(+), 40 deletions(-) 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 9b0704a20..7f145dcfe 100644 --- a/Data/Scripts/011_Battle/001_Battler/001_PokeBattle_Battler.rb +++ b/Data/Scripts/011_Battle/001_Battler/001_PokeBattle_Battler.rb @@ -40,6 +40,8 @@ class PokeBattle_Battler attr_accessor :currentMove # ID of multi-turn move currently being used attr_accessor :tookDamage # 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 :damageState attr_accessor :initialHP # Set at the start of each move's usage @@ -579,6 +581,18 @@ class PokeBattle_Battler return true end + def trappedInBattle? + return true if battler.effects[PBEffects::Trapping] > 0 + return true if battler.effects[PBEffects::MeanLook] >= 0 + return true if battler.effects[PBEffects::JawLock] >= 0 + @battle.eachBattler { |b| return true if b.effects[PBEffects::JawLock] == @index } + return true if battler.effects[PBEffects::Octolock] >= 0 + return true if battler.effects[PBEffects::Ingrain] + return true if battler.effects[PBEffects::NoRetreat] + return true if @field.effects[PBEffects::FairyLock] > 0 + return false + end + def movedThisRound? return @lastRoundMoved && @lastRoundMoved==@battle.turnCount end 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 3befdb8ae..c4c254d4f 100644 --- a/Data/Scripts/011_Battle/001_Battler/002_Battler_Initialize.rb +++ b/Data/Scripts/011_Battle/001_Battler/002_Battler_Initialize.rb @@ -150,6 +150,8 @@ class PokeBattle_Battler @lastHPLostFromFoe = 0 @tookDamage = false @tookPhysicalHit = false + @statsRaised = false + @statsLowered = false @lastMoveUsed = nil @lastMoveUsedType = nil @lastRegularMoveUsed = nil @@ -205,6 +207,10 @@ class PokeBattle_Battler @effects[PBEffects::Imprison] = false @effects[PBEffects::Instruct] = false @effects[PBEffects::Instructed] = false + @effects[PBEffects::JawLock] = -1 + @battle.eachBattler do |b| # Other battlers no longer blocked by self + b.effects[PBEffects::JawLock] = -1 if b.effects[PBEffects::JawLock] == @index + end @effects[PBEffects::KingsShield] = false @battle.eachBattler do |b| # Other battlers lose their lock-on against self next if b.effects[PBEffects::LockOn]==0 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 17058879c..ef85a8db4 100644 --- a/Data/Scripts/011_Battle/001_Battler/005_Battler_StatStages.rb +++ b/Data/Scripts/011_Battle/001_Battler/005_Battler_StatStages.rb @@ -37,6 +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 end return increment end @@ -169,6 +170,7 @@ class PokeBattle_Battler new = @stages[stat]-increment PBDebug.log("[Stat change] #{pbThis}'s #{stat_name}: #{@stages[stat]} -> #{new} (-#{increment})") @stages[stat] -= increment + @statsLowered = true end return increment end @@ -303,6 +305,13 @@ class PokeBattle_Battler end def pbResetStatStages - GameData::Stat.each_battle { |s| @stages[s.id] = 0 } + GameData::Stat.each_battle do |s| + if @stages[s.id] > 0 + @statsLowered = true + elsif @stages[s.id] < 0 + @statsRaised = true + end + @stages[s.id] = 0 + end end 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 a6b946b23..3f385ed6e 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 @@ -1030,10 +1030,12 @@ class PokeBattle_Move_03A < PokeBattle_Move user.pbReduceHP(hpLoss,false) if user.hasActiveAbility?(:CONTRARY) user.stages[:ATTACK] = -6 + user.statsLowered = 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 @battle.pbCommonAnimation("StatUp",user) @battle.pbDisplay(_INTL("{1} cut its own HP and maximized its Attack!",user.pbThis)) end @@ -1505,6 +1507,13 @@ class PokeBattle_Move_052 < 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 + elsif user.stages[s] < target.stages[s] + user.statsRaised = true + target.statsLowered = true + end user.stages[s],target.stages[s] = target.stages[s],user.stages[s] end @battle.pbDisplay(_INTL("{1} switched all changes to its Attack and Sp. Atk with the target!",user.pbThis)) @@ -1521,6 +1530,13 @@ class PokeBattle_Move_053 < 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 + elsif user.stages[s] < target.stages[s] + user.statsRaised = true + target.statsLowered = true + end user.stages[s],target.stages[s] = target.stages[s],user.stages[s] end @battle.pbDisplay(_INTL("{1} switched all changes to its Defense and Sp. Def with the target!",user.pbThis)) @@ -1537,6 +1553,13 @@ class PokeBattle_Move_054 < 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 + elsif user.stages[s.id] < target.stages[s.id] + user.statsRaised = true + target.statsLowered = true + end user.stages[s.id],target.stages[s.id] = target.stages[s.id],user.stages[s.id] end @battle.pbDisplay(_INTL("{1} switched stat changes with the target!",user.pbThis)) @@ -1552,7 +1575,14 @@ class PokeBattle_Move_055 < PokeBattle_Move def ignoresSubstitute?(user); return true; end def pbEffectAgainstTarget(user,target) - GameData::Stat.each_battle { |s| user.stages[s.id] = target.stages[s.id] } + GameData::Stat.each_battle do |s| + if user.stages[s.id] > target.stages[s.id] + user.statsLowered = true + elsif user.stages[s.id] < target.stages[s.id] + user.statsRaised = true + end + user.stages[s.id] = target.stages[s.id] + end if Settings::NEW_CRITICAL_HIT_RATE_MECHANICS user.effects[PBEffects::FocusEnergy] = target.effects[PBEffects::FocusEnergy] user.effects[PBEffects::LaserFocus] = target.effects[PBEffects::LaserFocus] diff --git a/Data/Scripts/011_Battle/002_Move/007_Move_Effects_100-17F.rb b/Data/Scripts/011_Battle/002_Move/007_Move_Effects_100-17F.rb index cda47acc8..6c484f831 100644 --- a/Data/Scripts/011_Battle/002_Move/007_Move_Effects_100-17F.rb +++ b/Data/Scripts/011_Battle/002_Move/007_Move_Effects_100-17F.rb @@ -1366,13 +1366,7 @@ end #=============================================================================== class PokeBattle_Move_141 < PokeBattle_Move def pbFailsAgainstTarget?(user,target) - failed = true - GameData::Stat.each_battle do |s| - next if target.stages[s.id] == 0 - failed = false - break - end - if failed + if !target.hasAlteredStatStages? @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -1380,7 +1374,14 @@ class PokeBattle_Move_141 < PokeBattle_Move end def pbEffectAgainstTarget(user,target) - GameData::Stat.each_battle { |s| target.stages[s.id] *= -1 } + GameData::Stat.each_battle do |s| + if target.stages[s.id] > 0 + target.statsLowered = true + elsif target.stages[s.id] < 0 + target.statsRaised = true + end + target.stages[s.id] *= -1 + end @battle.pbDisplay(_INTL("{1}'s stats were reversed!",target.pbThis)) end end @@ -1997,6 +1998,7 @@ class PokeBattle_Move_15D < PokeBattle_Move showAnim = false end end + target.statsLowered = true target.stages[s.id] = 0 end end 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 17fcb090f..efd31fb98 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 @@ -80,7 +80,10 @@ end # Burns the target if any of its stats were increased this round. # (Burning Jealousy) #=============================================================================== -class PokeBattle_Move_177 < PokeBattle_UnimplementedMove +class PokeBattle_Move_177 < PokeBattle_BurnMove + def pbEffectAgainstTarget(user, target) + super if target.statsRaised + end end #=============================================================================== @@ -123,10 +126,7 @@ class PokeBattle_Move_179 < PokeBattle_Move_02D def pbEffectGeneral(user) super - if battler.effects[PBEffects::Trapping] == 0 && - battler.effects[PBEffects::MeanLook] < 0 && - !battler.effects[PBEffects::Ingrain] && - @field.effects[PBEffects::FairyLock] == 0 + if !user.trappedInBattle? user.effects[PBEffects::NoRetreat] = true @battle.pbDisplay(_INTL("{1} can no longer escape because it used {2}!", user.pbThis, @name)) end @@ -337,7 +337,11 @@ end #=============================================================================== # Power is doubled if any of the user's stats were lowered this round. (Lash Out) #=============================================================================== -class PokeBattle_Move_184 < PokeBattle_UnimplementedMove +class PokeBattle_Move_184 < PokeBattle_Move + def pbBaseDamage(baseDmg, user, target) + baseDmg *= 2 if user.statsLowered + return baseDmg + end end #=============================================================================== @@ -567,7 +571,14 @@ end # isn't applied if either Pokémon is already prevented from switching out or # fleeing. (Jaw Lock) #=============================================================================== -class PokeBattle_Move_190 < PokeBattle_UnimplementedMove +class PokeBattle_Move_190 < PokeBattle_Move + def pbAdditionalEffect(user,target) + return if user.fainted? || target.fainted? || target.damageState.substitute + return if Settings::MORE_TYPE_EFFECTS && target.pbHasType?(:GHOST) + return if user.trappedInBattle? || target.trappedInBattle? + target.effects[PBEffects::JawLock] = user.index + @battle.pbDisplay(_INTL("Neither Pokémon can run away!")) + end end #=============================================================================== @@ -576,7 +587,41 @@ end # Room apply. Fails if the user is not holding a berry. This move cannot be # chosen to be used if the user is not holding a berry. (Stuff Cheeks) #=============================================================================== -class PokeBattle_Move_191 < PokeBattle_UnimplementedMove +class PokeBattle_Move_191 < PokeBattle_StatUpMove + def initialize(battle, move) + super + @statUp = [:DEFENSE, 2] + end + + def pbCanChooseMove?(user, commandPhase, showMessages) + item = user.item + if !item || !item.is_berry? || !user.itemActive? + if showMessages + msg = _INTL("{1} can't use that move because it doesn't have a Berry!", user.pbThis) + (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) + end + return false + end + return true + end + + def pbMoveFailed?(user, targets) + # NOTE: Unnerve does not stop a Pokémon using this move. + item = user.item + if !item || !item.is_berry? || !user.itemActive? + @battle.pbDisplay(_INTL("But it failed!")) + return true + end + return super + end + + def pbEffectGeneral(user) + super + @battle.pbDisplay(_INTL("{1} ate its {2}!", user.pbThis, user.itemName)) + item = user.item + user.pbConsumeItem(true, false) # Don't trigger Symbiosis yet + user.pbHeldItemTriggerCheck(item, false) + end end #=============================================================================== @@ -585,10 +630,40 @@ end # Fails if no Pokémon have a held berry. If this move would trigger an ability # that negates the move, e.g. Lightning Rod, the bearer of that ability will # have their ability triggered regardless of whether they are holding a berry, -# and they will not consume their berry (how does this interact with the move -# failing?). (Teatime) +# and they will not consume their berry. (Teatime) +# TODO: This isn't quite right for the messages shown when a berry is consumed. #=============================================================================== -class PokeBattle_Move_192 < PokeBattle_UnimplementedMove +class PokeBattle_Move_192 < PokeBattle_Move + def pbMoveFailed?(user, targets) + failed = true + targets.each do |b| + next if !b.item || !b.item.is_berry? + next if b.semiInvulnerable? + failed = false + break + end + if failed + @battle.pbDisplay(_INTL("But nothing happened!")) + return true + end + return false + end + + def pbOnStartUse(user,targets) + @battle.pbDisplay(_INTL("It's teatime! Everyone dug in to their Berries!")) + end + + def pbFailsAgainstTarget?(user, target) + return true if !target.item || !target.item.is_berry? || target.semiInvulnerable? + return false + end + + def pbEffectAgainstTarget(user, target) + @battle.pbCommonAnimation("EatBerry", target) + item = target.item + target.pbConsumeItem(true, false) # Don't trigger Symbiosis yet + target.pbHeldItemTriggerCheck(item, false) + end end #=============================================================================== @@ -597,7 +672,36 @@ end # item, the item is unlosable, the target has Sticky Hold, or the target is # behind a substitute. (Corrosive Gas) #=============================================================================== -class PokeBattle_Move_193 < PokeBattle_UnimplementedMove +class PokeBattle_Move_193 < PokeBattle_Move + def pbFailsAgainstTarget?(user, target) + if !target.item || target.unlosableItem?(target.item) || + target.effects[PBEffects::Substitute] > 0 + @battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) + return true + end + if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker + @battle.pbShowAbilitySplash(target) + if PokeBattle_SceneConstants::USE_ABILITY_SPLASH + @battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) + else + @battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!", + target.pbThis(true), target.abilityName)) + end + @battle.pbHideAbilitySplash(target) + return true + end + if @battle.corrosiveGas[target.index % 2][target.pokemonIndex] + @battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) + return true + end + return false + end + + def pbEffectAgainstTarget(user, target) + @battle.corrosiveGas[target.index % 2][target.pokemonIndex] = true + @battle.pbDisplay(_INTL("{1} corroded {2}'s {3}!", + user.pbThis, target.pbThis(true), target.itemName)) + end end #=============================================================================== diff --git a/Data/Scripts/011_Battle/003_Battle/002_PokeBattle_Battle.rb b/Data/Scripts/011_Battle/003_Battle/002_PokeBattle_Battle.rb index 7654d8725..e7c108541 100644 --- a/Data/Scripts/011_Battle/003_Battle/002_PokeBattle_Battle.rb +++ b/Data/Scripts/011_Battle/003_Battle/002_PokeBattle_Battle.rb @@ -74,6 +74,7 @@ class PokeBattle_Battle attr_reader :recycleItems attr_reader :belch attr_reader :battleBond + attr_reader :corrosiveGas attr_reader :usedInBattle # Whether each Pokémon was used in battle (for Burmy) attr_reader :successStates # Success states attr_accessor :lastMoveUsed # Last move used @@ -150,6 +151,7 @@ class PokeBattle_Battle @recycleItems = [Array.new(@party1.length, nil), Array.new(@party2.length, nil)] @belch = [Array.new(@party1.length, false), Array.new(@party2.length, false)] @battleBond = [Array.new(@party1.length, false), Array.new(@party2.length, false)] + @corrosiveGas = [Array.new(@party1.length, false), Array.new(@party2.length, false)] @usedInBattle = [Array.new(@party1.length, false), Array.new(@party2.length, false)] @successStates = [] @lastMoveUsed = nil @@ -585,6 +587,7 @@ class PokeBattle_Battle effectsToSwap = [PBEffects::Attract, PBEffects::BideTarget, PBEffects::CounterTarget, + PBEffects::JawLock, PBEffects::LockOnPos, PBEffects::MeanLook, PBEffects::MirrorCoatTarget, 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 6acd10c18..c36ec9827 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 @@ -66,12 +66,7 @@ class PokeBattle_Battle # Other certain switching effects return true if Settings::MORE_TYPE_EFFECTS && battler.pbHasType?(:GHOST) # Other certain trapping effects - if battler.effects[PBEffects::Trapping]>0 || - battler.effects[PBEffects::MeanLook]>=0 || - battler.effects[PBEffects::Octolock]>=0 || - battler.effects[PBEffects::Ingrain] || - battler.effects[PBEffects::NoRetreat] || - @field.effects[PBEffects::FairyLock]>0 + if battler.trappedInBattle? partyScene.pbDisplay(_INTL("{1} can't be switched out!",battler.pbThis)) if partyScene return false end diff --git a/Data/Scripts/011_Battle/003_Battle/008_Battle_Action_Running.rb b/Data/Scripts/011_Battle/003_Battle/008_Battle_Action_Running.rb index da01bd650..5be158384 100644 --- a/Data/Scripts/011_Battle/003_Battle/008_Battle_Action_Running.rb +++ b/Data/Scripts/011_Battle/003_Battle/008_Battle_Action_Running.rb @@ -11,12 +11,7 @@ class PokeBattle_Battle BattleHandlers.triggerRunFromBattleAbility(battler.ability,battler) return true if battler.itemActive? && BattleHandlers.triggerRunFromBattleItem(battler.item,battler) - return false if battler.effects[PBEffects::Trapping]>0 || - battler.effects[PBEffects::MeanLook]>=0 || - battler.effects[PBEffects::Octolock]>=0 || - battler.effects[PBEffects::Ingrain] || - battler.effects[PBEffects::NoRetreat] || - @field.effects[PBEffects::FairyLock]>0 + return false if battler.trappedInBattle? eachOtherSideBattler(idxBattler) do |b| return false if b.abilityActive? && BattleHandlers.triggerTrappingTargetAbility(b.ability,battler,b,self) @@ -101,12 +96,7 @@ class PokeBattle_Battle end end # Other certain trapping effects - if battler.effects[PBEffects::Trapping]>0 || - battler.effects[PBEffects::MeanLook]>=0 || - battler.effects[PBEffects::Octolock]>=0 || - battler.effects[PBEffects::Ingrain] || - battler.effects[PBEffects::NoRetreat] || - @field.effects[PBEffects::FairyLock]>0 + if battler.trappedInBattle? pbDisplayPaused(_INTL("You can't escape!")) return 0 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 a522fea6c..deec25ddc 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 @@ -648,6 +648,8 @@ class PokeBattle_Battle b.lastHPLostFromFoe = 0 b.tookDamage = false b.tookPhysicalHit = false + b.statsRaised = false + b.statsLowered = false b.lastRoundMoveFailed = b.lastMoveFailed b.lastAttacker.clear b.lastFoeAttacker.clear diff --git a/Data/Scripts/011_Battle/003_BattleHandlers_Abilities.rb b/Data/Scripts/011_Battle/003_BattleHandlers_Abilities.rb index 84532eb84..cdfd008a0 100644 --- a/Data/Scripts/011_Battle/003_BattleHandlers_Abilities.rb +++ b/Data/Scripts/011_Battle/003_BattleHandlers_Abilities.rb @@ -1314,6 +1314,7 @@ BattleHandlers::TargetAbilityOnHit.add(:ANGERPOINT, next if !target.pbCanRaiseStatStage?(:ATTACK,target) battle.pbShowAbilitySplash(target) target.stages[:ATTACK] = 6 + target.statsRaised = 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)) diff --git a/Data/Scripts/011_Battle/004_BattleHandlers_Items.rb b/Data/Scripts/011_Battle/004_BattleHandlers_Items.rb index 0462bec9b..6094a13d6 100644 --- a/Data/Scripts/011_Battle/004_BattleHandlers_Items.rb +++ b/Data/Scripts/011_Battle/004_BattleHandlers_Items.rb @@ -1317,6 +1317,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 reducedStats = true end next false if !reducedStats