Coded some Gen 9 ability/item/move effects

This commit is contained in:
Maruno17
2024-06-15 15:58:31 +01:00
parent 454d5a216a
commit 22b33ca6c2
35 changed files with 596 additions and 234 deletions

View File

@@ -278,7 +278,7 @@ class Battle::Battler
ret = (@pokemon) ? @pokemon.weight : 500
ret += @effects[PBEffects::WeightChange]
ret = 1 if ret < 1
if abilityActive? && !@battle.moldBreaker
if abilityActive? && !beingMoldBroken?
ret = Battle::AbilityEffects.triggerWeightCalc(self.ability, self, ret)
end
if itemActive?
@@ -382,7 +382,9 @@ class Battle::Battler
:COMATOSE,
:RKSSYSTEM
]
return ability_blacklist.include?(abil.id)
return true if ability_blacklist.include?(abil.id)
return true if hasActiveItem?(:ABILITYSHIELD)
return false
end
# Applies to gaining the ability.
@@ -492,6 +494,11 @@ class Battle::Battler
return hasActiveAbility?([:MOLDBREAKER, :TERAVOLT, :TURBOBLAZE])
end
def beingMoldBroken?
return false if hasActiveItem?(:ABILITYSHIELD)
return @battle.moldBreaker
end
def canChangeType?
return ![:MULTITYPE, :RKSSYSTEM].include?(@ability_id)
end
@@ -502,7 +509,7 @@ class Battle::Battler
return false if @effects[PBEffects::SmackDown]
return false if @battle.field.effects[PBEffects::Gravity] > 0
return true if pbHasType?(:FLYING)
return true if hasActiveAbility?(:LEVITATE) && !@battle.moldBreaker
return true if hasActiveAbility?(:LEVITATE) && !beingMoldBroken?
return true if hasActiveItem?(:AIRBALLOON)
return true if @effects[PBEffects::MagnetRise] > 0
return true if @effects[PBEffects::Telekinesis] > 0
@@ -571,7 +578,7 @@ class Battle::Battler
return false
end
if Settings::MECHANICS_GENERATION >= 6
if hasActiveAbility?(:OVERCOAT) && !@battle.moldBreaker
if hasActiveAbility?(:OVERCOAT) && !beingMoldBroken?
if showMsg
@battle.pbShowAbilitySplash(self)
if Battle::Scene::USE_ABILITY_SPLASH

View File

@@ -72,7 +72,7 @@ class Battle::Battler
end
end
# Uproar immunity
if newStatus == :SLEEP && !(hasActiveAbility?(:SOUNDPROOF) && !@battle.moldBreaker)
if newStatus == :SLEEP && !(hasActiveAbility?(:SOUNDPROOF) && !beingMoldBroken?)
@battle.allBattlers.each do |b|
next if b.effects[PBEffects::Uproar] == 0
@battle.pbDisplay(_INTL("But the uproar kept {1} awake!", pbThis(true))) if showMessages
@@ -105,17 +105,16 @@ class Battle::Battler
immAlly = nil
if Battle::AbilityEffects.triggerStatusImmunityNonIgnorable(self.ability, self, newStatus)
immuneByAbility = true
elsif self_inflicted || !@battle.moldBreaker
if abilityActive? && Battle::AbilityEffects.triggerStatusImmunity(self.ability, self, newStatus)
elsif abilityActive? && (self_inflicted || !beingMoldBroken?) &&
Battle::AbilityEffects.triggerStatusImmunity(self.ability, self, newStatus)
immuneByAbility = true
else
allAllies.each do |b|
next if !b.abilityActive? || (!self_inflicted && b.beingMoldBroken?)
next if !Battle::AbilityEffects.triggerStatusImmunityFromAlly(b.ability, self, newStatus)
immuneByAbility = true
else
allAllies.each do |b|
next if !b.abilityActive?
next if !Battle::AbilityEffects.triggerStatusImmunityFromAlly(b.ability, self, newStatus)
immuneByAbility = true
immAlly = b
break
end
immAlly = b
break
end
end
if immuneByAbility
@@ -456,7 +455,7 @@ class Battle::Battler
@battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!", pbThis(true))) if showMessages
return false
end
if (selfInflicted || !@battle.moldBreaker) && hasActiveAbility?(:OWNTEMPO)
if (selfInflicted || !beingMoldBroken?) && hasActiveAbility?(:OWNTEMPO)
if showMessages
@battle.pbShowAbilitySplash(self)
if Battle::Scene::USE_ABILITY_SPLASH
@@ -516,32 +515,30 @@ class Battle::Battler
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) if showMessages
return false
end
if !@battle.moldBreaker
if hasActiveAbility?([:AROMAVEIL, :OBLIVIOUS])
if hasActiveAbility?([:AROMAVEIL, :OBLIVIOUS]) && !beingMoldBroken?
if showMessages
@battle.pbShowAbilitySplash(self)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis))
else
@battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", pbThis, abilityName))
end
@battle.pbHideAbilitySplash(self)
end
return false
else
allAllies.each do |b|
next if !b.hasActiveAbility?(:AROMAVEIL) || b.beingMoldBroken?
if showMessages
@battle.pbShowAbilitySplash(self)
@battle.pbShowAbilitySplash(b)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis))
else
@battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", pbThis, abilityName))
@battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", b.pbThis, b.abilityName))
end
@battle.pbHideAbilitySplash(self)
@battle.pbHideAbilitySplash(b)
end
return false
else
allAllies.each do |b|
next if !b.hasActiveAbility?(:AROMAVEIL)
if showMessages
@battle.pbShowAbilitySplash(b)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis))
else
@battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", b.pbThis, b.abilityName))
end
@battle.pbHideAbilitySplash(b)
end
return false
end
end
end
return true
@@ -569,7 +566,7 @@ class Battle::Battler
# Flinching
#=============================================================================
def pbFlinch(_user = nil)
return if hasActiveAbility?(:INNERFOCUS) && !@battle.moldBreaker
return if hasActiveAbility?(:INNERFOCUS) && !beingMoldBroken?
@effects[PBEffects::Flinch] = true
end
end

