Tweaked Fissure's function code, added Mirror Armor's effect

This commit is contained in:
Maruno17
2021-09-10 20:40:45 +01:00
parent 27be1cb330
commit df7c033a9d
17 changed files with 153 additions and 60 deletions

View File

@@ -222,7 +222,7 @@ module GameData
when "06F" then new_code = "FixedDamageUserLevelRandom" when "06F" then new_code = "FixedDamageUserLevelRandom"
when "070" when "070"
if data[:id] == :FISSURE if data[:id] == :FISSURE
new_code = "OHKOHitsTargetUnderground" new_code = "OHKOHitsUndergroundTarget"
elsif data[:id] == :SHEERCOLD && Settings::MECHANICS_GENERATION >= 7 elsif data[:id] == :SHEERCOLD && Settings::MECHANICS_GENERATION >= 7
new_code = "OHKOIce" new_code = "OHKOIce"
else else

View File

@@ -115,14 +115,20 @@ class PokeBattle_Battler
return @stages[stat]<=-6 return @stages[stat]<=-6
end end
def pbCanLowerStatStage?(stat,user=nil,move=nil,showFailMsg=false,ignoreContrary=false) def pbCanLowerStatStage?(stat, user = nil, move = nil, showFailMsg = false, ignoreContrary = false, ignoreMirrorArmor = false)
return false if fainted? return false if fainted?
# Contrary if !@battle.moldBreaker
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker # Contrary
return pbCanRaiseStatStage?(stat,user,move,showFailMsg,true) if hasActiveAbility?(:CONTRARY) && !ignoreContrary
return pbCanRaiseStatStage?(stat, user, move, showFailMsg, true)
end
# Mirror Armor
if hasActiveAbility?(:MIRRORARMOR) && !ignoreMirrorArmor && user && user.index != @index
return true if !statStageAtMin?(stat)
end
end end
if !user || user.index!=@index # Not self-inflicted if !user || user.index!=@index # Not self-inflicted
if @effects[PBEffects::Substitute]>0 && !(move && move.ignoresSubstitute?(user)) if @effects[PBEffects::Substitute]>0 && (ignoreMirrorArmor || !(move && move.ignoresSubstitute?(user)))
@battle.pbDisplay(_INTL("{1} is protected by its substitute!",pbThis)) if showFailMsg @battle.pbDisplay(_INTL("{1} is protected by its substitute!",pbThis)) if showFailMsg
return false return false
end end
@@ -175,10 +181,29 @@ class PokeBattle_Battler
return increment return increment
end end
def pbLowerStatStage(stat,increment,user,showAnim=true,ignoreContrary=false) def pbLowerStatStage(stat, increment, user, showAnim = true, ignoreContrary = false,
# Contrary mirrorArmorSplash = 0, ignoreMirrorArmor = false)
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker if !@battle.moldBreaker
return pbRaiseStatStage(stat,increment,user,showAnim,true) # Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary
return pbRaiseStatStage(stat, increment, user, showAnim, true)
end
# Mirror Armor
if hasActiveAbility?(:MIRRORARMOR) && !ignoreMirrorArmor &&
user && user.index != @index && !statStageAtMin?(stat)
if mirrorArmorSplash < 2
@battle.pbShowAbilitySplash(self)
if !PokeBattle_SceneConstants::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1}'s {2} activated!", pbThis, abilityName))
end
end
ret = false
if user.pbCanLowerStatStage?(stat, self, nil, true, ignoreContrary, true)
ret = user.pbLowerStatStage(stat, increment, self, showAnim, ignoreContrary, mirrorArmorSplash, true)
end
@battle.pbHideAbilitySplash(self) if mirrorArmorSplash.even? # i.e. not 1 or 3
return ret
end
end end
# Perform the stat stage change # Perform the stat stage change
increment = pbLowerStatStageBasic(stat,increment,ignoreContrary) increment = pbLowerStatStageBasic(stat,increment,ignoreContrary)
@@ -197,10 +222,27 @@ class PokeBattle_Battler
return true return true
end end
def pbLowerStatStageByCause(stat,increment,user,cause,showAnim=true,ignoreContrary=false) def pbLowerStatStageByCause(stat, increment, user, cause, showAnim = true,
# Contrary ignoreContrary = false, ignoreMirrorArmor = false)
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker if !@battle.moldBreaker
return pbRaiseStatStageByCause(stat,increment,user,cause,showAnim,true) # Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary
return pbRaiseStatStageByCause(stat, increment, user, cause, showAnim, true)
end
# Mirror Armor
if hasActiveAbility?(:MIRRORARMOR) && !ignoreMirrorArmor &&
user && user.index != @index && !statStageAtMin?(stat)
@battle.pbShowAbilitySplash(self)
if !PokeBattle_SceneConstants::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1}'s {2} activated!", pbThis, abilityName))
end
ret = false
if user.pbCanLowerStatStage?(stat, self, nil, true, ignoreContrary, true)
ret = user.pbLowerStatStageByCause(stat, increment, self, abilityName, showAnim, ignoreContrary, true)
end
@battle.pbHideAbilitySplash(self)
return ret
end
end end
# Perform the stat stage change # Perform the stat stage change
increment = pbLowerStatStageBasic(stat,increment,ignoreContrary) increment = pbLowerStatStageBasic(stat,increment,ignoreContrary)

