update to latest 6.0 release

This commit is contained in:
infinitefusion
2023-11-12 21:45:07 -05:00
parent ba7ee9bae2
commit d3662c3f10
4980 changed files with 21185 additions and 317635 deletions

View File

@@ -322,6 +322,7 @@ class PokeBattle_Battler
return @pokemon.isFusion?()
end
# Returns the active types of this Pokémon. The array should not include the
# same type more than once, and should not include any invalid type numbers
# (e.g. -1).

View File

@@ -2,45 +2,45 @@ class PokeBattle_Battler
#=============================================================================
# Turn processing
#=============================================================================
def pbProcessTurn(choice,tryFlee=true)
def pbProcessTurn(choice, tryFlee = true)
return false if fainted?
# Wild roaming Pokémon always flee if possible
if tryFlee && @battle.wildBattle? && opposes? &&
@battle.rules["alwaysflee"] && @battle.pbCanRun?(@index)
@battle.rules["alwaysflee"] && @battle.pbCanRun?(@index)
pbBeginTurn(choice)
pbSEPlay("Battle flee")
@battle.pbDisplay(_INTL("{1} fled from battle!",pbThis))
@battle.pbDisplay(_INTL("{1} fled from battle!", pbThis))
@battle.decision = 3
pbEndTurn(choice)
return true
end
# Shift with the battler next to this one
if choice[0]==:Shift
if choice[0] == :Shift
idxOther = -1
case @battle.pbSideSize(@index)
when 2
idxOther = (@index+2)%4
idxOther = (@index + 2) % 4
when 3
if @index!=2 && @index!=3 # If not in middle spot already
idxOther = ((@index%2)==0) ? 2 : 3
if @index != 2 && @index != 3 # If not in middle spot already
idxOther = ((@index % 2) == 0) ? 2 : 3
end
end
if idxOther>=0
@battle.pbSwapBattlers(@index,idxOther)
if idxOther >= 0
@battle.pbSwapBattlers(@index, idxOther)
case @battle.pbSideSize(@index)
when 2
@battle.pbDisplay(_INTL("{1} moved across!",pbThis))
@battle.pbDisplay(_INTL("{1} moved across!", pbThis))
when 3
@battle.pbDisplay(_INTL("{1} moved to the center!",pbThis))
@battle.pbDisplay(_INTL("{1} moved to the center!", pbThis))
end
end
pbBeginTurn(choice)
pbCancelMoves
@lastRoundMoved = @battle.turnCount # Done something this round
@lastRoundMoved = @battle.turnCount # Done something this round
return true
end
# If this battler's action for this round wasn't "use a move"
if choice[0]!=:UseMove
if choice[0] != :UseMove
# Clean up effects that end at battler's turn
pbBeginTurn(choice)
pbEndTurn(choice)
@@ -56,8 +56,8 @@ class PokeBattle_Battler
end
# Use the move
PBDebug.log("[Move usage] #{pbThis} started using #{choice[2].name}")
PBDebug.logonerr{
pbUseMove(choice,choice[2]==@battle.struggle)
PBDebug.logonerr {
pbUseMove(choice, choice[2] == @battle.struggle)
}
@battle.pbJudge
# Update priority order
@@ -70,15 +70,15 @@ class PokeBattle_Battler
#=============================================================================
def pbBeginTurn(_choice)
# Cancel some lingering effects which only apply until the user next moves
@effects[PBEffects::BeakBlast] = false
@effects[PBEffects::BeakBlast] = false
@effects[PBEffects::DestinyBondPrevious] = @effects[PBEffects::DestinyBond]
@effects[PBEffects::DestinyBond] = false
@effects[PBEffects::Grudge] = false
@effects[PBEffects::MoveNext] = false
@effects[PBEffects::Quash] = 0
@effects[PBEffects::DestinyBond] = false
@effects[PBEffects::Grudge] = false
@effects[PBEffects::MoveNext] = false
@effects[PBEffects::Quash] = 0
# Encore's effect ends if the encored move is no longer available
if @effects[PBEffects::Encore]>0 && pbEncoredMoveIndex<0
@effects[PBEffects::Encore] = 0
if @effects[PBEffects::Encore] > 0 && pbEncoredMoveIndex < 0
@effects[PBEffects::Encore] = 0
@effects[PBEffects::EncoreMove] = nil
end
end
@@ -91,50 +91,50 @@ class PokeBattle_Battler
def pbCancelMoves(full_cancel = false)
# Outragers get confused anyway if they are disrupted during their final
# turn of using the move
if @effects[PBEffects::Outrage]==1 && pbCanConfuseSelf?(false) && !full_cancel
pbConfuse(_INTL("{1} became confused due to fatigue!",pbThis))
if @effects[PBEffects::Outrage] == 1 && pbCanConfuseSelf?(false) && !full_cancel
pbConfuse(_INTL("{1} became confused due to fatigue!", pbThis))
end
# Cancel usage of most multi-turn moves
@effects[PBEffects::TwoTurnAttack] = nil
@effects[PBEffects::Rollout] = 0
@effects[PBEffects::Outrage] = 0
@effects[PBEffects::Uproar] = 0
@effects[PBEffects::Bide] = 0
@effects[PBEffects::Rollout] = 0
@effects[PBEffects::Outrage] = 0
@effects[PBEffects::Uproar] = 0
@effects[PBEffects::Bide] = 0
@currentMove = nil
# Reset counters for moves which increase them when used in succession
@effects[PBEffects::FuryCutter] = 0
@effects[PBEffects::FuryCutter] = 0
end
def pbEndTurn(_choice)
@lastRoundMoved = @battle.turnCount # Done something this round
@lastRoundMoved = @battle.turnCount # Done something this round
if !@effects[PBEffects::ChoiceBand] &&
hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF])
hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF])
if @lastMoveUsed && pbHasMove?(@lastMoveUsed)
@effects[PBEffects::ChoiceBand] = @lastMoveUsed
elsif @lastRegularMoveUsed && pbHasMove?(@lastRegularMoveUsed)
@effects[PBEffects::ChoiceBand] = @lastRegularMoveUsed
end
end
@effects[PBEffects::BeakBlast] = false
@effects[PBEffects::Charge] = 0 if @effects[PBEffects::Charge]==1
@effects[PBEffects::BeakBlast] = false
@effects[PBEffects::Charge] = 0 if @effects[PBEffects::Charge] == 1
@effects[PBEffects::GemConsumed] = nil
@effects[PBEffects::ShellTrap] = false
@battle.eachBattler { |b| b.pbContinualAbilityChecks } # Trace, end primordial weathers
@effects[PBEffects::ShellTrap] = false
@battle.eachBattler { |b| b.pbContinualAbilityChecks } # Trace, end primordial weathers
end
def pbConfusionDamage(msg)
@damageState.reset
@damageState.initialHP = @hp
confusionMove = PokeBattle_Confusion.new(@battle,nil)
confusionMove.calcType = confusionMove.pbCalcType(self) # nil
@damageState.typeMod = confusionMove.pbCalcTypeMod(confusionMove.calcType,self,self) # 8
confusionMove.pbCheckDamageAbsorption(self,self)
confusionMove.pbCalcDamage(self,self)
confusionMove.pbReduceDamage(self,self)
confusionMove = PokeBattle_Confusion.new(@battle, nil)
confusionMove.calcType = confusionMove.pbCalcType(self) # nil
@damageState.typeMod = confusionMove.pbCalcTypeMod(confusionMove.calcType, self, self) # 8
confusionMove.pbCheckDamageAbsorption(self, self)
confusionMove.pbCalcDamage(self, self)
confusionMove.pbReduceDamage(self, self)
self.hp -= @damageState.hpLost
confusionMove.pbAnimateHitAndHPLost(self,[self])
@battle.pbDisplay(msg) # "It hurt itself in its confusion!"
confusionMove.pbRecordDamageLost(self,self)
confusionMove.pbAnimateHitAndHPLost(self, [self])
@battle.pbDisplay(msg) # "It hurt itself in its confusion!"
confusionMove.pbRecordDamageLost(self, self)
confusionMove.pbEndureKOMessage(self)
pbFaint if fainted?
pbItemHPHealCheck
@@ -144,74 +144,74 @@ class PokeBattle_Battler
# Simple "use move" method, used when a move calls another move and for Future
# Sight's attack
#=============================================================================
def pbUseMoveSimple(moveID,target=-1,idxMove=-1,specialUsage=true)
def pbUseMoveSimple(moveID, target = -1, idxMove = -1, specialUsage = true)
choice = []
choice[0] = :UseMove # "Use move"
choice[1] = idxMove # Index of move to be used in user's moveset
if idxMove>=0
choice[0] = :UseMove # "Use move"
choice[1] = idxMove # Index of move to be used in user's moveset
if idxMove >= 0
choice[2] = @moves[idxMove]
else
choice[2] = PokeBattle_Move.from_pokemon_move(@battle, Pokemon::Move.new(moveID))
choice[2].pp = -1
end
choice[3] = target # Target (-1 means no target yet)
choice[3] = target # Target (-1 means no target yet)
PBDebug.log("[Move usage] #{pbThis} started using the called/simple move #{choice[2].name}")
pbUseMove(choice,specialUsage)
pbUseMove(choice, specialUsage)
end
#=============================================================================
# Master "use move" method
#=============================================================================
def pbUseMove(choice,specialUsage=false)
def pbUseMove(choice, specialUsage = false)
# NOTE: This is intentionally determined before a multi-turn attack can
# set specialUsage to true.
skipAccuracyCheck = (specialUsage && choice[2]!=@battle.struggle)
skipAccuracyCheck = (specialUsage && choice[2] != @battle.struggle)
# Start using the move
pbBeginTurn(choice)
# Force the use of certain moves if they're already being used
if usingMultiTurnAttack?
choice[2] = PokeBattle_Move.from_pokemon_move(@battle, Pokemon::Move.new(@currentMove))
specialUsage = true
elsif @effects[PBEffects::Encore]>0 && choice[1]>=0 &&
@battle.pbCanShowCommands?(@index)
elsif @effects[PBEffects::Encore] > 0 && choice[1] >= 0 &&
@battle.pbCanShowCommands?(@index)
idxEncoredMove = pbEncoredMoveIndex
if idxEncoredMove>=0 && @battle.pbCanChooseMove?(@index,idxEncoredMove,false)
if choice[1]!=idxEncoredMove # Change move if battler was Encored mid-round
if idxEncoredMove >= 0 && @battle.pbCanChooseMove?(@index, idxEncoredMove, false)
if choice[1] != idxEncoredMove # Change move if battler was Encored mid-round
choice[1] = idxEncoredMove
choice[2] = @moves[idxEncoredMove]
choice[3] = -1 # No target chosen
choice[3] = -1 # No target chosen
end
end
end
# Labels the move being used as "move"
move = choice[2]
return if !move # if move was not chosen somehow
return if !move # if move was not chosen somehow
# Try to use the move (inc. disobedience)
@lastMoveFailed = false
if !pbTryUseMove(choice,move,specialUsage,skipAccuracyCheck)
@lastMoveUsed = nil
if !pbTryUseMove(choice, move, specialUsage, skipAccuracyCheck)
@lastMoveUsed = nil
@lastMoveUsedType = nil
if !specialUsage
@lastRegularMoveUsed = nil
@lastRegularMoveUsed = nil
@lastRegularMoveTarget = -1
end
@battle.pbGainExp # In case self is KO'd due to confusion
@battle.pbGainExp # In case self is KO'd due to confusion
pbCancelMoves
pbEndTurn(choice)
return
end
move = choice[2] # In case disobedience changed the move to be used
return if !move # if move was not chosen somehow
move = choice[2] # In case disobedience changed the move to be used
return if !move # if move was not chosen somehow
# Subtract PP
if !specialUsage
if !pbReducePP(move)
@battle.pbDisplay(_INTL("{1} used {2}!",pbThis,move.name))
@battle.pbDisplay(_INTL("{1} used {2}!", pbThis, move.name))
@battle.pbDisplay(_INTL("But there was no PP left for the move!"))
@lastMoveUsed = nil
@lastMoveUsedType = nil
@lastRegularMoveUsed = nil
@lastMoveUsed = nil
@lastMoveUsedType = nil
@lastRegularMoveUsed = nil
@lastRegularMoveTarget = -1
@lastMoveFailed = true
@lastMoveFailed = true
pbCancelMoves
pbEndTurn(choice)
return
@@ -220,11 +220,11 @@ class PokeBattle_Battler
# Stance Change
if self.ability == :STANCECHANGE
if move.damagingMove?
user = pbFindUser(choice,move)
stanceChangeEffect(user,true)
user = pbFindUser(choice, move)
stanceChangeEffect(user, true)
elsif move.id == :KINGSSHIELD
user = pbFindUser(choice,move)
stanceChangeEffect(user,false)
user = pbFindUser(choice, move)
stanceChangeEffect(user, false)
end
end
# Calculate the move's type during this usage
@@ -237,34 +237,34 @@ class PokeBattle_Battler
@effects[PBEffects::TwoTurnAttack] = move.id
@currentMove = move.id
else
@effects[PBEffects::TwoTurnAttack] = nil # Cancel use of two-turn attack
@effects[PBEffects::TwoTurnAttack] = nil # Cancel use of two-turn attack
end
# Add to counters for moves which increase them when used in succession
move.pbChangeUsageCounters(self,specialUsage)
move.pbChangeUsageCounters(self, specialUsage)
# Charge up Metronome item
if hasActiveItem?(:METRONOME) && !move.callsAnotherMove?
if @lastMoveUsed && @lastMoveUsed==move.id && !@lastMoveFailed
if @lastMoveUsed && @lastMoveUsed == move.id && !@lastMoveFailed
@effects[PBEffects::Metronome] += 1
else
@effects[PBEffects::Metronome] = 0
end
end
# Record move as having been used
@lastMoveUsed = move.id
@lastMoveUsedType = move.calcType # For Conversion 2
@lastMoveUsed = move.id
@lastMoveUsedType = move.calcType # For Conversion 2
if !specialUsage
@lastRegularMoveUsed = move.id # For Disable, Encore, Instruct, Mimic, Mirror Move, Sketch, Spite
@lastRegularMoveTarget = choice[3] # For Instruct (remembering original target is fine)
@movesUsed.push(move.id) if !@movesUsed.include?(move.id) # For Last Resort
@lastRegularMoveUsed = move.id # For Disable, Encore, Instruct, Mimic, Mirror Move, Sketch, Spite
@lastRegularMoveTarget = choice[3] # For Instruct (remembering original target is fine)
@movesUsed.push(move.id) if !@movesUsed.include?(move.id) # For Last Resort
end
@battle.lastMoveUsed = move.id # For Copycat
@battle.lastMoveUser = @index # For "self KO" battle clause to avoid draws
@battle.successStates[@index].useState = 1 # Battle Arena - assume failure
@battle.lastMoveUsed = move.id # For Copycat
@battle.lastMoveUser = @index # For "self KO" battle clause to avoid draws
@battle.successStates[@index].useState = 1 # Battle Arena - assume failure
# Find the default user (self or Snatcher) and target(s)
user = pbFindUser(choice,move)
user = pbChangeUser(choice,move,user)
targets = pbFindTargets(choice,move,user)
targets = pbChangeTargets(move,user,targets)
user = pbFindUser(choice, move)
user = pbChangeUser(choice, move, user)
targets = pbFindTargets(choice, move, user)
targets = pbChangeTargets(move, user, targets)
# Pressure
if !specialUsage
targets.each do |b|
@@ -283,10 +283,10 @@ class PokeBattle_Battler
# Dazzling/Queenly Majesty make the move fail here
@battle.pbPriority(true).each do |b|
next if !b || !b.abilityActive?
if BattleHandlers.triggerMoveBlockingAbility(b.ability,b,user,targets,move,@battle)
@battle.pbDisplayBrief(_INTL("{1} used {2}!",user.pbThis,move.name))
if BattleHandlers.triggerMoveBlockingAbility(b.ability, b, user, targets, move, @battle)
@battle.pbDisplayBrief(_INTL("{1} used {2}!", user.pbThis, move.name))
@battle.pbShowAbilitySplash(b)
@battle.pbDisplay(_INTL("{1} cannot use {2}!",user.pbThis,move.name))
@battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, move.name))
@battle.pbHideAbilitySplash(b)
user.lastMoveFailed = true
pbCancelMoves
@@ -302,12 +302,12 @@ class PokeBattle_Battler
move.pbDisplayUseMessage(self)
# Snatch's message (user is the new user, self is the original user)
if move.snatched
@lastMoveFailed = true # Intentionally applies to self, not user
@battle.pbDisplay(_INTL("{1} snatched {2}'s move!",user.pbThis,pbThis(true)))
@lastMoveFailed = true # Intentionally applies to self, not user
@battle.pbDisplay(_INTL("{1} snatched {2}'s move!", user.pbThis, pbThis(true)))
end
# "But it failed!" checks
if move.pbMoveFailed?(user,targets)
PBDebug.log(sprintf("[Move failed] In function code %s's def pbMoveFailed?",move.function))
if move.pbMoveFailed?(user, targets)
PBDebug.log(sprintf("[Move failed] In function code %s's def pbMoveFailed?", move.function))
user.lastMoveFailed = true
pbCancelMoves
pbEndTurn(choice)
@@ -315,22 +315,22 @@ class PokeBattle_Battler
end
# Perform set-up actions and display messages
# Messages include Magnitude's number and Pledge moves' "it's a combo!"
move.pbOnStartUse(user,targets)
move.pbOnStartUse(user, targets)
# Self-thawing due to the move
if user.status == :FROZEN && move.thawsUser?
user.pbCureStatus(false)
@battle.pbDisplay(_INTL("{1} melted the ice!",user.pbThis))
@battle.pbDisplay(_INTL("{1} melted the ice!", user.pbThis))
end
# Powder
if user.effects[PBEffects::Powder] && move.calcType == :FIRE
@battle.pbCommonAnimation("Powder",user)
@battle.pbCommonAnimation("Powder", user)
@battle.pbDisplay(_INTL("When the flame touched the powder on the Pokémon, it exploded!"))
user.lastMoveFailed = true
if ![:Rain, :HeavyRain].include?(@battle.pbWeather) && user.takesIndirectDamage?
oldHP = user.hp
user.pbReduceHP((user.totalhp/4.0).round,false)
user.pbReduceHP((user.totalhp / 4.0).round, false)
user.pbFaint if user.fainted?
@battle.pbGainExp # In case user is KO'd by this
@battle.pbGainExp # In case user is KO'd by this
user.pbItemHPHealCheck
if user.pbAbilitiesOnDamageTaken(oldHP)
user.pbEffectsOnSwitchIn(true)
@@ -367,20 +367,20 @@ class PokeBattle_Battler
@battle.pbShowAbilitySplash(user)
user.pbChangeTypes(move.calcType)
typeName = GameData::Type.get(move.calcType).name
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!",user.pbThis,typeName))
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!", user.pbThis, typeName))
@battle.pbHideAbilitySplash(user)
# NOTE: The GF games say that if Curse is used by a non-Ghost-type
# Pokémon which becomes Ghost-type because of Protean, it should
# target and curse itself. I think this is silly, so I'm making it
# choose a random opponent to curse instead.
if move.function=="10D" && targets.length==0 # Curse
if move.function == "10D" && targets.length == 0 # Curse
choice[3] = -1
targets = pbFindTargets(choice,move,user)
targets = pbFindTargets(choice, move, user)
end
end
end
#---------------------------------------------------------------------------
magicCoater = -1
magicCoater = -1
magicBouncer = -1
if targets.length == 0 && move.pbTarget(user).num_targets > 0 && !move.worksWithNoTargets?
# def pbFindTargets should have found a target(s), but it didn't because
@@ -388,18 +388,19 @@ class PokeBattle_Battler
# All target types except: None, User, UserSide, FoeSide, BothSides
@battle.pbDisplay(_INTL("But there was no target..."))
user.lastMoveFailed = true
else # We have targets, or move doesn't use targets
else
# We have targets, or move doesn't use targets
# Reset whole damage state, perform various success checks (not accuracy)
user.initialHP = user.hp
targets.each do |b|
b.damageState.reset
b.damageState.initialHP = b.hp
if !pbSuccessCheckAgainstTarget(move,user,b)
if !pbSuccessCheckAgainstTarget(move, user, b)
b.damageState.unaffected = true
end
end
# Magic Coat/Magic Bounce checks (for moves which don't target Pokémon)
if targets.length==0 && move.canMagicCoat?
if targets.length == 0 && move.canMagicCoat?
@battle.pbPriority(true).each do |b|
next if b.fainted? || !b.opposes?(user)
next if b.semiInvulnerable?
@@ -408,7 +409,7 @@ class PokeBattle_Battler
b.effects[PBEffects::MagicCoat] = false
break
elsif b.hasActiveAbility?(:MAGICBOUNCE) && !@battle.moldBreaker &&
!b.effects[PBEffects::MagicBounce]
!b.effects[PBEffects::MagicBounce]
magicBouncer = b.index
b.effects[PBEffects::MagicBounce] = true
break
@@ -416,14 +417,14 @@ class PokeBattle_Battler
end
end
# Get the number of hits
numHits = move.pbNumHits(user,targets)
numHits = move.pbNumHits(user, targets)
# Process each hit in turn
realNumHits = 0
for i in 0...numHits
break if magicCoater>=0 || magicBouncer>=0
success = pbProcessMoveHit(move,user,targets,i,skipAccuracyCheck)
break if magicCoater >= 0 || magicBouncer >= 0
success = pbProcessMoveHit(move, user, targets, i, skipAccuracyCheck)
if !success
if i==0 && targets.length>0
if i == 0 && targets.length > 0
hasFailed = false
targets.each do |t|
next if t.damageState.protected
@@ -440,11 +441,11 @@ class PokeBattle_Battler
# NOTE: If a multi-hit move becomes disabled partway through doing those
# hits (e.g. by Cursed Body), the rest of the hits continue as
# normal.
break if !targets.any? { |t| !t.fainted? } # All targets are fainted
break if !targets.any? { |t| !t.fainted? } # All targets are fainted
end
# Battle Arena only - attack is successful
@battle.successStates[user.index].useState = 2
if targets.length>0
if targets.length > 0
@battle.successStates[user.index].typeMod = 0
targets.each do |b|
next if b.damageState.unaffected
@@ -454,17 +455,17 @@ class PokeBattle_Battler
# Effectiveness message for multi-hit moves
# NOTE: No move is both multi-hit and multi-target, and the messages below
# aren't quite right for such a hypothetical move.
if numHits>1
if numHits > 1
if move.damagingMove?
targets.each do |b|
next if b.damageState.unaffected || b.damageState.substitute
move.pbEffectivenessMessage(user,b,targets.length)
move.pbEffectivenessMessage(user, b, targets.length)
end
end
if realNumHits==1
if realNumHits == 1
@battle.pbDisplay(_INTL("Hit 1 time!"))
elsif realNumHits>1
@battle.pbDisplay(_INTL("Hit {1} times!",realNumHits))
elsif realNumHits > 1
@battle.pbDisplay(_INTL("Hit {1} times!", realNumHits))
end
end
# Magic Coat's bouncing back (move has targets)
@@ -472,38 +473,38 @@ class PokeBattle_Battler
next if b.fainted?
next if !b.damageState.magicCoat && !b.damageState.magicBounce
@battle.pbShowAbilitySplash(b) if b.damageState.magicBounce
@battle.pbDisplay(_INTL("{1} bounced the {2} back!",b.pbThis,move.name))
@battle.pbDisplay(_INTL("{1} bounced the {2} back!", b.pbThis, move.name))
@battle.pbHideAbilitySplash(b) if b.damageState.magicBounce
newChoice = choice.clone
newChoice[3] = user.index
newTargets = pbFindTargets(newChoice,move,b)
newTargets = pbChangeTargets(move,b,newTargets)
success = pbProcessMoveHit(move,b,newTargets,0,false)
newTargets = pbFindTargets(newChoice, move, b)
newTargets = pbChangeTargets(move, b, newTargets)
success = pbProcessMoveHit(move, b, newTargets, 0, false)
b.lastMoveFailed = true if !success
targets.each { |otherB| otherB.pbFaint if otherB && otherB.fainted? }
user.pbFaint if user.fainted?
end
# Magic Coat's bouncing back (move has no targets)
if magicCoater>=0 || magicBouncer>=0
mc = @battle.battlers[(magicCoater>=0) ? magicCoater : magicBouncer]
if magicCoater >= 0 || magicBouncer >= 0
mc = @battle.battlers[(magicCoater >= 0) ? magicCoater : magicBouncer]
if !mc.fainted?
user.lastMoveFailed = true
@battle.pbShowAbilitySplash(mc) if magicBouncer>=0
@battle.pbDisplay(_INTL("{1} bounced the {2} back!",mc.pbThis,move.name))
@battle.pbHideAbilitySplash(mc) if magicBouncer>=0
success = pbProcessMoveHit(move,mc,[],0,false)
@battle.pbShowAbilitySplash(mc) if magicBouncer >= 0
@battle.pbDisplay(_INTL("{1} bounced the {2} back!", mc.pbThis, move.name))
@battle.pbHideAbilitySplash(mc) if magicBouncer >= 0
success = pbProcessMoveHit(move, mc, [], 0, false)
mc.lastMoveFailed = true if !success
targets.each { |b| b.pbFaint if b && b.fainted? }
user.pbFaint if user.fainted?
end
end
# Move-specific effects after all hits
targets.each { |b| move.pbEffectAfterAllHits(user,b) }
targets.each { |b| move.pbEffectAfterAllHits(user, b) }
# Faint if 0 HP
targets.each { |b| b.pbFaint if b && b.fainted? }
user.pbFaint if user.fainted?
# External/general effects after all hits. Eject Button, Shell Bell, etc.
pbEffectsAfterMove(user,targets,move,realNumHits)
pbEffectsAfterMove(user, targets, move, realNumHits)
end
# End effect of Mold Breaker
@battle.moldBreaker = false
@@ -512,7 +513,7 @@ class PokeBattle_Battler
# Battle Arena only - update skills
@battle.eachBattler { |b| @battle.successStates[b.index].updateSkill }
# Shadow Pokémon triggering Hyper Mode
pbHyperMode if @battle.choices[@index][0]!=:None # Not if self is replaced
pbHyperMode if @battle.choices[@index][0] != :None # Not if self is replaced
# End of move usage
pbEndTurn(choice)
# Instruct
@@ -520,102 +521,129 @@ class PokeBattle_Battler
next if !b.effects[PBEffects::Instruct] || !b.lastMoveUsed
b.effects[PBEffects::Instruct] = false
idxMove = -1
b.eachMoveWithIndex { |m,i| idxMove = i if m.id==b.lastMoveUsed }
next if idxMove<0
b.eachMoveWithIndex { |m, i| idxMove = i if m.id == b.lastMoveUsed }
next if idxMove < 0
oldLastRoundMoved = b.lastRoundMoved
@battle.pbDisplay(_INTL("{1} used the move instructed by {2}!",b.pbThis,user.pbThis(true)))
PBDebug.logonerr{
@battle.pbDisplay(_INTL("{1} used the move instructed by {2}!", b.pbThis, user.pbThis(true)))
PBDebug.logonerr {
b.effects[PBEffects::Instructed] = true
b.pbUseMoveSimple(b.lastMoveUsed,b.lastRegularMoveTarget,idxMove,false)
b.pbUseMoveSimple(b.lastMoveUsed, b.lastRegularMoveTarget, idxMove, false)
b.effects[PBEffects::Instructed] = false
}
b.lastRoundMoved = oldLastRoundMoved
@battle.pbJudge
return if @battle.decision>0
return if @battle.decision > 0
end
# Dancer
if !@effects[PBEffects::Dancer] && !user.lastMoveFailed && realNumHits>0 &&
!move.snatched && magicCoater<0 && @battle.pbCheckGlobalAbility(:DANCER) &&
move.danceMove?
if !@effects[PBEffects::Dancer] && !user.lastMoveFailed && realNumHits > 0 &&
!move.snatched && magicCoater < 0 && @battle.pbCheckGlobalAbility(:DANCER) &&
move.danceMove?
dancers = []
@battle.pbPriority(true).each do |b|
dancers.push(b) if b.index!=user.index && b.hasActiveAbility?(:DANCER)
dancers.push(b) if b.index != user.index && b.hasActiveAbility?(:DANCER)
end
while dancers.length>0
while dancers.length > 0
nextUser = dancers.pop
oldLastRoundMoved = nextUser.lastRoundMoved
# NOTE: Petal Dance being used because of Dancer shouldn't lock the
# Dancer into using that move, and shouldn't contribute to its
# turn counter if it's already locked into Petal Dance.
oldOutrage = nextUser.effects[PBEffects::Outrage]
nextUser.effects[PBEffects::Outrage] += 1 if nextUser.effects[PBEffects::Outrage]>0
nextUser.effects[PBEffects::Outrage] += 1 if nextUser.effects[PBEffects::Outrage] > 0
oldCurrentMove = nextUser.currentMove
preTarget = choice[3]
preTarget = user.index if nextUser.opposes?(user) || !nextUser.opposes?(preTarget)
@battle.pbShowAbilitySplash(nextUser,true)
@battle.pbShowAbilitySplash(nextUser, true)
@battle.pbHideAbilitySplash(nextUser)
if !PokeBattle_SceneConstants::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} kept the dance going with {2}!",
nextUser.pbThis,nextUser.abilityName))
nextUser.pbThis, nextUser.abilityName))
end
PBDebug.logonerr{
PBDebug.logonerr {
nextUser.effects[PBEffects::Dancer] = true
nextUser.pbUseMoveSimple(move.id,preTarget)
nextUser.pbUseMoveSimple(move.id, preTarget)
nextUser.effects[PBEffects::Dancer] = false
}
nextUser.lastRoundMoved = oldLastRoundMoved
nextUser.effects[PBEffects::Outrage] = oldOutrage
nextUser.currentMove = oldCurrentMove
@battle.pbJudge
return if @battle.decision>0
return if @battle.decision > 0
end
end
end
def stanceChangeEffect(user,attacking=false)
inSwordForm = user.effects[PBEffects::PowerTrick]
def stanceChangeEffect(user, attacking = false)
inSwordForm = user.effects[PBEffects::PowerTrick]
if !inSwordForm && attacking
user.effects[PBEffects::PowerTrick] = true
user.attack,user.defense = user.defense,user.attack
user.spatk,user.spdef = user.spdef,user.spatk
user.attack, user.defense = user.defense, user.attack
user.spatk, user.spdef = user.spdef, user.spatk
@battle.pbDisplay(_INTL("{1} changed to Sword Mode!",pbThis))
#changeForm(1,:AEGISLASH)
@battle.pbDisplay(_INTL("{1} changed to Sword Mode!", pbThis))
elsif inSwordForm && !attacking
user.effects[PBEffects::PowerTrick] = false
user.attack,user.defense = user.defense,user.attack
user.spatk,user.spdef = user.spdef,user.spatk
@battle.pbDisplay(_INTL("{1} changed to Shield Mode!",pbThis))
user.effects[PBEffects::PowerTrick] = false
user.attack, user.defense = user.defense, user.attack
user.spatk, user.spdef = user.spdef, user.spatk
#user.changeForm(nil,:AEGISLASH)
@battle.pbDisplay(_INTL("{1} changed to Shield Mode!", pbThis))
end
end
def changeForm(newForm, formChangingSpecies, animation = "UltraBurst2")
spriteform_body = newForm if @pokemon.hasBodyOf?(formChangingSpecies)
spriteform_head = newForm if @pokemon.hasHeadOf?(formChangingSpecies)
if self.isFusion?
current_form_has_custom = customSpriteExists(@pokemon.species)
new_form_has_custom = customSpriteExistsForm(@pokemon.species, spriteform_head, spriteform_body)
should_change_sprite = (current_form_has_custom && new_form_has_custom) || !current_form_has_custom
else
should_change_sprite=true
end
if should_change_sprite
@pokemon.spriteform_body = spriteform_body
@pokemon.spriteform_head = spriteform_head
end
@battle.scene.pbChangePokemon(self, @pokemon)
@battle.scene.pbCommonAnimation(animation, self)
@battle.scene.pbRefreshOne(@index)
end
#=============================================================================
# Attack a single target
#=============================================================================
def pbProcessMoveHit(move,user,targets,hitNum,skipAccuracyCheck)
def pbProcessMoveHit(move, user, targets, hitNum, skipAccuracyCheck)
return false if user.fainted?
# For two-turn attacks being used in a single turn
move.pbInitialEffect(user,targets,hitNum)
numTargets = 0 # Number of targets that are affected by this hit
move.pbInitialEffect(user, targets, hitNum)
numTargets = 0 # Number of targets that are affected by this hit
targets.each { |b| b.damageState.resetPerHit }
# Count a hit for Parental Bond (if it applies)
user.effects[PBEffects::ParentalBond] -= 1 if user.effects[PBEffects::ParentalBond]>0
user.effects[PBEffects::ParentalBond] -= 1 if user.effects[PBEffects::ParentalBond] > 0
# Accuracy check (accuracy/evasion calc)
if hitNum==0 || move.successCheckPerHit?
if hitNum == 0 || move.successCheckPerHit?
targets.each do |b|
next if b.damageState.unaffected
if pbSuccessCheckPerHit(move,user,b,skipAccuracyCheck)
if pbSuccessCheckPerHit(move, user, b, skipAccuracyCheck)
numTargets += 1
else
b.damageState.missed = true
b.damageState.missed = true
b.damageState.unaffected = true
end
end
# If failed against all targets
if targets.length>0 && numTargets==0 && !move.worksWithNoTargets?
if targets.length > 0 && numTargets == 0 && !move.worksWithNoTargets?
targets.each do |b|
next if !b.damageState.missed || b.damageState.magicCoat
pbMissMessage(move,user,b)
pbMissMessage(move, user, b)
end
move.pbCrashDamage(user)
user.pbItemHPHealCheck
@@ -630,30 +658,30 @@ class PokeBattle_Battler
targets.each do |b|
next if b.damageState.unaffected
# Check whether Substitute/Disguise will absorb the damage
move.pbCheckDamageAbsorption(user,b)
move.pbCheckDamageAbsorption(user, b)
# Calculate the damage against b
# pbCalcDamage shows the "eat berry" animation for SE-weakening
# berries, although the message about it comes after the additional
# effect below
move.pbCalcDamage(user,b,targets.length) # Stored in damageState.calcDamage
move.pbCalcDamage(user, b, targets.length) # Stored in damageState.calcDamage
# Lessen damage dealt because of False Swipe/Endure/etc.
move.pbReduceDamage(user,b) # Stored in damageState.hpLost
move.pbReduceDamage(user, b) # Stored in damageState.hpLost
end
end
# Show move animation (for this hit)
move.pbShowAnimation(move.id,user,targets,hitNum)
move.pbShowAnimation(move.id, user, targets, hitNum)
# Type-boosting Gem consume animation/message
if user.effects[PBEffects::GemConsumed] && hitNum==0
if user.effects[PBEffects::GemConsumed] && hitNum == 0
# NOTE: The consume animation and message for Gems are shown now, but the
# actual removal of the item happens in def pbEffectsAfterMove.
@battle.pbCommonAnimation("UseItem",user)
@battle.pbCommonAnimation("UseItem", user)
@battle.pbDisplay(_INTL("The {1} strengthened {2}'s power!",
GameData::Item.get(user.effects[PBEffects::GemConsumed]).name,move.name))
GameData::Item.get(user.effects[PBEffects::GemConsumed]).name, move.name))
end
# Messages about missed target(s) (relevant for multi-target moves only)
targets.each do |b|
next if !b.damageState.missed
pbMissMessage(move,user,b)
pbMissMessage(move, user, b)
end
# Deal the damage (to all allies first simultaneously, then all foes
# simultaneously)
@@ -664,29 +692,29 @@ class PokeBattle_Battler
move.pbInflictHPDamage(b)
end
# Animate the hit flashing and HP bar changes
move.pbAnimateHitAndHPLost(user,targets)
move.pbAnimateHitAndHPLost(user, targets)
end
# Self-Destruct/Explosion's damaging and fainting of user
move.pbSelfKO(user) if hitNum==0
move.pbSelfKO(user) if hitNum == 0
user.pbFaint if user.fainted?
if move.pbDamagingMove?
targets.each do |b|
next if b.damageState.unaffected
# NOTE: This method is also used for the OKHO special message.
move.pbHitEffectivenessMessages(user,b,targets.length)
move.pbHitEffectivenessMessages(user, b, targets.length)
# Record data about the hit for various effects' purposes
move.pbRecordDamageLost(user,b)
move.pbRecordDamageLost(user, b)
end
# Close Combat/Superpower's stat-lowering, Flame Burst's splash damage,
# and Incinerate's berry destruction
targets.each do |b|
next if b.damageState.unaffected
move.pbEffectWhenDealingDamage(user,b)
move.pbEffectWhenDealingDamage(user, b)
end
# Ability/item effects such as Static/Rocky Helmet, and Grudge, etc.
targets.each do |b|
next if b.damageState.unaffected
pbEffectsOnMakingHit(move,user,b)
pbEffectsOnMakingHit(move, user, b)
end
# Disguise/Endure/Sturdy/Focus Sash/Focus Band messages
targets.each do |b|
@@ -700,11 +728,11 @@ class PokeBattle_Battler
# because Flame Burst's splash damage affects non-targets)
@battle.pbPriority(true).each { |b| b.pbFaint if b && b.fainted? }
end
@battle.pbJudgeCheckpoint(user,move)
@battle.pbJudgeCheckpoint(user, move)
# Main effect (recoil/drain, etc.)
targets.each do |b|
next if b.damageState.unaffected
move.pbEffectAgainstTarget(user,b)
move.pbEffectAgainstTarget(user, b)
end
move.pbEffectGeneral(user)
targets.each { |b| b.pbFaint if b && b.fainted? }
@@ -712,21 +740,21 @@ class PokeBattle_Battler
# Additional effect
if !user.hasActiveAbility?(:SHEERFORCE)
targets.each do |b|
next if b.damageState.calcDamage==0
chance = move.pbAdditionalEffectChance(user,b)
next if chance<=0
if @battle.pbRandom(100)<chance
move.pbAdditionalEffect(user,b)
next if b.damageState.calcDamage == 0
chance = move.pbAdditionalEffectChance(user, b)
next if chance <= 0
if @battle.pbRandom(100) < chance
move.pbAdditionalEffect(user, b)
end
end
end
# Make the target flinch (because of an item/ability)
targets.each do |b|
next if b.fainted?
next if b.damageState.calcDamage==0 || b.damageState.substitute
chance = move.pbFlinchChance(user,b)
next if chance<=0
if @battle.pbRandom(100)<chance
next if b.damageState.calcDamage == 0 || b.damageState.substitute
chance = move.pbFlinchChance(user, b)
next if chance <= 0
if @battle.pbRandom(100) < chance
PBDebug.log("[Item/ability triggered] #{user.pbThis}'s King's Rock/Razor Fang or Stench")
b.pbFlinch(user)
end
@@ -738,7 +766,7 @@ class PokeBattle_Battler
targets.each do |b|
next if b.damageState.unaffected
next if !b.damageState.berryWeakened
@battle.pbDisplay(_INTL("The {1} weakened the damage to {2}!",b.itemName,b.pbThis(true)))
@battle.pbDisplay(_INTL("The {1} weakened the damage to {2}!", b.itemName, b.pbThis(true)))
b.pbConsumeItem
end
targets.each { |b| b.pbFaint if b && b.fainted? }

