Implemented Neutralizing Gas

This commit is contained in:
Maruno17
2021-10-17 18:35:57 +01:00
parent 56c9b69c44
commit c68e5e7abf
8 changed files with 85 additions and 25 deletions

View File

@@ -336,11 +336,12 @@ class PokeBattle_Battler
# NOTE: Do not create any held item which affects whether a Pokémon's ability
# is active. The ability Klutz affects whether a Pokémon's item is
# active, and the code for the two combined would cause an infinite loop
# (regardless of whether any Pokémon actualy has either the ability or
# (regardless of whether any Pokémon actually has either the ability or
# the item - the code existing is enough to cause the loop).
def abilityActive?(ignore_fainted = false)
return false if fainted? && !ignore_fainted
return false if @effects[PBEffects::GastroAcid]
return false if self.ability != :NEUTRALIZINGGAS && @battle.pbCheckGlobalAbility(:NEUTRALIZINGGAS)
return true
end
@@ -402,7 +403,9 @@ class PokeBattle_Battler
:IMPOSTER,
# Abilities intended to be inherent properties of a certain species
:COMATOSE,
:RKSSYSTEM
:RKSSYSTEM,
# Abilities that can't be negated
:NEUTRALIZINGGAS
]
return ability_blacklist.include?(abil.id)
end

View File

@@ -11,6 +11,8 @@ class PokeBattle_Battler
# Treat self as fainted
@hp = 0
@fainted = true
# Check for end of Neutralizing Gas
pbAbilitiesOnNeutralizingGasEnding if hasActiveAbility?(:NEUTRALIZINGGAS, true)
# Check for end of primordial weather
@battle.pbEndPrimordialWeather
end
@@ -25,6 +27,7 @@ class PokeBattle_Battler
next if !b || !b.abilityActive?
BattleHandlers.triggerAbilityOnBattlerFainting(b.ability,b,self,@battle)
end
pbAbilitiesOnNeutralizingGasEnding if hasActiveAbility?(:NEUTRALIZINGGAS, true)
end
# Used for Emergency Exit/Wimp Out. Returns whether self has switched out.
@@ -45,6 +48,17 @@ class PokeBattle_Battler
BattleHandlers.triggerAbilityOnIntimidated(self.ability, self, @battle)
end
def pbAbilitiesOnNeutralizingGasEnding
return if @battle.pbCheckGlobalAbility(:NEUTRALIZINGGAS)
@battle.pbDisplay(_INTL("The effects of the neutralizing gas wore off!"))
@battle.pbEndPrimordialWeather
@battle.pbPriority(true).each do |b|
next if b.fainted?
next if !b.unstoppableAbility? && !b.abilityActive?
BattleHandlers.triggerAbilityOnSwitchIn(b.ability, b, @battle)
end
end
# Called when a Pokémon (self) enters battle, at the end of each move used,
# and at the end of each round.
def pbContinualAbilityChecks(onSwitchIn=false)
@@ -88,8 +102,10 @@ class PokeBattle_Battler
#=============================================================================
# Ability change
#=============================================================================
def pbOnLosingAbility(oldAbil)
if @effects[PBEffects::Illusion] && oldAbil == :ILLUSION
def pbOnLosingAbility(oldAbil, suppressed = false)
if oldAbil == :NEUTRALIZINGGAS && (suppressed || !@effects[PBEffects::GastroAcid])
pbAbilitiesOnNeutralizingGasEnding
elsif oldAbil == :ILLUSION && @effects[PBEffects::Illusion]
@effects[PBEffects::Illusion] = nil
if !@effects[PBEffects::Transform]
@battle.scene.pbChangePokemon(self, @pokemon)
@@ -99,6 +115,7 @@ class PokeBattle_Battler
end
@effects[PBEffects::GastroAcid] = false if unstoppableAbility?
@effects[PBEffects::SlowStart] = 0 if self.ability != :SLOWSTART
@effects[PBEffects::Truant] = false if self.ability != :TRUANT
# Check for end of primordial weather
@battle.pbEndPrimordialWeather
# Revert form if Flower Gift/Forecast was lost
@@ -138,8 +155,8 @@ class PokeBattle_Battler
# permanent is whether the item is lost even after battle. Is false for Knock
# Off.
def pbRemoveItem(permanent = true)
@effects[PBEffects::ChoiceBand] = nil if ability_id != :GORILLATACTICS
@effects[PBEffects::Unburden] = true if self.item
@effects[PBEffects::ChoiceBand] = nil if !hasActiveAbility?(:GORILLATACTICS)
@effects[PBEffects::Unburden] = true if self.item && hasActiveAbility?(:UNBURDEN)
setInitialItem(nil) if permanent && self.item == self.initialItem
self.item = nil
end
@@ -174,7 +191,7 @@ class PokeBattle_Battler
end
self.item = b.item
b.item = nil
b.effects[PBEffects::Unburden] = true
b.effects[PBEffects::Unburden] = true if b.hasActiveAbility?(:UNBURDEN)
@battle.pbHideAbilitySplash(b)
pbHeldItemTriggerCheck
break

