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 "070"
if data[:id] == :FISSURE
new_code = "OHKOHitsTargetUnderground"
new_code = "OHKOHitsUndergroundTarget"
elsif data[:id] == :SHEERCOLD && Settings::MECHANICS_GENERATION >= 7
new_code = "OHKOIce"
else

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

View File

@@ -383,26 +383,49 @@ class PokeBattle_TargetMultiStatDownMove < PokeBattle_Move
return false
end
def pbEffectAgainstTarget(user,target)
return if damagingMove?
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
def pbCheckForMirrorArmor(user, target)
if target.hasActiveAbility?(:MIRRORARMOR) && user.index != target.index
failed = true
for i in 0...@statDown.length / 2
next if target.statStageAtMin?(@statDown[i * 2])
next if !user.pbCanLowerStatStage?(@statDown[i * 2], target, self, false, false, true)
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
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
def pbAdditionalEffect(user,target)
return 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
pbLowerTargetMultipleStats(user, target) if !target.damageState.substitute
end
end

View File

@@ -1321,6 +1321,11 @@ end
class PokeBattle_Move_LowerPoisonedTargetAtkSpAtkSpd1 < PokeBattle_Move
def canMagicCoat?; return true; end
def initialize(battle,move)
super
@statDown = [:ATTACK, 1, :SPECIAL_ATTACK, 1, :SPEED, 1]
end
def pbMoveFailed?(user,targets)
@validTargets = []
targets.each do |b|
@@ -1338,15 +1343,42 @@ class PokeBattle_Move_LowerPoisonedTargetAtkSpAtkSpd1 < PokeBattle_Move
return false
end
def pbEffectAgainstTarget(user,target)
return if !@validTargets.include?(target.index)
showAnim = true
[:ATTACK,:SPECIAL_ATTACK,:SPEED].each do |s|
next if !target.pbCanLowerStatStage?(s,user,self)
if target.pbLowerStatStage(s,1,user,showAnim)
showAnim = false
def pbCheckForMirrorArmor(user, target)
if target.hasActiveAbility?(:MIRRORARMOR) && user.index != target.index
failed = true
for i in 0...@statDown.length / 2
next if target.statStageAtMin?(@statDown[i * 2])
next if !user.pbCanLowerStatStage?(@statDown[i * 2], target, self, false, false, true)
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
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

View File

@@ -131,7 +131,7 @@ end
# OHKO. Accuracy increases by difference between levels of user and target. Hits
# 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
end

View File

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

View File

@@ -1547,7 +1547,7 @@ class PokeBattle_AI
when "FixedDamageUserLevelRandom"
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.level>user.level
#---------------------------------------------------------------------------

View File

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

View File

@@ -200,7 +200,7 @@ end
class PokeBattle_Move_OHKOHitsTargetUnderground
class PokeBattle_Move_OHKOHitsUndergroundTarget
alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget?
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
Suppresses all other abilities. Once this ability stops applying, triggers all
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,
proc { |item, battler, battle|
next if battle.field.effects[PBEffects::TrickRoom] == 0
next if !battler.pbCanLowerStatStage?(:SPEED, battler)
next if !battler.pbCanLowerStatStage?(:SPEED)
battle.pbCommonAnimation("UseItem", battler)
battler.pbLowerStatStage(:SPEED, 1, battler)
battler.pbLowerStatStage(:SPEED, 1, nil)
battler.pbConsumeItem
}
)

View File

@@ -2825,7 +2825,7 @@ BaseDamage = 1
Accuracy = 30
TotalPP = 5
Target = NearOther
FunctionCode = OHKOHitsTargetUnderground
FunctionCode = OHKOHitsUndergroundTarget
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.
#-------------------------------

View File

@@ -3728,7 +3728,7 @@ BaseDamage = 1
Accuracy = 30
TotalPP = 5
Target = NearOther
FunctionCode = OHKOHitsTargetUnderground
FunctionCode = OHKOHitsUndergroundTarget
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.
#-------------------------------

View File

@@ -4234,7 +4234,7 @@ BaseDamage = 1
Accuracy = 30
TotalPP = 5
Target = NearOther
FunctionCode = OHKOHitsTargetUnderground
FunctionCode = OHKOHitsUndergroundTarget
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.
#-------------------------------

View File

@@ -4234,7 +4234,7 @@ BaseDamage = 1
Accuracy = 30
TotalPP = 5
Target = NearOther
FunctionCode = OHKOHitsTargetUnderground
FunctionCode = OHKOHitsUndergroundTarget
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.
#-------------------------------