=begin
#==============================================================================
** Icon Balloon
Author: Tsukihime
Date: Sep 3, 2012
------------------------------------------------------------------------------
** Change log
Sep 3
- updated with more method aliasing
- initial release
------------------------------------------------------------------------------
Similar to the emotion balloons, except it uses an icon instead.
You will need a copy of the Icon-Balloon.png file, which is basically
one row of balloon frames copied from the Balloon.png file.
Script call:
show_icon_balloon(char_id, icon_index, wait?)
`char_id` is the character on the map
(-1 = player, 0 = this event, 1+ is specific event ID)
`icon_index` is the index of the icon
`wait` is a boolean representing whether the game should wait until the balloon disappears
#==============================================================================
=end
$imported = {} if $imported.nil?
$imported["Tsuki_IconBalloons"] = true
#==============================================================================
# ** Configuration
#==============================================================================
module Tsuki
module Icon_Balloon
end
end
#==============================================================================
# ** Rest of script
#==============================================================================
class Game_Interpreter
def show_icon_balloon(char_id, icon_index, need_wait=false)
character = get_character(char_id)
if character
character.icon_balloon_id = icon_index
Fiber.yield while character.icon_balloon_id > 0 if need_wait
end
end
end
class Game_CharacterBase
attr_accessor :icon_balloon_id
alias :th_icon_balloon_init_public :init_public_members
def init_public_members
th_icon_balloon_init_public
@icon_balloon_id = 0
end
end
class Sprite_Character
alias :th_icon_balloon_initialize :initialize
def initialize(viewport, character = nil)
@icon_balloon_duration = 0
th_icon_balloon_initialize(viewport, character)
end
alias :th_icon_balloon_dispose :dispose
def dispose
th_icon_balloon_dispose
end_icon_balloon
end
alias :th_icon_balloon_update :update
def update
th_icon_balloon_update
update_icon_balloon #new
end
alias :th_icon_balloon_setup_new :setup_new_effect
def setup_new_effect
th_icon_balloon_setup_new
if !@icon_balloon_sprite && @character.icon_balloon_id > 0
@icon_balloon_id = @character.icon_balloon_id
start_icon_balloon
end
end
# new icon balloon methods
def start_icon_balloon
dispose_icon_balloon
@icon_balloon_duration = 8 * balloon_speed + balloon_wait
@icon_balloon_sprite = ::Sprite.new(viewport)
@icon_balloon_sprite.bitmap = Cache.system("Icon-Balloon")
@icon_balloon_sprite.ox = 16
@icon_balloon_sprite.oy = 32
@icon = Cache.system("Iconset")
@icon_rect = Rect.new(@icon_balloon_id % 16 * 24, @icon_balloon_id / 16 * 24, 24, 24)
@icon_balloon_sprite.bitmap.blt(4, 2, @icon, @icon_rect, 255)
update_icon_balloon
end
#--------------------------------------------------------------------------
# * Free Balloon Icon
#--------------------------------------------------------------------------
def dispose_icon_balloon
if @icon_balloon_sprite
@icon_balloon_sprite.dispose
@icon_balloon_sprite = nil
end
end
#--------------------------------------------------------------------------
# * Update Balloon Icon
#--------------------------------------------------------------------------
def update_icon_balloon
if @icon_balloon_duration > 0
@icon_balloon_duration -= 1
if @icon_balloon_duration > 0
@icon_balloon_sprite.x = x
@icon_balloon_sprite.y = y - height
@icon_balloon_sprite.z = z + 200
sx = balloon_frame_index * 32
sy = 0
@icon_balloon_sprite.src_rect.set(sx, sy, 32, 32)
@icon_balloon_sprite.bitmap.blt(sx+4, sy+2, @icon, @icon_rect, 255)
else
end_icon_balloon
end
end
end
#--------------------------------------------------------------------------
# * End Balloon Icon
#--------------------------------------------------------------------------
def end_icon_balloon
dispose_icon_balloon
@character.icon_balloon_id = 0
end
#--------------------------------------------------------------------------
# * Balloon Icon Display Speed
#--------------------------------------------------------------------------
def balloon_speed
return 8
end
#--------------------------------------------------------------------------
# * Wait Time for Last Frame of Balloon
#--------------------------------------------------------------------------
def balloon_wait
return 12
end
#--------------------------------------------------------------------------
# * Frame Number of Balloon Icon
#--------------------------------------------------------------------------
def balloon_frame_index
return 7 - [(@icon_balloon_duration - balloon_wait) / balloon_speed, 0].max
end
end