Combined overwriting code from the new animation editor files

This commit is contained in:
Maruno17
2025-01-17 00:18:27 +00:00
parent 0c0c826e82
commit db2df5c8b4
17 changed files with 381 additions and 1259 deletions

View File

@@ -4,7 +4,6 @@
class Game_Temp
attr_accessor :regional_dexes_data
attr_accessor :battle_animations_data
attr_accessor :move_to_battle_animation_data
attr_accessor :map_infos
end
@@ -12,7 +11,6 @@ def pbClearData
if $game_temp
$game_temp.regional_dexes_data = nil
$game_temp.battle_animations_data = nil
$game_temp.move_to_battle_animation_data = nil
$game_temp.map_infos = nil
end
MapFactoryHelper.clear
@@ -34,7 +32,7 @@ def pbLoadRegionalDexes
end
#===============================================================================
# Methods relating to battle animations data.
# Method relating to battle animations data.
#===============================================================================
def pbLoadBattleAnimations
$game_temp = Game_Temp.new if !$game_temp
@@ -44,14 +42,6 @@ def pbLoadBattleAnimations
return $game_temp.battle_animations_data
end
def pbLoadMoveToAnim
$game_temp = Game_Temp.new if !$game_temp
if !$game_temp.move_to_battle_animation_data
$game_temp.move_to_battle_animation_data = load_data("Data/move2anim.dat") || []
end
return $game_temp.move_to_battle_animation_data
end
#===============================================================================
# Method relating to map infos data.
#===============================================================================

View File

@@ -32,34 +32,34 @@ class Battle::Scene
# Create message box graphic
messageBox = pbAddSprite("messageBox", 0, Graphics.height - 96,
"Graphics/UI/Battle/overlay_message", @viewport)
messageBox.z = 195
messageBox.z = 10195
# Create message window (displays the message)
msgWindow = Window_AdvancedTextPokemon.newWithSize(
"", 16, Graphics.height - 96 + 2, Graphics.width - 32, 96, @viewport
)
msgWindow.z = 200
msgWindow.z = 10200
msgWindow.opacity = 0
msgWindow.baseColor = MESSAGE_BASE_COLOR
msgWindow.shadowColor = MESSAGE_SHADOW_COLOR
msgWindow.letterbyletter = true
@sprites["messageWindow"] = msgWindow
# Create command window
@sprites["commandWindow"] = CommandMenu.new(@viewport, 200)
@sprites["commandWindow"] = CommandMenu.new(@viewport, 10200)
# Create fight window
@sprites["fightWindow"] = FightMenu.new(@viewport, 200)
@sprites["fightWindow"] = FightMenu.new(@viewport, 10200)
# Create targeting window
@sprites["targetWindow"] = TargetMenu.new(@viewport, 200, @battle.sideSizes)
@sprites["targetWindow"] = TargetMenu.new(@viewport, 10200, @battle.sideSizes)
pbShowWindow(MESSAGE_BOX)
# The party lineup graphics (bar and balls) for both sides
2.times do |side|
partyBar = pbAddSprite("partyBar_#{side}", 0, 0,
"Graphics/UI/Battle/overlay_lineup", @viewport)
partyBar.z = 120
partyBar.z = 10120
partyBar.mirror = true if side == 0 # Player's lineup bar only
partyBar.visible = false
NUM_BALLS.times do |i|
ball = pbAddSprite("partyBall_#{side}_#{i}", 0, 0, nil, @viewport)
ball.z = 121
ball.z = 10121
ball.visible = false
end
# Ability splash bars
@@ -136,22 +136,22 @@ class Battle::Scene
messageBG = "Graphics/Battlebacks/" + messageFilename + "_message"
# Apply graphics
bg = pbAddSprite("battle_bg", 0, 0, battleBG, @viewport)
bg.z = 0
bg.z = -200
bg = pbAddSprite("battle_bg2", -Graphics.width, 0, battleBG, @viewport)
bg.z = 0
bg.z = -200
bg.mirror = true
2.times do |side|
baseX, baseY = Battle::Scene.pbBattlerPosition(side)
base = pbAddSprite("base_#{side}", baseX, baseY,
(side == 0) ? playerBase : enemyBase, @viewport)
base.z = 1
base.z = -199
if base.bitmap
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.z = 180
cmdBarBG.z = 10180
end
def pbCreateTrainerBackSprite(idxTrainer, trainerType, numTrainers = 1)
@@ -164,7 +164,7 @@ class Battle::Scene
trainer = pbAddSprite("player_#{idxTrainer + 1}", spriteX, spriteY, trainerFile, @viewport)
return if !trainer.bitmap
# Alter position of sprite
trainer.z = 80 + idxTrainer
trainer.z = 1500 + (idxTrainer * 100)
if trainer.bitmap.width > trainer.bitmap.height * 2
trainer.src_rect.x = 0
trainer.src_rect.width = trainer.bitmap.width / 5
@@ -179,7 +179,7 @@ class Battle::Scene
trainer = pbAddSprite("trainer_#{idxTrainer + 1}", spriteX, spriteY, trainerFile, @viewport)
return if !trainer.bitmap
# Alter position of sprite
trainer.z = 7 + idxTrainer
trainer.z = 500 - (idxTrainer * 100)
trainer.ox = trainer.src_rect.width / 2
trainer.oy = trainer.bitmap.height
end

View File

