Added decent spacing to all scripts thanks to Rubocop

This commit is contained in:
Maruno17
2021-12-18 15:25:40 +00:00
parent f7b76ae62e
commit d17fc40a47
207 changed files with 18577 additions and 18587 deletions

View File

@@ -29,7 +29,7 @@ class Battle::Move
#=============================================================================
# Type effectiveness calculation
#=============================================================================
def pbCalcTypeModSingle(moveType,defType,user,target)
def pbCalcTypeModSingle(moveType, defType, user, target)
ret = Effectiveness.calculate_one(moveType, defType)
# Ring Target
if target.hasActiveItem?(:RINGTARGET)
@@ -57,7 +57,7 @@ class Battle::Move
return ret
end
def pbCalcTypeMod(moveType,user,target)
def pbCalcTypeMod(moveType, user, target)
return Effectiveness::NORMAL_EFFECTIVE if !moveType
return Effectiveness::NORMAL_EFFECTIVE if moveType == :GROUND &&
target.pbHasType?(:FLYING) &&
@@ -73,8 +73,8 @@ class Battle::Move
typeMods[0] = Effectiveness::SUPER_EFFECTIVE_ONE
end
else
tTypes.each_with_index do |type,i|
typeMods[i] = pbCalcTypeModSingle(moveType,type,user,target)
tTypes.each_with_index do |type, i|
typeMods[i] = pbCalcTypeModSingle(moveType, type, user, target)
end
end
# Multiply all effectivenesses together
@@ -87,15 +87,15 @@ class Battle::Move
#=============================================================================
# Accuracy check
#=============================================================================
def pbBaseAccuracy(user,target); return @accuracy; end
def pbBaseAccuracy(user, target); return @accuracy; end
# Accuracy calculations for one-hit KO moves are handled elsewhere.
def pbAccuracyCheck(user,target)
def pbAccuracyCheck(user, target)
# "Always hit" effects and "always hit" accuracy
return true if target.effects[PBEffects::Telekinesis]>0
return true if target.effects[PBEffects::Telekinesis] > 0
return true if target.effects[PBEffects::Minimize] && tramplesMinimize?(1)
baseAcc = pbBaseAccuracy(user,target)
return true if baseAcc==0
baseAcc = pbBaseAccuracy(user, target)
return true if baseAcc == 0
# Calculate all multiplier effects
modifiers = {}
modifiers[:base_accuracy] = baseAcc
@@ -103,14 +103,14 @@ class Battle::Move
modifiers[:evasion_stage] = target.stages[:EVASION]
modifiers[:accuracy_multiplier] = 1.0
modifiers[:evasion_multiplier] = 1.0
pbCalcAccuracyModifiers(user,target,modifiers)
pbCalcAccuracyModifiers(user, target, modifiers)
# Check if move can't miss
return true if modifiers[:base_accuracy] == 0
# Calculation
accStage = [[modifiers[:accuracy_stage], -6].max, 6].min + 6
evaStage = [[modifiers[:evasion_stage], -6].max, 6].min + 6
stageMul = [3,3,3,3,3,3, 3, 4,5,6,7,8,9]
stageDiv = [9,8,7,6,5,4, 3, 3,3,3,3,3,3]
stageMul = [3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9]
stageDiv = [9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3]
accuracy = 100.0 * stageMul[accStage] / stageDiv[accStage]
evasion = 100.0 * stageMul[evaStage] / stageDiv[evaStage]
accuracy = (accuracy * modifiers[:accuracy_multiplier]).round
@@ -128,29 +128,29 @@ class Battle::Move
return r < threshold
end
def pbCalcAccuracyModifiers(user,target,modifiers)
def pbCalcAccuracyModifiers(user, target, modifiers)
# Ability effects that alter accuracy calculation
if user.abilityActive?
Battle::AbilityEffects.triggerAccuracyCalcFromUser(user.ability,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
user.allAllies.each do |b|
next if !b.abilityActive?
Battle::AbilityEffects.triggerAccuracyCalcFromAlly(b.ability,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
if target.abilityActive? && !@battle.moldBreaker
Battle::AbilityEffects.triggerAccuracyCalcFromTarget(target.ability,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
# Item effects that alter accuracy calculation
if user.itemActive?
Battle::ItemEffects.triggerAccuracyCalcFromUser(user.item,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
if target.itemActive?
Battle::ItemEffects.triggerAccuracyCalcFromTarget(target.item,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
# Other effects, inc. ones that set accuracy_multiplier or evasion_stage to
# specific values
@@ -172,41 +172,41 @@ class Battle::Move
# -1: Never a critical hit.
# 0: Calculate normally.
# 1: Always a critical hit.
def pbCritialOverride(user,target); return 0; end
def pbCritialOverride(user, target); return 0; end
# Returns whether the move will be a critical hit.
def pbIsCritical?(user,target)
return false if target.pbOwnSide.effects[PBEffects::LuckyChant]>0
def pbIsCritical?(user, target)
return false if target.pbOwnSide.effects[PBEffects::LuckyChant] > 0
# Set up the critical hit ratios
ratios = (Settings::NEW_CRITICAL_HIT_RATE_MECHANICS) ? [24,8,2,1] : [16,8,4,3,2]
ratios = (Settings::NEW_CRITICAL_HIT_RATE_MECHANICS) ? [24, 8, 2, 1] : [16, 8, 4, 3, 2]
c = 0
# Ability effects that alter critical hit rate
if c>=0 && user.abilityActive?
if c >= 0 && user.abilityActive?
c = Battle::AbilityEffects.triggerCriticalCalcFromUser(user.ability, user, target, c)
end
if c>=0 && target.abilityActive? && !@battle.moldBreaker
if c >= 0 && target.abilityActive? && !@battle.moldBreaker
c = Battle::AbilityEffects.triggerCriticalCalcFromTarget(target.ability, user, target, c)
end
# Item effects that alter critical hit rate
if c>=0 && user.itemActive?
if c >= 0 && user.itemActive?
c = Battle::ItemEffects.triggerCriticalCalcFromUser(user.item, user, target, c)
end
if c>=0 && target.itemActive?
if c >= 0 && target.itemActive?
c = Battle::ItemEffects.triggerCriticalCalcFromTarget(target.item, user, target, c)
end
return false if c<0
return false if c < 0
# Move-specific "always/never a critical hit" effects
case pbCritialOverride(user,target)
case pbCritialOverride(user, target)
when 1 then return true
when -1 then return false
end
# Other effects
return true if c>50 # Merciless
return true if user.effects[PBEffects::LaserFocus]>0
return true if c > 50 # Merciless
return true if user.effects[PBEffects::LaserFocus] > 0
c += 1 if highCriticalRate?
c += user.effects[PBEffects::FocusEnergy]
c += 1 if user.inHyperMode? && @type == :SHADOW
c = ratios.length-1 if c>=ratios.length
c = ratios.length - 1 if c >= ratios.length
# Calculation
return true if ratios[c] == 1
r = @battle.pbRandom(ratios[c])
@@ -222,49 +222,49 @@ class Battle::Move
#=============================================================================
# Damage calculation
#=============================================================================
def pbBaseDamage(baseDmg,user,target); return baseDmg; end
def pbBaseDamageMultiplier(damageMult,user,target); return damageMult; end
def pbModifyDamage(damageMult,user,target); return damageMult; end
def pbBaseDamage(baseDmg, user, target); return baseDmg; end
def pbBaseDamageMultiplier(damageMult, user, target); return damageMult; end
def pbModifyDamage(damageMult, user, target); return damageMult; end
def pbGetAttackStats(user,target)
def pbGetAttackStats(user, target)
if specialMove?
return user.spatk, user.stages[:SPECIAL_ATTACK]+6
return user.spatk, user.stages[:SPECIAL_ATTACK] + 6
end
return user.attack, user.stages[:ATTACK]+6
return user.attack, user.stages[:ATTACK] + 6
end
def pbGetDefenseStats(user,target)
def pbGetDefenseStats(user, target)
if specialMove?
return target.spdef, target.stages[:SPECIAL_DEFENSE]+6
return target.spdef, target.stages[:SPECIAL_DEFENSE] + 6
end
return target.defense, target.stages[:DEFENSE]+6
return target.defense, target.stages[:DEFENSE] + 6
end
def pbCalcDamage(user,target,numTargets = 1)
def pbCalcDamage(user, target, numTargets = 1)
return if statusMove?
if target.damageState.disguise || target.damageState.iceFace
target.damageState.calcDamage = 1
return
end
stageMul = [2,2,2,2,2,2, 2, 3,4,5,6,7,8]
stageDiv = [8,7,6,5,4,3, 2, 2,2,2,2,2,2]
stageMul = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8]
stageDiv = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2]
# Get the move's type
type = @calcType # nil is treated as physical
# Calculate whether this hit deals critical damage
target.damageState.critical = pbIsCritical?(user,target)
target.damageState.critical = pbIsCritical?(user, target)
# Calcuate base power of move
baseDmg = pbBaseDamage(@baseDamage,user,target)
baseDmg = pbBaseDamage(@baseDamage, user, target)
# Calculate user's attack stat
atk, atkStage = pbGetAttackStats(user,target)
atk, atkStage = pbGetAttackStats(user, target)
if !target.hasActiveAbility?(:UNAWARE) || @battle.moldBreaker
atkStage = 6 if target.damageState.critical && atkStage<6
atk = (atk.to_f*stageMul[atkStage]/stageDiv[atkStage]).floor
atkStage = 6 if target.damageState.critical && atkStage < 6
atk = (atk.to_f * stageMul[atkStage] / stageDiv[atkStage]).floor
end
# Calculate target's defense stat
defense, defStage = pbGetDefenseStats(user,target)
defense, defStage = pbGetDefenseStats(user, target)
if !user.hasActiveAbility?(:UNAWARE)
defStage = 6 if target.damageState.critical && defStage>6
defense = (defense.to_f*stageMul[defStage]/stageDiv[defStage]).floor
defStage = 6 if target.damageState.critical && defStage > 6
defense = (defense.to_f * stageMul[defStage] / stageDiv[defStage]).floor
end
# Calculate all multiplier effects
multipliers = {
@@ -273,17 +273,17 @@ class Battle::Move
:defense_multiplier => 1.0,
:final_damage_multiplier => 1.0
}
pbCalcDamageMultipliers(user,target,numTargets,type,baseDmg,multipliers)
pbCalcDamageMultipliers(user, target, numTargets, type, baseDmg, multipliers)
# Main damage calculation
baseDmg = [(baseDmg * multipliers[:base_damage_multiplier]).round, 1].max
atk = [(atk * multipliers[:attack_multiplier]).round, 1].max
defense = [(defense * multipliers[:defense_multiplier]).round, 1].max
damage = (((2.0 * user.level / 5 + 2).floor * baseDmg * atk / defense).floor / 50).floor + 2
damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max
damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max
target.damageState.calcDamage = damage
end
def pbCalcDamageMultipliers(user,target,numTargets,type,baseDmg,multipliers)
def pbCalcDamageMultipliers(user, target, numTargets, type, baseDmg, multipliers)
# Global abilities
if (@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY)
@@ -296,7 +296,7 @@ class Battle::Move
# Ability effects that alter damage
if user.abilityActive?
Battle::AbilityEffects.triggerDamageCalcFromUser(user.ability,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
if !@battle.moldBreaker
# NOTE: It's odd that the user's Mold Breaker prevents its partner's
@@ -305,31 +305,31 @@ class Battle::Move
user.allAllies.each do |b|
next if !b.abilityActive?
Battle::AbilityEffects.triggerDamageCalcFromAlly(b.ability,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
if target.abilityActive?
Battle::AbilityEffects.triggerDamageCalcFromTarget(target.ability,
user,target,self,multipliers,baseDmg,type) if !@battle.moldBreaker
user, target, self, multipliers, baseDmg, type) if !@battle.moldBreaker
Battle::AbilityEffects.triggerDamageCalcFromTargetNonIgnorable(target.ability,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
target.allAllies.each do |b|
next if !b.abilityActive?
Battle::AbilityEffects.triggerDamageCalcFromTargetAlly(b.ability,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
end
# Item effects that alter damage
if user.itemActive?
Battle::ItemEffects.triggerDamageCalcFromUser(user.item,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
if target.itemActive?
Battle::ItemEffects.triggerDamageCalcFromTarget(target.item,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
# Parental Bond's second attack
if user.effects[PBEffects::ParentalBond]==1
if user.effects[PBEffects::ParentalBond] == 1
multipliers[:base_damage_multiplier] /= (Settings::MECHANICS_GENERATION >= 7) ? 4 : 2
end
# Other
@@ -339,7 +339,7 @@ class Battle::Move
if user.effects[PBEffects::HelpingHand] && !self.is_a?(Battle::Move::Confusion)
multipliers[:base_damage_multiplier] *= 1.5
end
if user.effects[PBEffects::Charge]>0 && type == :ELECTRIC
if user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC
multipliers[:base_damage_multiplier] *= 2
end
# Mud Sport
@@ -347,7 +347,7 @@ class Battle::Move
if @battle.allBattlers.any? { |b| b.effects[PBEffects::MudSport] }
multipliers[:base_damage_multiplier] /= 3
end
if @battle.field.effects[PBEffects::MudSportField]>0
if @battle.field.effects[PBEffects::MudSportField] > 0
multipliers[:base_damage_multiplier] /= 3
end
end
@@ -356,7 +356,7 @@ class Battle::Move
if @battle.allBattlers.any? { |b| b.effects[PBEffects::WaterSport] }
multipliers[:base_damage_multiplier] /= 3
end
if @battle.field.effects[PBEffects::WaterSportField]>0
if @battle.field.effects[PBEffects::WaterSportField] > 0
multipliers[:base_damage_multiplier] /= 3
end
end
@@ -390,7 +390,7 @@ class Battle::Move
end
end
# Multi-targeting attacks
if numTargets>1
if numTargets > 1
multipliers[:final_damage_multiplier] *= 0.75
end
# Weather
@@ -422,7 +422,7 @@ class Battle::Move
end
# Random variance
if !self.is_a?(Battle::Move::Confusion)
random = 85+@battle.pbRandom(16)
random = 85 + @battle.pbRandom(16)
multipliers[:final_damage_multiplier] *= random / 100.0
end
# STAB
@@ -444,13 +444,13 @@ class Battle::Move
if !ignoresReflect? && !target.damageState.critical &&
!user.hasActiveAbility?(:INFILTRATOR)
if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0
if @battle.pbSideBattlerCount(target)>1
if @battle.pbSideBattlerCount(target) > 1
multipliers[:final_damage_multiplier] *= 2 / 3.0
else
multipliers[:final_damage_multiplier] /= 2
end
elsif target.pbOwnSide.effects[PBEffects::Reflect] > 0 && physicalMove?
if @battle.pbSideBattlerCount(target)>1
if @battle.pbSideBattlerCount(target) > 1
multipliers[:final_damage_multiplier] *= 2 / 3.0
else
multipliers[:final_damage_multiplier] /= 2
@@ -476,12 +476,12 @@ class Battle::Move
#=============================================================================
# Additional effect chance
#=============================================================================
def pbAdditionalEffectChance(user,target,effectChance = 0)
def pbAdditionalEffectChance(user, target, effectChance = 0)
return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
ret = (effectChance>0) ? effectChance : @addlEffect
ret = (effectChance > 0) ? effectChance : @addlEffect
if Settings::MECHANICS_GENERATION >= 6 || @function != "EffectDependsOnEnvironment"
ret *= 2 if user.hasActiveAbility?(:SERENEGRACE) ||
user.pbOwnSide.effects[PBEffects::Rainbow]>0
user.pbOwnSide.effects[PBEffects::Rainbow] > 0
end
ret = 100 if $DEBUG && Input.press?(Input::CTRL)
return ret
@@ -489,17 +489,17 @@ class Battle::Move
# NOTE: Flinching caused by a move's effect is applied in that move's code,
# not here.
def pbFlinchChance(user,target)
def pbFlinchChance(user, target)
return 0 if flinchingMove?
return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
ret = 0
if user.hasActiveAbility?(:STENCH,true)
if user.hasActiveAbility?(:STENCH, true)
ret = 10
elsif user.hasActiveItem?([:KINGSROCK,:RAZORFANG],true)
elsif user.hasActiveItem?([:KINGSROCK, :RAZORFANG], true)
ret = 10
end
ret *= 2 if user.hasActiveAbility?(:SERENEGRACE) ||
user.pbOwnSide.effects[PBEffects::Rainbow]>0
user.pbOwnSide.effects[PBEffects::Rainbow] > 0
return ret
end
end