View File

@@ -361,8 +361,8 @@ class PokeBattle_Battler
target.damageState.protected = true target.damageState.protected = true
@battle.successStates[user.index].protected = true @battle.successStates[user.index].protected = true
if move.pbContactMove?(user) && user.affectedByContactEffect? if move.pbContactMove?(user) && user.affectedByContactEffect?
if user.pbCanLowerStatStage?(:ATTACK) if user.pbCanLowerStatStage?(:ATTACK, target)
user.pbLowerStatStage(:ATTACK, (Settings::MECHANICS_GENERATION >= 8) ? 1 : 2, nil) user.pbLowerStatStage(:ATTACK, (Settings::MECHANICS_GENERATION >= 8) ? 1 : 2, target)
end end
end end
return false return false
@@ -405,8 +405,8 @@ class PokeBattle_Battler
target.damageState.protected = true target.damageState.protected = true
@battle.successStates[user.index].protected = true @battle.successStates[user.index].protected = true
if move.pbContactMove?(user) && user.affectedByContactEffect? if move.pbContactMove?(user) && user.affectedByContactEffect?
if user.pbCanLowerStatStage?(:DEFENSE) if user.pbCanLowerStatStage?(:DEFENSE, target)
user.pbLowerStatStage(:DEFENSE, 2, nil) user.pbLowerStatStage(:DEFENSE, 2, target)
end end
end end
return false return false

View File

@@ -148,9 +148,9 @@ class PokeBattle_Battler
if move.function == "StartSlowerBattlersActFirst" && @battle.field.effects[PBEffects::TrickRoom] > 0 if move.function == "StartSlowerBattlersActFirst" && @battle.field.effects[PBEffects::TrickRoom] > 0
@battle.battlers.each do |b| @battle.battlers.each do |b|
next if !b.hasActiveItem?(:ROOMSERVICE) next if !b.hasActiveItem?(:ROOMSERVICE)
next if !b.pbCanLowerStatStage?(:SPEED, b) next if !b.pbCanLowerStatStage?(:SPEED)
@battle.pbCommonAnimation("UseItem", b) @battle.pbCommonAnimation("UseItem", b)
b.pbLowerStatStage(:SPEED, 1, b) b.pbLowerStatStage(:SPEED, 1, nil)
b.pbConsumeItem b.pbConsumeItem
end end
end end

View File