File diff suppressed because it is too large Load Diff

View File

@@ -515,6 +515,8 @@ class PokeBattle_Battle
next if !pkmn
@peer.pbOnLeavingBattle(self,pkmn,@usedInBattle[0][i],true) # Reset form
pkmn.item = @initialItems[0][i]
pkmn.spriteform_head=nil
pkmn.spriteform_body=nil
end
return @decision
end

View File

@@ -89,6 +89,7 @@ class PokeBattle_Battle
end
end
def pbGainExpOne(idxParty, defeatedBattler, numPartic, expShare, expAll, showMessages = true)
pkmn = pbParty(0)[idxParty] # The Pokémon gaining EVs from defeatedBattler
growth_rate = pkmn.growth_rate
@@ -153,8 +154,15 @@ class PokeBattle_Battle
end
exp = i if i >= 0
# Make sure Exp doesn't exceed the maximum
exp = 0 if $PokemonSystem.level_caps==1 && pokemonExceedsLevelCap(pkmn)
expFinal = growth_rate.add_exp(pkmn.exp, exp)
expGained = expFinal - pkmn.exp
return if expGained <= 0
# "Exp gained" message
if showMessages
@@ -166,11 +174,14 @@ class PokeBattle_Battle
end
curLevel = pkmn.level
newLevel = growth_rate.level_from_exp(expFinal)
dontAnimate=false
if newLevel < curLevel
debugInfo = "Levels: #{curLevel}->#{newLevel} | Exp: #{pkmn.exp}->#{expFinal} | gain: #{expGained}"
raise RuntimeError.new(
_INTL("{1}'s new level is less than its\r\ncurrent level, which shouldn't happen.\r\n[Debug: {2}]",
pkmn.name, debugInfo))
dontAnimate = true
# debugInfo = "Levels: #{curLevel}->#{newLevel} | Exp: #{pkmn.exp}->#{expFinal} | gain: #{expGained}"
# raise RuntimeError.new(
# echoln _INTL("{1}'s new level is less than its\r\ncurrent level, which shouldn't happen.\r\n[Debug: {2}]",
# pkmn.name, debugInfo)
pbDisplayPaused(_INTL("{1}'s growth rate has changed to '{2}''. Its level will be adjusted to reflect its current exp.", pkmn.name, pkmn.growth_rate.real_name))
end
# Give Exp
if pkmn.shadowPokemon?
@@ -187,6 +198,8 @@ class PokeBattle_Battle
tempExp2 = (levelMaxExp < expFinal) ? levelMaxExp : expFinal
pkmn.exp = tempExp2
if pkmn.isFusion?
if pkmn.exp_gained_since_fused == nil
pkmn.exp_gained_since_fused = expGained
@@ -195,7 +208,9 @@ class PokeBattle_Battle
end
end
@scene.pbEXPBar(battler, levelMinExp, levelMaxExp, tempExp1, tempExp2)
@scene.pbEXPBar(battler, levelMinExp, levelMaxExp, tempExp1, tempExp2) if !dontAnimate
tempExp1 = tempExp2
curLevel += 1
if curLevel > newLevel
@@ -225,6 +240,8 @@ class PokeBattle_Battle
oldSpAtk, oldSpDef, oldSpeed)
end
echoln "256"
# Learn all moves learned at this level
moveList = pkmn.getMoveList
moveList.each { |m| pbLearnMove(idxParty, m[1]) if m[0] == curLevel }

