Tidied up semicolon use, refactored random dungeon generation code, fixed visual bug in Day Care debug screen

This commit is contained in:
Maruno17
2021-08-22 23:18:34 +01:00
parent ecc5a040cd
commit 8bb70a226e
64 changed files with 1286 additions and 926 deletions

View File

@@ -100,7 +100,8 @@ class PokeBattle_Battler
return false
end
# Ability immunity
immuneByAbility = false; immAlly = nil
immuneByAbility = false
immAlly = nil
if BattleHandlers.triggerStatusImmunityAbilityNonIgnorable(self.ability,self,newStatus)
immuneByAbility = true
elsif selfInflicted || !@battle.moldBreaker

View File

@@ -10,7 +10,8 @@ class PokeBattle_Battler
# Snatch
move.snatched = false
if move.statusMove? && move.canSnatch?
newUser = nil; strength = 100
newUser = nil
strength = 100
@battle.eachBattler do |b|
next if b.effects[PBEffects::Snatch]==0 ||
b.effects[PBEffects::Snatch]>=strength
@@ -101,7 +102,8 @@ class PokeBattle_Battler
priority = @battle.pbPriority(true)
nearOnly = !target_data.can_choose_distant_target?
# Spotlight (takes priority over Follow Me/Rage Powder/Lightning Rod/Storm Drain)
newTarget = nil; strength = 100 # Lower strength takes priority
newTarget = nil
strength = 100 # Lower strength takes priority
priority.each do |b|
next if b.fainted? || b.effects[PBEffects::SkyDrop]>=0
next if b.effects[PBEffects::Spotlight]==0 ||
@@ -118,7 +120,8 @@ class PokeBattle_Battler
return targets
end
# Follow Me/Rage Powder (takes priority over Lightning Rod/Storm Drain)
newTarget = nil; strength = 100 # Lower strength takes priority
newTarget = nil
strength = 100 # Lower strength takes priority
priority.each do |b|
next if b.fainted? || b.effects[PBEffects::SkyDrop]>=0
next if b.effects[PBEffects::RagePowder] && !user.affectedByPowder?

View File

@@ -506,7 +506,8 @@ class PokeBattle_Battler
user.effects[PBEffects::LockOnPos]==target.index
# Toxic
return true if move.pbOverrideSuccessCheckPerHit(user,target)
miss = false; hitsInvul = false
miss = false
hitsInvul = false
# No Guard
hitsInvul = true if user.hasActiveAbility?(:NOGUARD) ||
target.hasActiveAbility?(:NOGUARD)

View File

@@ -493,8 +493,10 @@ def pbBattleConfusionBerry(battler,battle,item,forced,flavor,confuseMsg)
return false if !forced && !battler.canConsumePinchBerry?(Settings::MECHANICS_GENERATION >= 7)
itemName = GameData::Item.get(item).name
fraction_to_heal = 8 # Gens 6 and lower
if Settings::MECHANICS_GENERATION == 7; fraction_to_heal = 2
elsif Settings::MECHANICS_GENERATION >= 8; fraction_to_heal = 3
if Settings::MECHANICS_GENERATION == 7
fraction_to_heal = 2
elsif Settings::MECHANICS_GENERATION >= 8
fraction_to_heal = 3
end
amt = battler.totalhp / fraction_to_heal
ripening = false

View File

@@ -240,8 +240,10 @@ class PokeBattle_Move
oldHP = b.hp+b.damageState.hpLost
PBDebug.log("[Move damage] #{b.pbThis} lost #{b.damageState.hpLost} HP (#{oldHP}=>#{b.hp})")
effectiveness = 0
if Effectiveness.resistant?(b.damageState.typeMod); effectiveness = 1
elsif Effectiveness.super_effective?(b.damageState.typeMod); effectiveness = 2
if Effectiveness.resistant?(b.damageState.typeMod)
effectiveness = 1
elsif Effectiveness.super_effective?(b.damageState.typeMod)
effectiveness = 2
end
animArray.push([b,oldHP,effectiveness])
end

View File