@@ -383,26 +383,49 @@ class PokeBattle_TargetMultiStatDownMove < PokeBattle_Move
return false return false
end end
def pbEffectAgainstTarget(user,target) def pbCheckForMirrorArmor(user, target)
return if damagingMove? if target.hasActiveAbility?(:MIRRORARMOR) && user.index != target.index
showAnim = true failed = true
for i in 0...@statDown.length/2 for i in 0...@statDown.length / 2
next if !target.pbCanLowerStatStage?(@statDown[i*2],user,self) next if target.statStageAtMin?(@statDown[i * 2])
if target.pbLowerStatStage(@statDown[i*2],@statDown[i*2+1],user,showAnim) next if !user.pbCanLowerStatStage?(@statDown[i * 2], target, self, false, false, true)
showAnim = false failed = false
break
end
if failed
@battle.pbShowAbilitySplash(target)
if !PokeBattle_SceneConstants::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1}'s {2} activated!", target.pbThis, target.abilityName))
end
user.pbCanLowerStatStage?(@statDown[0], target, self, true, false, true) # Show fail message
@battle.pbHideAbilitySplash(target)
return false
end end
end end
return true
end
def pbLowerTargetMultipleStats(user, target)
return if !pbCheckForMirrorArmor(user, target)
showAnim = true
showMirrorArmorSplash = true
for i in 0...@statDown.length / 2
next if !target.pbCanLowerStatStage?(@statDown[i * 2], user, self)
if target.pbLowerStatStage(@statDown[i * 2], @statDown[i * 2 + 1], user,
showAnim, false, (showMirrorArmorSplash) ? 1 : 3)
showAnim = false
end
showMirrorArmorSplash = false
end
@battle.pbHideAbilitySplash(target) # To hide target's Mirror Armor splash
end
def pbEffectAgainstTarget(user,target)
pbLowerTargetMultipleStats(user, target) if !damagingMove?
end end
def pbAdditionalEffect(user,target) def pbAdditionalEffect(user,target)
return if target.damageState.substitute pbLowerTargetMultipleStats(user, target) if !target.damageState.substitute
showAnim = true
for i in 0...@statDown.length/2
next if !target.pbCanLowerStatStage?(@statDown[i*2],user,self)
if target.pbLowerStatStage(@statDown[i*2],@statDown[i*2+1],user,showAnim)
showAnim = false
end
end
end end
end end

View File

@@ -1321,6 +1321,11 @@ end
class PokeBattle_Move_LowerPoisonedTargetAtkSpAtkSpd1 < PokeBattle_Move class PokeBattle_Move_LowerPoisonedTargetAtkSpAtkSpd1 < PokeBattle_Move
def canMagicCoat?; return true; end def canMagicCoat?; return true; end
def initialize(battle,move)
super
@statDown = [:ATTACK, 1, :SPECIAL_ATTACK, 1, :SPEED, 1]
end
def pbMoveFailed?(user,targets) def pbMoveFailed?(user,targets)
@validTargets = [] @validTargets = []
targets.each do |b| targets.each do |b|
@@ -1338,15 +1343,42 @@ class PokeBattle_Move_LowerPoisonedTargetAtkSpAtkSpd1 < PokeBattle_Move
return false return false
end end
def pbEffectAgainstTarget(user,target) def pbCheckForMirrorArmor(user, target)
return if !@validTargets.include?(target.index) if target.hasActiveAbility?(:MIRRORARMOR) && user.index != target.index
showAnim = true failed = true
[:ATTACK,:SPECIAL_ATTACK,:SPEED].each do |s| for i in 0...@statDown.length / 2
next if !target.pbCanLowerStatStage?(s,user,self) next if target.statStageAtMin?(@statDown[i * 2])
if target.pbLowerStatStage(s,1,user,showAnim) next if !user.pbCanLowerStatStage?(@statDown[i * 2], target, self, false, false, true)
showAnim = false failed = false
break
end
if failed
@battle.pbShowAbilitySplash(target)
if !PokeBattle_SceneConstants::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1}'s {2} activated!", target.pbThis, target.abilityName))
end
user.pbCanLowerStatStage?(@statDown[0], target, self, true, false, true) # Show fail message
@battle.pbHideAbilitySplash(target)
return false
end end
end end
return true
end
def pbEffectAgainstTarget(user,target)
return if !@validTargets.include?(target.index)
return if !pbCheckForMirrorArmor(user, target)
showAnim = true
showMirrorArmorSplash = true
for i in 0...@statDown.length / 2
next if !target.pbCanLowerStatStage?(@statDown[i * 2], user, self)
if target.pbLowerStatStage(@statDown[i * 2], @statDown[i * 2 + 1], user,
showAnim, false, (showMirrorArmorSplash) ? 1 : 3)
showAnim = false
end
showMirrorArmorSplash = false
end
@battle.pbHideAbilitySplash(target) # To hide target's Mirror Armor splash
end end
end end

View File