View File

@@ -79,12 +79,12 @@ class PokeBattle_AI
# For switching. Determines the effectiveness of a potential switch-in against
# an opposing battler.
def pbCalcTypeModPokemon(battlerThis,_battlerOther)
def pbCalcTypeModPokemon(battlerThis,target)
mod1 = Effectiveness.calculate(battlerThis.type1,target.type1,target.type2)
mod2 = Effectiveness::NORMAL_EFFECTIVE
if battlerThis.type1!=battlerThis.type2
mod2 = Effectiveness.calculate(battlerThis.type2,target.type1,target.type2)
mod2 = mod2.to_f / Effectivenesss::NORMAL_EFFECTIVE
mod2 = mod2.to_f / Effectiveness::NORMAL_EFFECTIVE
end
return mod1*mod2
end

View File

@@ -90,6 +90,7 @@ module PokeBattle_BallAnimationMixin
if !pbResolveBitmap(file_path)
file_path = sprintf("Graphics/Battle animations/ball_%02d", pbGetBallType(poke_ball).id_number)
end
echoln file_path
ball = addNewSprite(ballX, ballY, file_path, PictureOrigin::Center)
@ballSprite = @pictureSprites.last
if @ballSprite.bitmap.width >= @ballSprite.bitmap.height

View File