@@ -492,8 +492,10 @@ class PokeBattle_TwoTurnMove < PokeBattle_Move
end
def pbEffectAgainstTarget(user,target)
if @damagingTurn; pbAttackingTurnEffect(user,target)
elsif @chargingTurn; pbChargingTurnEffect(user,target)
if @damagingTurn
pbAttackingTurnEffect(user,target)
elsif @chargingTurn
pbChargingTurnEffect(user,target)
end
end
@@ -652,14 +654,20 @@ end
#===============================================================================
class PokeBattle_PledgeMove < PokeBattle_Move
def pbOnStartUse(user,targets)
@pledgeSetup = false; @pledgeCombo = false; @pledgeOtherUser = nil
@comboEffect = nil; @overrideType = nil; @overrideAnim = nil
@pledgeSetup = false
@pledgeCombo = false
@pledgeOtherUser = nil
@comboEffect = nil
@overrideType = nil
@overrideAnim = nil
# Check whether this is the use of a combo move
@combos.each do |i|
next if i[0]!=user.effects[PBEffects::FirstPledge]
@battle.pbDisplay(_INTL("The two moves have become one! It's a combined move!"))
@pledgeCombo = true
@comboEffect = i[1]; @overrideType = i[2]; @overrideAnim = i[3]
@comboEffect = i[1]
@overrideType = i[2]
@overrideAnim = i[3]
@overrideType = nil if !GameData::Type.exists?(@overrideType)
break
end
@@ -706,7 +714,8 @@ class PokeBattle_PledgeMove < PokeBattle_Move
def pbEffectAfterAllHits(user,target)
return if !@pledgeCombo
msg = nil; animName = nil
msg = nil
animName = nil
case @comboEffect
when :SeaOfFire # Grass + Fire
if user.pbOpposingSide.effects[PBEffects::SeaOfFire]==0

View File

@@ -927,12 +927,14 @@ class PokeBattle_Move_035 < PokeBattle_Move
failed = true
for i in 0...@statUp.length/2
if user.pbCanRaiseStatStage?(@statUp[i*2],user,self)
failed = false; break
failed = false
break
end
end
for i in 0...@statDown.length/2
if user.pbCanLowerStatStage?(@statDown[i*2],user,self)
failed = false; break
failed = false
break
end
end
if failed
@@ -1686,11 +1688,15 @@ end
class PokeBattle_Move_05A < PokeBattle_Move
def pbEffectAgainstTarget(user,target)
newHP = (user.hp+target.hp)/2
if user.hp>newHP; user.pbReduceHP(user.hp-newHP,false,false)
elsif user.hp<newHP; user.pbRecoverHP(newHP-user.hp,false)
if user.hp>newHP
user.pbReduceHP(user.hp-newHP,false,false)
elsif user.hp<newHP
user.pbRecoverHP(newHP-user.hp,false)
end
if target.hp>newHP; target.pbReduceHP(target.hp-newHP,false,false)
elsif target.hp<newHP; target.pbRecoverHP(newHP-target.hp,false)
if target.hp>newHP
target.pbReduceHP(target.hp-newHP,false,false)
elsif target.hp<newHP
target.pbRecoverHP(newHP-target.hp,false)
end
@battle.pbDisplay(_INTL("The battlers shared their pain!"))
user.pbItemHPHealCheck

View File