View File

@@ -9,7 +9,7 @@ class Battle::Battler
def pbCanRaiseStatStage?(stat, user = nil, move = nil, showFailMsg = false, ignoreContrary = false)
return false if fainted?
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !beingMoldBroken?
return pbCanLowerStatStage?(stat, user, move, showFailMsg, true)
end
# Check the stat stage
@@ -24,7 +24,7 @@ class Battle::Battler
end
def pbRaiseStatStageBasic(stat, increment, ignoreContrary = false)
if !@battle.moldBreaker
if !beingMoldBroken?
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary
return pbLowerStatStageBasic(stat, increment, true)
@@ -46,7 +46,7 @@ class Battle::Battler
def pbRaiseStatStage(stat, increment, user, showAnim = true, ignoreContrary = false)
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
if hasActiveAbility?(:CONTRARY) && !beingMoldBroken? && !ignoreContrary
return pbLowerStatStage(stat, increment, user, showAnim, true)
end
# Perform the stat stage change
@@ -69,7 +69,7 @@ class Battle::Battler
def pbRaiseStatStageByCause(stat, increment, user, cause, showAnim = true, ignoreContrary = false)
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
if hasActiveAbility?(:CONTRARY) && !beingMoldBroken? && !ignoreContrary
return pbLowerStatStageByCause(stat, increment, user, cause, showAnim, true)
end
# Perform the stat stage change
@@ -123,7 +123,7 @@ class Battle::Battler
def pbCanLowerStatStage?(stat, user = nil, move = nil, showFailMsg = false,
ignoreContrary = false, ignoreMirrorArmor = false)
return false if fainted?
if !@battle.moldBreaker
if !beingMoldBroken?
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary
return pbCanRaiseStatStage?(stat, user, move, showFailMsg, true)
@@ -146,22 +146,25 @@ class Battle::Battler
return false
end
if abilityActive?
return false if !@battle.moldBreaker && Battle::AbilityEffects.triggerStatLossImmunity(
return false if !beingMoldBroken? && Battle::AbilityEffects.triggerStatLossImmunity(
self.ability, self, stat, @battle, showFailMsg
)
return false if Battle::AbilityEffects.triggerStatLossImmunityNonIgnorable(
self.ability, self, stat, @battle, showFailMsg
)
end
if !@battle.moldBreaker
allAllies.each do |b|
next if !b.abilityActive?
return false if Battle::AbilityEffects.triggerStatLossImmunityFromAlly(
b.ability, b, self, stat, @battle, showFailMsg
)
end
allAllies.each do |b|
next if !b.abilityActive? || b.beingMoldBroken?
return false if Battle::AbilityEffects.triggerStatLossImmunityFromAlly(
b.ability, b, self, stat, @battle, showFailMsg
)
end
end
if user && user.index != @index # Only protects against moves/abilities of non-self
return false if itemActive? && Battle::ItemEffects.triggerStatLossImmunity(
self.item, self, stat, @battle, showFailMsg
)
end
# Check the stat stage
if statStageAtMin?(stat)
if showFailMsg
@@ -174,7 +177,7 @@ class Battle::Battler
end
def pbLowerStatStageBasic(stat, increment, ignoreContrary = false)
if !@battle.moldBreaker
if !beingMoldBroken?
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary
return pbRaiseStatStageBasic(stat, increment, true)
@@ -197,7 +200,7 @@ class Battle::Battler
def pbLowerStatStage(stat, increment, user, showAnim = true, ignoreContrary = false,
mirrorArmorSplash = 0, ignoreMirrorArmor = false)
if !@battle.moldBreaker
if !beingMoldBroken?
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary
return pbRaiseStatStage(stat, increment, user, showAnim, true)
@@ -239,7 +242,7 @@ class Battle::Battler
def pbLowerStatStageByCause(stat, increment, user, cause, showAnim = true,
ignoreContrary = false, ignoreMirrorArmor = false)
if !@battle.moldBreaker
if !beingMoldBroken?
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary
return pbRaiseStatStageByCause(stat, increment, user, cause, showAnim, true)
@@ -350,6 +353,12 @@ class Battle::Battler
return false
end
end
if itemActive? &&
Battle::ItemEffects.triggerStatLossImmunity(self.item, self, :ATTACK, @battle, false)
@battle.pbDisplay(_INTL("{1}'s {2} prevented {3}'s {4} from working!",
pbThis, itemName, user.pbThis(true), user.abilityName))
return false
end
end
return false if !pbCanLowerStatStage?(:ATTACK, user)
return pbLowerStatStageByCause(:ATTACK, 1, user, user.abilityName)

View File

@@ -395,7 +395,7 @@ class Battle::Battler
magicCoater = b.index
b.effects[PBEffects::MagicCoat] = false
break
elsif b.hasActiveAbility?(:MAGICBOUNCE) && !@battle.moldBreaker &&
elsif b.hasActiveAbility?(:MAGICBOUNCE) && !b.beingMoldBroken? &&
!b.effects[PBEffects::MagicBounce]
magicBouncer = b.index
b.effects[PBEffects::MagicBounce] = true

View File

@@ -334,7 +334,7 @@ class Battle::Battler
@battle.successStates[user.index].protected = true
return false
end
if !(user.hasActiveAbility?(:UNSEENFIST) && move.contactMove?)
if !(user.hasActiveAbility?(:UNSEENFIST) && move.pbContactMove?(user))
# Wide Guard
if target.pbOwnSide.effects[PBEffects::WideGuard] && user.index != target.index &&
move.pbTarget(user).num_targets > 1 &&
@@ -444,7 +444,7 @@ class Battle::Battler
target.effects[PBEffects::MagicCoat] = false
return false
end
if target.hasActiveAbility?(:MAGICBOUNCE) && !@battle.moldBreaker &&
if target.hasActiveAbility?(:MAGICBOUNCE) && !target.beingMoldBroken? &&
!target.effects[PBEffects::MagicBounce]
target.damageState.magicBounce = true
target.effects[PBEffects::MagicBounce] = true
@@ -469,7 +469,7 @@ class Battle::Battler
# Airborne-based immunity to Ground moves
if move.damagingMove? && move.calcType == :GROUND &&
target.airborne? && !move.hitsFlyingTargets?
if target.hasActiveAbility?(:LEVITATE) && !@battle.moldBreaker
if target.hasActiveAbility?(:LEVITATE) && !target.beingMoldBroken?
if show_message
@battle.pbShowAbilitySplash(target)
if Battle::Scene::USE_ABILITY_SPLASH
@@ -502,7 +502,7 @@ class Battle::Battler
return false
end
if Settings::MECHANICS_GENERATION >= 6
if target.hasActiveAbility?(:OVERCOAT) && !@battle.moldBreaker
if target.hasActiveAbility?(:OVERCOAT) && !target.beingMoldBroken?
if show_message
@battle.pbShowAbilitySplash(target)
if Battle::Scene::USE_ABILITY_SPLASH