View File

@@ -1096,7 +1096,7 @@ class PokeBattle_Move_NegateTargetAbility < PokeBattle_Move
target.effects[PBEffects::GastroAcid] = true
target.effects[PBEffects::Truant] = false
@battle.pbDisplay(_INTL("{1}'s Ability was suppressed!",target.pbThis))
target.pbOnLosingAbility(target.ability)
target.pbOnLosingAbility(target.ability, true)
end
end
@@ -1114,7 +1114,7 @@ class PokeBattle_Move_NegateTargetAbilityIfTargetActed < PokeBattle_Move
target.effects[PBEffects::GastroAcid] = true
target.effects[PBEffects::Truant] = false
@battle.pbDisplay(_INTL("{1}'s Ability was suppressed!",target.pbThis))
target.pbOnLosingAbility(target.ability)
target.pbOnLosingAbility(target.ability, true)
end
end

View File

@@ -115,11 +115,11 @@ class PokeBattle_Move_UserTargetSwapItems < PokeBattle_Move
oldTargetItem = target.item
oldTargetItemName = target.itemName
user.item = oldTargetItem
user.effects[PBEffects::ChoiceBand] = nil if user.ability_id != :GORILLATACTICS
user.effects[PBEffects::Unburden] = (!user.item && oldUserItem)
user.effects[PBEffects::ChoiceBand] = nil if !user.hasActiveAbility?(:GORILLATACTICS)
user.effects[PBEffects::Unburden] = (!user.item && oldUserItem) if user.hasActiveAbility?(:UNBURDEN)
target.item = oldUserItem
target.effects[PBEffects::ChoiceBand] = nil if target.ability_id != :GORILLATACTICS
target.effects[PBEffects::Unburden] = (!target.item && oldTargetItem)
target.effects[PBEffects::ChoiceBand] = nil if !target.hasActiveAbility?(:GORILLATACTICS)
target.effects[PBEffects::Unburden] = (!target.item && oldTargetItem) if target.hasActiveAbility?(:UNBURDEN)
# Permanently steal the item from wild Pokémon
if @battle.wildBattle? && target.opposes? && !user.initialItem &&
oldTargetItem == target.initialItem

View File

@@ -165,7 +165,7 @@ class PokeBattle_Battle
pbCanChooseNonActive?(0) && @battlers[0].effects[PBEffects::Outrage]==0
idxPartyForName = idxPartyNew
enemyParty = pbParty(idxBattler)
if enemyParty[idxPartyNew].ability == :ILLUSION
if enemyParty[idxPartyNew].ability == :ILLUSION && !pbCheckGlobalAbility(:NEUTRALIZINGGAS)
new_index = pbLastInTeam(idxBattler)
idxPartyForName = new_index if new_index >= 0 && new_index != idxPartyNew
end
@@ -249,7 +249,7 @@ class PokeBattle_Battle
def pbMessagesOnReplace(idxBattler,idxParty)
party = pbParty(idxBattler)
newPkmnName = party[idxParty].name
if party[idxParty].ability == :ILLUSION
if party[idxParty].ability == :ILLUSION && !pbCheckGlobalAbility(:NEUTRALIZINGGAS)
new_index = pbLastInTeam(idxBattler)
newPkmnName = party[new_index].name if new_index >= 0 && new_index != idxParty
end
@@ -314,15 +314,24 @@ class PokeBattle_Battle
# Called when one or more Pokémon switch in. Does a lot of things, including
# entry hazards, form changes and items/abilities that trigger upon switching
# in.
def pbOnBattlerEnteringBattle(*battler_indices)
battler_indices.flatten!
eachBattler do |b|
b.droppedBelowHalfHP = false
b.statsDropped = false
def pbOnBattlerEnteringBattle(battler_index, skip_event_reset = false)
battler_index = [battler_index] if !battler_index.is_a?(Array)
battler_index.flatten!
# NOTE: This isn't done for switch commands, because they previously call
# pbRecallAndReplace, which could cause Neutralizing Gas to end, which
# in turn could cause Intimidate to trigger another Pokémon's Eject
# Pack. That Eject Pack should trigger at the end of this method, but
# this resetting would prevent that from happening, so it is skipped
# and instead done earlier in def pbAttackPhaseSwitch.
if !skip_event_reset
eachBattler do |b|
b.droppedBelowHalfHP = false
b.statsDropped = false
end
end
# For each battler that entered battle, in speed order
pbPriority(true).each do |b|
next if !battler_indices.include?(b.index) || b.fainted?
next if !battler_index.include?(b.index) || b.fainted?
pbRecordBattlerAsParticipated(b)
pbMessagesOnBattlerEnteringBattle(b)
# Position/field effects triggered by the battler appearing

