=begin
Khai's Item Found
Version: 1.1
Release: 8.13.08 4:42pm
Updated: 8.13.08 8:41pm
Author: Khai
http://ktbanh.wordpress.com/
Description: A basic script to display popup window(s) from common events
such as treasure chest or other custom designs.
Notes:
1.0 - simple usage, initial release.
1.1 - bug fixes, note correction, item add included. (requires no hassle to
create item obtain events now)
Setup: Place above Main. [config below]
Usage: Create an event such as a treasure chest and place this in Scripts
under tab 3 of event commands:
$scene = Khai_Item_Found.new(type,index,number)
[Type(0-3): 0:Items 1:Armors 2:Weapons 3:Gold]
[Index: item list in database]
[Number: amount displayed]
Example:
$scene = Khai_Item_Found.new(2,5,10) display, "10x Leather Whip Found"
$scene = Khai_Item_Found.new(3,5,1234) display, "1234G Found"
IMPORTANT NOTICE!
If you want a chest to display multiple items, create [Wait: 1 frame(s)] in
the current event after each call.
=end
# Configuration:
SE = "Saint5" # Sound effect when item found. Leave blank to disable.
# Exact name from Sound Test/SE
MSG = "Found" # Message for item found eg. "You have Found..."
Align = 1 # Text alignment of message window. 0=L 1=Center 2=R
Width = 300 # Width of message window.
Format = 1 # 0:[msg,number,type] 1:[number,type,msg]
Fade = false #enable/disable message fade overtime.
Fade_Speed = 2 #speed of fade
Fade_Length = 10 #length of fade
# Screen Setting: for 640x480 users else void
Graphic_W = 544 # Screen Width
Graphic_H = 416 # Screen Height
# Configuration end
class Khai_Window_Found_Icon < Window_Base
def initialize(index,type)
super(0, 0, 54, WLH + 32)
gold = $data_system.terms.gold
self.draw_icon($data_items[index].icon_index, 0, 0, true) if type == 0
self.draw_icon($data_armors[index].icon_index, 0, 0, true) if type == 1
self.draw_icon($data_weapons[index].icon_index, 0, 0, true) if type == 2
self.contents.draw_text(6, 0, 54, WLH, gold) if type == 3
end
end
#------------------------------------------------------------------------------
class Khai_Window_Found < Window_Base
def initialize
super(0, 0, Width, WLH + 32)
end
#------------------------------------------------------------------------------
def dispose_item_window
self.dispose
end
#------------------------------------------------------------------------------
def set_text(text, align = Align)
if text != @text
@text = text
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, self.width - 40, WLH, text, align)
end
end
end
#------------------------------------------------------------------------------
class Khai_Item_Found < Scene_Base
def initialize(type,index,num)
@index = index
@setting = type
@fade_length = Fade_Length
case type
when 0
@type = $data_items[@index].name
$game_party.gain_item($data_items[@index], num)
when 1
@type = $data_armors[@index].name
$game_party.gain_item($data_armors[@index], num)
when 2
@type = $data_weapons[@index].name
$game_party.gain_item($data_weapons[@index], num)
when 3
@type = Vocab::gold
$game_party.gain_gold(num)
end
@text = "#{MSG} #{num}x #{@type}" if Format == 0 && type != 3
@text = "#{num}x #{@type} #{MSG}" if Format == 1 && type != 3
@text = "#{num} #{@type} #{MSG}" if type == 3
end
#------------------------------------------------------------------------------
def start
@spriteset = Spriteset_Map.new
@khai_info_window = Khai_Window_Found.new
@khai_info_window.width = (@khai_info_window.contents.text_size(@text).width) + 42
@khai_icon_window = Khai_Window_Found_Icon.new(@index, @setting)
@khai_info_window.set_text(@text)
@khai_info_window.x = (Graphic_W-(@khai_info_window.width-@khai_icon_window.width))/2
@khai_info_window.y = (Graphic_H-@khai_info_window.height)/2
@khai_icon_window.x = ((Graphic_W-(@khai_info_window.width+@khai_icon_window.width))/2)
@khai_icon_window.y = ((Graphic_H-@khai_icon_window.height)/2)
Audio.se_play("Audio/SE/#{SE}", 100, 100) if SE != ""
end
#------------------------------------------------------------------------------
def terminate
super
@spriteset.dispose
dispose_item_window
end
#------------------------------------------------------------------------------
def dispose_item_window
@khai_icon_window.dispose
@khai_info_window.dispose
end
#------------------------------------------------------------------------------
def update
@khai_info_window.update
@khai_icon_window.update
if Fade
@fade_length -= 1
if @fade_length <= 0
@khai_info_window.opacity -= Fade_Speed
@khai_info_window.contents_opacity -= Fade_Speed
@khai_icon_window.opacity -= Fade_Speed
@khai_icon_window.contents_opacity -= Fade_Speed
end
if @khai_info_window.opacity == 0
$scene = Scene_Map.new
end
end
$scene = Scene_Map.new if Input.trigger?(Input::B)
$scene = Scene_Map.new if Input.trigger?(Input::C)
end
end