mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-12 15:44:57 +00:00
Refactoring of code relating to switching, effect damage and effects that trigger after a move is used
This commit is contained in:
@@ -1,63 +1,4 @@
|
||||
class PokeBattle_Battler
|
||||
#=============================================================================
|
||||
# Called when a Pokémon (self) is sent into battle or its ability changes.
|
||||
#=============================================================================
|
||||
def pbEffectsOnSwitchIn(switchIn=false)
|
||||
# Healing Wish/Lunar Dance/entry hazards
|
||||
@battle.pbOnActiveOne(self) if switchIn
|
||||
# Primal Revert upon entering battle
|
||||
@battle.pbPrimalReversion(@index) if !fainted?
|
||||
# Ending primordial weather, checking Trace
|
||||
pbContinualAbilityChecks(true)
|
||||
# Abilities that trigger upon switching in
|
||||
if (!fainted? && unstoppableAbility?) || abilityActive?
|
||||
BattleHandlers.triggerAbilityOnSwitchIn(self.ability,self,@battle)
|
||||
end
|
||||
# Check for end of primordial weather
|
||||
@battle.pbEndPrimordialWeather
|
||||
# Items that trigger upon switching in (Air Balloon message)
|
||||
if switchIn && itemActive?
|
||||
BattleHandlers.triggerItemOnSwitchIn(self.item,self,@battle)
|
||||
end
|
||||
# Berry check, status-curing ability check
|
||||
pbHeldItemTriggerCheck if switchIn
|
||||
pbAbilityStatusCureCheck
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Called when a Pokémon enters battle, and when Ally Switch is used.
|
||||
#=============================================================================
|
||||
def pbEffectsOnEnteringPosition
|
||||
position = @battle.positions[@index]
|
||||
# Healing Wish
|
||||
if position.effects[PBEffects::HealingWish]
|
||||
if canHeal? || self.status != :NONE
|
||||
@battle.pbCommonAnimation("HealingWish", self)
|
||||
@battle.pbDisplay(_INTL("The healing wish came true for {1}!", pbThis(true)))
|
||||
pbRecoverHP(@totalhp)
|
||||
pbCureStatus(false)
|
||||
position.effects[PBEffects::HealingWish] = false
|
||||
elsif Settings::MECHANICS_GENERATION < 8
|
||||
position.effects[PBEffects::HealingWish] = false
|
||||
end
|
||||
end
|
||||
# Lunar Dance
|
||||
if position.effects[PBEffects::LunarDance]
|
||||
full_pp = true
|
||||
eachMove { |m| full_pp = false if m.pp < m.total_pp }
|
||||
if canHeal? || self.status != :NONE || !full_pp
|
||||
@battle.pbCommonAnimation("LunarDance", self)
|
||||
@battle.pbDisplay(_INTL("{1} became cloaked in mystical moonlight!", pbThis))
|
||||
pbRecoverHP(@totalhp)
|
||||
pbCureStatus(false)
|
||||
eachMove { |m| m.pp = m.total_pp }
|
||||
position.effects[PBEffects::LunarDance] = false
|
||||
elsif Settings::MECHANICS_GENERATION < 8
|
||||
position.effects[PBEffects::LunarDance] = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Ability effects
|
||||
#=============================================================================
|
||||
@@ -86,13 +27,11 @@ class PokeBattle_Battler
|
||||
end
|
||||
end
|
||||
|
||||
# Used for Emergency Exit/Wimp Out.
|
||||
def pbAbilitiesOnDamageTaken(oldHP,newHP=-1)
|
||||
# Used for Emergency Exit/Wimp Out. Returns whether self has switched out.
|
||||
def pbAbilitiesOnDamageTaken(move_user = nil)
|
||||
return false if !@droppedBelowHalfHP
|
||||
return false if !abilityActive?
|
||||
newHP = @hp if newHP<0
|
||||
return false if oldHP<@totalhp/2 || newHP>=@totalhp/2 # Didn't drop below half
|
||||
ret = BattleHandlers.triggerAbilityOnHPDroppedBelowHalf(self.ability,self,@battle)
|
||||
return ret # Whether self has switched out
|
||||
return BattleHandlers.triggerAbilityOnHPDroppedBelowHalf(self.ability, self, move_user, @battle)
|
||||
end
|
||||
|
||||
def pbAbilityOnTerrainChange(ability_changed = false)
|
||||
@@ -149,7 +88,7 @@ class PokeBattle_Battler
|
||||
#=============================================================================
|
||||
# Ability change
|
||||
#=============================================================================
|
||||
def pbOnAbilityChanged(oldAbil)
|
||||
def pbOnLosingAbility(oldAbil)
|
||||
if @effects[PBEffects::Illusion] && oldAbil == :ILLUSION
|
||||
@effects[PBEffects::Illusion] = nil
|
||||
if !@effects[PBEffects::Transform]
|
||||
@@ -160,10 +99,23 @@ class PokeBattle_Battler
|
||||
end
|
||||
@effects[PBEffects::GastroAcid] = false if unstoppableAbility?
|
||||
@effects[PBEffects::SlowStart] = 0 if self.ability != :SLOWSTART
|
||||
# Check for end of primordial weather
|
||||
@battle.pbEndPrimordialWeather
|
||||
# Revert form if Flower Gift/Forecast was lost
|
||||
pbCheckFormOnWeatherChange(true)
|
||||
# Abilities that trigger when the terrain changes
|
||||
pbAbilityOnTerrainChange(true)
|
||||
end
|
||||
|
||||
def pbTriggerAbilityOnGainingIt
|
||||
# Ending primordial weather, checking Trace
|
||||
pbContinualAbilityChecks(true) # Don't trigger Traced ability as it's triggered below
|
||||
# Abilities that trigger upon switching in
|
||||
if (!fainted? && unstoppableAbility?) || abilityActive?
|
||||
BattleHandlers.triggerAbilityOnSwitchIn(self.ability, self, @battle)
|
||||
end
|
||||
# Status-curing ability check
|
||||
pbAbilityStatusCureCheck
|
||||
# Check for end of primordial weather
|
||||
@battle.pbEndPrimordialWeather
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user