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

@@ -115,14 +115,20 @@ class PokeBattle_Battler
return @stages[stat]<=-6
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?
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
return pbCanRaiseStatStage?(stat,user,move,showFailMsg,true)
if !@battle.moldBreaker
# Contrary
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
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
return false
end
@@ -175,10 +181,29 @@ class PokeBattle_Battler
return increment
end
def pbLowerStatStage(stat,increment,user,showAnim=true,ignoreContrary=false)
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
return pbRaiseStatStage(stat,increment,user,showAnim,true)
def pbLowerStatStage(stat, increment, user, showAnim = true, ignoreContrary = false,
mirrorArmorSplash = 0, ignoreMirrorArmor = false)
if !@battle.moldBreaker
# 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
# Perform the stat stage change
increment = pbLowerStatStageBasic(stat,increment,ignoreContrary)
@@ -197,10 +222,27 @@ class PokeBattle_Battler
return true
end
def pbLowerStatStageByCause(stat,increment,user,cause,showAnim=true,ignoreContrary=false)
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
return pbRaiseStatStageByCause(stat,increment,user,cause,showAnim,true)
def pbLowerStatStageByCause(stat, increment, user, cause, showAnim = true,
ignoreContrary = false, ignoreMirrorArmor = false)
if !@battle.moldBreaker
# 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
# Perform the stat stage change
increment = pbLowerStatStageBasic(stat,increment,ignoreContrary)

View File

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

View File

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