@@ -260,7 +260,8 @@ def pbHiddenPower(pkmn)
# NOTE: This allows Hidden Power to be Fairy-type (if you have that type in
# your game). I don't care that the official games don't work like that.
iv = pkmn.iv
idxType = 0; power = 60
idxType = 0
power = 60
types = []
GameData::Type.each do |t|
types[t.icon_position] ||= []
@@ -355,9 +356,12 @@ class PokeBattle_Move_094 < PokeBattle_Move
def pbOnStartUse(user,targets)
@presentDmg = 0 # 0 = heal, >0 = damage
r = @battle.pbRandom(100)
if r<40; @presentDmg = 40
elsif r<70; @presentDmg = 80
elsif r<80; @presentDmg = 120
if r<40
@presentDmg = 40
elsif r<70
@presentDmg = 80
elsif r<80
@presentDmg = 120
end
end
@@ -549,11 +553,16 @@ class PokeBattle_Move_098 < PokeBattle_Move
def pbBaseDamage(baseDmg,user,target)
ret = 20
n = 48*user.hp/user.totalhp
if n<2; ret = 200
elsif n<5; ret = 150
elsif n<10; ret = 100
elsif n<17; ret = 80
elsif n<33; ret = 40
if n<2
ret = 200
elsif n<5
ret = 150
elsif n<10
ret = 100
elsif n<17
ret = 80
elsif n<33
ret = 40
end
return ret
end
@@ -568,10 +577,14 @@ class PokeBattle_Move_099 < PokeBattle_Move
def pbBaseDamage(baseDmg,user,target)
ret = 40
n = user.pbSpeed/target.pbSpeed
if n>=4; ret = 150
elsif n>=3; ret = 120
elsif n>=2; ret = 80
elsif n>=1; ret = 60
if n>=4
ret = 150
elsif n>=3
ret = 120
elsif n>=2
ret = 80
elsif n>=1
ret = 60
end
return ret
end
@@ -586,11 +599,16 @@ class PokeBattle_Move_09A < PokeBattle_Move
def pbBaseDamage(baseDmg,user,target)
ret = 20
weight = target.pbWeight
if weight>=2000; ret = 120
elsif weight>=1000; ret = 100
elsif weight>=500; ret = 80
elsif weight>=250; ret = 60
elsif weight>=100; ret = 40
if weight>=2000
ret = 120
elsif weight>=1000
ret = 100
elsif weight>=500
ret = 80
elsif weight>=250
ret = 60
elsif weight>=100
ret = 40
end
return ret
end
@@ -611,10 +629,14 @@ class PokeBattle_Move_09B < PokeBattle_Move
def pbBaseDamage(baseDmg,user,target)
ret = 40
n = (user.pbWeight/target.pbWeight).floor
if n>=5; ret = 120
elsif n>=4; ret = 100
elsif n>=3; ret = 80
elsif n>=2; ret = 60
if n>=5
ret = 120
elsif n>=4
ret = 100
elsif n>=3
ret = 80
elsif n>=2
ret = 60
end
return ret
end
@@ -3324,8 +3346,10 @@ class PokeBattle_Move_0F2 < PokeBattle_Move
end
def pbEffectAgainstTarget(user,target)
oldUserItem = user.item; oldUserItemName = user.itemName
oldTargetItem = target.item; oldTargetItemName = target.itemName
oldUserItem = user.item
oldUserItemName = user.itemName
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)

View File

@@ -1017,7 +1017,9 @@ end
#===============================================================================
class PokeBattle_Move_125 < PokeBattle_Move
def pbFailsAgainstTarget?(user,target)
hasThisMove = false; hasOtherMoves = false; hasUnusedMoves = false
hasThisMove = false
hasOtherMoves = false
hasUnusedMoves = false
user.eachMove do |m|
hasThisMove = true if m.id==@id
hasOtherMoves = true if m.id!=@id

View File

@@ -195,11 +195,16 @@ module PokeBattle_BattleCommon
if Settings::ENABLE_CRITICAL_CAPTURES
dex_modifier = 0
numOwned = $Trainer.pokedex.owned_count
if numOwned>600; dex_modifier = 5
elsif numOwned>450; dex_modifier = 4
elsif numOwned>300; dex_modifier = 3
elsif numOwned>150; dex_modifier = 2
elsif numOwned>30; dex_modifier = 1
if numOwned>600
dex_modifier = 5
elsif numOwned>450
dex_modifier = 4
elsif numOwned>300
dex_modifier = 3
elsif numOwned>150
dex_modifier = 2
elsif numOwned>30
dex_modifier = 1
end
dex_modifier *= 2 if $PokemonBag.pbHasItem?(:CATCHINGCHARM)
c = x * dex_modifier / 12

View File

@@ -531,9 +531,12 @@ class PokeBattle_Battle
def pbJudge
fainted1 = pbAllFainted?(0)
fainted2 = pbAllFainted?(1)
if fainted1 && fainted2; @decision = pbDecisionOnDraw # Draw
elsif fainted1; @decision = 2 # Loss
elsif fainted2; @decision = 1 # Win
if fainted1 && fainted2
@decision = pbDecisionOnDraw # Draw
elsif fainted1
@decision = 2 # Loss
elsif fainted2
@decision = 1 # Win
end
end
end

View File

