Some more code for Gen 9 abilities

This commit is contained in:
Maruno17
2024-08-21 22:11:01 +01:00
parent 6cc07d1c7a
commit 8841a534fe
6 changed files with 95 additions and 35 deletions

View File

@@ -638,6 +638,29 @@ class Battle::Battler
return false
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?
return @lastRoundMoved && @lastRoundMoved == @battle.turnCount
end

View File

@@ -332,7 +332,14 @@ class Battle::Battler
return false
end
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
# NOTE: These checks exist to ensure appropriate messages are shown if
# Intimidate is blocked somehow (i.e. the messages should mention the
@@ -365,6 +372,10 @@ class Battle::Battler
return false
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 pbLowerStatStageByCause(:ATTACK, 1, user, user.abilityName)
end