View File

@@ -59,8 +59,12 @@ class PokeBattle_Battle
pbPursuit(b.index)
return if @decision>0
# Switch Pokémon
eachBattler do |b|
b.droppedBelowHalfHP = false
b.statsDropped = false
end
pbRecallAndReplace(b.index,idxNewPkmn)
pbOnBattlerEnteringBattle(b.index)
pbOnBattlerEnteringBattle(b.index, true)
end
end

View File

@@ -1683,7 +1683,7 @@ BattleHandlers::UserAbilityEndOfMove.add(:MAGICIAN,
end
user.item = b.item
b.item = nil
b.effects[PBEffects::Unburden] = true
b.effects[PBEffects::Unburden] = true if n.hasActiveAbility?(:UNBURDEN)
if battle.wildBattle? && !user.initialItem && user.item == b.initialItem
user.setInitialItem(user.item)
b.setInitialItem(nil)
@@ -1762,7 +1762,7 @@ BattleHandlers::TargetAbilityAfterMoveUse.add(:PICKPOCKET,
end
target.item = user.item
user.item = nil
user.effects[PBEffects::Unburden] = true
user.effects[PBEffects::Unburden] = true if user.hasActiveAbility?(:UNBURDEN)
if battle.wildBattle? && !target.initialItem && target.item == user.initialItem
target.setInitialItem(target.item)
user.setInitialItem(nil)
@@ -2338,6 +2338,33 @@ BattleHandlers::AbilityOnSwitchIn.add(:MOLDBREAKER,
}
)
BattleHandlers::AbilityOnSwitchIn.add(:NEUTRALIZINGGAS,
proc { |ability,battler,battle|
battle.pbShowAbilitySplash(battler, true)
battle.pbHideAbilitySplash(battler)
battle.pbDisplay(_INTL("Neutralizing gas filled the area!"))
battle.eachBattler do |b|
# Slow Start - end all turn counts
b.effects[PBEffects::SlowStart] = 0
# Truant - let b move on its first turn after Neutralizing Gas disappears
b.effects[PBEffects::Truant] = false
# Gorilla Tactics - end choice lock
if !hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF])
b.effects[PBEffects::ChoiceBand] = nil
end
# Illusion - end illusions
if b.effects[PBEffects::Illusion]
b.effects[PBEffects::Illusion] = nil
if !b.effects[PBEffects::Transform]
battle.scene.pbChangePokemon(b, b.pokemon)
battle.pbDisplay(_INTL("{1}'s {2} wore off!", b.pbThis, b.abilityName))
battle.pbSetSeen(b)
end
end
end
}
)
BattleHandlers::AbilityOnSwitchIn.add(:PRESSURE,
proc { |ability,battler,battle|
battle.pbShowAbilitySplash(battler)

View File

@@ -1201,7 +1201,7 @@ BattleHandlers::TargetItemOnHit.add(:STICKYBARB,
next if user.fainted? || user.item
user.item = target.item
target.item = nil
target.effects[PBEffects::Unburden] = true
target.effects[PBEffects::Unburden] = true if target.hasActiveAbility?(:UNBURDEN)
if battle.wildBattle? && !user.opposes?
if !user.initialItem && user.item == target.initialItem
user.setInitialItem(user.item)