@@ -2003,7 +2003,9 @@ BattleHandlers::EORGainItemAbility.add(:HARVEST,
BattleHandlers::EORGainItemAbility.add(:PICKUP,
proc { |ability,battler,battle|
next if battler.item
foundItem = nil; fromBattler = nil; use = 0
foundItem = nil
fromBattler = nil
use = 0
battle.eachBattler do |b|
next if b.index==battler.index
next if b.effects[PBEffects::PickupUse]<=use

View File

@@ -193,10 +193,14 @@ class PokeBattle_AI
# Pick a good move for the Choice items
if user.hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF]) ||
user.hasActiveAbility?(:GORILLATACTICS)
if move.baseDamage>=60; score += 60
elsif move.damagingMove?; score += 30
elsif move.function=="0F2"; score += 70 # Trick
else; score -= 60
if move.baseDamage>=60
score += 60
elsif move.damagingMove?
score += 30
elsif move.function=="0F2"
score += 70 # Trick
else
score -= 60
end
end
# If user is asleep, prefer moves that are usable while asleep

View File

@@ -166,11 +166,14 @@ class PokeBattle_AI
agender = user.gender
ogender = target.gender
if agender==2 || ogender==2 || agender==ogender
score -= 90; canattract = false
score -= 90
canattract = false
elsif target.effects[PBEffects::Attract]>=0
score -= 80; canattract = false
score -= 80
canattract = false
elsif skill>=PBTrainerAI.bestSkill && target.hasActiveAbility?(:OBLIVIOUS)
score -= 80; canattract = false
score -= 80
canattract = false
end
if skill>=PBTrainerAI.highSkill
if canattract && target.hasActiveItem?(:DESTINYKNOT) &&
@@ -727,7 +730,8 @@ class PokeBattle_AI
end
#---------------------------------------------------------------------------
when "037"
avgStat = 0; canChangeStat = false
avgStat = 0
canChangeStat = false
GameData::Stat.each_battle do |s|
next if target.statStageAtMax?(s.id)
avgStat -= target.stages[s.id]
@@ -1116,7 +1120,8 @@ class PokeBattle_AI
if target.effects[PBEffects::Substitute]>0
score -= 90
else
avg = 0; anyChange = false
avg = 0
anyChange = false
GameData::Stat.each_battle do |s|
next if target.stages[s.id]==0
avg += target.stages[s.id]
@@ -1178,7 +1183,8 @@ class PokeBattle_AI
#---------------------------------------------------------------------------
when "054"
if skill>=PBTrainerAI.mediumSkill
userStages = 0; targetStages = 0
userStages = 0
targetStages = 0
GameData::Stat.each_battle do |s|
userStages += user.stages[s.id]
targetStages += target.stages[s.id]
@@ -2675,7 +2681,8 @@ class PokeBattle_AI
if target.effects[PBEffects::Substitute]>0
score -= 90
else
numpos = 0; numneg = 0
numpos = 0
numneg = 0
GameData::Stat.each_battle do |s|
numpos += target.stages[s.id] if target.stages[s.id] > 0
numneg += target.stages[s.id] if target.stages[s.id] < 0

View File

@@ -106,9 +106,12 @@ BallHandlers::ModifyCatchRate.add(:LEVELBALL,proc { |ball,catchRate,battle,battl
battle.eachSameSideBattler do |b|
maxlevel = b.level if b.level>maxlevel
end
if maxlevel>=battler.level*4; catchRate *= 8
elsif maxlevel>=battler.level*2; catchRate *= 4
elsif maxlevel>battler.level; catchRate *= 2
if maxlevel >= battler.level * 4
catchRate *= 8
elsif maxlevel >= battler.level * 2
catchRate *= 4
elsif maxlevel > battler.level
catchRate *= 2
end
next [catchRate,255].min
})
@@ -123,15 +126,22 @@ BallHandlers::ModifyCatchRate.add(:HEAVYBALL,proc { |ball,catchRate,battle,battl
next 0 if catchRate==0
weight = battler.pokemon.species_data.base_stats[:SPEED]
if Settings::NEW_POKE_BALL_CATCH_RATES
if weight>=3000; catchRate += 30
elsif weight>=2000; catchRate += 20
elsif weight<1000; catchRate -= 20
if weight >= 3000
catchRate += 30
elsif weight >= 2000
catchRate += 20
elsif weight < 1000
catchRate -= 20
end
else
if weight>=4096; catchRate += 40
elsif weight>=3072; catchRate += 30
elsif weight>=2048; catchRate += 20
else; catchRate -= 20
if weight >= 4096
catchRate += 40
elsif weight >= 3072
catchRate += 30
elsif weight >= 2048
catchRate += 20
else
catchRate -= 20
end
end
catchRate = [catchRate,1].max

View File

@@ -37,7 +37,9 @@ class PokeBattle_Scene
# animations (including cry)
@animations.push(BattleIntroAnimation2.new(@sprites,@viewport,@battle.sideSizes[1]))
# Play all the animations
while inPartyAnimation?; pbUpdate; end
while inPartyAnimation?
pbUpdate
end
# Show shiny animation for wild Pokémon
if @battle.showAnims
for i in 0...@battle.sideSizes[1]
@@ -59,7 +61,9 @@ class PokeBattle_Scene
@animations.push(LineupAppearAnimation.new(@sprites,@viewport,
side,@battle.pbParty(side),@battle.pbPartyStarts(side),fullAnim))
if !fullAnim
while inPartyAnimation?; pbUpdate; end
while inPartyAnimation?
pbUpdate
end
end
end
@@ -73,7 +77,9 @@ class PokeBattle_Scene
appearAnim = TrainerAppearAnimation.new(@sprites,@viewport,idxTrainer)
@animations.push(appearAnim)
# Play the animation
while inPartyAnimation?; pbUpdate; end
while inPartyAnimation?
pbUpdate
end
end
#=============================================================================
@@ -86,7 +92,9 @@ class PokeBattle_Scene
return if sendOuts.length==0
# If party balls are still appearing, wait for them to finish showing up, as
# the FadeAnimation will make them disappear.
while inPartyAnimation?; pbUpdate; end
while inPartyAnimation?
pbUpdate
end
@briefMessage = false
# Make all trainers and party lineups disappear (player-side trainers may
# animate throwing a Poké Ball)
@@ -130,7 +138,10 @@ class PokeBattle_Scene
end
end
fadeAnim.dispose
sendOutAnims.each { |a| a[0].dispose; a[1].dispose }
sendOutAnims.each do |a|
a[0].dispose
a[1].dispose
end
# Play shininess animations for shiny Pokémon
sendOuts.each do |b|
next if !@battle.showAnims || !@battle.battlers[b[0]].shiny?
@@ -274,7 +285,9 @@ class PokeBattle_Scene
expRange = endExp-startExp
dataBox = @sprites["dataBox_#{battler.index}"]
dataBox.animateExp(startExpLevel,endExpLevel,expRange)
while dataBox.animatingExp; pbUpdate; end
while dataBox.animatingExp
pbUpdate
end
end
#=============================================================================

View File

@@ -440,7 +440,7 @@ class PBAnimation < Array
@position = 4 # 1=target, 2=user, 3=user and target, 4=screen
@array = []
size = 1 if size<1 # Always create at least one frame
size.times do; addFrame; end
size.times { addFrame }
@timing = []
@scope = 0
end

View File

@@ -20,10 +20,14 @@ class PokeBattle_SuccessState
if @useState==1
@skill = -2 if !@protected
elsif @useState==2
if Effectiveness.super_effective?(@typeMod); @skill = 2
elsif Effectiveness.normal?(@typeMod); @skill = 1
elsif Effectiveness.not_very_effective?(@typeMod); @skill = -1
else; @skill = -2 # Ineffective
if Effectiveness.super_effective?(@typeMod)
@skill = 2
elsif Effectiveness.normal?(@typeMod)
@skill = 1
elsif Effectiveness.not_very_effective?(@typeMod)
@skill = -1
else # Ineffective
@skill = -2
end
end
clear(false)

View File

@@ -41,8 +41,10 @@ class PokeBattle_Battle
if @rules["suddendeath"] && @decision==0
p1able = pbAbleCount(0)
p2able = pbAbleCount(1)
if p1able>p2able; @decision = 1 # loss
elsif p1able<p2able; @decision = 2 # win
if p1able>p2able
@decision = 1 # loss
elsif p1able<p2able
@decision = 2 # win
end
end
end