Serafim |
Администратор |
|
|
Зарегистрирован: 08.03.2012 |
Сообщения: 238 |
Откуда: ЛНР |
|
|
|
|
|
|
Добавляет книгу монстров
Код: |
#===============================================================
# ● [VX] ◦ Monster Book II ◦ □
#--------------------------------------------------------------
# ◦ by Woratana [woratana@hotmail.com]
# ◦ Thaiware RPG Maker Community
# ◦ Released on: 02/01/2009
# ◦ Version: 2.0
# ◦ Special Thanks: Momomo~ for interface from Monster Book XP version
#--------------------------------------------------------------
# ** FEATURES
#--------------------------------------------------------------
# - Built-in snippet to add 'Monster Book' in the menu's command
# - Show enemies' data in Monster Book after player fight with them
# - All the texts are editable in setup part
# - Call script to clear/complete Monster Book's data
# - Call script to show/hide monster's data in Monster Book
# - Compare monster's status with the highest level actors in party
# - Turn ON switch to stop adding data into Monster Book temporarily
# - Choose the monsters you don't want to show their name and data
#--------------------------------------------------------------
# ** HOW TO USE
#--------------------------------------------------------------
# * Call Scene Monster Book by call script:
# $scene = Scene_MonsterBook.new
# * Complete all enemies' information by call script:
# $game_system.set_monbook_complete
# * Clear all enemies' information by call script:
# $game_system.reset_monbook
#--------------------------------------------------------------
# * Show enemy's information by call script:
# $game_system.monbook[enemy_id] = true
# * Hide enemy's information by call script:
# $game_system.monbook[enemy_id] = false
# ^ Change 'enemy_id' to ID of enemy you want
# ** e.g. $game_system.monbook[10] = true
#===============================================================
module Wora_Monbook
#===============================================================
# ** [Setup Part] - Config script in this part
#--------------------------------------------------------------
SHOW_IN_MENU = false # Show Monster Book in Menu Command? (true / false)
MENU_COMMAND = 'MonsterBook' # Menu command name for Monster Book
MENU_INDEX = # Index of menu command you want to insert monster book
TEXT_TITLE = 'Монстры'
# Monster Book Title (Show at top left of the screen)
TEXT_FOUND = 'Найдено: '
# Text before number of how many monster are found
TEXT_COMPLETED = 'Завершено: '
# Text before percentage of how many monster are found
TEXT_DOT = '.'
# Text show after enemy's ID (e.g. '.' will make '2.' and ')' will make '2)' )
COMPARE_STATUS = true
# Use Compare Status System? It will compare enemy's status with highest level
# actor in party. Show GREEN number if enemy has lower status.
# Show RED-GRAY number if enemy has higher status. (true / false)
NO_RECORD_SWITCH = 10
# If this switch ID turn ON, any monster the player fight with won't be added
# into Monster Book.
NO_DATA_MONSTER = []
# List of IDs of monster you don't want to show name and data on Monster Book
# e.g. [1, 3, 5] will make monster ID 1, 3, and 5 show no data in Monster Book
#===============================================================
end
#===============================================================
# ** [Alias] Game_System
#--------------------------------------------------------------
class Game_System
attr_accessor :monbook
alias :wora_monbook_gamsys_ini :initialize
def initialize
wora_monbook_gamsys_ini
create_monbook
end
def create_monbook
@monbook ||= Array.new($data_enemies.size) {false}
end
def set_monbook_complete
@monbook = Array.new($data_enemies.size) {true}
@monbook[0] = false
end
def reset_monbook
@monbook = Array.new($data_enemies.size) {false}
end
end
#===============================================================
# ** [Alias] Game_Troop
#--------------------------------------------------------------
class Game_Troop < Game_Unit
alias :wora_monbook_gamtroop_setup :setup
def setup(*args)
wora_monbook_gamtroop_setup(*args)
$game_system.create_monbook
unless $game_switches[Wora_Monbook::NO_RECORD_SWITCH]
@enemies.each {|e| $game_system.monbook[e.enemy_id] = true }
end
end
end
#===============================================================
# ** Window_MonsterBHelp
#--------------------------------------------------------------
class Window_MonsterBHelp < Window_Base
include Wora_Monbook
def initialize
super(0, 0, 544, WLH + 32)
# Write Monster Book Title
contents.font.color = system_color
contents.draw_text(0, 0, contents.width, WLH, TEXT_TITLE)
# Calculate found monster & complete percentage
found_count = 0
$game_system.monbook.each {|e| found_count += 1 if e }
percent_count = (found_count * 100) / ($data_enemies.size - 1)
# Collect & Store Text in variables
found_text = found_count.to_s + '/' + ($data_enemies.size - 1).to_s
percent_text = percent_count.to_s + '%'
mid_text = ' | '
right_text = TEXT_FOUND + found_text + mid_text + TEXT_COMPLETED +
percent_text
# Calculate Text Width
found_t_width = contents.text_size(TEXT_FOUND).width
found_width = contents.text_size(found_text).width
percent_t_width = contents.text_size(TEXT_COMPLETED).width
mid_width = contents.text_size(mid_text).width
right_width = contents.text_size(right_text).width
# Write Monster Found & Complete Percentage
contents.font.color = normal_color
contents.draw_text(contents.width - right_width, 0, contents.width, WLH,
TEXT_FOUND)
contents.draw_text(contents.width - right_width + found_t_width +
found_width, 0, contents.width, WLH, mid_text + TEXT_COMPLETED)
contents.font.color = crisis_color
contents.draw_text(contents.width - right_width + found_t_width, 0,
contents.width, WLH, found_text)
contents.draw_text(contents.width - right_width + found_t_width +
found_width + mid_width + percent_t_width, 0, contents.width, WLH,
percent_text)
end
end
#===============================================================
# ** Window_MonsterBDetail
#--------------------------------------------------------------
class Window_MonsterBDetail < Window_Base
def initialize(window_temp)
super(window_temp.x, window_temp.y, window_temp.width, window_temp.height)
self.opacity = 0
@win_image = Window_Base.new(self.x, self.y, self.width, self.height)
self.z = @win_image.z + 1
@last_enemy = 0
end
def visible=(bool)
super
@win_image.visible = bool
end
def dispose
@win_image.dispose
super
end
def write_detail(enemy_id)
return if @last_enemy == enemy_id
contents.clear
@win_image.contents.clear
@last_enemy = enemy_id
data = $data_enemies[enemy_id]
# Draw Enemy Graphic
bitmap = Cache.battler(data.battler_name, data.battler_hue)
bw = bitmap.width < 160 ? (160 - bitmap.width) / 2 : 0
bh = contents.height - bitmap.height
@win_image.contents.blt(bw, bh, bitmap, bitmap.rect)
bitmap.dispose
# Write Name
contents.font.color = normal_color
contents.draw_text(0, 0, contents.width, WLH,
data.id.to_s + Wora_Monbook::TEXT_DOT + ' ' + data.name)
# Write Enemy Status
hpx = 120
draw_enemy_stat(data, contents.width - (hpx * 2) - 32, 0, hpx, 'hp')
draw_enemy_stat(data, contents.width - hpx, 0, hpx, 'mp')
draw_enemy_stat(data, contents.width - (hpx * 2) - 32, WLH * 2, hpx, 'atk')
draw_enemy_stat(data, contents.width - hpx, WLH * 2, hpx, 'def')
draw_enemy_stat(data, contents.width - (hpx * 2) - 32, WLH * 3, hpx, 'spi')
draw_enemy_stat(data, contents.width - hpx, WLH * 3, hpx, 'agi')
draw_enemy_stat(data, contents.width - (hpx * 2) - 32, WLH * 4, hpx, 'hit')
draw_enemy_stat(data, contents.width - hpx, WLH * 4, hpx, 'eva')
draw_enemy_stat(data, contents.width - (hpx * 2) - 32, WLH * 6, hpx, 'exp')
draw_enemy_stat(data, contents.width - hpx, WLH * 6, hpx, 'gold')
rect = Rect.new(contents.width - (hpx * 2) - 8, (WLH * 8) - 8, 216,
(WLH * 4) + 16)
contents.fill_rect(rect, Color.new(0,0,0,140))
lsize = 2 # Line Size
lcolor = Color.new(255,255,255,160) # Line Color
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)
contents.font.color = system_color
contents.draw_text(contents.width - (hpx * 2), WLH * 8, 200, WLH,
'Drop Item 1')
draw_enemy_drop(data, 1, contents.width - (hpx * 2), WLH * 9)
contents.font.color = system_color
contents.draw_text(contents.width - (hpx * 2), WLH * 10, 200, WLH,
'Drop Item 2')
draw_enemy_drop(data, 2, contents.width - (hpx * 2), WLH * 11)
end
def draw_enemy_stat(actor, x, y, width, stat)
color1 = system_color
color2 = normal_color
slash = false
# Find highest level actor
if Wora_Monbook::COMPARE_STATUS
hactor = ($game_party.members.sort {|a,b| a.level <=> b.level })
hactor = hactor[hactor.size - 1]
end
case stat
when 'hp'
vocab = Vocab::hp
number = actor.maxhp
hnumber = hactor.maxhp if Wora_Monbook::COMPARE_STATUS
slash = true
when 'mp'
vocab = Vocab::mp
number = actor.maxmp
hnumber = hactor.maxmp if Wora_Monbook::COMPARE_STATUS
slash = true
when 'atk'
vocab = Vocab::atk
number = actor.atk
hnumber = hactor.atk if Wora_Monbook::COMPARE_STATUS
when 'def'
vocab = Vocab::def
number = actor.def
hnumber = hactor.def if Wora_Monbook::COMPARE_STATUS
when 'spi'
vocab = Vocab::spi
number = actor.spi
hnumber = hactor.spi if Wora_Monbook::COMPARE_STATUS
when 'agi'
vocab = Vocab::agi
number = actor.agi
hnumber = hactor.agi if Wora_Monbook::COMPARE_STATUS
when 'hit'
vocab = 'HIT'
number = actor.hit
hnumber = hactor.hit if Wora_Monbook::COMPARE_STATUS
when 'eva'
vocab = 'EVA'
number = actor.eva
hnumber = hactor.eva if Wora_Monbook::COMPARE_STATUS
when 'exp'
vocab = 'EXP'
number = actor.exp
color2 = crisis_color
when 'gold'
vocab = 'Gold'
number = actor.gold
color2 = crisis_color
end
if Wora_Monbook::COMPARE_STATUS and !hnumber.nil?
if hnumber > number # Higher
color2 = power_up_color
elsif hnumber < number # Less
color2 = power_down_color
elsif hnumber == number # Equal
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
#===============================================================
# ** Scene_MonsterBook
#--------------------------------------------------------------
class Scene_MonsterBook < Scene_Base
def initialize(from_menu = false)
@from_menu = from_menu
end
def start
super
create_menu_background
$game_system.create_monbook
@window_help = Window_MonsterBHelp.new
# Create Monster List
monlist = []
$game_system.monbook.each_index do |i|
next if i == 0 # The first index in $data_enemies is blank
# If player found the monster
if $game_system.monbook[i] and
!Wora_Monbook::NO_DATA_MONSTER.include?(i)
montext = i.to_s + Wora_Monbook::TEXT_DOT + ' ' + $data_enemies[i].name
else # If player haven't found
montext = i.to_s + Wora_Monbook::TEXT_DOT
end
monlist << montext
end
@window_monlist = Window_Command.new(544, monlist, 2)
@window_monlist.y = @window_help.height
@window_monlist.height = Graphics.height - @window_help.height
@window_monlist.active = true
@window_mondetail = Window_MonsterBDetail.new(@window_monlist)
@window_mondetail.visible = false
end
def update
super
if @window_monlist.active
@window_monlist.update
if Input.trigger?(Input::C)
# View monster's detail if found monster
if $game_system.monbook[@window_monlist.index + 1] and
!Wora_Monbook::NO_DATA_MONSTER.include?(@window_monlist.index + 1)
Sound.play_decision
@window_monlist.active = false
@window_monlist.visible = false
@window_mondetail.active = true
@window_mondetail.visible = true
@window_mondetail.write_detail(@window_monlist.index + 1)
else
Sound.play_cancel
end
elsif Input.trigger?(Input::B)
Sound.play_cancel
# Return
$scene = @from_menu ? Scene_Menu.new(Wora_Monbook::MENU_INDEX) :
Scene_Map.new
end
elsif @window_mondetail.active
if Input.trigger?(Input::B)
Sound.play_cancel
@window_monlist.active = true
@window_monlist.visible = true
@window_mondetail.active = false
@window_mondetail.visible = false
end
end
end
def terminate
super
dispose_menu_background
@window_help.dispose
@window_monlist.dispose
@window_mondetail.dispose
end
end
|
|
|