mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 22:24:58 +00:00
Made multiple special battle animations easier to register
This commit is contained in:
@@ -1,3 +1,33 @@
|
|||||||
|
#===============================================================================
|
||||||
|
#
|
||||||
|
#===============================================================================
|
||||||
|
module SpecialBattleIntroAnimations
|
||||||
|
# [name, priority number, "trigger if" proc, animation proc]
|
||||||
|
@@anims = []
|
||||||
|
|
||||||
|
def self.register(name, priority, condition, hash)
|
||||||
|
@@anims.push([name, priority, condition, hash])
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.remove(name)
|
||||||
|
@@anims.delete_if { |anim| anim[0] == name }
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.each
|
||||||
|
ret = @@anims.sort { |a, b| b[1] <=> a[1] }
|
||||||
|
ret.each { |anim| yield anim[0], anim[1], anim[2], anim[3] }
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.has?(name)
|
||||||
|
return @@anims.any? { |anim| anim[0] == name }
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.get(name)
|
||||||
|
@@anims.each { |anim| return anim if anim[0] == name }
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Battle intro animation
|
# Battle intro animation
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
@@ -29,7 +59,12 @@ def pbBattleAnimation(bgm=nil,battletype=0,foe=nil)
|
|||||||
bgm = pbGetWildBattleBGM([]) if !bgm
|
bgm = pbGetWildBattleBGM([]) if !bgm
|
||||||
pbBGMPlay(bgm)
|
pbBGMPlay(bgm)
|
||||||
# Check for custom battle intro animations
|
# Check for custom battle intro animations
|
||||||
handled = pbBattleAnimationOverride(viewport,battletype,foe)
|
handled = false
|
||||||
|
SpecialBattleIntroAnimations.each do |name, priority, condition, animation|
|
||||||
|
next if !condition.call(battletype, foe)
|
||||||
|
animation.call(viewport, battletype, foe)
|
||||||
|
handled = true
|
||||||
|
end
|
||||||
# Default battle intro animation
|
# Default battle intro animation
|
||||||
if !handled
|
if !handled
|
||||||
# Determine which animation is played
|
# Determine which animation is played
|
||||||
@@ -129,25 +164,54 @@ end
|
|||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Vs. battle intro animation
|
# Vs. battle intro animation
|
||||||
|
# If you want to add a custom battle intro animation, copy the code below for
|
||||||
|
# the Vs. animation and adapt it to your own. The register call has 4 arguments:
|
||||||
|
# 1) The name of the animation. Typically unused, but helps to identify an
|
||||||
|
# animation.
|
||||||
|
# 2) The animation's priority. If multiple special animations could trigger
|
||||||
|
# for the same battle, the one with the highest priority number is used.
|
||||||
|
# 3) A condition proc which decides whether the animation should trigger.
|
||||||
|
# 4) The animation itself. Could be a bunch of code, or a call to, say,
|
||||||
|
# pbCommonEvent(20) or something else. By the end of the animation, the
|
||||||
|
# screen should be black.
|
||||||
|
# Note that you can get an image of the current game screen with
|
||||||
|
# Graphics.snap_to_bitmap.
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbBattleAnimationOverride(viewport,battletype=0,foe=nil)
|
|
||||||
##### VS. animation, by Luka S.J. #####
|
##### VS. animation, by Luka S.J. #####
|
||||||
##### Tweaked by Maruno #####
|
##### Tweaked by Maruno #####
|
||||||
if (battletype==1 || battletype==3) && foe.length==1 # Against single trainer
|
SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50
|
||||||
|
Proc.new { |battle_type, foe| # Condition
|
||||||
|
next false unless [1, 3].include?(battle_type) && foe.length == 1 # Only if a single trainer
|
||||||
tr_type = foe[0].trainer_type
|
tr_type = foe[0].trainer_type
|
||||||
if tr_type
|
next false if !tr_type
|
||||||
tbargraphic = sprintf("vsBar_%s", tr_type.to_s) rescue nil
|
trainer_bar_graphic = sprintf("vsBar_%s", tr_type.to_s) rescue nil
|
||||||
tgraphic = sprintf("vsTrainer_%s", tr_type.to_s) rescue nil
|
trainer_graphic = sprintf("vsTrainer_%s", tr_type.to_s) rescue nil
|
||||||
if pbResolveBitmap("Graphics/Transitions/" + tbargraphic) && pbResolveBitmap("Graphics/Transitions/" + tgraphic)
|
next pbResolveBitmap("Graphics/Transitions/" + trainer_bar_graphic) &&
|
||||||
|
pbResolveBitmap("Graphics/Transitions/" + trainer_graphic)
|
||||||
|
},
|
||||||
|
Proc.new { |viewport, battle_type, foe| # Animation
|
||||||
|
# Determine filenames of graphics to be used
|
||||||
|
tr_type = foe[0].trainer_type
|
||||||
|
trainer_bar_graphic = sprintf("vsBar_%s", tr_type.to_s) rescue nil
|
||||||
|
trainer_graphic = sprintf("vsTrainer_%s", tr_type.to_s) rescue nil
|
||||||
player_tr_type = $Trainer.trainer_type
|
player_tr_type = $Trainer.trainer_type
|
||||||
outfit = $Trainer.outfit
|
outfit = $Trainer.outfit
|
||||||
# Set up
|
player_bar_graphic = sprintf("vsBar_%s_%d", player_tr_type.to_s, outfit) rescue nil
|
||||||
|
if !pbResolveBitmap("Graphics/Transitions/" + player_bar_graphic)
|
||||||
|
player_bar_graphic = sprintf("vsBar_%s", player_tr_type.to_s) rescue nil
|
||||||
|
end
|
||||||
|
player_graphic = sprintf("vsTrainer_%s_%d", player_tr_type.to_s, outfit) rescue nil
|
||||||
|
if !pbResolveBitmap("Graphics/Transitions/" + player_graphic)
|
||||||
|
player_graphic = sprintf("vsTrainer_%s", player_tr_type.to_s) rescue nil
|
||||||
|
end
|
||||||
|
# Set up viewports
|
||||||
viewplayer = Viewport.new(0, Graphics.height / 3, Graphics.width / 2, 128)
|
viewplayer = Viewport.new(0, Graphics.height / 3, Graphics.width / 2, 128)
|
||||||
viewplayer.z = viewport.z
|
viewplayer.z = viewport.z
|
||||||
viewopp = Viewport.new(Graphics.width / 2, Graphics.height / 3, Graphics.width / 2, 128)
|
viewopp = Viewport.new(Graphics.width / 2, Graphics.height / 3, Graphics.width / 2, 128)
|
||||||
viewopp.z = viewport.z
|
viewopp.z = viewport.z
|
||||||
viewvs = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
viewvs = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||||
viewvs.z = viewport.z
|
viewvs.z = viewport.z
|
||||||
|
# Set up sprites
|
||||||
fade = Sprite.new(viewport)
|
fade = Sprite.new(viewport)
|
||||||
fade.bitmap = RPG::Cache.transition("vsFlash")
|
fade.bitmap = RPG::Cache.transition("vsFlash")
|
||||||
fade.tone = Tone.new(-255, -255, -255)
|
fade.tone = Tone.new(-255, -255, -255)
|
||||||
@@ -155,16 +219,12 @@ def pbBattleAnimationOverride(viewport,battletype=0,foe=nil)
|
|||||||
overlay = Sprite.new(viewport)
|
overlay = Sprite.new(viewport)
|
||||||
overlay.bitmap = Bitmap.new(Graphics.width, Graphics.height)
|
overlay.bitmap = Bitmap.new(Graphics.width, Graphics.height)
|
||||||
pbSetSystemFont(overlay.bitmap)
|
pbSetSystemFont(overlay.bitmap)
|
||||||
pbargraphic = sprintf("vsBar_%s_%d", player_tr_type.to_s, outfit) rescue nil
|
|
||||||
if !pbResolveBitmap("Graphics/Transitions/" + pbargraphic)
|
|
||||||
pbargraphic = sprintf("vsBar_%s", player_tr_type.to_s) rescue nil
|
|
||||||
end
|
|
||||||
xoffset = ((Graphics.width / 2) / 10) * 10
|
xoffset = ((Graphics.width / 2) / 10) * 10
|
||||||
bar1 = Sprite.new(viewplayer)
|
bar1 = Sprite.new(viewplayer)
|
||||||
bar1.bitmap = RPG::Cache.transition(pbargraphic)
|
bar1.bitmap = RPG::Cache.transition(player_bar_graphic)
|
||||||
bar1.x = -xoffset
|
bar1.x = -xoffset
|
||||||
bar2 = Sprite.new(viewopp)
|
bar2 = Sprite.new(viewopp)
|
||||||
bar2.bitmap = RPG::Cache.transition(tbargraphic)
|
bar2.bitmap = RPG::Cache.transition(trainer_bar_graphic)
|
||||||
bar2.x = xoffset
|
bar2.x = xoffset
|
||||||
vs = Sprite.new(viewvs)
|
vs = Sprite.new(viewvs)
|
||||||
vs.bitmap = RPG::Cache.transition("vs")
|
vs.bitmap = RPG::Cache.transition("vs")
|
||||||
@@ -191,18 +251,14 @@ def pbBattleAnimationOverride(viewport,battletype=0,foe=nil)
|
|||||||
flash.opacity = 255
|
flash.opacity = 255
|
||||||
# Replace bar sprites with AnimatedPlanes, set up trainer sprites
|
# Replace bar sprites with AnimatedPlanes, set up trainer sprites
|
||||||
bar1 = AnimatedPlane.new(viewplayer)
|
bar1 = AnimatedPlane.new(viewplayer)
|
||||||
bar1.bitmap = RPG::Cache.transition(pbargraphic)
|
bar1.bitmap = RPG::Cache.transition(player_bar_graphic)
|
||||||
bar2 = AnimatedPlane.new(viewopp)
|
bar2 = AnimatedPlane.new(viewopp)
|
||||||
bar2.bitmap = RPG::Cache.transition(tbargraphic)
|
bar2.bitmap = RPG::Cache.transition(trainer_bar_graphic)
|
||||||
pgraphic = sprintf("vsTrainer_%s_%d", player_tr_type.to_s, outfit) rescue nil
|
|
||||||
if !pbResolveBitmap("Graphics/Transitions/" + pgraphic)
|
|
||||||
pgraphic = sprintf("vsTrainer_%s", player_tr_type.to_s) rescue nil
|
|
||||||
end
|
|
||||||
player = Sprite.new(viewplayer)
|
player = Sprite.new(viewplayer)
|
||||||
player.bitmap = RPG::Cache.transition(pgraphic)
|
player.bitmap = RPG::Cache.transition(player_graphic)
|
||||||
player.x = -xoffset
|
player.x = -xoffset
|
||||||
trainer = Sprite.new(viewopp)
|
trainer = Sprite.new(viewopp)
|
||||||
trainer.bitmap = RPG::Cache.transition(tgraphic)
|
trainer.bitmap = RPG::Cache.transition(trainer_graphic)
|
||||||
trainer.x = xoffset
|
trainer.x = xoffset
|
||||||
trainer.tone = Tone.new(-255, -255, -255)
|
trainer.tone = Tone.new(-255, -255, -255)
|
||||||
# Dim the flash and make the trainer sprites appear, while animating bars
|
# Dim the flash and make the trainer sprites appear, while animating bars
|
||||||
@@ -228,9 +284,9 @@ def pbBattleAnimationOverride(viewport,battletype=0,foe=nil)
|
|||||||
trainername = foe[0].name
|
trainername = foe[0].name
|
||||||
textpos = [
|
textpos = [
|
||||||
[$Trainer.name, Graphics.width / 4, (Graphics.height / 1.5) + 4, 2,
|
[$Trainer.name, Graphics.width / 4, (Graphics.height / 1.5) + 4, 2,
|
||||||
Color.new(248,248,248),Color.new(12*6,12*6,12*6)],
|
Color.new(248, 248, 248), Color.new(72, 72, 72)],
|
||||||
[trainername, (Graphics.width / 4) + (Graphics.width / 2), (Graphics.height / 1.5) + 4, 2,
|
[trainername, (Graphics.width / 4) + (Graphics.width / 2), (Graphics.height / 1.5) + 4, 2,
|
||||||
Color.new(248,248,248),Color.new(12*6,12*6,12*6)]
|
Color.new(248, 248, 248), Color.new(72, 72, 72)]
|
||||||
]
|
]
|
||||||
pbDrawTextPositions(overlay.bitmap, textpos)
|
pbDrawTextPositions(overlay.bitmap, textpos)
|
||||||
# Fade out flash, shudder Vs logo and expand it, and then fade to black
|
# Fade out flash, shudder Vs logo and expand it, and then fade to black
|
||||||
@@ -276,37 +332,5 @@ def pbBattleAnimationOverride(viewport,battletype=0,foe=nil)
|
|||||||
viewopp.dispose
|
viewopp.dispose
|
||||||
viewplayer.dispose
|
viewplayer.dispose
|
||||||
viewport.color = Color.new(0, 0, 0, 255)
|
viewport.color = Color.new(0, 0, 0, 255)
|
||||||
return true
|
}
|
||||||
end
|
)
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# Override battle intro animation
|
|
||||||
#===============================================================================
|
|
||||||
# If you want to add a custom battle intro animation, copy the following alias
|
|
||||||
# line and method into a new script section. Change the name of the alias part
|
|
||||||
# ("__over1__") in your copied code in both places. Then add in your custom
|
|
||||||
# transition code in the place shown.
|
|
||||||
# Note that you can get an image of the current game screen with
|
|
||||||
# Graphics.snap_to_bitmap.
|
|
||||||
# When the custom animation has finished, the screen should have faded to black
|
|
||||||
# somehow.
|
|
||||||
|
|
||||||
alias __over1__pbBattleAnimationOverride pbBattleAnimationOverride
|
|
||||||
|
|
||||||
def pbBattleAnimationOverride(viewport,battletype=0,foe=nil)
|
|
||||||
# The following example runs a common event that ought to do a custom
|
|
||||||
# animation if some condition is true:
|
|
||||||
#
|
|
||||||
# if $game_map.map_id==20 # If on map 20
|
|
||||||
# pbCommonEvent(20)
|
|
||||||
# return true # Note that the battle animation is done
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# The following line needs to call the aliased method if the custom transition
|
|
||||||
# animation was NOT shown.
|
|
||||||
return __over1__pbBattleAnimationOverride(viewport,battletype,foe)
|
|
||||||
end
|
|
||||||
|
|||||||
Reference in New Issue
Block a user