@@ -2,6 +2,28 @@
#
#===============================================================================
class Battle::Scene
ANIMATION_DEFAULTS = [:TACKLE, :DEFENSECURL] # With target, without target
ANIMATION_DEFAULTS_FOR_TYPE_CATEGORY = {
:NORMAL => [:TACKLE, :SONICBOOM, :DEFENSECURL, :BODYSLAM, nil, :TAILWHIP],
:FIGHTING => [:MACHPUNCH, :AURASPHERE, :BULKUP, nil, nil, nil],
:FLYING => [:WINGATTACK, :GUST, :ROOST, nil, :AIRCUTTER, :FEATHERDANCE],
:POISON => [:POISONSTING, :SLUDGE, :ACIDARMOR, nil, :ACID, :POISONPOWDER],
:GROUND => [:SANDTOMB, :MUDSLAP, :MUDSPORT, :EARTHQUAKE, :EARTHPOWER, :SANDATTACK],
:ROCK => [:ROCKTHROW, :POWERGEM, :ROCKPOLISH, :ROCKSLIDE, nil, :SANDSTORM],
:BUG => [:TWINEEDLE, :BUGBUZZ, :QUIVERDANCE, nil, :STRUGGLEBUG, :STRINGSHOT],
:GHOST => [:ASTONISH, :SHADOWBALL, :GRUDGE, nil, nil, :CONFUSERAY],
:STEEL => [:IRONHEAD, :MIRRORSHOT, :IRONDEFENSE, nil, nil, :METALSOUND],
:FIRE => [:FIREPUNCH, :EMBER, :SUNNYDAY, nil, :INCINERATE, :WILLOWISP],
:WATER => [:CRABHAMMER, :WATERGUN, :AQUARING, nil, :SURF, :WATERSPORT],
:GRASS => [:VINEWHIP, :RAZORLEAF, :COTTONGUARD, nil, nil, :SPORE],
:ELECTRIC => [:THUNDERPUNCH, :THUNDERSHOCK, :CHARGE, nil, :DISCHARGE, :THUNDERWAVE],
:PSYCHIC => [:ZENHEADBUTT, :CONFUSION, :CALMMIND, nil, :SYNCHRONOISE, :MIRACLEEYE],
:ICE => [:ICEPUNCH, :ICEBEAM, :MIST, :AVALANCHE, :POWDERSNOW, :HAIL],
:DRAGON => [:DRAGONCLAW, :DRAGONRAGE, :DRAGONDANCE, nil, :TWISTER, nil],
:DARK => [:KNOCKOFF, :DARKPULSE, :HONECLAWS, nil, :SNARL, :EMBARGO],
:FAIRY => [:TACKLE, :FAIRYWIND, :MOONLIGHT, nil, :DAZZLINGGLEAM, :SWEETKISS]
}
# Animates the battle intro.
def pbBattleIntroAnimation
# Make everything appear
@@ -377,7 +399,7 @@ class Battle::Scene
throwAnim.dispose
end
#=============================================================================
#-----------------------------------------------------------------------------
# Hides all battler shadows before yielding to a move animation, and then
# restores the shadows afterwards.
@@ -399,119 +421,241 @@ class Battle::Scene
end
#-----------------------------------------------------------------------------
# Loads a move/common animation.
# Loads a move animation.
#-----------------------------------------------------------------------------
# Returns the animation ID to use for a given move/user. Returns nil if that
# move has no animations defined for it.
def pbFindMoveAnimDetails(move2anim, moveID, idxUser, hitNum = 0)
real_move_id = GameData::Move.try_get(moveID)&.id || moveID
noFlip = false
if (idxUser & 1) == 0 # On player's side
anim = move2anim[0][real_move_id]
else # On opposing side
anim = move2anim[1][real_move_id]
noFlip = true if anim
anim = move2anim[0][real_move_id] if !anim
# Returns an array of GameData::Animation if a new animation(s) is found.
# Return [animation index, shouldn't be flipped] if an old animation is found.
def find_move_animation(move_id, version, user_index)
# Get animation
anims = find_move_animation_for_move(move_id, version, user_index)
return anims if anims
# Get information to decide which default animation to try
move_data = GameData::Move.get(move_id)
target_data = GameData::Target.get(move_data.target)
move_type = move_data.type
default_idx = move_data.category
default_idx += 3 if target_data.num_targets > 1 ||
(target_data.num_targets > 0 && move_data.status?)
# Check for a default animation
wanted_move = ANIMATION_DEFAULTS_FOR_TYPE_CATEGORY[move_type][default_idx]
anims = find_move_animation_for_move(wanted_move, 0, user_index)
return anims if anims
if default_idx >= 3
wanted_move = ANIMATION_DEFAULTS_FOR_TYPE_CATEGORY[move_type][default_idx - 3]
anims = find_move_animation_for_move(wanted_move, 0, user_index)
return anims if anims
return nil if ANIMATION_DEFAULTS.include?(wanted_move) # No need to check for these animations twice
end
return [anim + hitNum, noFlip] if anim
# Use Tackle or Defense Curl's animation
if target_data.num_targets == 0 && target.data.id != :None
return find_move_animation_for_move(ANIMATION_DEFAULTS[1], 0, user_index)
end
return find_move_animation_for_move(ANIMATION_DEFAULTS[0], 0, user_index)
end
# Find an animation(s) for the given move_id.
def find_move_animation_for_move(move_id, version, user_index)
# Find new animation
anims = try_get_better_move_animation(move_id, version, user_index)
return anims if anims
if version > 0
anims = try_get_better_move_animation(move_id, 0, user_index)
return anims if anims
end
# Find old animation
anim = pbFindMoveAnimDetails(move_id, user_index, version)
return anim
end
# Finds a new animation for the given move_id and version. Prefers opposing
# animations if the user is opposing. Can return multiple animations.
def try_get_better_move_animation(move_id, version, user_index)
ret = []
backup_ret = []
GameData::Animation.each do |anim|
next if !anim.move_animation? || anim.ignore
next if anim.move != move_id.to_s
next if anim.version != version
if !user_index
ret.push(anim)
next
end
if user_index.even? # User is on player's side
ret.push(anim) if !anim.opposing_animation?
else # User is on opposing side
(anim.opposing_animation?) ? ret.push(anim) : backup_ret.push(anim)
end
end
return ret if !ret.empty?
return backup_ret if !backup_ret.empty?
return nil
end
# Returns the animation ID to use for a given move. If the move has no
# animations, tries to use a default move animation depending on the move's
# type. If that default move animation doesn't exist, trues to use Tackle's
# move animation. Returns nil if it can't find any of these animations to use.
def pbFindMoveAnimation(moveID, idxUser, hitNum)
begin
move2anim = pbLoadMoveToAnim
# Find actual animation requested (an opponent using the animation first
# looks for an OppMove version then a Move version)
anim = pbFindMoveAnimDetails(move2anim, moveID, idxUser, hitNum)
return anim if anim
# Actual animation not found, get the default animation for the move's type
moveData = GameData::Move.get(moveID)
target_data = GameData::Target.get(moveData.target)
moveType = moveData.type
moveKind = moveData.category
moveKind += 3 if target_data.num_targets > 1 || target_data.affects_foe_side
moveKind += 3 if moveData.status? && target_data.num_targets > 0
# [one target physical, one target special, user status,
# multiple targets physical, multiple targets special, non-user status]
typeDefaultAnim = {
:NORMAL => [:TACKLE, :SONICBOOM, :DEFENSECURL, :EXPLOSION, :SWIFT, :TAILWHIP],
:FIGHTING => [:MACHPUNCH, :AURASPHERE, :DETECT, nil, nil, nil],
:FLYING => [:WINGATTACK, :GUST, :ROOST, nil, :AIRCUTTER, :FEATHERDANCE],
:POISON => [:POISONSTING, :SLUDGE, :ACIDARMOR, nil, :ACID, :POISONPOWDER],
:GROUND => [:SANDTOMB, :MUDSLAP, nil, :EARTHQUAKE, :EARTHPOWER, :MUDSPORT],
:ROCK => [:ROCKTHROW, :POWERGEM, :ROCKPOLISH, :ROCKSLIDE, nil, :SANDSTORM],
:BUG => [:TWINEEDLE, :BUGBUZZ, :QUIVERDANCE, nil, :STRUGGLEBUG, :STRINGSHOT],
:GHOST => [:LICK, :SHADOWBALL, :GRUDGE, nil, nil, :CONFUSERAY],
:STEEL => [:IRONHEAD, :MIRRORSHOT, :IRONDEFENSE, nil, nil, :METALSOUND],
:FIRE => [:FIREPUNCH, :EMBER, :SUNNYDAY, nil, :INCINERATE, :WILLOWISP],
:WATER => [:CRABHAMMER, :WATERGUN, :AQUARING, nil, :SURF, :WATERSPORT],
:GRASS => [:VINEWHIP, :MEGADRAIN, :COTTONGUARD, :RAZORLEAF, nil, :SPORE],
:ELECTRIC => [:THUNDERPUNCH, :THUNDERSHOCK, :CHARGE, nil, :DISCHARGE, :THUNDERWAVE],
:PSYCHIC => [:ZENHEADBUTT, :CONFUSION, :CALMMIND, nil, :SYNCHRONOISE, :MIRACLEEYE],
:ICE => [:ICEPUNCH, :ICEBEAM, :MIST, nil, :POWDERSNOW, :HAIL],
:DRAGON => [:DRAGONCLAW, :DRAGONRAGE, :DRAGONDANCE, nil, :TWISTER, nil],
:DARK => [:PURSUIT, :DARKPULSE, :HONECLAWS, nil, :SNARL, :EMBARGO],
:FAIRY => [:TACKLE, :FAIRYWIND, :MOONLIGHT, nil, :SWIFT, :SWEETKISS]
}
if typeDefaultAnim[moveType]
anims = typeDefaultAnim[moveType]
if GameData::Move.exists?(anims[moveKind])
anim = pbFindMoveAnimDetails(move2anim, anims[moveKind], idxUser)
# Returns the animation ID to use for a given move/user. Returns nil if that
# move has no animations defined for it.
def pbFindMoveAnimDetails(moveID, idxUser, hitNum = 0)
real_move_id = GameData::Move.try_get(moveID)&.id || moveID
anims = pbLoadBattleAnimations
return nil if !anims
anim_id = -1
foe_anim_id = -1
no_flip = false
anims.length.times do |i|
next if !anims[i]
if anims[i].name[/^OppMove\:\s*(.*)$/]
if GameData::Move.exists?($~[1])
moveid = GameData::Move.get($~[1]).id
foe_anim_id = i if moveid == real_move_id
end
if !anim && moveKind >= 3 && GameData::Move.exists?(anims[moveKind - 3])
anim = pbFindMoveAnimDetails(move2anim, anims[moveKind - 3], idxUser)
end
if !anim && GameData::Move.exists?(anims[2])
anim = pbFindMoveAnimDetails(move2anim, anims[2], idxUser)
elsif anims[i].name[/^Move\:\s*(.*)$/]
if GameData::Move.exists?($~[1])
moveid = GameData::Move.get($~[1]).id
anim_id = i if moveid == real_move_id
end
end
return anim if anim
# Default animation for the move's type not found, use Tackle's animation
if GameData::Move.exists?(:TACKLE)
return pbFindMoveAnimDetails(move2anim, :TACKLE, idxUser)
end
rescue
end
if (idxUser & 1) == 0 # On player's side
anim = anim_id
else # On opposing side
anim = foe_anim_id
no_flip = true if anim >= 0
anim = anim_id if anim < 0
end
return [anim + hitNum, no_flip] if anim >= 0
return nil
end
#-----------------------------------------------------------------------------
# Loads a common animation.
#-----------------------------------------------------------------------------
def try_get_better_common_animation(anim_name, user_index)
# Find a new format common animation to play
ret = []
backup_ret = []
GameData::Animation.each do |anim|
next if !anim.common_animation? || anim.ignore
next if anim.move != anim_name
if !user_index
ret.push(anim)
next
end
if user_index.even? # User is on player's side
ret.push(anim) if !anim.opposing_animation?
else # User is on opposing side
(anim.opposing_animation?) ? ret.push(anim) : backup_ret.push(anim)
end
end
return ret if !ret.empty?
return backup_ret if !backup_ret.empty?
# Find an old format common animation to play
target = target[0] if target.is_a?(Array)
animations = pbLoadBattleAnimations
return nil if !animations
animations.each do |anim|
next if !anim || anim.name != "Common:" + anim_name
ret = anim
break
end
return ret
end
#-----------------------------------------------------------------------------
# Plays a move/common animation.
#-----------------------------------------------------------------------------
# Plays a move animation.
def pbAnimation(moveID, user, targets, hitNum = 0)
animID = pbFindMoveAnimation(moveID, user.index, hitNum)
return if !animID
anim = animID[0]
target = (targets.is_a?(Array)) ? targets[0] : targets
animations = pbLoadBattleAnimations
return if !animations
pbSaveShadows do
if animID[1] # On opposing side and using OppMove animation
pbAnimationCore(animations[anim], target, user, true)
else # On player's side, and/or using Move animation
pbAnimationCore(animations[anim], user, target)
def pbAnimation(move_id, user, targets, version = 0)
anims = find_move_animation(move_id, version, user&.index)
return if !anims || anims.empty?
if anims[0].is_a?(GameData::Animation) # New format animation
pbSaveShadows do
# NOTE: anims.sample is a random valid animation.
play_better_animation(anims.sample, user, targets)
end
else # Old format animation
anim = anims[0]
target = (targets.is_a?(Array)) ? targets[0] : targets
animations = pbLoadBattleAnimations
return if !animations
pbSaveShadows do
if anims[1] # On opposing side and using OppMove animation
pbAnimationCore(animations[anim], target, user, true)
else # On player's side, and/or using Move animation
pbAnimationCore(animations[anim], user, target)
end
end
end
end
# Plays a common animation.
def pbCommonAnimation(animName, user = nil, target = nil)
return if nil_or_empty?(animName)
target = target[0] if target.is_a?(Array)
animations = pbLoadBattleAnimations
return if !animations
animations.each do |a|
next if !a || a.name != "Common:" + animName
pbAnimationCore(a, user, target || user)
def pbCommonAnimation(anim_name, user = nil, target = nil)
return if nil_or_empty?(anim_name)
# Find an animation to play (new format or old format)
anims = try_get_better_common_animation(anim_name, user.index)
return if !anims
# Play a new format animation
if anims.is_a?(Array)
# NOTE: anims.sample is a random valid animation.
play_better_animation(anims.sample, user, target)
return
end
# Play an old format animation
target = target[0] if target.is_a?(Array)
pbAnimationCore(anims, user, target || user)
end
# Ball burst common animations should have a focus of "Target" and a priority
# of "Front".
# TODO: This is unused. It also doesn't support the new animation format.
def pbBallBurstCommonAnimation(_picture_ex, anim_name, battler, target_x, target_y)
return if nil_or_empty?(anim_name)
animations = pbLoadBattleAnimations
anim = animations&.get_from_name("Common:" + anim_name)
return if !anim
animPlayer = PBAnimationPlayerX.new(anim, battler, nil, self)
animPlayer.discard_user_and_target_sprites # Don't involve user/target in animation
animPlayer.set_target_origin(target_x, target_y)
animPlayer.start
@animations.push(animPlayer)
end
#-----------------------------------------------------------------------------
def play_better_animation(anim_data, user, targets)
return if !anim_data
@briefMessage = false
# Memorize old battler coordinates, to be reset after the animation
old_battler_coords = []
if user
sprite = @sprites["pokemon_#{user.index}"]
old_battler_coords[user.index] = [sprite.x, sprite.y]
end
if targets
targets.each do |target|
sprite = @sprites["pokemon_#{target.index}"]
old_battler_coords[target.index] = [sprite.x, sprite.y]
end
end
# Create animation player
anim_player = AnimationPlayer.new(anim_data, user, targets, self)
anim_player.set_up
# Play animation
anim_player.start
loop do
pbUpdate
anim_player.update
break if anim_player.can_continue_battle?
end
anim_player.dispose
# Restore old battler coordinates
old_battler_coords.each_with_index do |values, i|
next if !values
sprite = @sprites["pokemon_#{i}"]
sprite.x = values[0]
sprite.y = values[1]
end
end
def pbAnimationCore(animation, user, target, oppMove = false)
@@ -558,18 +702,4 @@ class Battle::Scene
targetSprite.pbSetOrigin
end
end
# Ball burst common animations should have a focus of "Target" and a priority
# of "Front".
def pbBallBurstCommonAnimation(_picture_ex, anim_name, battler, target_x, target_y)
return if nil_or_empty?(anim_name)
animations = pbLoadBattleAnimations
anim = animations&.get_from_name("Common:" + anim_name)
return if !anim
animPlayer = PBAnimationPlayerX.new(anim, battler, nil, self)
animPlayer.discard_user_and_target_sprites # Don't involve user/target in animation
animPlayer.set_target_origin(target_x, target_y)
animPlayer.start
@animations.push(animPlayer)
end
end