@@ -131,7 +131,7 @@ end
# OHKO. Accuracy increases by difference between levels of user and target. Hits # OHKO. Accuracy increases by difference between levels of user and target. Hits
# targets that are semi-invulnerable underground. (Fissure) # targets that are semi-invulnerable underground. (Fissure)
#=============================================================================== #===============================================================================
class PokeBattle_Move_OHKOHitsTargetUnderground < PokeBattle_Move_OHKO class PokeBattle_Move_OHKOHitsUndergroundTarget < PokeBattle_Move_OHKO
def hitsDiggingTargets?; return true; end def hitsDiggingTargets?; return true; end
end end

View File

@@ -2104,9 +2104,9 @@ BattleHandlers::AbilityOnSwitchIn.add(:ANTICIPATION,
eff = Effectiveness.calculate(moveType,type1,type2,type3) eff = Effectiveness.calculate(moveType,type1,type2,type3)
next if Effectiveness.ineffective?(eff) next if Effectiveness.ineffective?(eff)
next if !Effectiveness.super_effective?(eff) && next if !Effectiveness.super_effective?(eff) &&
!["OHKO", "OHKOIce", "OHKOHitsTargetUnderground"].include?(m.function) !["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function)
else else
next if !["OHKO", "OHKOIce", "OHKOHitsTargetUnderground"].include?(m.function) next if !["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function)
end end
found = true found = true
break break
@@ -2206,7 +2206,7 @@ BattleHandlers::AbilityOnSwitchIn.add(:FOREWARN,
battle.eachOtherSideBattler(battler.index) do |b| battle.eachOtherSideBattler(battler.index) do |b|
b.eachMove do |m| b.eachMove do |m|
power = m.baseDamage power = m.baseDamage
power = 160 if ["OHKO", "OHKOIce", "OHKOHitsTargetUnderground"].include?(m.function) power = 160 if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function)
power = 150 if ["PowerHigherWithUserHP"].include?(m.function) # Eruption power = 150 if ["PowerHigherWithUserHP"].include?(m.function) # Eruption
# Counter, Mirror Coat, Metal Burst # Counter, Mirror Coat, Metal Burst
power = 120 if ["CounterPhysicalDamage", power = 120 if ["CounterPhysicalDamage",

View File

@@ -1547,7 +1547,7 @@ class PokeBattle_AI
when "FixedDamageUserLevelRandom" when "FixedDamageUserLevelRandom"
score += 30 if target.hp<=user.level score += 30 if target.hp<=user.level
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "OHKO", "OHKOIce", "OHKOHitsTargetUnderground" when "OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"
score -= 90 if target.hasActiveAbility?(:STURDY) score -= 90 if target.hasActiveAbility?(:STURDY)
score -= 90 if target.level>user.level score -= 90 if target.level>user.level
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------

View File

@@ -180,7 +180,7 @@ class PokeBattle_AI
baseDmg = move.pbFixedDamage(user,target) baseDmg = move.pbFixedDamage(user,target)
when "FixedDamageUserLevelRandom" # Psywave when "FixedDamageUserLevelRandom" # Psywave
baseDmg = user.level baseDmg = user.level
when "OHKO", "OHKOIce", "OHKOHitsTargetUnderground" when "OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"
baseDmg = 200 baseDmg = 200
when "CounterPhysicalDamage", "CounterSpecialDamage", "CounterDamagePlusHalf" when "CounterPhysicalDamage", "CounterSpecialDamage", "CounterDamagePlusHalf"
baseDmg = 60 baseDmg = 60
@@ -692,7 +692,7 @@ class PokeBattle_AI
modifiers[:base_accuracy] = 0 if Settings::MORE_TYPE_EFFECTS && move.statusMove? && modifiers[:base_accuracy] = 0 if Settings::MORE_TYPE_EFFECTS && move.statusMove? &&
user.pbHasType?(:POISON) user.pbHasType?(:POISON)
end end
if ["OHKO", "OHKOIce", "OHKOHitsTargetUnderground"].include?(move.function) if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(move.function)
modifiers[:base_accuracy] = move.accuracy + user.level - target.level modifiers[:base_accuracy] = move.accuracy + user.level - target.level
modifiers[:accuracy_multiplier] = 0 if target.level > user.level modifiers[:accuracy_multiplier] = 0 if target.level > user.level
if skill>=PBTrainerAI.bestSkill if skill>=PBTrainerAI.bestSkill

View File

@@ -200,7 +200,7 @@ end
class PokeBattle_Move_OHKOHitsTargetUnderground class PokeBattle_Move_OHKOHitsUndergroundTarget
alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget? alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget?
def pbFailsAgainstTarget?(user, target, show_message) def pbFailsAgainstTarget?(user, target, show_message)

View File

@@ -342,10 +342,6 @@ BattleHandlers::AbilityOnSwitchIn.add(:MIMICRY,
#=============================================================================== #===============================================================================
Mirror Armor
If a move/ability tries to lower the bearer's stat(s), the effect is reflected
back at the causer.
Neutralizing Gas Neutralizing Gas
Suppresses all other abilities. Once this ability stops applying, triggers all Suppresses all other abilities. Once this ability stops applying, triggers all
abilities that activate when gained (if this happens because bearer switches abilities that activate when gained (if this happens because bearer switches

View File

@@ -343,9 +343,9 @@ BattleHandlers::UserItemAfterMoveUse.add(:THROATSPRAY,
BattleHandlers::ItemOnSwitchIn.add(:ROOMSERVICE, BattleHandlers::ItemOnSwitchIn.add(:ROOMSERVICE,
proc { |item, battler, battle| proc { |item, battler, battle|
next if battle.field.effects[PBEffects::TrickRoom] == 0 next if battle.field.effects[PBEffects::TrickRoom] == 0
next if !battler.pbCanLowerStatStage?(:SPEED, battler) next if !battler.pbCanLowerStatStage?(:SPEED)
battle.pbCommonAnimation("UseItem", battler) battle.pbCommonAnimation("UseItem", battler)
battler.pbLowerStatStage(:SPEED, 1, battler) battler.pbLowerStatStage(:SPEED, 1, nil)
battler.pbConsumeItem battler.pbConsumeItem
} }
) )

View File

@@ -2825,7 +2825,7 @@ BaseDamage = 1
Accuracy = 30 Accuracy = 30
TotalPP = 5 TotalPP = 5
Target = NearOther Target = NearOther
FunctionCode = OHKOHitsTargetUnderground FunctionCode = OHKOHitsUndergroundTarget
Flags = CanProtect,CanMirrorMove Flags = CanProtect,CanMirrorMove
Description = The user opens up a fissure in the ground and drops the foe in. The target instantly faints if it hits. Description = The user opens up a fissure in the ground and drops the foe in. The target instantly faints if it hits.
#------------------------------- #-------------------------------

View File

@@ -3728,7 +3728,7 @@ BaseDamage = 1
Accuracy = 30 Accuracy = 30
TotalPP = 5 TotalPP = 5
Target = NearOther Target = NearOther
FunctionCode = OHKOHitsTargetUnderground FunctionCode = OHKOHitsUndergroundTarget
Flags = CanProtect,CanMirrorMove Flags = CanProtect,CanMirrorMove
Description = The user opens up a fissure in the ground and drops the foe in. The target instantly faints if it hits. Description = The user opens up a fissure in the ground and drops the foe in. The target instantly faints if it hits.
#------------------------------- #-------------------------------

View File

@@ -4234,7 +4234,7 @@ BaseDamage = 1
Accuracy = 30 Accuracy = 30
TotalPP = 5 TotalPP = 5
Target = NearOther Target = NearOther
FunctionCode = OHKOHitsTargetUnderground FunctionCode = OHKOHitsUndergroundTarget
Flags = CanProtect,CanMirrorMove Flags = CanProtect,CanMirrorMove
Description = The user opens up a fissure in the ground and drops the foe in. The target instantly faints if it hits. Description = The user opens up a fissure in the ground and drops the foe in. The target instantly faints if it hits.
#------------------------------- #-------------------------------

View File

@@ -4234,7 +4234,7 @@ BaseDamage = 1
Accuracy = 30 Accuracy = 30
TotalPP = 5 TotalPP = 5
Target = NearOther Target = NearOther
FunctionCode = OHKOHitsTargetUnderground FunctionCode = OHKOHitsUndergroundTarget
Flags = CanProtect,CanMirrorMove Flags = CanProtect,CanMirrorMove
Description = The user opens up a fissure in the ground and drops the foe in. The target instantly faints if it hits. Description = The user opens up a fissure in the ground and drops the foe in. The target instantly faints if it hits.
#------------------------------- #-------------------------------