mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-10 06:34:59 +00:00
Some more code for Gen 9 abilities
This commit is contained in:
@@ -638,6 +638,29 @@ class Battle::Battler
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns whether this battler can be made to switch out because of another
|
||||||
|
# battler's move.
|
||||||
|
def canBeForcedOutOfBattle?(show_message = true)
|
||||||
|
if hasActiveAbility?(:SUCTIONCUPS) && !beingMoldBroken?
|
||||||
|
if show_message
|
||||||
|
@battle.pbShowAbilitySplash(self)
|
||||||
|
if Battle::Scene::USE_ABILITY_SPLASH
|
||||||
|
@battle.pbDisplay(_INTL("{1} anchors itself!", pbThis))
|
||||||
|
else
|
||||||
|
@battle.pbDisplay(_INTL("{1} anchors itself with {2}!", pbThis, abilityName))
|
||||||
|
end
|
||||||
|
@battle.pbHideAbilitySplash(self)
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return false if hasActiveAbility?(:GUARDDOG) && !beingMoldBroken?
|
||||||
|
if @effects[PBEffects::Ingrain]
|
||||||
|
@battle.pbDisplay(_INTL("{1} anchored itself with its roots!", pbThis)) if show_message
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
def movedThisRound?
|
def movedThisRound?
|
||||||
return @lastRoundMoved && @lastRoundMoved == @battle.turnCount
|
return @lastRoundMoved && @lastRoundMoved == @battle.turnCount
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -332,7 +332,14 @@ class Battle::Battler
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if Battle::Scene::USE_ABILITY_SPLASH
|
if Battle::Scene::USE_ABILITY_SPLASH
|
||||||
return pbLowerStatStageByAbility(:ATTACK, 1, user, false)
|
if hasActiveAbility?(:GUARDDOG)
|
||||||
|
@battle.pbShowAbilitySplash(self)
|
||||||
|
ret = pbRaiseStatStageByAbility(:ATTACK, 1, user, false)
|
||||||
|
@battle.pbHideAbilitySplash(self)
|
||||||
|
return ret
|
||||||
|
else
|
||||||
|
return pbLowerStatStageByAbility(:ATTACK, 1, user, false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
# NOTE: These checks exist to ensure appropriate messages are shown if
|
# NOTE: These checks exist to ensure appropriate messages are shown if
|
||||||
# Intimidate is blocked somehow (i.e. the messages should mention the
|
# Intimidate is blocked somehow (i.e. the messages should mention the
|
||||||
@@ -365,6 +372,10 @@ class Battle::Battler
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if hasActiveAbility?(:GUARDDOG)
|
||||||
|
return false if !pbCanRaiseStatStage?(:ATTACK, user)
|
||||||
|
return pbRaiseStatStageByCause(:ATTACK, 1, user, user.abilityName)
|
||||||
|
end
|
||||||
return false if !pbCanLowerStatStage?(:ATTACK, user)
|
return false if !pbCanLowerStatStage?(:ATTACK, user)
|
||||||
return pbLowerStatStageByCause(:ATTACK, 1, user, user.abilityName)
|
return pbLowerStatStageByCause(:ATTACK, 1, user, user.abilityName)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -155,22 +155,7 @@ class Battle::Move::SwitchOutTargetStatusMove < Battle::Move
|
|||||||
def canMagicCoat?; return true; end
|
def canMagicCoat?; return true; end
|
||||||
|
|
||||||
def pbFailsAgainstTarget?(user, target, show_message)
|
def pbFailsAgainstTarget?(user, target, show_message)
|
||||||
if target.hasActiveAbility?(:SUCTIONCUPS) && !target.beingMoldBroken?
|
return true if !target.canBeForcedOutOfBattle?(show_message)
|
||||||
if show_message
|
|
||||||
@battle.pbShowAbilitySplash(target)
|
|
||||||
if Battle::Scene::USE_ABILITY_SPLASH
|
|
||||||
@battle.pbDisplay(_INTL("{1} anchors itself!", target.pbThis))
|
|
||||||
else
|
|
||||||
@battle.pbDisplay(_INTL("{1} anchors itself with {2}!", target.pbThis, target.abilityName))
|
|
||||||
end
|
|
||||||
@battle.pbHideAbilitySplash(target)
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
if target.effects[PBEffects::Ingrain]
|
|
||||||
@battle.pbDisplay(_INTL("{1} anchored itself with its roots!", target.pbThis)) if show_message
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
if target.wild? && target.allAllies.length == 0 && @battle.canRun
|
if target.wild? && target.allAllies.length == 0 && @battle.canRun
|
||||||
# End the battle
|
# End the battle
|
||||||
if target.level > user.level
|
if target.level > user.level
|
||||||
@@ -205,8 +190,7 @@ class Battle::Move::SwitchOutTargetStatusMove < Battle::Move
|
|||||||
targets.each do |b|
|
targets.each do |b|
|
||||||
next if b.fainted? || b.damageState.unaffected
|
next if b.fainted? || b.damageState.unaffected
|
||||||
next if b.wild?
|
next if b.wild?
|
||||||
next if b.effects[PBEffects::Ingrain]
|
next if !b.canBeForcedOutOfBattle?(false)
|
||||||
next if b.hasActiveAbility?(:SUCTIONCUPS) && !b.beingMoldBroken?
|
|
||||||
newPkmn = @battle.pbGetReplacementPokemonIndex(b.index, true) # Random
|
newPkmn = @battle.pbGetReplacementPokemonIndex(b.index, true) # Random
|
||||||
next if newPkmn < 0
|
next if newPkmn < 0
|
||||||
@battle.pbRecallAndReplace(b.index, newPkmn, true)
|
@battle.pbRecallAndReplace(b.index, newPkmn, true)
|
||||||
@@ -240,8 +224,7 @@ class Battle::Move::SwitchOutTargetDamagingMove < Battle::Move
|
|||||||
targets.each do |b|
|
targets.each do |b|
|
||||||
next if b.fainted? || b.damageState.unaffected || b.damageState.substitute
|
next if b.fainted? || b.damageState.unaffected || b.damageState.substitute
|
||||||
next if b.wild?
|
next if b.wild?
|
||||||
next if b.effects[PBEffects::Ingrain]
|
next if !b.canBeForcedOutOfBattle?(false)
|
||||||
next if b.hasActiveAbility?(:SUCTIONCUPS) && !b.beingMoldBroken?
|
|
||||||
newPkmn = @battle.pbGetReplacementPokemonIndex(b.index, true) # Random
|
newPkmn = @battle.pbGetReplacementPokemonIndex(b.index, true) # Random
|
||||||
next if newPkmn < 0
|
next if newPkmn < 0
|
||||||
@battle.pbRecallAndReplace(b.index, newPkmn, true)
|
@battle.pbRecallAndReplace(b.index, newPkmn, true)
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("SwitchOutTargetDamagingM
|
|||||||
next score if target.wild?
|
next score if target.wild?
|
||||||
# No score modification if the target can't be made to switch out
|
# No score modification if the target can't be made to switch out
|
||||||
next score if target.has_active_ability?(:SUCTIONCUPS) && !target.being_mold_broken?
|
next score if target.has_active_ability?(:SUCTIONCUPS) && !target.being_mold_broken?
|
||||||
|
next score if target.has_active_ability?(:GUARDDOG) && !target.being_mold_broken?
|
||||||
next score if target.effects[PBEffects::Ingrain]
|
next score if target.effects[PBEffects::Ingrain]
|
||||||
# No score modification if the target can't be replaced
|
# No score modification if the target can't be replaced
|
||||||
can_switch = false
|
can_switch = false
|
||||||
|
|||||||
@@ -364,6 +364,61 @@ Battle::AbilityEffects::WeightCalc.add(:LIGHTMETAL,
|
|||||||
# OnHPDroppedBelowHalf handlers
|
# OnHPDroppedBelowHalf handlers
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
|
Battle::AbilityEffects::OnHPDroppedBelowHalf.add(:ANGERSHELL,
|
||||||
|
proc { |ability, battler, move_user, battle|
|
||||||
|
next false if !move_user # Not triggered if damage wasn't from a move
|
||||||
|
next false if move_user.index == battler.index # Not triggered by self-injury
|
||||||
|
stat_up = [:ATTACK, 1, :SPECIAL_ATTACK, 1, :SPEED, 1]
|
||||||
|
stat_down = [:DEFENSE, 1, :SPECIAL_DEFENSE, 1]
|
||||||
|
# Check if it will have any effect
|
||||||
|
failed = true
|
||||||
|
(stat_down.length / 2).times do |i|
|
||||||
|
next if !battler.pbCanLowerStatStage?(stat_down[i * 2], battler)
|
||||||
|
failed = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
(stat_up.length / 2).times do |i|
|
||||||
|
next if !battler.pbCanRaiseStatStage?(stat_up[i * 2], battler)
|
||||||
|
failed = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
next false if failed
|
||||||
|
# Ability will have an effect; do it
|
||||||
|
battle.pbShowAbilitySplash(battler)
|
||||||
|
# Lower stats
|
||||||
|
show_anim = true
|
||||||
|
(stat_down.length / 2).times do |i|
|
||||||
|
next if !battler.pbCanLowerStatStage?(stat_down[i * 2], battler)
|
||||||
|
if Battle::Scene::USE_ABILITY_SPLASH
|
||||||
|
if battler.pbLowerStatStage(stat_down[i * 2], stat_down[(i * 2) + 1], battler, show_anim)
|
||||||
|
show_anim = false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if battler.pbLowerStatStageByCause(stat_down[i * 2], stat_down[(i * 2) + 1], battler, battler.abilityName, show_anim)
|
||||||
|
show_anim = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# Raise stats
|
||||||
|
show_anim = true
|
||||||
|
(stat_up.length / 2).times do |i|
|
||||||
|
next if !battler.pbCanRaiseStatStage?(stat_up[i * 2], battler)
|
||||||
|
if Battle::Scene::USE_ABILITY_SPLASH
|
||||||
|
if battler.pbRaiseStatStage(stat_up[i * 2], stat_up[(i * 2) + 1], battler, show_anim)
|
||||||
|
show_anim = false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if battler.pbRaiseStatStageByCause(stat_up[i * 2], stat_up[(i * 2) + 1], battler, battler.abilityName, show_anim)
|
||||||
|
show_anim = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
battle.pbHideAbilitySplash(battler)
|
||||||
|
next false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
Battle::AbilityEffects::OnHPDroppedBelowHalf.add(:EMERGENCYEXIT,
|
Battle::AbilityEffects::OnHPDroppedBelowHalf.add(:EMERGENCYEXIT,
|
||||||
proc { |ability, battler, move_user, battle|
|
proc { |ability, battler, move_user, battle|
|
||||||
next false if battler.effects[PBEffects::SkyDrop] >= 0 ||
|
next false if battler.effects[PBEffects::SkyDrop] >= 0 ||
|
||||||
|
|||||||
@@ -1591,20 +1591,7 @@ Battle::ItemEffects::AfterMoveUseFromTarget.add(:REDCARD,
|
|||||||
battle.pbDisplay(_INTL("{1} held up its {2} against {3}!",
|
battle.pbDisplay(_INTL("{1} held up its {2} against {3}!",
|
||||||
battler.pbThis, battler.itemName, user.pbThis(true)))
|
battler.pbThis, battler.itemName, user.pbThis(true)))
|
||||||
battler.pbConsumeItem
|
battler.pbConsumeItem
|
||||||
if user.hasActiveAbility?(:SUCTIONCUPS) && !user.being_mold_broken?
|
next if !user.canBeForcedOutOfBattle?
|
||||||
battle.pbShowAbilitySplash(user)
|
|
||||||
if Battle::Scene::USE_ABILITY_SPLASH
|
|
||||||
battle.pbDisplay(_INTL("{1} anchors itself!", user.pbThis))
|
|
||||||
else
|
|
||||||
battle.pbDisplay(_INTL("{1} anchors itself with {2}!", user.pbThis, user.abilityName))
|
|
||||||
end
|
|
||||||
battle.pbHideAbilitySplash(user)
|
|
||||||
next
|
|
||||||
end
|
|
||||||
if user.effects[PBEffects::Ingrain]
|
|
||||||
battle.pbDisplay(_INTL("{1} anchored itself with its roots!", user.pbThis))
|
|
||||||
next
|
|
||||||
end
|
|
||||||
battle.pbRecallAndReplace(user.index, newPkmn, true)
|
battle.pbRecallAndReplace(user.index, newPkmn, true)
|
||||||
battle.pbDisplay(_INTL("{1} was dragged out!", user.pbThis))
|
battle.pbDisplay(_INTL("{1} was dragged out!", user.pbThis))
|
||||||
battle.pbClearChoice(user.index) # Replacement Pokémon does nothing this round
|
battle.pbClearChoice(user.index) # Replacement Pokémon does nothing this round
|
||||||
|
|||||||
Reference in New Issue
Block a user