- Joined
- Aug 6, 2017
- Messages
- 51
- Reaction score
- 19
- First Language
- English
- Primarily Uses
- RMVXA
I can't figure out how to get this script to work exactly, was wondering if I could get some insight on it please.
Original Page Link
Original Page Link
Code:
#===============================================================================
# GIF Animation Player v1.0 (RGSS3)
# by ???nOBodY???
# Last Updated: 12/12/2011
#
# Version 1.0
#
#===============================================================================
#
# Update History:
# - Version 1.0 - Initial release; RGSS2 => RGSS3
#
#===============================================================================
#
# This script was designed to act as a GIF animation player. Because GIF images
# aren't supported in RMVXA, this script uses a series of numbered images in a
# specifiable directory.
#
# Keep in mind this script isn't really noob-friendly, but it does offer quite a
# bit of potential for eventers and scripters alike, eliminating the need to play
# in-game videos via the API, which doesn't always work... These GIF animation
# sequences can even be looped within a customized scene, such as a slightly
# modified Scene_Status, or customized windows, such as Window_Status!
#
# NOTE: The GIF Animation Player engine code is located within the "test" sample
# below, within Scene_Map. To use GIF sequences in other scenes, copy and paste
# this code into, say, the Scene_Base main method, directly under the update
# method. You could also make a new method, stick this code in there, then put the
# new method under update instead. Actually, there are many ways to implement this
# script, but by default, Scene_Map is supported, as well as my FES script, if you
# use that... This is the code, although the update_gif_player(i) should be
# replaced by the actual method, unless you would prefer to input the code the way
# I did; creating a new method...
#
# for i in 1..20
# update_gif_player(i)
# end
#
###=============================================================================
###Script Calls!================================================================
###=============================================================================
#
# $game_system.gif_master_selector[id] = x
#
# Where id is the id of the GIF sequence (1-20).
# Where x is a string determining the name of the folder of the sequence within
# the Graphics/Pictures/ directory, by default.
#
# $game_system.gif_master_controller[id] = x
#
# Where id is the id of the GIF sequence (1-20).
# Where x is a boolean value determining whether or not that specific GIF sequence
# should play or not.
#
###=============================================================================
###Script Calls!================================================================
###=============================================================================
#
#===============================================================================
# Credits:
#
# -???nOBodY??? (aka sUBzeR_0)
#===============================================================================
#
# Aliases:
# - Spriteset_Map: initialize
# - Spriteset_Map: dispose
# - Spriteset_Map: update
# - Scene_Map: update
#
#===============================================================================
class Game_Temp
attr_accessor :gif_index # index for GIF animation player
attr_accessor :gif_show_picture # ON switch for GIF animation player
attr_accessor :gif_erase_fix # GIF erase fix
attr_accessor :gif_counter1 # GIF counter 1 (frame_delay)
attr_accessor :gif_counter2 # GIF counter 2 (loop_delay)
alias gif_initialize initialize
def initialize
@gif_index = []
for i in 1..20
@gif_index[i] = -1
end
@gif_show_picture = []
for i in 1..20
@gif_show_picture[i] = false
end
@gif_erase_fix = []
for i in 1..20
@gif_erase_fix[i] = false
end
@gif_counter1 = []
for i in 1..20
@gif_counter1[i] = 0
end
@gif_counter2 = []
for i in 1..20
@gif_counter2[i] = 0
end
gif_initialize
end
end
class Game_System
attr_accessor :gif_master_controller # GIF master controller
attr_accessor :gif_master_selector # GIF master selector
alias gif_initialize initialize
def initialize
@gif_master_controller = []
for i in 1..20
@gif_master_controller[i] = false
end
@gif_master_selector = []
for i in 1..20
@gif_master_selector[i] = ""
end
gif_initialize
end
end
#==============================================================================
# ** Cache
#------------------------------------------------------------------------------
# This module loads each of graphics, creates a Bitmap object, and retains it.
# To speed up load times and conserve memory, this module holds the created
# Bitmap object in the internal hash, allowing the program to return
# preexisting objects when the same bitmap is requested again.
#==============================================================================
module Cache
#--------------------------------------------------------------------------
# * Get Picture Graphic
# filename : Filename
#--------------------------------------------------------------------------
def self.gif_sequence(filename,dir)
load_bitmap("Graphics/Pictures/"+dir, filename)
end
end
#==============================================================================
# ** Game_Screen
#------------------------------------------------------------------------------
# This class handles screen maintenance data, such as change in color tone,
# flashes, etc. It's used within the Game_Map and Game_Troop classes.
#==============================================================================
class Game_Screen
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :gif_sequences # gif sequences
#--------------------------------------------------------------------------
# * Clear
#--------------------------------------------------------------------------
alias gif_clear clear
def clear
gif_clear
@gif_sequences = []
for i in 0..20
@gif_sequences.push(Game_Picture_GIF.new(i))
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias gif_update update
def update
gif_update
update_gif_pictures
end
#--------------------------------------------------------------------------
# * Update Pictures
#--------------------------------------------------------------------------
def update_gif_pictures
for picture in @gif_sequences
picture.update
end
end
end
#==============================================================================
# ** Game_Picture_GIF
#------------------------------------------------------------------------------
# This class handles GIF sequences. This class is used within the Game_Screen
# class. Map screen pictures and battle screen pictures are handled separately.
#==============================================================================
class Game_Picture_GIF
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :number # sequence index
attr_reader :name # filename
attr_reader :origin # starting point
attr_reader :x # x-coordinate
attr_reader :y # y-coordinate
attr_reader :zoom_x # x directional zoom rate
attr_reader :zoom_y # y directional zoom rate
attr_reader :opacity # opacity level
attr_reader :blend_type # blend method
attr_reader :tone # color tone
attr_reader :angle # rotation angle
attr_reader :dir # file directory
attr_reader :size # sequence size (in frames)
attr_reader :frame_delay # determines delay between frames
attr_reader :loop_delay # determines delay before looping
#--------------------------------------------------------------------------
# * Object Initialization
# number : picture index
#--------------------------------------------------------------------------
def initialize(number)
@number = number
@name = ""
@dir = ""
@size = 0
@frame_delay = 0
@loop_delay = 0
@origin = 0
@x = 0.0
@y = 0.0
@zoom_x = 100.0
@zoom_y = 100.0
@opacity = 255.0
@blend_type = 1
@duration = 0
@target_x = @x
@target_y = @y
@target_zoom_x = @zoom_x
@target_zoom_y = @zoom_y
@target_opacity = @opacity
@tone = Tone.new(0, 0, 0, 0)
@tone_target = Tone.new(0, 0, 0, 0)
@tone_duration = 0
@angle = 0
@rotate_speed = 0
end
#--------------------------------------------------------------------------
# * Show Picture
# dir : file directory
# name : filename
# size : sequence size
# origin : starting point
# x : x-coordinate
# y : y-coordinate
# zoom_x : x directional zoom rate
# zoom_y : y directional zoom rate
# opacity : opacity level
# blend_type : blend method
#--------------------------------------------------------------------------
def show(dir, name, size, origin, x, y, zoom_x, zoom_y, opacity, blend_type, frame_delay=0, loop_delay=0)
@name = name
@dir = dir
@size = size
@frame_delay = frame_delay
@loop_delay = loop_delay
@origin = origin
@x = x.to_f
@y = y.to_f
@zoom_x = zoom_x.to_f
@zoom_y = zoom_y.to_f
@opacity = opacity.to_f
@blend_type = blend_type
@duration = 0
@target_x = @x
@target_y = @y
@target_zoom_x = @zoom_x
@target_zoom_y = @zoom_y
@target_opacity = @opacity
@tone = Tone.new(0, 0, 0, 0)
@tone_target = Tone.new(0, 0, 0, 0)
@tone_duration = 0
@angle = 0
@rotate_speed = 0
end
#--------------------------------------------------------------------------
# * Move Picture
# origin : starting point
# x : x-coordinate
# y : y-coordinate
# zoom_x : x directional zoom rate
# zoom_y : y directional zoom rate
# opacity : opacity level
# blend_type : blend method
# duration : time
#--------------------------------------------------------------------------
def move(origin, x, y, zoom_x, zoom_y, opacity, blend_type, duration)
@origin = origin
@target_x = x.to_f
@target_y = y.to_f
@target_zoom_x = zoom_x.to_f
@target_zoom_y = zoom_y.to_f
@target_opacity = opacity.to_f
@blend_type = blend_type
@duration = duration
end
#--------------------------------------------------------------------------
# * Change Rotation Speed
# speed : rotation speed
#--------------------------------------------------------------------------
def rotate(speed)
@rotate_speed = speed
end
#--------------------------------------------------------------------------
# * Start Changing Color Tone
# tone : color tone
# duration : time
#--------------------------------------------------------------------------
def start_tone_change(tone, duration)
@tone_target = tone.clone
@tone_duration = duration
if @tone_duration == 0
@tone = @tone_target.clone
end
end
#--------------------------------------------------------------------------
# * Erase Picture
#--------------------------------------------------------------------------
def erase
@name = ""
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if @duration >= 1
d = @duration
@x = (@x * (d - 1) + @target_x) / d
@y = (@y * (d - 1) + @target_y) / d
@zoom_x = (@zoom_x * (d - 1) + @target_zoom_x) / d
@zoom_y = (@zoom_y * (d - 1) + @target_zoom_y) / d
@opacity = (@opacity * (d - 1) + @target_opacity) / d
@duration -= 1
end
if @tone_duration >= 1
d = @tone_duration
@tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
@tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
@tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
@tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
@tone_duration -= 1
end
if @rotate_speed != 0
@angle += @rotate_speed / 2.0
while @angle < 0
@angle += 360
end
@angle %= 360
end
end
end
#==============================================================================
# ** Sprite_Picture_GIF
#------------------------------------------------------------------------------
# This sprite is used to display picturea. It observes a instance of the
# Game_Picture class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Picture_GIF < Sprite
#--------------------------------------------------------------------------
# * Object Initialization
# viewport : viewport
# picture : picture (Game_Picture)
#--------------------------------------------------------------------------
def initialize(viewport, picture)
super(viewport)
@picture = picture
update
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
if @picture_name != @picture.name
@picture_name = @picture.name
if @picture_name != ""
self.bitmap = Cache.gif_sequence(@picture_name, @picture.dir)
end
end
if @picture_name == ""
self.visible = false
else
self.visible = true
if @picture.origin == 0
self.ox = 0
self.oy = 0
else
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height / 2
end
self.x = @picture.x
self.y = @picture.y
self.z = 100 + @picture.number
self.zoom_x = @picture.zoom_x / 100.0
self.zoom_y = @picture.zoom_y / 100.0
self.opacity = @picture.opacity
self.blend_type = @picture.blend_type
self.angle = @picture.angle
self.tone = @picture.tone
end
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias gif_initialize initialize
def initialize
create_GIF_pictures
gif_initialize
end
#--------------------------------------------------------------------------
# * Create Picture Sprite
#--------------------------------------------------------------------------
def create_GIF_pictures
@gif_picture_sprites = []
for i in 1..20
@gif_picture_sprites.push(Sprite_Picture_GIF.new(@viewport2,
$game_map.screen.gif_sequences[i]))
end
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
alias gif_dispose dispose
def dispose
dispose_GIF_pictures
gif_dispose
end
#--------------------------------------------------------------------------
# * Dispose of Picture Sprite
#--------------------------------------------------------------------------
def dispose_GIF_pictures
for sprite in @gif_picture_sprites
sprite.dispose
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias gif_update update
def update
update_GIF_pictures
gif_update
end
#--------------------------------------------------------------------------
# *Update Picture Sprite
#--------------------------------------------------------------------------
def update_GIF_pictures
for sprite in @gif_picture_sprites
sprite.update
end
end
end
#==============================================================================
# ** Spriteset_FES
#------------------------------------------------------------------------------
# This class brings together menu screen sprites, tilemaps, etc. It's used
# within the Scene_FES_Status class, and was originally designed as a sort of
# optional add-on, but can be expanded to a wider variety of uses. Mainly gives
# the GIF Animation Player access to scenes/windows.
#==============================================================================
class Spriteset_FES
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
#alias gif_initialize initialize
def initialize
create_viewports
create_GIF_pictures
#gif_initialize
end
#--------------------------------------------------------------------------
# * Create Viewport
#--------------------------------------------------------------------------
def create_viewports
@viewport1 = Viewport.new#(0, 0, 544, 416)
@viewport2 = Viewport.new#(0, 0, 544, 416)
@viewport3 = Viewport.new#(0, 0, 544, 416)
@viewport2.z = 50
@viewport3.z = 100
end
#--------------------------------------------------------------------------
# * Create Picture Sprite
#--------------------------------------------------------------------------
def create_GIF_pictures
@gif_picture_sprites = []
for i in 1..20
@gif_picture_sprites.push(Sprite_Picture_GIF.new(@viewport2,
$game_map.screen.gif_sequences[i]))
end
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
#alias gif_dispose dispose
def dispose
dispose_GIF_pictures
dispose_viewports
#gif_dispose
end
#--------------------------------------------------------------------------
# * Dispose of Picture Sprite
#--------------------------------------------------------------------------
def dispose_GIF_pictures
for sprite in @gif_picture_sprites
sprite.dispose
end
end
#--------------------------------------------------------------------------
# * Dispose of Viewport
#--------------------------------------------------------------------------
def dispose_viewports
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
#alias gif_update update
def update
update_GIF_pictures
update_viewports
#gif_update
end
#--------------------------------------------------------------------------
# *Update Picture Sprite
#--------------------------------------------------------------------------
def update_GIF_pictures
for sprite in @gif_picture_sprites
sprite.update
end
end
#--------------------------------------------------------------------------
# * Update Viewport
#--------------------------------------------------------------------------
def update_viewports
@viewport1.tone = $game_map.screen.tone
@viewport1.ox = $game_map.screen.shake
@viewport2.color = $game_map.screen.flash_color
@viewport3.color.set(0, 0, 0, 255 - $game_map.screen.brightness)
@viewport1.update
@viewport2.update
@viewport3.update
end
end
#--------------------------------------------------------------------------
# * Show Picture
#--------------------------------------------------------------------------
def gif_show_picture(id, dir, name, size, origin, x, y, zoom_x, zoom_y, opacity, blend_type, frame_delay=0, loop_delay=0)
$game_map.screen.gif_sequences[id].show(dir, name, size, origin, x, y, zoom_x, zoom_y, opacity, blend_type, frame_delay, loop_delay)
$game_temp.gif_show_picture[id] = true
$game_temp.gif_erase_fix[id] = true
return true
end
#--------------------------------------------------------------------------
# * Erase Picture
#--------------------------------------------------------------------------
def gif_erase_picture(id)
$game_map.screen.gif_sequences[id].erase
$game_temp.gif_show_picture[id] = false
return true
end
#===============================================================================
# Scene Map [TEST]
#===============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias gif_update update
def update
gif_update
unless $game_message.visible # Unless displaying a message
for i in 1..20
update_gif_player(i)
end
end
end
#--------------------------------------------------------------------------
# * Update GIF Animation Sequence
#--------------------------------------------------------------------------
def update_gif_player(i)
if $game_system.gif_master_controller[i] == true
if $game_temp.gif_show_picture[i] == false
if $game_temp.gif_index[i] == $game_map.screen.gif_sequences[i].size #SUBZERO_MODULE::GIF_ANIMATION_SIZE
if $game_map.screen.gif_sequences[i].loop_delay > 0
unless $game_temp.gif_counter2[i] == $game_map.screen.gif_sequences[i].loop_delay
$game_temp.gif_counter2[i] += 1
else
$game_temp.gif_counter2[i] = 0
$game_temp.gif_index[i] = -1
end
else
$game_temp.gif_index[i] = -1
end
else
if $game_map.screen.gif_sequences[i].frame_delay > 0
unless $game_temp.gif_counter1[i] == $game_map.screen.gif_sequences[i].frame_delay
$game_temp.gif_counter1[i] += 1
else
$game_temp.gif_counter1[i] = 0
$game_temp.gif_index[i] += 1
gif_show_picture(i, $game_system.gif_master_selector[i], $game_temp.gif_index[i].to_s, 49, 0, 277, 208, 45, 45, 225, 0, 5, 15)
$game_temp.gif_show_picture[i] = false
end
else
$game_temp.gif_index[i] += 1
gif_show_picture(i, $game_system.gif_master_selector[i], $game_temp.gif_index[i].to_s, 49, 0, 277, 208, 45, 45, 225, 0, 5, 15)
$game_temp.gif_show_picture[i] = false
end
end
end
else
gif_erase_picture(i) if $game_temp.gif_erase_fix[i] == true
end
end
end