View File

@@ -98,7 +98,7 @@ class Battle::Scene::PokemonDataBox < Sprite
@contents = Bitmap.new(@databoxBitmap.width, @databoxBitmap.height)
self.bitmap = @contents
self.visible = false
self.z = 150 + ((@battler.index / 2) * 5)
self.z = 10150 + ((@battler.index / 2) * 5)
pbSetSystemFont(self.bitmap)
end
@@ -438,7 +438,7 @@ class Battle::Scene::AbilitySplashBar < Sprite
# Position the bar
self.x = (side == 0) ? -Graphics.width / 2 : Graphics.width
self.y = (side == 0) ? 180 : 80
self.z = 120
self.z = 10120
self.visible = false
end
@@ -578,9 +578,9 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
return if !@_iconBitmap
pbSetOrigin
if @index.even?
self.z = 50 + (5 * @index / 2)
self.z = 1100 + (100 * @index / 2)
else
self.z = 50 - (5 * (@index + 1) / 2)
self.z = 1000 - (100 * (@index + 1) / 2)
end
# Set original position
p = Battle::Scene.pbBattlerPosition(@index, @sideSize)
@@ -672,7 +672,7 @@ class Battle::Scene::BattlerShadowSprite < RPG::Sprite
def pbSetPosition
return if !@_iconBitmap
pbSetOrigin
self.z = 3
self.z = -198
# Set original position
p = Battle::Scene.pbBattlerPosition(@index, @sideSize)
self.x = p[0]

View File

@@ -367,7 +367,7 @@ module Battle::Scene::Animation::BallAnimationMixin
glare1 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[11]}", PictureOrigin::CENTER)
glare2 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[8]}", PictureOrigin::CENTER)
[glare1, glare2].each_with_index do |particle, num|
particle.setZ(0, 105 + num)
particle.setZ(0, 5105 + num)
particle.setZoom(0, 0)
particle.setTone(0, variances[12 - (3 * num)])
particle.setVisible(0, false)
@@ -405,7 +405,7 @@ module Battle::Scene::Animation::BallAnimationMixin
ray = addNewSprite(ballX + (ray_min_radius * Math.cos(radian)),
ballY - (ray_min_radius * Math.sin(radian)),
"Graphics/Battle animations/ballBurst_ray", PictureOrigin::BOTTOM)
ray.setZ(0, 100)
ray.setZ(0, 5100)
ray.setZoomXY(0, 200, start_zoom)
ray.setTone(0, variances[0]) if poke_ball != :CHERISHBALL
ray.setOpacity(0, 0)
@@ -432,7 +432,7 @@ module Battle::Scene::Animation::BallAnimationMixin
particle1 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[5]}", PictureOrigin::CENTER)
particle2 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[2]}", PictureOrigin::CENTER)
[particle1, particle2].each_with_index do |particle, num|
particle.setZ(0, 110 + num)
particle.setZ(0, 5110 + num)
particle.setZoom(0, (80 - (num * 20)) / (["ring2"].include?(variances[5 - (3 * num)]) ? 2 : 1))
particle.setTone(0, variances[6 - (3 * num)])
particle.setVisible(0, false)
@@ -580,7 +580,7 @@ module Battle::Scene::Animation::BallAnimationMixin
glare2 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[3]}", PictureOrigin::CENTER)
glare3 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[0]}", PictureOrigin::CENTER)
[glare1, glare2, glare3].each_with_index do |particle, num|
particle.setZ(0, 100 + num)
particle.setZ(0, 5100 + num)
particle.setZoom(0, 0)
particle.setTone(0, variances[7 - (3 * num)])
particle.setVisible(0, false)
@@ -618,7 +618,7 @@ module Battle::Scene::Animation::BallAnimationMixin
num_particles.times do |i|
# Set up particle that keeps moving out
particle1 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_particle", PictureOrigin::CENTER)
particle1.setZ(0, 105)
particle1.setZ(0, 5105)
particle1.setZoom(0, 150)
particle1.setOpacity(0, 160)
particle1.setVisible(0, false)
@@ -626,7 +626,7 @@ module Battle::Scene::Animation::BallAnimationMixin
particle2 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[12]}", PictureOrigin::CENTER)
particle3 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[9]}", PictureOrigin::CENTER)
[particle2, particle3].each_with_index do |particle, num|
particle.setZ(0, 110 + num)
particle.setZ(0, 5110 + num)
particle.setZoom(0, (poke_ball == :NESTBALL) ? 50 : 0)
particle.setTone(0, variances[13 - (3 * num)])
particle.setVisible(0, false)
@@ -690,7 +690,7 @@ module Battle::Scene::Animation::BallAnimationMixin
# Web sprite (for Net Ball)
if poke_ball == :NETBALL
web = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_web", PictureOrigin::CENTER)
web.setZ(0, 123)
web.setZ(0, 5123)
web.setZoom(0, 120)
web.setOpacity(0, 0)
web.setTone(0, Tone.new(-32, -32, -128))
@@ -710,7 +710,7 @@ module Battle::Scene::Animation::BallAnimationMixin
end
# Ring particle
ring = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_ring1", PictureOrigin::CENTER)
ring.setZ(0, 110)
ring.setZ(0, 5110)
ring.setZoom(0, 0)
ring.setTone(0, variances[15])
ring.setVisible(0, false)
@@ -735,7 +735,7 @@ module Battle::Scene::Animation::BallAnimationMixin
3.times do |i| # Left, middle, right
# Set up particle
star = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_star", PictureOrigin::CENTER)
star.setZ(0, 110)
star.setZ(0, 5110)
star.setZoom(0, [50, 50, 33][i])
start_angle = [0, 345, 15][i]
star.setAngle(0, start_angle)
@@ -775,7 +775,7 @@ module Battle::Scene::Animation::BallAnimationMixin
num_particles.times do |i|
# Set up particle
particle = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_particle", PictureOrigin::CENTER)
particle.setZ(0, 110)
particle.setZ(0, 5110)
particle.setZoom(0, 150)
particle.setOpacity(0, 0)
particle.setVisible(0, false)
@@ -807,11 +807,11 @@ module Battle::Scene::Animation::BallAnimationMixin
end
# Ring particles
ring1 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_ring1", PictureOrigin::CENTER)
ring1.setZ(0, 110)
ring1.setZ(0, 5110)
ring1.setZoom(0, 0)
ring1.setVisible(0, false)
ring2 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_ring2", PictureOrigin::CENTER)
ring2.setZ(0, 110)
ring2.setZ(0, 5110)
ring2.setVisible(0, false)
# Ring particle animations
ring1.setVisible(delay + burst_duration - 2, true)

View File

