Код:
#-------------------------------------------------------------------------------
# * Munkis' Bestiary
# * V 1.1
# * Made by munkis
# ╔══════════╗
# ║ FEATURES ║
# ╚══════════╝
# * Pretty much self-explanitory; creates a bestiary that keeps track of what
# you've killed, how many different monsters you've collected data on, and
# total percentage of collected data.
# * Incompatible with other scripts that do the same thing.
# * You can add the following script call as a main menu or "script" event
# command: $scene = Munkis_Bestiary.new
# * V 1.0: Initial release
# * V 1.1: Fixed a minor bug that I just recently discovered where the monster
# data window wouldn't update properly when the user highlighted the
# index of a monster whose ID was in the NO_DATA_MONSTER array. The
# messages now displayed can be changed from within the config module.
#-------------------------------------------------------------------------------
module MNK_Bestiary
#Change the static text messages here.
INFO_MESSAGE = ["'My First Animal Book'","Number Found:","Percent Completed:"]
#Disable/Enable recording of monster data.
NO_RECORD_SWITCH = 59
#The data from these monsters will never be recorded.
NO_DATA_MONSTER = [37]
#Text to display on the index of a monster not being recorded in the bestiary.
NO_RECORD_TEXT = ["Page Missing","This page is missing. Where is it?"]
#Shows a transparent box around the dropped items.
SHOW_BOX = false
#If the above is true, fill the box.
FILL_BOX = true
#Set the return destination here.
RETURN_TO = Scene_Menu.new
end
#------------------------------------------------------------------------------
# * <Alias> Game_System
#------------------------------------------------------------------------------
class Game_System
attr_accessor :bestiary
alias :munkis_bestiary_ini :initialize
def initialize
munkis_bestiary_ini
create_bestiary
end
def create_bestiary
@bestiary ||= Array.new($data_enemies.size) {false}
end
def set_bestiary_complete
@bestiary = Array.new($data_enemies.size) {true}
@bestiary[0] = false
end
def reset_bestiary
@bestiary = Array.new($data_enemies.size) {false}
end
end
#------------------------------------------------------------------------------
# * <Alias> Game_Troop
#------------------------------------------------------------------------------
class Game_Troop < Game_Unit
alias :munkis_bestiary_gamtroop_setup :setup
def setup(*args)
munkis_bestiary_gamtroop_setup(*args)
$game_system.create_bestiary
unless $game_switches[MNK_Bestiary::NO_RECORD_SWITCH]
@enemies.each {|e| $game_system.bestiary[e.enemy_id] = true }
end
end
end
#------------------------------------------------------------------------------
# * This draws the Title bar.
#------------------------------------------------------------------------------
class Window_Bestiary_Title_Bar < Window_Base
def initialize
super(0, 0, 544, WLH + 32)
contents.font.color = knockout_color
contents.draw_text(0, 0, contents.width, WLH, MNK_Bestiary::INFO_MESSAGE[0])
end
end
#------------------------------------------------------------------------------
# * This draws the monsters found bar.
#------------------------------------------------------------------------------
class Window_Bestiary_Data_Found_Bar < Window_Base
def initialize
super(0, WLH + 32, 272, WLH + 32)
found_count = 0
$game_system.bestiary.each {|e| found_count += 1 if e }
found_text = found_count.to_s + '/' + ($data_enemies.size - 1).to_s
right_text = MNK_Bestiary::INFO_MESSAGE[1] + found_text
found_t_width = contents.text_size(MNK_Bestiary::INFO_MESSAGE[1]).width
found_width = contents.text_size(found_text).width
right_width = contents.text_size(right_text).width
contents.font.color = normal_color
contents.draw_text(contents.width - right_width, 0, contents.width, WLH, MNK_Bestiary::INFO_MESSAGE[1])
contents.font.color = crisis_color
contents.draw_text(contents.width - right_width + found_t_width, 0, contents.width, WLH, found_text)
end
end
#------------------------------------------------------------------------------
# * This draws the percent completed bar.
#------------------------------------------------------------------------------
class Window_Bestiary_Data_Percent_Bar < Window_Base
def initialize
super(272, WLH + 32, 272, WLH + 32)
found_count = 0
$game_system.bestiary.each {|e| found_count += 1 if e }
percent_count = (found_count * 100) / ($data_enemies.size - 1)
percent_text = percent_count.to_s + '%'
percent_t_width = contents.text_size(MNK_Bestiary::INFO_MESSAGE[2]).width
right_text = MNK_Bestiary::INFO_MESSAGE[2] + percent_text
right_width = contents.text_size(right_text).width
contents.draw_text(contents.width - right_width, 0, contents.width, WLH, MNK_Bestiary::INFO_MESSAGE[2])
contents.font.color = crisis_color
contents.draw_text(contents.width - right_width + percent_t_width, 0, contents.width, WLH, percent_text)
end
end
#------------------------------------------------------------------------------
# * This draws the monster data window.
#------------------------------------------------------------------------------
class Window_BestiaryDetail < Window_Base
def initialize(window_temp)
super(165, (WLH + 32) * 2, 380, 416 - ((WLH + 32) * 2))
self.opacity = 255
self.z = 1
@last_enemy = 0
end
def write_detail(enemy_id)
return if @last_enemy == enemy_id
contents.clear
@last_enemy = enemy_id
data = $data_enemies[enemy_id]
bitmap = Cache.battler(data.battler_name, data.battler_hue)
bw = bitmap.width < 160 ? (160 - bitmap.width) / 2 : 0
bh = contents.height - bitmap.height
contents.blt(bw, bh, bitmap, bitmap.rect)
bitmap.dispose
contents.font.color = normal_color
contents.draw_text(0, 0, contents.width, WLH,
data.id.to_s + '.' + ' ' + data.name)
hpx = 120
draw_enemy_stat(data, contents.width - (hpx*1.75) - 32, WLH, hpx, 'hp')
draw_enemy_stat(data, contents.width - hpx, WLH, hpx, 'mp')
draw_enemy_stat(data, contents.width - (hpx*1.75) - 32, WLH * 2, hpx, 'atk')
draw_enemy_stat(data, contents.width - hpx, WLH * 2, hpx, 'def')
draw_enemy_stat(data, contents.width - (hpx*1.75) - 32, WLH * 3, hpx, 'spi')
draw_enemy_stat(data, contents.width - hpx, WLH * 3, hpx, 'agi')
draw_enemy_stat(data, contents.width - (hpx*1.75) - 32, WLH * 4, hpx, 'hit')
draw_enemy_stat(data, contents.width - hpx, WLH * 4, hpx, 'eva')
draw_enemy_stat(data, contents.width - (hpx*1.75) - 32, WLH * 5, hpx, 'exp')
draw_enemy_stat(data, contents.width - hpx, WLH * 5, hpx, 'gold')
if MNK_Bestiary::SHOW_BOX == true
rect = Rect.new(contents.width - (hpx * 2)+36, (WLH * 8)-32, 204, (WLH * 4) + 16)
contents.fill_rect(rect, Color.new(0,0,0,140)) if MNK_Bestiary::FILL_BOX == true
lsize = 2
lcolor = Color.new(255,255,255,160)
contents.fill_rect(rect.x, rect.y, lsize, rect.height, lcolor)
contents.fill_rect(rect.x, rect.y, rect.width, lsize, lcolor)
contents.fill_rect(rect.x + rect.width - lsize, rect.y, lsize, rect.height, lcolor)
contents.fill_rect(rect.x, rect.y + rect.height - lsize, rect.width, lsize, lcolor)
end
contents.font.color = system_color
contents.draw_text(contents.width - (hpx * 2)+50, WLH * 6.8, 200, WLH, 'Drop Item 1')
draw_enemy_drop(data, 1, contents.width - (hpx * 2)+50, WLH * 7.8)
contents.font.color = system_color
contents.draw_text(contents.width - (hpx * 2)+50, WLH * 8.8, 200, WLH, 'Drop Item 2')
draw_enemy_drop(data, 2, contents.width - (hpx * 2)+50, WLH * 9.8)
end
def clear_detail
@last_enemy = 0
contents.clear
end
def draw_enemy_stat(actor, x, y, width, stat)
color1 = system_color
color2 = normal_color
slash = false
hactor = ($game_party.members.sort {|a,b| a.level <=> b.level })
hactor = hactor[hactor.size - 1]
case stat
when 'hp'
vocab = Vocab::hp
number = actor.maxhp
hnumber = hactor.maxhp
slash = true
when 'mp'
vocab = Vocab::mp
number = actor.maxmp
hnumber = hactor.maxmp
slash = true
when 'atk'
vocab = Vocab::atk
number = actor.atk
hnumber = hactor.atk
when 'def'
vocab = Vocab::def
number = actor.def
hnumber = hactor.def
when 'spi'
vocab = Vocab::spi
number = actor.spi
hnumber = hactor.spi
when 'agi'
vocab = Vocab::agi
number = actor.agi
hnumber = hactor.agi
when 'hit'
vocab = 'HIT'
number = actor.hit
hnumber = hactor.hit
when 'eva'
vocab = 'EVA'
number = actor.eva
hnumber = hactor.eva
when 'exp'
vocab = 'EXP'
number = actor.exp
color2 = crisis_color
when 'gold'
vocab = 'Gold'
number = actor.gold
color2 = crisis_color
end
if !hnumber.nil?
if hnumber > number
color2 = power_up_color
elsif hnumber < number
color2 = knockout_color
elsif hnumber == number
color2 = normal_color
end
end
contents.font.color = color1
contents.draw_text(x, y, 50, WLH, vocab)
xr = x + width
contents.font.color = color2
if slash
contents.draw_text(xr - 95, y, 40, WLH, number, 2)
contents.draw_text(xr - 55, y, 11, WLH, '/', 2)
end
w_ava = slash ? 40 : 80
contents.draw_text(xr - w_ava, y, w_ava, WLH, number, 2)
end
def draw_enemy_drop(actor, drop_id, x, y)
drop = eval('actor.drop_item' + drop_id.to_s)
if drop.kind.zero?
contents.font.color = normal_color
contents.draw_text(x, y, 200, WLH, " ---------")
else
case drop.kind
when 1; item = $data_items[drop.item_id]
when 2; item = $data_weapons[drop.weapon_id]
when 3; item = $data_armors[drop.armor_id]
end
draw_item_name(item, x, y)
end
end
end
#------------------------------------------------------------------------------
# * This draws the monster list window.
#------------------------------------------------------------------------------
class Munkis_Bestiary < Scene_Base
#----------------------------------------------------------------------------
# * Start processing
#----------------------------------------------------------------------------
def initialize(from_menu = false)
@from_menu = from_menu
end
def start
super
create_menu_background
$game_system.create_bestiary
@window_title = Window_Bestiary_Title_Bar.new
@window_data_found = Window_Bestiary_Data_Found_Bar.new
@window_data_percent = Window_Bestiary_Data_Percent_Bar.new
bestiary = []
$game_system.bestiary.each_index do |i|
next if i == 0
if $game_system.bestiary[i] and !MNK_Bestiary::NO_DATA_MONSTER.include?(i)
montext = i.to_s + '.' + ' ' + $data_enemies[i].name
elsif MNK_Bestiary::NO_DATA_MONSTER.include?(i)
montext = i.to_s + '.' + ' ' + MNK_Bestiary::NO_RECORD_TEXT[0]
else
montext = i.to_s + '.'
end
bestiary << montext
end
@window_bestiarylist = Window_Command.new(165, bestiary)
@window_bestiarylist.y = @window_title.height + @window_data_found.height
@window_bestiarylist.height = (Graphics.height - @window_title.height) - @window_data_found.height
@window_bestiarydetail = Window_BestiaryDetail.new(@window_bestiarylist)
end
def update
super
@window_bestiarylist.update
if !$game_system.bestiary[@window_bestiarylist.index + 1]
@window_bestiarydetail.clear_detail
end
if $game_system.bestiary[@window_bestiarylist.index + 1] and !MNK_Bestiary::NO_DATA_MONSTER.include?(@window_bestiarylist.index + 1)
@window_bestiarydetail.write_detail(@window_bestiarylist.index + 1)
end
if MNK_Bestiary::NO_DATA_MONSTER.include?(@window_bestiarylist.index + 1)
@window_bestiarydetail.clear_detail
@window_bestiarydetail.contents.draw_text(0, 0, @window_bestiarydetail.width, 32, MNK_Bestiary::NO_RECORD_TEXT[1])
end
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = MNK_Bestiary::RETURN_TO
end
end
def terminate
super
dispose_menu_background
@window_title.dispose
@window_data_found.dispose
@window_data_percent.dispose
@window_bestiarylist.dispose
@window_bestiarydetail.dispose
end
end
#------------------------------------------------------------------------------
# * This adds the entries to the monster list window.
#------------------------------------------------------------------------------
class Window_Command < Window_Selectable
unless method_defined? :munkis_insert_command_ini
alias munkis_insert_command_ini initialize
alias munkis_insert_command_drawitem draw_item
end
#----------------------------------------------------------------------------
# * <Alias> Initialize
#----------------------------------------------------------------------------
def initialize(*args)
@disabled_commands = []
munkis_insert_command_ini(*args)
end
#----------------------------------------------------------------------------
# * <Alias> Draw_Item
#----------------------------------------------------------------------------
def draw_item(*args)
munkis_insert_command_drawitem(*args)
@disabled_commands[args[0]] = args[1].nil? || args[1] ? nil : true
end
#----------------------------------------------------------------------------
# * Insert Command
#----------------------------------------------------------------------------
def ins_command(index, text)
@commands.insert(index, text)
@disabled_commands.insert(index, nil)
old_disabled_commands = @disabled_commands.dup
self.height = (@commands.size + @column_max - 1) / @column_max * WLH + 32
@item_max = @commands.size
create_contents
refresh
old_disabled_commands.each_index do |i|
if !old_disabled_commands[i].nil?
draw_item(i, false)
end
end
end
#----------------------------------------------------------------------------
# * Add Command
#----------------------------------------------------------------------------
def add_command(text)
ins_command(@commands.size, text)
end
end
Но вроде бы он не вносит никаких изменений в коммандное окно...
Социальные закладки