@@ -324,7 +324,7 @@ class PokeBattle_Scene
pkmnSprite.setPokemonBitmap(pkmn,back)
pkmnSprite.mirror=true if back
# Set visibility of battler's shadow
shadowSprite.visible = pkmn.species_data.shows_shadow? if shadowSprite && !back
shadowSprite.visible = true#pkmn.species_data.shows_shadow? if shadowSprite #&& !back
end
def pbResetMoveIndex(idxBattler)

View File

@@ -3,21 +3,21 @@ class PokeBattle_Scene
# Create the battle scene and its elements
#=============================================================================
def initialize
@battle = nil
@abortable = false
@aborted = false
@battleEnd = false
@animations = []
@battle = nil
@abortable = false
@aborted = false
@battleEnd = false
@animations = []
@frameCounter = 0
end
# Called whenever the battle begins.
def pbStartBattle(battle)
@battle = battle
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
@battle = battle
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@lastCmd = Array.new(@battle.battlers.length,0)
@lastMove = Array.new(@battle.battlers.length,0)
@lastCmd = Array.new(@battle.battlers.length, 0)
@lastMove = Array.new(@battle.battlers.length, 0)
pbInitSprites
pbBattleIntroAnimation
end
@@ -27,178 +27,186 @@ class PokeBattle_Scene
# The background image and each side's base graphic
pbCreateBackdropSprites
# Create message box graphic
messageBox = pbAddSprite("messageBox",0,Graphics.height-96,
"Graphics/Pictures/Battle/overlay_message",@viewport)
messageBox = pbAddSprite("messageBox", 0, Graphics.height - 96,
"Graphics/Pictures/Battle/overlay_message", @viewport)
messageBox.z = 195
# Create message window (displays the message)
msgWindow = Window_AdvancedTextPokemon.newWithSize("",
16,Graphics.height-96+2,Graphics.width-32,96,@viewport)
msgWindow.z = 200
msgWindow.opacity = 0
msgWindow.baseColor = PokeBattle_SceneConstants::MESSAGE_BASE_COLOR
msgWindow.shadowColor = PokeBattle_SceneConstants::MESSAGE_SHADOW_COLOR
16, Graphics.height - 96 + 2, Graphics.width - 32, 96, @viewport)
msgWindow.z = 200
msgWindow.opacity = 0
msgWindow.baseColor = PokeBattle_SceneConstants::MESSAGE_BASE_COLOR
msgWindow.shadowColor = PokeBattle_SceneConstants::MESSAGE_SHADOW_COLOR
msgWindow.letterbyletter = true
@sprites["messageWindow"] = msgWindow
# Create command window
@sprites["commandWindow"] = CommandMenuDisplay.new(@viewport,200)
@sprites["commandWindow"] = CommandMenuDisplay.new(@viewport, 200)
# Create fight window
@sprites["fightWindow"] = FightMenuDisplay.new(@viewport,200)
@sprites["fightWindow"] = FightMenuDisplay.new(@viewport, 200)
# Create targeting window
@sprites["targetWindow"] = TargetMenuDisplay.new(@viewport,200,@battle.sideSizes)
@sprites["targetWindow"] = TargetMenuDisplay.new(@viewport, 200, @battle.sideSizes)
pbShowWindow(MESSAGE_BOX)
# The party lineup graphics (bar and balls) for both sides
for side in 0...2
partyBar = pbAddSprite("partyBar_#{side}",0,0,
"Graphics/Pictures/Battle/overlay_lineup",@viewport)
partyBar.z = 120
partyBar.mirror = true if side==0 # Player's lineup bar only
partyBar = pbAddSprite("partyBar_#{side}", 0, 0,
"Graphics/Pictures/Battle/overlay_lineup", @viewport)
partyBar.z = 120
partyBar.mirror = true if side == 0 # Player's lineup bar only
partyBar.visible = false
for i in 0...PokeBattle_SceneConstants::NUM_BALLS
ball = pbAddSprite("partyBall_#{side}_#{i}",0,0,nil,@viewport)
ball.z = 121
ball = pbAddSprite("partyBall_#{side}_#{i}", 0, 0, nil, @viewport)
ball.z = 121
ball.visible = false
end
# Ability splash bars
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
@sprites["abilityBar_#{side}"] = AbilitySplashBar.new(side,@viewport)
@sprites["abilityBar_#{side}"] = AbilitySplashBar.new(side, @viewport)
if $game_switches[SWITCH_DOUBLE_ABILITIES]
@sprites["ability2Bar_#{side}"] = AbilitySplashBar.new(side,@viewport,true)
@sprites["ability2Bar_#{side}"].y = @sprites["ability2Bar_#{side}"].y+30
@sprites["ability2Bar_#{side}"] = AbilitySplashBar.new(side, @viewport, true)
@sprites["ability2Bar_#{side}"].y = @sprites["ability2Bar_#{side}"].y + 30
end
end
end
# Player's and partner trainer's back sprite
@battle.player.each_with_index do |p,i|
pbCreateTrainerBackSprite(i,p.trainer_type,@battle.player.length)
@battle.player.each_with_index do |p, i|
pbCreateTrainerBackSprite(i, p.trainer_type, @battle.player.length)
end
# Opposing trainer(s) sprites
if @battle.trainerBattle?
@battle.opponent.each_with_index do |p,i|
pbCreateTrainerFrontSprite(i,p.trainer_type,@battle.opponent.length,p.sprite_override)
@battle.opponent.each_with_index do |p, i|
pbCreateTrainerFrontSprite(i, p.trainer_type, @battle.opponent.length, p.sprite_override)
end
end
# Data boxes and Pokémon sprites
@battle.battlers.each_with_index do |b,i|
@battle.battlers.each_with_index do |b, i|
next if !b
@sprites["dataBox_#{i}"] = PokemonDataBox.new(b,@battle.pbSideSize(i),@viewport)
@sprites["dataBox_#{i}"] = PokemonDataBox.new(b, @battle.pbSideSize(i), @viewport)
pbCreatePokemonSprite(i)
end
# Wild battle, so set up the Pokémon sprite(s) accordingly
if @battle.wildBattle?
@battle.pbParty(1).each_with_index do |pkmn,i|
index = i*2+1
pbChangePokemon(index,pkmn)
@battle.pbParty(1).each_with_index do |pkmn, i|
index = i * 2 + 1
pbChangePokemon(index, pkmn)
pkmnSprite = @sprites["pokemon_#{index}"]
pkmnSprite.tone = Tone.new(-80,-80,-80)
pkmnSprite.tone = Tone.new(-80, -80, -80)
pkmnSprite.visible = true
end
end
end
def pbCreateBackdropSprites
def getBackdropTimeSuffix()
@battle.time = 2 if darknessEffectOnCurrentMap()
case @battle.time
when 1 then time = "eve"
when 2 then time = "night"
when 1 then
time = "eve"
when 2 then
time = "night"
end
# Put everything together into backdrop, bases and message bar filenames
backdropFilename = @battle.backdrop.downcase
baseFilename = @battle.backdrop.downcase
baseFilename = sprintf("%s_%s",baseFilename,@battle.backdropBase).downcase if @battle.backdropBase
messageFilename = @battle.backdrop.downcase
if time
trialName = sprintf("%s_%s",backdropFilename,time).downcase
if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_bg"))
backdropFilename = trialName
end
trialName = sprintf("%s_%s",baseFilename,time).downcase
if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_base0"))
baseFilename = trialName
end
trialName = sprintf("%s_%s",messageFilename,time).downcase
if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_message"))
messageFilename = trialName
end
end
if !pbResolveBitmap(sprintf("Graphics/Battlebacks/"+baseFilename+"_base0")) &&
@battle.backdropBase
baseFilename = @battle.backdropBase
if time
trialName = sprintf("%s_%s",baseFilename,time).downcase
if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_base0"))
baseFilename = trialName
end
end
end
# Finalise filenames
# battleBG = "Graphics/Battlebacks/"+backdropFilename+"_bg"
# playerBase = "Graphics/Battlebacks/"+baseFilename+"_base0"
# enemyBase = "Graphics/Battlebacks/"+baseFilename+"_base1"
# messageBG = "Graphics/Battlebacks/"+messageFilename+"_message"
return time
end
battleBG = "Graphics/Battlebacks/battlebg/"+backdropFilename
playerBase = "Graphics/Battlebacks/playerbase/"+baseFilename
enemyBase = "Graphics/Battlebacks/enemybase/"+baseFilename
messageBG = "Graphics/Battlebacks/"+messageFilename+"_message"
if !pbResolveBitmap(messageBG)
messageBG = "Graphics/Battlebacks/default_message"
def getBackdropBasePath(type)
case type
when :BACKGROUND then
base_path = "Graphics/Battlebacks/battlebg/"
when :ENEMYBASE then
base_path = "Graphics/Battlebacks/enemybase/"
when :PLAYERBASE then
base_path = "Graphics/Battlebacks/playerbase/"
when :MESSAGE then
base_path = "Graphics/Battlebacks/"
end
# Apply graphics
bg = pbAddSprite("battle_bg",0,0,battleBG,@viewport)
return base_path
end
def getBackdropSpriteFullPath(filename, backdrop_type)
time = getBackdropTimeSuffix()
base_path = getBackdropBasePath(backdrop_type)
default_name = base_path + filename
time_adjusted_name = _INTL("{1}{2}_{3}",base_path,filename,time)
if pbResolveBitmap(time_adjusted_name)
return time_adjusted_name
end
return default_name
end
def apply_backdrop_graphics(battleBG,playerBase,enemyBase,messageBG)
bg = pbAddSprite("battle_bg", 0, 0, battleBG, @viewport)
bg.z = 0
bg = pbAddSprite("battle_bg2", -Graphics.width, 0, battleBG, @viewport)
bg.z = 0
bg = pbAddSprite("battle_bg2",-Graphics.width,0,battleBG,@viewport)
bg.z = 0
bg.mirror = true
for side in 0...2
baseX, baseY = PokeBattle_SceneConstants.pbBattlerPosition(side)
base = pbAddSprite("base_#{side}",baseX,baseY,
(side==0) ? playerBase : enemyBase,@viewport)
base.z = 1
base = pbAddSprite("base_#{side}", baseX, baseY,
(side == 0) ? playerBase : enemyBase, @viewport)
base.z = 1
if base.bitmap
base.ox = base.bitmap.width/2
base.oy = (side==0) ? base.bitmap.height : base.bitmap.height/2
base.ox = base.bitmap.width / 2
base.oy = (side == 0) ? base.bitmap.height : base.bitmap.height / 2
end
end
cmdBarBG = pbAddSprite("cmdBar_bg",0,Graphics.height-96,messageBG,@viewport)
cmdBarBG = pbAddSprite("cmdBar_bg", 0, Graphics.height - 96, messageBG, @viewport)
cmdBarBG.z = 180
end
def pbCreateTrainerBackSprite(idxTrainer,trainerType,numTrainers=1)
if idxTrainer==0 # Player's sprite
DEFAULT_BACKGROUND_NAME = "indoora"
DEFAULT_MESSAGE_NAME = "default_message"
def pbCreateBackdropSprites
background_name = @battle.backdrop ? @battle.backdrop.downcase : DEFAULT_BACKGROUND_NAME
battlebase_name = @battle.backdropBase ? @battle.backdropBase.downcase : background_name
message_name = background_name + "_message"
battleBG =getBackdropSpriteFullPath(background_name, :BACKGROUND)
playerBase =getBackdropSpriteFullPath(battlebase_name, :PLAYERBASE)
enemyBase =getBackdropSpriteFullPath(battlebase_name, :ENEMYBASE)
messageBG =getBackdropSpriteFullPath(message_name, :MESSAGE)
if !pbResolveBitmap(messageBG)
messageBG = "Graphics/Battlebacks/default_message"
end
apply_backdrop_graphics(battleBG,playerBase,enemyBase,messageBG)
end
def pbCreateTrainerBackSprite(idxTrainer, trainerType, numTrainers = 1)
if idxTrainer == 0 # Player's sprite
trainerFile = GameData::TrainerType.player_back_sprite_filename(trainerType)
else # Partner trainer's sprite
else
# Partner trainer's sprite
trainerFile = GameData::TrainerType.back_sprite_filename(trainerType)
end
spriteX, spriteY = PokeBattle_SceneConstants.pbTrainerPosition(0,idxTrainer,numTrainers)
trainer = pbAddSprite("player_#{idxTrainer+1}",spriteX,spriteY,trainerFile,@viewport)
spriteX, spriteY = PokeBattle_SceneConstants.pbTrainerPosition(0, idxTrainer, numTrainers)
trainer = pbAddSprite("player_#{idxTrainer + 1}", spriteX, spriteY, trainerFile, @viewport)
return if !trainer.bitmap
# Alter position of sprite
trainer.z = 30+idxTrainer
if trainer.bitmap.width>trainer.bitmap.height*2
trainer.src_rect.x = 0
trainer.src_rect.width = trainer.bitmap.width/5
trainer.z = 30 + idxTrainer
if trainer.bitmap.width > trainer.bitmap.height * 2
trainer.src_rect.x = 0
trainer.src_rect.width = trainer.bitmap.width / 5
end
trainer.ox = trainer.src_rect.width/2
trainer.ox = trainer.src_rect.width / 2
trainer.oy = trainer.bitmap.height
end
def pbCreateTrainerFrontSprite(idxTrainer,trainerType,numTrainers=1,sprite_override=nil)
def pbCreateTrainerFrontSprite(idxTrainer, trainerType, numTrainers = 1, sprite_override = nil)
trainerFile = GameData::TrainerType.front_sprite_filename(trainerType)
trainerFile = sprite_override if sprite_override
spriteX, spriteY = PokeBattle_SceneConstants.pbTrainerPosition(1,idxTrainer,numTrainers)
trainer = pbAddSprite("trainer_#{idxTrainer+1}",spriteX,spriteY,trainerFile,@viewport)
spriteX, spriteY = PokeBattle_SceneConstants.pbTrainerPosition(1, idxTrainer, numTrainers)
trainer = pbAddSprite("trainer_#{idxTrainer + 1}", spriteX, spriteY, trainerFile, @viewport)
return if !trainer.bitmap
# Alter position of sprite
trainer.z = 7+idxTrainer
trainer.ox = trainer.src_rect.width/2
trainer.z = 7 + idxTrainer
trainer.ox = trainer.src_rect.width / 2
trainer.oy = trainer.bitmap.height
end
def pbCreatePokemonSprite(idxBattler)
sideSize = @battle.pbSideSize(idxBattler)
batSprite = PokemonBattlerSprite.new(@viewport,sideSize,idxBattler,@animations)
batSprite = PokemonBattlerSprite.new(@viewport, sideSize, idxBattler, @animations)
@sprites["pokemon_#{idxBattler}"] = batSprite
shaSprite = PokemonBattlerShadowSprite.new(@viewport,sideSize,idxBattler)
shaSprite = PokemonBattlerShadowSprite.new(@viewport, sideSize, idxBattler)
shaSprite.visible = false
@sprites["shadow_#{idxBattler}"] = shaSprite
end

View File

@@ -275,6 +275,7 @@ class PokeBattle_Scene
# Animates a data box's Exp bar
#=============================================================================
def pbEXPBar(battler,startExp,endExp,tempExp1,tempExp2)
return if startExp > endExp
return if !battler
startExpLevel = tempExp1-startExp
endExpLevel = tempExp2-startExp