@@ -38,12 +38,12 @@ class Battle::Scene::Animation::Intro < Battle::Scene::Animation
end
# Fading blackness over whole screen
blackScreen = addNewSprite(0, 0, "Graphics/Battle animations/black_screen")
blackScreen.setZ(0, 999)
blackScreen.setZ(0, 99999)
blackScreen.moveOpacity(0, 8, 0)
# Fading blackness over command bar
blackBar = addNewSprite(@sprites["cmdBar_bg"].x, @sprites["cmdBar_bg"].y,
"Graphics/Battle animations/black_bar")
blackBar.setZ(0, 998)
blackBar.setZ(0, 99998)
blackBar.moveOpacity(appearTime * 3 / 4, appearTime / 4, 0)
end
@@ -419,7 +419,7 @@ class Battle::Scene::Animation::PokeballPlayerSendOut < Battle::Scene::Animation
ballMidY = battlerStartY - 144
# Set up Poké Ball sprite
ball = addBallSprite(ballStartX, ballStartY, poke_ball)
ball.setZ(0, 25)
ball.setZ(0, 1025)
ball.setVisible(0, false)
# Poké Ball tracking the player's hand animation (if trainer is visible)
if @showingTrainer && traSprite && traSprite.x > 0
@@ -835,7 +835,7 @@ class Battle::Scene::Animation::PokeballThrowDeflect < Battle::Scene::Animation
ballEndY = 112
# Set up Poké Ball sprite
ball = addBallSprite(ballStartX, ballStartY, @poke_ball)
ball.setZ(0, 90)
ball.setZ(0, 5090)
# Poké Ball arc animation
ball.setSE(0, "Battle throw")
createBallTrajectory(ball, 0, 16,

View File

@@ -1277,8 +1277,23 @@ MenuHandlers.add(:debug_menu, :editors_menu, {
"description" => _INTL("Edit battle animations, terrain tags, map data, etc.")
})
MenuHandlers.add(:debug_menu, :use_pc, {
"name" => _INTL("New battle animation editor"),
"parent" => :editors_menu,
"description" => _INTL("Edit the battle animations."),
"effect" => proc {
Graphics.resize_screen(AnimationEditor::WINDOW_WIDTH, AnimationEditor::WINDOW_HEIGHT)
pbSetResizeFactor(1)
screen = AnimationEditor::AnimationSelector.new
screen.run
Graphics.resize_screen(Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT)
pbSetResizeFactor($PokemonSystem.screensize)
$game_map&.autoplay
}
})
MenuHandlers.add(:debug_menu, :animation_editor, {
"name" => _INTL("Battle animation editor"),
"name" => _INTL("Old battle animation editor"),
"parent" => :editors_menu,
"description" => _INTL("Edit the battle animations."),
"effect" => proc {
@@ -1287,9 +1302,9 @@ MenuHandlers.add(:debug_menu, :animation_editor, {
})
MenuHandlers.add(:debug_menu, :animation_organiser, {
"name" => _INTL("Battle animation organiser"),
"name" => _INTL("Old battle animation organiser"),
"parent" => :editors_menu,
"description" => _INTL("Rearrange/add/delete battle animations."),
"description" => _INTL("Rearrange/add/delete old battle animations."),
"effect" => proc {
pbFadeOutIn { pbAnimationsOrganiser }
}

View File

@@ -485,60 +485,38 @@ module Compiler
enumer = schema[2 + i - start]
case enumer
when Array
file.write((value.is_a?(Integer) && !enumer[value].nil?) ? enumer[value] : value)
file.write(enumer[value])
when Symbol, String
if GameData.const_defined?(enumer.to_sym)
mod = GameData.const_get(enumer.to_sym)
file.write(mod.get(value).id.to_s)
else
mod = Object.const_get(enumer.to_sym)
file.write(getConstantName(mod, value))
end
mod = Object.const_get(enumer.to_sym)
file.write(getConstantName(mod, value))
when Module
file.write(getConstantName(enumer, value))
when Hash
if value.is_a?(String)
file.write(value)
else
enumer.each_key do |key|
next if enumer[key] != value
file.write(key)
break
end
enumer.each_key do |key|
next if enumer[key] != value
file.write(key)
break
end
end
when "y", "Y" # Enumerable or integer
enumer = schema[2 + i - start]
case enumer
when Array
file.write((value.is_a?(Integer) && !enumer[value].nil?) ? enumer[value] : value)
file.write((enumer[value].nil?) ? value : enumer[value])
when Symbol, String
if !Kernel.const_defined?(enumer.to_sym) && GameData.const_defined?(enumer.to_sym)
mod = GameData.const_get(enumer.to_sym)
if mod.exists?(value)
file.write(mod.get(value).id.to_s)
else
file.write(value.to_s)
end
else
mod = Object.const_get(enumer.to_sym)
file.write(getConstantNameOrValue(mod, value))
end
mod = Object.const_get(enumer.to_sym)
file.write(getConstantNameOrValue(mod, value))
when Module
file.write(getConstantNameOrValue(enumer, value))
when Hash
if value.is_a?(String)
file.write(value)
else
has_enum = false
enumer.each_key do |key|
next if enumer[key] != value
file.write(key)
has_enum = true
break
end
file.write(value) if !has_enum
has_enum = false
enumer.each_key do |key|
next if enumer[key] != value
file.write(key)
has_enum = true
break
end
file.write(value) if !has_enum
end
else
if value.is_a?(String)

View File

@@ -1,64 +0,0 @@
#===============================================================================
#
#===============================================================================
module Compiler
@@categories[:animations] = {
:should_compile => proc { |compiling| next false },
:header_text => proc { next _INTL("Compiling animations") },
:skipped_text => proc { next _INTL("Not compiled") },
:compile => proc { compile_animations }
}
module_function
#-----------------------------------------------------------------------------
# Compile battle animations.
#-----------------------------------------------------------------------------
def compile_animations
Console.echo_li(_INTL("Compiling animations..."))
begin
pbanims = load_data("Data/PkmnAnimations.rxdata")
rescue
pbanims = PBAnimations.new
end
changed = false
move2anim = [{}, {}]
# anims = load_data("Data/Animations.rxdata")
# for anim in anims
# next if !anim || anim.frames.length == 1
# found = false
# for i in 0...pbanims.length
# if pbanims[i] && pbanims[i].id == anim.id
# found = true if pbanims[i].array.length > 1
# break
# end
# end
# pbanims[anim.id] = pbConvertRPGAnimation(anim) if !found
# end
idx = 0
pbanims.length.times do |i|
echo "." if idx % 100 == 0
Graphics.update if idx % 500 == 0
idx += 1
next if !pbanims[i]
if pbanims[i].name[/^OppMove\:\s*(.*)$/]
if GameData::Move.exists?($~[1])
moveid = GameData::Move.get($~[1]).id
changed = true if !move2anim[0][moveid] || move2anim[1][moveid] != i
move2anim[1][moveid] = i
end
elsif pbanims[i].name[/^Move\:\s*(.*)$/]
if GameData::Move.exists?($~[1])
moveid = GameData::Move.get($~[1]).id
changed = true if !move2anim[0][moveid] || move2anim[0][moveid] != i
move2anim[0][moveid] = i
end
end
end
if changed
save_data(move2anim, "Data/move2anim.dat")
save_data(pbanims, "Data/PkmnAnimations.rxdata")
end
process_pbs_file_message_end
end
end

View File

@@ -1,6 +1,71 @@
#===============================================================================
#
#===============================================================================
module Compiler
@@categories[:animations] = {
:should_compile => proc { |compiling| next should_compile_animations? },
:header_text => proc { next _INTL("Compiling animations") },
:skipped_text => proc { next _INTL("Not compiled") },
:compile => proc { compile_animations }
}
@@categories[:animations] = {
:should_compile => proc { |compiling| next should_compile_animations? },
:header_text => proc { next _INTL("Compiling animations") },
:skipped_text => proc { next _INTL("Not compiled") },
:compile => proc {
# Delete old data files in preparation for recompiling
begin
File.delete("Data/animations.dat") if FileTest.exist?("Data/animations.dat")
rescue SystemCallError
end
text_files = get_animation_pbs_files_to_compile
compile_battle_animations(*text_files)
}
}
module_function
def get_animation_pbs_files_to_compile
ret = []
if FileTest.directory?("PBS/Animations")
Dir.all("PBS/Animations", "**/**.txt").each { |file| ret.push(file) }
end
return ret
end
def should_compile_animations?
# Get all data files and PBS files to be checked for their last modified times
data_file = "animations.dat"
text_files = get_animation_pbs_files_to_compile
# Check data files for their latest modify time
latest_data_write_time = 0
if FileTest.exist?("Data/" + data_file)
begin
File.open("Data/#{data_file}") do |file|
latest_data_write_time = [latest_data_write_time, file.mtime.to_i].max
end
rescue SystemCallError
return true
end
else
return true
end
# Check PBS files for their latest modify time
latest_text_edit_time = 0
text_files.each do |filepath|
begin
File.open(filepath) { |file| latest_text_edit_time = [latest_text_edit_time, file.mtime.to_i].max }
rescue SystemCallError
end
end
# Decide to compile if a PBS file was edited more recently than any .dat files
return (latest_text_edit_time >= latest_data_write_time)
end
#-----------------------------------------------------------------------------
# Compile battle animations.
#-----------------------------------------------------------------------------
def compile_battle_animations(*paths)
GameData::Animation::DATA.clear
schema = GameData::Animation.schema
@@ -125,7 +190,7 @@ module Compiler
particle.keys.each do |property|
next if [:name, :se, :user_cry, :target_cry].include?(property)
raise _INTL("Particle \"{1}\" has a command that isn't a \"Play\"-type command.",
particle[:name]) + "\n" + FileLineData.linereport
particle[:name]) + "\n" + FileLineData.linereport
end
else
if particle[:se]
@@ -206,17 +271,17 @@ module Compiler
# Ensure that only particles that have an entity as a focus can have a
# smart angle
if (particle[:angle_override] || :none) != :none &&
!GameData::Animation::FOCUS_TYPES_WITH_USER.include?(particle[:focus]) &&
!GameData::Animation::FOCUS_TYPES_WITH_TARGET.include?(particle[:focus])
!GameData::Animation::FOCUS_TYPES_WITH_USER.include?(particle[:focus]) &&
!GameData::Animation::FOCUS_TYPES_WITH_TARGET.include?(particle[:focus])
raise _INTL("Particle \"{1}\" can't set \"AngleOverride\" if its focus isn't a specific thing(s).",
particle[:name]) + "\n" + FileLineData.linereport
end
# Ensure that a particle with a user's/target's graphic doesn't have any
# :frame commands
if !["User", "Target", "SE"].include?(particle[:name]) &&
["USER", "USER_OPP", "USER_FRONT", "USER_BACK",
["USER", "USER_OPP", "USER_FRONT", "USER_BACK",
"TARGET", "TARGET_OPP", "TARGET_FRONT", "TARGET_BACK"].include?(particle[:graphic]) &&
particle[:frame] && !particle[:frame].empty?
particle[:frame] && !particle[:frame].empty?
raise _INTL("Particle \"{1}\" can't have any \"Frame\" commands if its graphic is a Pokémon's sprite.",
particle[:name]) + "\n" + FileLineData.linereport
end
@@ -287,87 +352,3 @@ module Compiler
def validate_all_compiled_animations; end
end
#===============================================================================
# Hook into the regular Compiler to also compile animation PBS files.
# This is a separate Compiler that runs after the regular one.
#===============================================================================
module Compiler
module_function
def get_animation_pbs_files_to_compile
ret = []
if FileTest.directory?("PBS/Animations")
Dir.all("PBS/Animations", "**/**.txt").each { |file| ret.push(file) }
end
return ret
end
class << self
if !method_defined?(:__new_anims_main)
alias_method :__new_anims_main, :main
end
end
def main
__new_anims_main
return if !$DEBUG
begin
Console.echo_h1(_INTL("Checking new animations data"))
must_compile = false
data_file = "animations.dat"
text_files = get_animation_pbs_files_to_compile
latest_data_time = 0
latest_text_time = 0
# Check data file for its latest modify time
if FileTest.exist?("Data/" + data_file)
begin
File.open("Data/#{data_file}") do |file|
latest_data_time = [latest_data_time, file.mtime.to_i].max
end
rescue SystemCallError
must_compile = true
end
else
must_compile = true if text_files.length > 0
end
# Check PBS files for their latest modify time
text_files.each do |filepath|
begin
File.open(filepath) do |file|
latest_text_time = [latest_text_time, file.mtime.to_i].max
end
rescue SystemCallError
end
end
# Decide to compile if a PBS file was edited more recently than the .dat file
must_compile |= (latest_text_time >= latest_data_time)
# Should recompile if holding Ctrl
Input.update
must_compile = true if $full_compile || Input.press?(Input::CTRL)
# Delete old data file in preparation for recompiling
if must_compile
begin
File.delete("Data/#{data_file}") if FileTest.exist?("Data/#{data_file}")
rescue SystemCallError
end
# Recompile all data
compile_battle_animations(*text_files)
else
Console.echoln_li(_INTL("New animations data were not compiled"))
end
echoln ""
rescue Exception
e = $!
raise e if e.class.to_s == "Reset" || e.is_a?(Reset) || e.is_a?(SystemExit)
pbPrintException(e)
begin
File.delete("Data/#{data_file}") if FileTest.exist?("Data/#{data_file}")
rescue SystemCallError
end
raise Reset.new if e.is_a?(Hangup)
raise SystemExit.new if e.is_a?(RuntimeError)
raise "Unknown exception when compiling animations."
end
end
end

View File

@@ -89,36 +89,15 @@ module Compiler
end
end
#===============================================================================
# Hook into the regular Compiler to also write all animation PBS files.
#===============================================================================
module Compiler
module_function
class << self
if !method_defined?(:__new_anims__write_all)
alias_method :__new_anims__write_all, :write_all
end
end
def write_all
__new_anims__write_all
Console.echo_h1(_INTL("Writing all animation PBS files"))
write_all_battle_animations
echoln ""
Console.echo_h2(_INTL("Successfully rewrote all animation PBS files"), text: :green)
end
end
#===============================================================================
# Debug menu function for writing all animation PBS files. Shouldn't need to be
# used, but it's here if you want it.
#===============================================================================
MenuHandlers.add(:debug_menu, :create_animation_pbs_files, {
"name" => _INTL("Write all animation PBS files"),
"parent" => :files_menu,
"description" => _INTL("Write all animation PBS files."),
"effect" => proc {
Compiler.write_all_battle_animations
}
})
# MenuHandlers.add(:debug_menu, :create_animation_pbs_files, {
# "name" => _INTL("Write all animation PBS files"),
# "parent" => :files_menu,
# "description" => _INTL("Write all animation PBS files."),
# "effect" => proc {
# Compiler.write_all_battle_animations
# }
# })

View File

@@ -87,91 +87,3 @@ class Bitmap
end
end
end
#===============================================================================
# Fixed Compiler.pbWriteCsvRecord to make it detect enums first, allowing enum
# values to be turned into symbols/booleans/whatever instead of just numbers.
#===============================================================================
module Compiler
module_function
def pbWriteCsvRecord(record, file, schema)
rec = (record.is_a?(Array)) ? record.flatten : [record]
start = (["*", "^"].include?(schema[1][0, 1])) ? 1 : 0
index = -1
loop do
(start...schema[1].length).each do |i|
index += 1
value = rec[index]
if schema[1][i, 1][/[A-Z]/] # Optional
# Check the rest of the values for non-nil things
later_value_found = false
(index...rec.length).each do |j|
later_value_found = true if !rec[j].nil?
break if later_value_found
end
if !later_value_found
start = -1
break
end
end
file.write(",") if index > 0
next if value.nil?
case schema[1][i, 1]
when "e", "E" # Enumerable
enumer = schema[2 + i - start]
case enumer
when Array
file.write(enumer[value])
when Symbol, String
mod = Object.const_get(enumer.to_sym)
file.write(getConstantName(mod, value))
when Module
file.write(getConstantName(enumer, value))
when Hash
enumer.each_key do |key|
next if enumer[key] != value
file.write(key)
break
end
end
when "y", "Y" # Enumerable or integer
enumer = schema[2 + i - start]
case enumer
when Array
file.write((enumer[value].nil?) ? value : enumer[value])
when Symbol, String
mod = Object.const_get(enumer.to_sym)
file.write(getConstantNameOrValue(mod, value))
when Module
file.write(getConstantNameOrValue(enumer, value))
when Hash
has_enum = false
enumer.each_key do |key|
next if enumer[key] != value
file.write(key)
has_enum = true
break
end
file.write(value) if !has_enum
end
else
if value.is_a?(String)
file.write((schema[1][i, 1].downcase == "q") ? value : csvQuote(value))
elsif value.is_a?(Symbol)
file.write(csvQuote(value.to_s))
elsif value == true
file.write("true")
elsif value == false
file.write("false")
else
file.write(value.inspect)
end
end
end
break if start > 0 && index >= rec.length - 1
break if start <= 0
end
return record
end
end

View File

@@ -425,21 +425,3 @@ class AnimationEditor::AnimationSelector
dispose
end
end
#===============================================================================
# Add to Debug menu.
#===============================================================================
MenuHandlers.add(:debug_menu, :use_pc, {
"name" => _INTL("New Animation Editor"),
"parent" => :main,
"description" => _INTL("Open the new animation editor."),
"effect" => proc {
Graphics.resize_screen(AnimationEditor::WINDOW_WIDTH, AnimationEditor::WINDOW_HEIGHT)
pbSetResizeFactor(1)
screen = AnimationEditor::AnimationSelector.new
screen.run
Graphics.resize_screen(Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT)
pbSetResizeFactor($PokemonSystem.screensize)
$game_map&.autoplay
}
})

View File

@@ -1,191 +0,0 @@
#===============================================================================
#
#===============================================================================
class Battle::Scene
ANIMATION_DEFAULTS = [:TACKLE, :DEFENSECURL] # With target, without target
ANIMATION_DEFAULTS_FOR_TYPE_CATEGORY = {
:NORMAL => [:TACKLE, :SONICBOOM, :DEFENSECURL, :BODYSLAM, nil, :TAILWHIP],
:FIGHTING => [:MACHPUNCH, :AURASPHERE, :BULKUP, nil, nil, nil],
:FLYING => [:WINGATTACK, :GUST, :ROOST, nil, :AIRCUTTER, :FEATHERDANCE],
:POISON => [:POISONSTING, :SLUDGE, :ACIDARMOR, nil, :ACID, :POISONPOWDER],
:GROUND => [:SANDTOMB, :MUDSLAP, :MUDSPORT, :EARTHQUAKE, :EARTHPOWER, :SANDATTACK],
:ROCK => [:ROCKTHROW, :POWERGEM, :ROCKPOLISH, :ROCKSLIDE, nil, :SANDSTORM],
:BUG => [:TWINEEDLE, :BUGBUZZ, :QUIVERDANCE, nil, :STRUGGLEBUG, :STRINGSHOT],
:GHOST => [:ASTONISH, :SHADOWBALL, :GRUDGE, nil, nil, :CONFUSERAY],
:STEEL => [:IRONHEAD, :MIRRORSHOT, :IRONDEFENSE, nil, nil, :METALSOUND],
:FIRE => [:FIREPUNCH, :EMBER, :SUNNYDAY, nil, :INCINERATE, :WILLOWISP],
:WATER => [:CRABHAMMER, :WATERGUN, :AQUARING, nil, :SURF, :WATERSPORT],
:GRASS => [:VINEWHIP, :RAZORLEAF, :COTTONGUARD, nil, nil, :SPORE],
:ELECTRIC => [:THUNDERPUNCH, :THUNDERSHOCK, :CHARGE, nil, :DISCHARGE, :THUNDERWAVE],
:PSYCHIC => [:ZENHEADBUTT, :CONFUSION, :CALMMIND, nil, :SYNCHRONOISE, :MIRACLEEYE],
:ICE => [:ICEPUNCH, :ICEBEAM, :MIST, :AVALANCHE, :POWDERSNOW, :HAIL],
:DRAGON => [:DRAGONCLAW, :DRAGONRAGE, :DRAGONDANCE, nil, :TWISTER, nil],
:DARK => [:KNOCKOFF, :DARKPULSE, :HONECLAWS, nil, :SNARL, :EMBARGO],
:FAIRY => [:TACKLE, :FAIRYWIND, :MOONLIGHT, nil, :DAZZLINGGLEAM, :SWEETKISS]
}
#-----------------------------------------------------------------------------
def pbAnimation(move_id, user, targets, version = 0)
anims = find_move_animation(move_id, version, user&.index)
return if !anims || anims.empty?
if anims[0].is_a?(GameData::Animation) # New animation
pbSaveShadows do
# NOTE: anims.sample is a random valid animation.
play_better_animation(anims.sample, user, targets)
end
else # Old animation
anim = anims[0]
target = (targets.is_a?(Array)) ? targets[0] : targets
animations = pbLoadBattleAnimations
return if !animations
pbSaveShadows do
if anims[1] # On opposing side and using OppMove animation
pbAnimationCore(animations[anim], target, user, true)
else # On player's side, and/or using Move animation
pbAnimationCore(animations[anim], user, target)
end
end
end
end
alias __newanims__pbCommonAnimation pbCommonAnimation unless method_defined?(:__newanims__pbCommonAnimation)
def pbCommonAnimation(anim_name, user = nil, target = nil)
return if nil_or_empty?(anim_name)
anims = try_get_better_common_animation(anim_name, user.index)
if anims
# NOTE: anims.sample is a random valid animation.
play_better_animation(anims.sample, user, target)
else
__newanims__pbCommonAnimation(anim_name, user, target)
end
end
#-----------------------------------------------------------------------------
# Returns an array of GameData::Animation if a new animation(s) is found.
# Return [animation index, shouldn't be flipped] if an old animation is found.
def find_move_animation(move_id, version, user_index)
# Get animation
anims = find_move_animation_for_move(move_id, version, user_index)
return anims if anims
# Get information to decide which default animation to try
move_data = GameData::Move.get(move_id)
target_data = GameData::Target.get(move_data.target)
move_type = move_data.type
default_idx = move_data.category
default_idx += 3 if target_data.num_targets > 1 ||
(target_data.num_targets > 0 && move_data.status?)
# Check for a default animation
wanted_move = ANIMATION_DEFAULTS_FOR_TYPE_CATEGORY[move_type][default_idx]
anims = find_move_animation_for_move(wanted_move, 0, user_index)
return anims if anims
if default_idx >= 3
wanted_move = ANIMATION_DEFAULTS_FOR_TYPE_CATEGORY[move_type][default_idx - 3]
anims = find_move_animation_for_move(wanted_move, 0, user_index)
return anims if anims
return nil if ANIMATION_DEFAULTS.include?(wanted_move) # No need to check for these animations twice
end
# Use Tackle or Defense Curl's animation
if target_data.num_targets == 0 && target.data.id != :None
return find_move_animation_for_move(ANIMATION_DEFAULTS[1], 0, user_index)
end
return find_move_animation_for_move(ANIMATION_DEFAULTS[0], 0, user_index)
end
# Find an animation(s) for the given move_id.
def find_move_animation_for_move(move_id, version, user_index)
# Find new animation
anims = try_get_better_move_animation(move_id, version, user_index)
return anims if anims
if version > 0
anims = try_get_better_move_animation(move_id, 0, user_index)
return anims if anims
end
# Find old animation
anim = pbFindMoveAnimDetails(pbLoadMoveToAnim, move_id, user_index, version)
return anim
end
# Finds a new animation for the given move_id and version. Prefers opposing
# animations if the user is opposing. Can return multiple animations.
def try_get_better_move_animation(move_id, version, user_index)
ret = []
backup_ret = []
GameData::Animation.each do |anim|
next if !anim.move_animation? || anim.ignore
next if anim.move != move_id.to_s
next if anim.version != version
if !user_index
ret.push(anim)
next
end
if user_index.even? # User is on player's side
ret.push(anim) if !anim.opposing_animation?
else # User is on opposing side
(anim.opposing_animation?) ? ret.push(anim) : backup_ret.push(anim)
end
end
return ret if !ret.empty?
return backup_ret if !backup_ret.empty?
return nil
end
def try_get_better_common_animation(anim_name, user_index)
ret = []
backup_ret = []
GameData::Animation.each do |anim|
next if !anim.common_animation? || anim.ignore
next if anim.move != anim_name
if !user_index
ret.push(anim)
next
end
if user_index.even? # User is on player's side
ret.push(anim) if !anim.opposing_animation?
else # User is on opposing side
(anim.opposing_animation?) ? ret.push(anim) : backup_ret.push(anim)
end
end
return ret if !ret.empty?
return backup_ret if !backup_ret.empty?
return nil
end
#-----------------------------------------------------------------------------
def play_better_animation(anim_data, user, targets)
return if !anim_data
@briefMessage = false
# Memorize old battler coordinates, to be reset after the animation
old_battler_coords = []
if user
sprite = @sprites["pokemon_#{user.index}"]
old_battler_coords[user.index] = [sprite.x, sprite.y]
end
if targets
targets.each do |target|
sprite = @sprites["pokemon_#{target.index}"]
old_battler_coords[target.index] = [sprite.x, sprite.y]
end
end
# Create animation player
anim_player = AnimationPlayer.new(anim_data, user, targets, self)
anim_player.set_up
# Play animation
anim_player.start
loop do
pbUpdate
anim_player.update
break if anim_player.can_continue_battle?
end
anim_player.dispose
# Restore old battler coordinates
old_battler_coords.each_with_index do |values, i|
next if !values
sprite = @sprites["pokemon_#{i}"]
sprite.x = values[0]
sprite.y = values[1]
end
end
end

View File

@@ -1,590 +0,0 @@
#===============================================================================
#
#===============================================================================
class Battle::Scene
alias __newanims__pbCreateBackdropSprites pbCreateBackdropSprites unless method_defined?(:__newanims__pbCreateBackdropSprites)
def pbCreateBackdropSprites
__newanims__pbCreateBackdropSprites
["battle_bg", "battle_bg2"].each { |spr| @sprites[spr].z = -200 }
2.times do |side|
@sprites["base_#{side}"].z = -199
end
@sprites["cmdBar_bg"].z += 9999
end
alias __newanims__pbInitSprites pbInitSprites unless method_defined?(:__newanims__pbInitSprites)
def pbInitSprites
__newanims__pbInitSprites
@sprites["messageBox"].z += 9999
@sprites["messageWindow"].z += 9999
@sprites["commandWindow"].z += 9999
@sprites["fightWindow"].z += 9999
@sprites["targetWindow"].z += 9999
2.times do |side|
@sprites["partyBar_#{side}"].z += 9999
NUM_BALLS.times do |i|
@sprites["partyBall_#{side}_#{i}"].z += 9999
end
# Ability splash bars
@sprites["abilityBar_#{side}"].z += 9999 if USE_ABILITY_SPLASH
end
@battle.battlers.each_with_index do |b, i|
@sprites["dataBox_#{i}"].z += 9999 if b
end
@battle.player.each_with_index do |p, i|
@sprites["player_#{i + 1}"].z = 1500 + (i * 100)
end
if @battle.trainerBattle?
@battle.opponent.each_with_index do |p, i|
@sprites["trainer_#{i + 1}"].z = 500 - (i * 100)
end
end
end
end
#===============================================================================
# Pokémon sprite (used in battle)
#===============================================================================
class Battle::Scene::BattlerSprite < RPG::Sprite
def pbSetPosition
return if !@_iconBitmap
pbSetOrigin
if @index.even?
self.z = 1100 + (100 * @index / 2)
else
self.z = 1000 - (100 * (@index + 1) / 2)
end
# Set original position
p = Battle::Scene.pbBattlerPosition(@index, @sideSize)
@spriteX = p[0]
@spriteY = p[1]
# Apply metrics
@pkmn.species_data.apply_metrics_to_sprite(self, @index)
end
end
#===============================================================================
# Shadow sprite for Pokémon (used in battle)
#===============================================================================
class Battle::Scene::BattlerShadowSprite < RPG::Sprite
def pbSetPosition
return if !@_iconBitmap
pbSetOrigin
self.z = -198
# Set original position
p = Battle::Scene.pbBattlerPosition(@index, @sideSize)
self.x = p[0]
self.y = p[1]
# Apply metrics
@pkmn.species_data.apply_metrics_to_sprite(self, @index, true)
end
end
#===============================================================================
# Mixin module for certain hardcoded battle animations that involve Poké Balls.
#===============================================================================
module Battle::Scene::Animation::BallAnimationMixin
# The regular Poké Ball burst animation, for when a Pokémon appears from a
# Poké Ball.
def ballBurst(delay, ball, ballX, ballY, poke_ball)
num_particles = 15
num_rays = 10
glare_fade_duration = 8 # Lifetimes/durations are in 20ths of a second
particle_lifetime = 15
particle_fade_duration = 8
ray_lifetime = 13
ray_fade_duration = 5
ray_min_radius = 24 # How far out from the center a ray starts
cherish_ball_ray_tones = [Tone.new(-104, -144, -8), # Indigo
Tone.new(-64, -144, -24), # Purple
Tone.new(-8, -144, -64), # Pink
Tone.new(-8, -48, -152), # Orange
Tone.new(-8, -32, -160)] # Yellow
# Get array of things that vary for each kind of Poké Ball
variances = BALL_BURST_VARIANCES[poke_ball] || BALL_BURST_VARIANCES[:POKEBALL]
# Set up glare particles
glare1 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[11]}", PictureOrigin::CENTER)
glare2 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[8]}", PictureOrigin::CENTER)
[glare1, glare2].each_with_index do |particle, num|
particle.setZ(0, 5105 + num)
particle.setZoom(0, 0)
particle.setTone(0, variances[12 - (3 * num)])
particle.setVisible(0, false)
end
[glare1, glare2].each_with_index do |particle, num|
particle.moveTone(delay + glare_fade_duration + 3, glare_fade_duration / 2, variances[13 - (3 * num)])
end
# Animate glare particles
[glare1, glare2].each { |p| p.setVisible(delay, true) }
if poke_ball == :MASTERBALL
glare1.moveAngle(delay, 19, -135)
glare1.moveZoom(delay, glare_fade_duration, 250)
elsif poke_ball == :DUSKBALL
glare1.moveAngle(delay, 19, -270)
elsif ["whirl"].include?(variances[11])
glare1.moveZoom(delay, glare_fade_duration, 200)
else
glare1.moveZoom(delay, glare_fade_duration, (["dazzle", "ring3", "web"].include?(variances[11])) ? 100 : 250)
end
glare1.moveOpacity(delay + glare_fade_duration + 3, glare_fade_duration, 0)
if poke_ball == :MASTERBALL
glare2.moveAngle(delay, 19, -135)
glare2.moveZoom(delay, glare_fade_duration, 200)
else
glare2.moveZoom(delay, glare_fade_duration, (["dazzle", "ring3", "web"].include?(variances[8])) ? 125 : 200)
end
glare2.moveOpacity(delay + glare_fade_duration + 3, glare_fade_duration - 2, 0)
[glare1, glare2].each { |p| p.setVisible(delay + 19, false) }
# Rays
num_rays.times do |i|
# Set up ray
angle = rand(360)
radian = (angle + 90) * Math::PI / 180
start_zoom = rand(50...100)
ray = addNewSprite(ballX + (ray_min_radius * Math.cos(radian)),
ballY - (ray_min_radius * Math.sin(radian)),
"Graphics/Battle animations/ballBurst_ray", PictureOrigin::BOTTOM)
ray.setZ(0, 5100)
ray.setZoomXY(0, 200, start_zoom)
ray.setTone(0, variances[0]) if poke_ball != :CHERISHBALL
ray.setOpacity(0, 0)
ray.setVisible(0, false)
ray.setAngle(0, angle)
# Animate ray
start = delay + (i / 2)
ray.setVisible(start, true)
ray.moveZoomXY(start, ray_lifetime, 200, start_zoom * 6)
ray.moveOpacity(start, 2, 255) # Quickly fade in
ray.moveOpacity(start + ray_lifetime - ray_fade_duration, ray_fade_duration, 0) # Fade out
if poke_ball == :CHERISHBALL
ray_lifetime.times do |frame|
ray.setTone(start + frame, cherish_ball_ray_tones[frame % cherish_ball_ray_tones.length])
end
else
ray.moveTone(start + ray_lifetime - ray_fade_duration, ray_fade_duration, variances[1])
end
ray.setVisible(start + ray_lifetime, false)
end
# Particles
num_particles.times do |i|
# Set up particles
particle1 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[5]}", PictureOrigin::CENTER)
particle2 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[2]}", PictureOrigin::CENTER)
[particle1, particle2].each_with_index do |particle, num|
particle.setZ(0, 5110 + num)
particle.setZoom(0, (80 - (num * 20)) / (["ring2"].include?(variances[5 - (3 * num)]) ? 2 : 1))
particle.setTone(0, variances[6 - (3 * num)])
particle.setVisible(0, false)
end
# Animate particles
start = delay + (i / 4)
max_radius = rand(256...384)
angle = rand(360)
radian = angle * Math::PI / 180
[particle1, particle2].each_with_index do |particle, num|
particle.setVisible(start, true)
particle.moveDelta(start, particle_lifetime, max_radius * Math.cos(radian), max_radius * Math.sin(radian))
particle.moveZoom(start, particle_lifetime, 10)
particle.moveTone(start + particle_lifetime - particle_fade_duration,
particle_fade_duration / 2, variances[7 - (3 * num)])
particle.moveOpacity(start + particle_lifetime - particle_fade_duration,
particle_fade_duration,
0) # Fade out at end
particle.setVisible(start + particle_lifetime, false)
end
end
end
# The Poké Ball burst animation used when absorbing a wild Pokémon during a
# capture attempt.
def ballBurstCapture(delay, ball, ballX, ballY, poke_ball)
particle_duration = 10
ring_duration = 5
num_particles = 9
base_angle = 270
base_radius = (poke_ball == :MASTERBALL) ? 192 : 144 # How far out from the Poké Ball the particles go
# Get array of things that vary for each kind of Poké Ball
variances = BALL_BURST_CAPTURE_VARIANCES[poke_ball] || BALL_BURST_CAPTURE_VARIANCES[:POKEBALL]
# Set up glare particles
glare1 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[6]}", PictureOrigin::CENTER)
glare2 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[3]}", PictureOrigin::CENTER)
glare3 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[0]}", PictureOrigin::CENTER)
[glare1, glare2, glare3].each_with_index do |particle, num|
particle.setZ(0, 5100 + num)
particle.setZoom(0, 0)
particle.setTone(0, variances[7 - (3 * num)])
particle.setVisible(0, false)
end
glare2.setOpacity(0, 160)
glare3.setOpacity(0, 160) if poke_ball != :DUSKBALL
# Animate glare particles
[glare1, glare2, glare3].each { |p| p.setVisible(delay, true) }
case poke_ball
when :MASTERBALL
glare1.moveZoom(delay, particle_duration, 1200)
when :DUSKBALL
glare1.moveZoom(delay, particle_duration, 350)
else
glare1.moveZoom(delay, particle_duration, 600)
end
glare1.moveOpacity(delay + (particle_duration / 2), particle_duration / 2, 0)
[glare1, glare2, glare3].each_with_index do |particle, num|
particle.moveTone(delay, particle_duration, variances[8 - (3 * num)])
end
if poke_ball == :DUSKBALL
glare2.moveZoom(delay, particle_duration, 350)
glare3.moveZoom(delay, particle_duration, 500)
[glare2, glare3].each_with_index do |particle, num|
particle.moveOpacity(delay + (particle_duration / 2), particle_duration / 2, 0)
end
else
glare2.moveZoom(delay, particle_duration, (poke_ball == :MASTERBALL) ? 400 : 250)
glare2.moveOpacity(delay + (particle_duration / 2), particle_duration / 3, 0)
glare3.moveZoom(delay, particle_duration, (poke_ball == :MASTERBALL) ? 800 : 500)
glare3.moveOpacity(delay + (particle_duration / 2), particle_duration / 3, 0)
end
[glare1, glare2, glare3].each { |p| p.setVisible(delay + particle_duration, false) }
# Burst particles
num_particles.times do |i|
# Set up particle that keeps moving out
particle1 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_particle", PictureOrigin::CENTER)
particle1.setZ(0, 5105)
particle1.setZoom(0, 150)
particle1.setOpacity(0, 160)
particle1.setVisible(0, false)
# Set up particles that curve back in
particle2 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[12]}", PictureOrigin::CENTER)
particle3 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_#{variances[9]}", PictureOrigin::CENTER)
[particle2, particle3].each_with_index do |particle, num|
particle.setZ(0, 5110 + num)
particle.setZoom(0, (poke_ball == :NESTBALL) ? 50 : 0)
particle.setTone(0, variances[13 - (3 * num)])
particle.setVisible(0, false)
particle.setAngle(0, rand(360)) if poke_ball == :PREMIERBALL
end
particle3.setOpacity(0, 128) if poke_ball == :DIVEBALL
# Particle animations
[particle1, particle2, particle3].each { |p| p.setVisible(delay, true) }
particle2.setVisible(delay, false) if poke_ball == :NESTBALL
start_angle = base_angle + (i * 360 / num_particles)
p1_x_offset = base_radius * Math.cos(start_angle * Math::PI / 180)
p1_y_offset = base_radius * Math.sin(start_angle * Math::PI / 180)
particle_duration.times do |j|
index = j + 1
angle = start_angle + (index * (360 / num_particles) / particle_duration)
radian = angle * Math::PI / 180
radius = base_radius
prop = index.to_f / (particle_duration / 2)
prop = 2 - prop if index > particle_duration / 2
radius *= prop
particle1.moveXY(delay + j, 1,
ballX + (p1_x_offset * index * 2 / particle_duration),
ballY - (p1_y_offset * index * 2 / particle_duration))
[particle2, particle3].each do |particle|
particle.moveXY(delay + j, 1,
ballX + (radius * Math.cos(radian)),
ballY - (radius * Math.sin(radian)))
end
end
particle1.moveZoom(delay, particle_duration, 0)
particle1.moveOpacity(delay, particle_duration, 0)
[particle2, particle3].each_with_index do |particle, num|
# Zoom in
if num == 0 && poke_ball == :MASTERBALL
particle.moveZoom(delay, particle_duration / 2, 225)
elsif num == 0 && poke_ball == :DIVEBALL
particle.moveZoom(delay, particle_duration / 2, 125)
elsif ["particle"].include?(variances[12 - (3 * num)])
particle.moveZoom(delay, particle_duration / 2, (poke_ball == :PREMIERBALL) ? 50 : 80)
elsif ["ring3"].include?(variances[12 - (3 * num)])
particle.moveZoom(delay, particle_duration / 2, 50)
elsif ["dazzle", "ring4", "diamond"].include?(variances[12 - (3 * num)])
particle.moveZoom(delay, particle_duration / 2, 60)
else
particle.moveZoom(delay, particle_duration / 2, 100)
end
# Zoom out
if ["particle", "dazzle", "ring3", "ring4", "diamond"].include?(variances[12 - (3 * num)])
particle.moveZoom(delay + (particle_duration * 2 / 3), particle_duration / 3, 10)
else
particle.moveZoom(delay + (particle_duration * 2 / 3), particle_duration / 3, 25)
end
# Rotate (for Premier Ball)
particle.moveAngle(delay, particle_duration, -180) if poke_ball == :PREMIERBALL
# Change tone, fade out
particle.moveTone(delay + (particle_duration / 3), (particle_duration.to_f / 3).ceil, variances[14 - (3 * num)])
particle.moveOpacity(delay + particle_duration - 3, 3, 128) # Fade out at end
end
[particle1, particle2, particle3].each { |p| p.setVisible(delay + particle_duration, false) }
end
# Web sprite (for Net Ball)
if poke_ball == :NETBALL
web = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_web", PictureOrigin::CENTER)
web.setZ(0, 5123)
web.setZoom(0, 120)
web.setOpacity(0, 0)
web.setTone(0, Tone.new(-32, -32, -128))
web.setVisible(0, false)
start = particle_duration / 2
web.setVisible(delay + start, true)
web.moveOpacity(delay + start, 2, 160)
web_duration = particle_duration + ring_duration - (particle_duration / 2)
(web_duration / 4).times do |i|
web.moveZoom(delay + start + (i * 4), 2, 150)
web.moveZoom(delay + start + (i * 4) + 2, 2, 120)
end
now = start + ((web_duration / 4) * 4)
web.moveZoom(delay + now, particle_duration + ring_duration - now, 150)
web.moveOpacity(delay + particle_duration, ring_duration, 0)
web.setVisible(delay + particle_duration + ring_duration, false)
end
# Ring particle
ring = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_ring1", PictureOrigin::CENTER)
ring.setZ(0, 5110)
ring.setZoom(0, 0)
ring.setTone(0, variances[15])
ring.setVisible(0, false)
# Ring particle animation
ring.setVisible(delay + particle_duration, true)
ring.moveZoom(delay + particle_duration - 2, ring_duration + 2, 125) # Start slightly early
ring.moveTone(delay + particle_duration, ring_duration, variances[16])
ring.moveOpacity(delay + particle_duration, ring_duration, 0)
ring.setVisible(delay + particle_duration + ring_duration, false)
# Mark the end of the burst animation
ball.setDelta(delay + particle_duration + ring_duration, 0, 0)
end
# The animation shown over a thrown Poké Ball when it has successfully caught
# a Pokémon.
def ballCaptureSuccess(ball, delay, ballX, ballY)
ball.setSE(delay, "Battle catch click")
ball.moveTone(delay, 4, Tone.new(-128, -128, -128)) # Ball goes darker
delay = ball.totalDuration
star_duration = 12 # In 20ths of a second
y_offsets = [[0, 74, 52], [0, 62, 28], [0, 74, 48]]
3.times do |i| # Left, middle, right
# Set up particle
star = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_star", PictureOrigin::CENTER)
star.setZ(0, 5110)
star.setZoom(0, [50, 50, 33][i])
start_angle = [0, 345, 15][i]
star.setAngle(0, start_angle)
star.setOpacity(0, 0)
star.setVisible(0, false)
# Particle animation
star.setVisible(delay, true)
y_pos = y_offsets[i]
star_duration.times do |j|
index = j + 1
x = 72 * index / star_duration
proportion = index.to_f / star_duration
a = (2 * y_pos[2]) - (4 * y_pos[1])
b = y_pos[2] - a
y = ((a * proportion) + b) * proportion
star.moveXY(delay + j, 1, ballX + ([-1, 0, 1][i] * x), ballY - y)
end
star.moveAngle(delay, star_duration, start_angle + [144, 0, 45][i]) if i.even?
star.moveOpacity(delay, 4, 255) # Fade in
star.moveTone(delay + 3, 3, Tone.new(0, 0, -96)) # Light yellow
star.moveTone(delay + 6, 3, Tone.new(0, 0, 0)) # White
star.moveOpacity(delay + 8, 4, 0) # Fade out
end
end
# The Poké Ball burst animation used when recalling a Pokémon. In HGSS, this
# is the same for all types of Poké Ball except for the color that the battler
# turns - see def getBattlerColorFromPokeBall.
def ballBurstRecall(delay, ball, ballX, ballY, poke_ball)
color_duration = 10 # Change color of battler to a solid shade - see def battlerAbsorb
shrink_duration = 5 # Shrink battler into Poké Ball - see def battlerAbsorb
burst_duration = color_duration + shrink_duration
# Burst particles
num_particles = 5
base_angle = 55
base_radius = 64 # How far out from the Poké Ball the particles go
num_particles.times do |i|
# Set up particle
particle = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_particle", PictureOrigin::CENTER)
particle.setZ(0, 5110)
particle.setZoom(0, 150)
particle.setOpacity(0, 0)
particle.setVisible(0, false)
# Particle animation
particle.setVisible(delay, true)
particle.moveOpacity(delay, 2, 255) # Fade in quickly
burst_duration.times do |j|
angle = base_angle + (i * 360 / num_particles) + (135.0 * j / burst_duration)
radian = angle * Math::PI / 180
radius = base_radius
if j < burst_duration / 5
prop = j.to_f / (color_duration / 3)
radius *= 0.75 + (prop / 4)
elsif j >= burst_duration / 2
prop = (j.to_f - (burst_duration / 2)) / (burst_duration / 2)
radius *= 1 - prop
end
if j == 0
particle.setXY(delay + j, ballX + (radius * Math.cos(radian)), ballY - (radius * Math.sin(radian)))
else
particle.moveXY(delay + j, 1, ballX + (radius * Math.cos(radian)), ballY - (radius * Math.sin(radian)))
end
end
particle.moveZoom(delay, burst_duration, 0)
particle.moveTone(delay + (color_duration / 2), color_duration / 2, Tone.new(0, 0, -192)) # Yellow
particle.moveTone(delay + color_duration, shrink_duration, Tone.new(0, -128, -248)) # Dark orange
particle.moveOpacity(delay + color_duration, shrink_duration, 0) # Fade out at end
particle.setVisible(delay + burst_duration, false)
end
# Ring particles
ring1 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_ring1", PictureOrigin::CENTER)
ring1.setZ(0, 5110)
ring1.setZoom(0, 0)
ring1.setVisible(0, false)
ring2 = addNewSprite(ballX, ballY, "Graphics/Battle animations/ballBurst_ring2", PictureOrigin::CENTER)
ring2.setZ(0, 5110)
ring2.setVisible(0, false)
# Ring particle animations
ring1.setVisible(delay + burst_duration - 2, true)
ring1.moveZoom(delay + burst_duration - 2, 4, 100)
ring1.setVisible(delay + burst_duration + 2, false)
ring2.setVisible(delay + burst_duration + 2, true)
ring2.moveZoom(delay + burst_duration + 2, 4, 200)
ring2.moveOpacity(delay + burst_duration + 2, 4, 0)
end
end
#===============================================================================
# Shows the battle scene fading in while elements slide around into place
#===============================================================================
class Battle::Scene::Animation::Intro < Battle::Scene::Animation
def createProcesses
appearTime = 20 # This is in 1/20 seconds
# Background
if @sprites["battle_bg2"]
makeSlideSprite("battle_bg", 0.5, appearTime)
makeSlideSprite("battle_bg2", 0.5, appearTime)
end
# Bases
makeSlideSprite("base_0", 1, appearTime, PictureOrigin::BOTTOM)
makeSlideSprite("base_1", -1, appearTime, PictureOrigin::CENTER)
# Player sprite, partner trainer sprite
@battle.player.each_with_index do |_p, i|
makeSlideSprite("player_#{i + 1}", 1, appearTime, PictureOrigin::BOTTOM)
end
# Opposing trainer sprite(s) or wild Pokémon sprite(s)
if @battle.trainerBattle?
@battle.opponent.each_with_index do |_p, i|
makeSlideSprite("trainer_#{i + 1}", -1, appearTime, PictureOrigin::BOTTOM)
end
else # Wild battle
@battle.pbParty(1).each_with_index do |_pkmn, i|
idxBattler = (2 * i) + 1
makeSlideSprite("pokemon_#{idxBattler}", -1, appearTime, PictureOrigin::BOTTOM)
end
end
# Shadows
@battle.battlers.length.times do |i|
makeSlideSprite("shadow_#{i}", (i.even?) ? 1 : -1, appearTime, PictureOrigin::CENTER)
end
# Fading blackness over whole screen
blackScreen = addNewSprite(0, 0, "Graphics/Battle animations/black_screen")
blackScreen.setZ(0, 99999)
blackScreen.moveOpacity(0, 8, 0)
# Fading blackness over command bar
blackBar = addNewSprite(@sprites["cmdBar_bg"].x, @sprites["cmdBar_bg"].y,
"Graphics/Battle animations/black_bar")
blackBar.setZ(0, 99998)
blackBar.moveOpacity(appearTime * 3 / 4, appearTime / 4, 0)
end
end
#===============================================================================
# Shows a Pokémon being sent out on the player's side (including by a partner).
# Includes the Poké Ball being thrown.
#===============================================================================
class Battle::Scene::Animation::PokeballPlayerSendOut < Battle::Scene::Animation
def createProcesses
batSprite = @sprites["pokemon_#{@battler.index}"]
shaSprite = @sprites["shadow_#{@battler.index}"]
traSprite = @sprites["player_#{@idxTrainer}"]
# Calculate the Poké Ball graphic to use
poke_ball = (batSprite.pkmn) ? batSprite.pkmn.poke_ball : nil
# Calculate the color to turn the battler sprite
col = getBattlerColorFromPokeBall(poke_ball)
col.alpha = 255
# Calculate start and end coordinates for battler sprite movement
ballPos = Battle::Scene.pbBattlerPosition(@battler.index, batSprite.sideSize)
battlerStartX = ballPos[0] # Is also where the Ball needs to end
battlerStartY = ballPos[1] # Is also where the Ball needs to end + 18
battlerEndX = batSprite.x
battlerEndY = batSprite.y
# Calculate start and end coordinates for Poké Ball sprite movement
ballStartX = -6
ballStartY = 202
ballMidX = 0 # Unused in trajectory calculation
ballMidY = battlerStartY - 144
# Set up Poké Ball sprite
ball = addBallSprite(ballStartX, ballStartY, poke_ball)
ball.setZ(0, 1025)
ball.setVisible(0, false)
# Poké Ball tracking the player's hand animation (if trainer is visible)
if @showingTrainer && traSprite && traSprite.x > 0
ball.setZ(0, traSprite.z - 1)
ballStartX, ballStartY = ballTracksHand(ball, traSprite)
end
delay = ball.totalDuration # 0 or 7
# Poké Ball trajectory animation
createBallTrajectory(ball, delay, 12,
ballStartX, ballStartY, ballMidX, ballMidY, battlerStartX, battlerStartY - 18)
ball.setZ(9, batSprite.z - 1)
delay = ball.totalDuration + 4
delay += 10 * @idxOrder # Stagger appearances if multiple Pokémon are sent out at once
ballOpenUp(ball, delay - 2, poke_ball)
ballBurst(delay, ball, battlerStartX, battlerStartY - 18, poke_ball)
ball.moveOpacity(delay + 2, 2, 0)
# Set up battler sprite
battler = addSprite(batSprite, PictureOrigin::BOTTOM)
battler.setXY(0, battlerStartX, battlerStartY)
battler.setZoom(0, 0)
battler.setColor(0, col)
# Battler animation
battlerAppear(battler, delay, battlerEndX, battlerEndY, batSprite, col)
if @shadowVisible
# Set up shadow sprite
shadow = addSprite(shaSprite, PictureOrigin::CENTER)
shadow.setOpacity(0, 0)
# Shadow animation
shadow.setVisible(delay, @shadowVisible)
shadow.moveOpacity(delay + 5, 10, 255)
end
end
end
#===============================================================================
# Shows the player throwing a Poké Ball and it being deflected
#===============================================================================
class Battle::Scene::Animation::PokeballThrowDeflect < Battle::Scene::Animation
def createProcesses
# Calculate start and end coordinates for battler sprite movement
batSprite = @sprites["pokemon_#{@battler.index}"]
ballPos = Battle::Scene.pbBattlerPosition(@battler.index, batSprite.sideSize)
ballStartX = -6
ballStartY = 246
ballMidX = 190 # Unused in arc calculation
ballMidY = 78
ballEndX = ballPos[0]
ballEndY = 112
# Set up Poké Ball sprite
ball = addBallSprite(ballStartX, ballStartY, @poke_ball)
ball.setZ(0, 5090)
# Poké Ball arc animation
ball.setSE(0, "Battle throw")
createBallTrajectory(ball, 0, 16,
ballStartX, ballStartY, ballMidX, ballMidY, ballEndX, ballEndY)
# Poké Ball knocked back
delay = ball.totalDuration
ball.setSE(delay, "Battle ball drop")
ball.moveXY(delay, 8, -32, Graphics.height - 96 + 32) # Back to player's corner
createBallTumbling(ball, delay, 8)
end
end