mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 14:14:59 +00:00
Refactoring of code relating to switching, effect damage and effects that trigger after a move is used
This commit is contained in:
@@ -76,7 +76,7 @@ class PokeBattle_Move
|
||||
def pbEffectGeneral(user); end
|
||||
def pbAdditionalEffect(user,target); end
|
||||
def pbEffectAfterAllHits(user,target); end # Move effects that occur after all hits
|
||||
def pbSwitchOutTargetsEffect(user,targets,numHits,switchedBattlers); end
|
||||
def pbSwitchOutTargetEffect(user, targets, numHits, switched_battlers); end
|
||||
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers); end
|
||||
|
||||
#=============================================================================
|
||||
@@ -225,8 +225,8 @@ class PokeBattle_Move
|
||||
def pbInflictHPDamage(target)
|
||||
if target.damageState.substitute
|
||||
target.effects[PBEffects::Substitute] -= target.damageState.hpLost
|
||||
else
|
||||
target.hp -= target.damageState.hpLost
|
||||
elsif target.damageState.hpLost > 0
|
||||
target.pbReduceHP(target.damageState.hpLost, false, true, false)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -360,12 +360,12 @@ class PokeBattle_Move
|
||||
target.effects[PBEffects::BideTarget] = user.index
|
||||
end
|
||||
target.damageState.fainted = true if target.fainted?
|
||||
target.lastHPLost = damage # For Focus Punch
|
||||
target.tookDamage = true if damage>0 # For Assurance
|
||||
target.lastAttacker.push(user.index) # For Revenge
|
||||
target.lastHPLost = damage # For Focus Punch
|
||||
target.tookDamageThisRound = true if damage > 0 # For Assurance
|
||||
target.lastAttacker.push(user.index) # For Revenge
|
||||
if target.opposes?(user)
|
||||
target.lastHPLostFromFoe = damage # For Metal Burst
|
||||
target.lastFoeAttacker.push(user.index) # For Metal Burst
|
||||
target.lastHPLostFromFoe = damage # For Metal Burst
|
||||
target.lastFoeAttacker.push(user.index) # For Metal Burst
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -684,7 +684,7 @@ class PokeBattle_Move_UserSwapsPositionsWithAlly < PokeBattle_Move
|
||||
if @battle.pbSwapBattlers(idxA,idxB)
|
||||
@battle.pbDisplay(_INTL("{1} and {2} switched places!",
|
||||
@battle.battlers[idxB].pbThis,@battle.battlers[idxA].pbThis(true)))
|
||||
[idxA, idxB].each { |idx| @battle.battlers[idx].pbEffectsOnEnteringPosition }
|
||||
[idxA, idxB].each { |idx| @battle.pbEffectsOnBattlerEnteringPosition(@battle.battlers[idx]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -59,7 +59,7 @@ class PokeBattle_Move_MaxUserAttackLoseHalfOfTotalHP < PokeBattle_Move
|
||||
|
||||
def pbEffectGeneral(user)
|
||||
hpLoss = [user.totalhp/2,1].max
|
||||
user.pbReduceHP(hpLoss,false)
|
||||
user.pbReduceHP(hpLoss, false, false)
|
||||
if user.hasActiveAbility?(:CONTRARY)
|
||||
user.stages[:ATTACK] = -6
|
||||
user.statsLowered = true
|
||||
|
||||
@@ -891,7 +891,8 @@ class PokeBattle_Move_SetTargetAbilityToSimple < PokeBattle_Move
|
||||
@battle.pbReplaceAbilitySplash(target)
|
||||
@battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName))
|
||||
@battle.pbHideAbilitySplash(target)
|
||||
target.pbOnAbilityChanged(oldAbil)
|
||||
target.pbOnLosingAbility(oldAbil)
|
||||
target.pbTriggerAbilityOnGainingIt
|
||||
end
|
||||
end
|
||||
|
||||
@@ -924,7 +925,8 @@ class PokeBattle_Move_SetTargetAbilityToInsomnia < PokeBattle_Move
|
||||
@battle.pbReplaceAbilitySplash(target)
|
||||
@battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName))
|
||||
@battle.pbHideAbilitySplash(target)
|
||||
target.pbOnAbilityChanged(oldAbil)
|
||||
target.pbOnLosingAbility(oldAbil)
|
||||
target.pbTriggerAbilityOnGainingIt
|
||||
end
|
||||
end
|
||||
|
||||
@@ -963,8 +965,8 @@ class PokeBattle_Move_SetUserAbilityToTargetAbility < PokeBattle_Move
|
||||
@battle.pbDisplay(_INTL("{1} copied {2}'s {3}!",
|
||||
user.pbThis,target.pbThis(true),target.abilityName))
|
||||
@battle.pbHideAbilitySplash(user)
|
||||
user.pbOnAbilityChanged(oldAbil)
|
||||
user.pbEffectsOnSwitchIn
|
||||
user.pbOnLosingAbility(oldAbil)
|
||||
user.pbTriggerAbilityOnGainingIt
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1002,8 +1004,8 @@ class PokeBattle_Move_SetTargetAbilityToUserAbility < PokeBattle_Move
|
||||
@battle.pbReplaceAbilitySplash(target)
|
||||
@battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName))
|
||||
@battle.pbHideAbilitySplash(target)
|
||||
target.pbOnAbilityChanged(oldAbil)
|
||||
target.pbEffectsOnSwitchIn
|
||||
target.pbOnLosingAbility(oldAbil)
|
||||
target.pbTriggerAbilityOnGainingIt
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1069,10 +1071,10 @@ class PokeBattle_Move_UserTargetSwapAbilities < PokeBattle_Move
|
||||
@battle.pbHideAbilitySplash(user)
|
||||
@battle.pbHideAbilitySplash(target)
|
||||
end
|
||||
user.pbOnAbilityChanged(oldUserAbil)
|
||||
target.pbOnAbilityChanged(oldTargetAbil)
|
||||
user.pbEffectsOnSwitchIn
|
||||
target.pbEffectsOnSwitchIn
|
||||
user.pbOnLosingAbility(oldUserAbil)
|
||||
target.pbOnLosingAbility(oldTargetAbil)
|
||||
user.pbTriggerAbilityOnGainingIt
|
||||
target.pbTriggerAbilityOnGainingIt
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1094,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.pbOnAbilityChanged(target.ability)
|
||||
target.pbOnLosingAbility(target.ability)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1112,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.pbOnAbilityChanged(target.ability)
|
||||
target.pbOnLosingAbility(target.ability)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -157,14 +157,7 @@ class PokeBattle_Move_DamageTargetAlly < PokeBattle_Move
|
||||
@battle.battlers[b[0]].pbThis(true)))
|
||||
end
|
||||
end
|
||||
switchedAlly = []
|
||||
hitAlly.each do |b|
|
||||
@battle.battlers[b[0]].pbItemHPHealCheck
|
||||
if @battle.battlers[b[0]].pbAbilitiesOnDamageTaken(b[1])
|
||||
switchedAlly.push(@battle.battlers[b[0]])
|
||||
end
|
||||
end
|
||||
switchedAlly.each { |b| b.pbEffectsOnSwitchIn(true) }
|
||||
hitAlly.each { |b| @battle.battlers[b[0]].pbItemHPHealCheck }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -602,7 +595,7 @@ end
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_DoublePowerIfTargetLostHPThisTurn < PokeBattle_Move
|
||||
def pbBaseDamage(baseDmg,user,target)
|
||||
baseDmg *= 2 if target.tookDamage
|
||||
baseDmg *= 2 if target.tookDamageThisRound
|
||||
return baseDmg
|
||||
end
|
||||
end
|
||||
|
||||
@@ -189,7 +189,7 @@ class PokeBattle_Move_CurseTargetOrLowerUserSpd1RaiseUserAtkDef1 < PokeBattle_Mo
|
||||
# Ghost effect
|
||||
@battle.pbDisplay(_INTL("{1} cut its own HP and laid a curse on {2}!",user.pbThis,target.pbThis(true)))
|
||||
target.effects[PBEffects::Curse] = true
|
||||
user.pbReduceHP(user.totalhp/2,false)
|
||||
user.pbReduceHP(user.totalhp/2, false, false)
|
||||
user.pbItemHPHealCheck
|
||||
end
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ class PokeBattle_Move_SwitchOutUserStatusMove < PokeBattle_Move
|
||||
@battle.pbRecallAndReplace(user.index,newPkmn)
|
||||
@battle.pbClearChoice(user.index) # Replacement Pokémon does nothing this round
|
||||
@battle.moldBreaker = false
|
||||
@battle.pbOnBattlerEnteringBattle(user.index)
|
||||
switchedBattlers.push(user.index)
|
||||
user.pbEffectsOnSwitchIn(true)
|
||||
end
|
||||
|
||||
def pbEffectGeneral(user)
|
||||
@@ -79,8 +79,8 @@ class PokeBattle_Move_SwitchOutUserDamagingMove < PokeBattle_Move
|
||||
@battle.pbRecallAndReplace(user.index,newPkmn)
|
||||
@battle.pbClearChoice(user.index) # Replacement Pokémon does nothing this round
|
||||
@battle.moldBreaker = false
|
||||
@battle.pbOnBattlerEnteringBattle(user.index)
|
||||
switchedBattlers.push(user.index)
|
||||
user.pbEffectsOnSwitchIn(true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -111,8 +111,8 @@ class PokeBattle_Move_LowerTargetAtkSpAtk1SwitchOutUser < PokeBattle_TargetMulti
|
||||
@battle.pbRecallAndReplace(switcher.index,newPkmn)
|
||||
@battle.pbClearChoice(switcher.index) # Replacement Pokémon does nothing this round
|
||||
@battle.moldBreaker = false if switcher.index==user.index
|
||||
@battle.pbOnBattlerEnteringBattle(switcher.index)
|
||||
switchedBattlers.push(switcher.index)
|
||||
switcher.pbEffectsOnSwitchIn(true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -139,8 +139,8 @@ class PokeBattle_Move_SwitchOutUserPassOnEffects < PokeBattle_Move
|
||||
@battle.pbRecallAndReplace(user.index, newPkmn, false, true)
|
||||
@battle.pbClearChoice(user.index) # Replacement Pokémon does nothing this round
|
||||
@battle.moldBreaker = false
|
||||
@battle.pbOnBattlerEnteringBattle(user.index)
|
||||
switchedBattlers.push(user.index)
|
||||
user.pbEffectsOnSwitchIn(true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -198,25 +198,21 @@ class PokeBattle_Move_SwitchOutTargetStatusMove < PokeBattle_Move
|
||||
@battle.decision = 3 if @battle.wildBattle? # Escaped from battle
|
||||
end
|
||||
|
||||
def pbSwitchOutTargetsEffect(user,targets,numHits,switchedBattlers)
|
||||
return if @battle.wildBattle?
|
||||
return if user.fainted? || numHits==0
|
||||
roarSwitched = []
|
||||
def pbSwitchOutTargetEffect(user, targets, numHits, switched_battlers)
|
||||
return if @battle.wildBattle? || !switched_battlers.empty?
|
||||
return if user.fainted? || numHits == 0
|
||||
targets.each do |b|
|
||||
next if b.fainted? || b.damageState.unaffected || switchedBattlers.include?(b.index)
|
||||
next if b.fainted? || b.damageState.unaffected
|
||||
next if b.effects[PBEffects::Ingrain]
|
||||
next if b.hasActiveAbility?(:SUCTIONCUPS) && !@battle.moldBreaker
|
||||
newPkmn = @battle.pbGetReplacementPokemonIndex(b.index,true) # Random
|
||||
next if newPkmn<0
|
||||
@battle.pbRecallAndReplace(b.index, newPkmn, true)
|
||||
@battle.pbDisplay(_INTL("{1} was dragged out!",b.pbThis))
|
||||
@battle.pbClearChoice(b.index) # Replacement Pokémon does nothing this round
|
||||
switchedBattlers.push(b.index)
|
||||
roarSwitched.push(b.index)
|
||||
end
|
||||
if roarSwitched.length>0
|
||||
@battle.moldBreaker = false if roarSwitched.include?(user.index)
|
||||
@battle.pbPriority(true).each do |b|
|
||||
b.pbEffectsOnSwitchIn(true) if roarSwitched.include?(b.index)
|
||||
end
|
||||
@battle.pbOnBattlerEnteringBattle(b.index)
|
||||
switched_battlers.push(b.index)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -235,13 +231,11 @@ class PokeBattle_Move_SwitchOutTargetDamagingMove < PokeBattle_Move
|
||||
end
|
||||
end
|
||||
|
||||
def pbSwitchOutTargetsEffect(user,targets,numHits,switchedBattlers)
|
||||
return if @battle.wildBattle?
|
||||
return if user.fainted? || numHits==0
|
||||
roarSwitched = []
|
||||
def pbSwitchOutTargetEffect(user, targets, numHits, switched_battlers)
|
||||
return if @battle.wildBattle? || !switched_battlers.empty?
|
||||
return if user.fainted? || numHits == 0
|
||||
targets.each do |b|
|
||||
next if b.fainted? || b.damageState.unaffected || b.damageState.substitute
|
||||
next if switchedBattlers.include?(b.index)
|
||||
next if b.effects[PBEffects::Ingrain]
|
||||
next if b.hasActiveAbility?(:SUCTIONCUPS) && !@battle.moldBreaker
|
||||
newPkmn = @battle.pbGetReplacementPokemonIndex(b.index,true) # Random
|
||||
@@ -249,14 +243,9 @@ class PokeBattle_Move_SwitchOutTargetDamagingMove < PokeBattle_Move
|
||||
@battle.pbRecallAndReplace(b.index, newPkmn, true)
|
||||
@battle.pbDisplay(_INTL("{1} was dragged out!",b.pbThis))
|
||||
@battle.pbClearChoice(b.index) # Replacement Pokémon does nothing this round
|
||||
switchedBattlers.push(b.index)
|
||||
roarSwitched.push(b.index)
|
||||
end
|
||||
if roarSwitched.length>0
|
||||
@battle.moldBreaker = false if roarSwitched.include?(user.index)
|
||||
@battle.pbPriority(true).each do |b|
|
||||
b.pbEffectsOnSwitchIn(true) if roarSwitched.include?(b.index)
|
||||
end
|
||||
@battle.pbOnBattlerEnteringBattle(b.index)
|
||||
switched_battlers.push(b.index)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user