Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # DSI Bestiary v1.2
- # -- Last Updated: 2017.03.29
- # -- Author: dsiver144
- # -- Level: Normal
- # -- Requires: n/a
- # -- Conmission for: Luke / Golden Unicorn Gaming
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["DSI-Bestiary"] = true
- #==============================================================================
- # + Updates
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2017.03.12 - Finish first version.
- # 2017.03.15 - Fix encounter issues & Add notetag to rearrange enemy in bestiary
- # 2017.03.29 - Add a notetag for zero luk.
- #==============================================================================
- # + Instructions
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
- # Put this below "Sixth Menu Add Ons"! <- IMPORTANT!
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Script Call:
- # SceneManager.call(Scene_DSI_Bestiary) -> Open Bestiary Scene
- # reveal_beast(id) -> Reveal an enemy from Database.
- # can_upgrade_bestiary? -> Use in conditional branches for checking if player
- # can upgrade bestiary
- # upgrade_bestiary -> Upgrade bestiary.
- # -----------------------------------------------------------------------------
- # Notetags:
- # <hide_from_list> : Hide enemy from Bestiary List
- # <bestiary_level: x> : This enemy will be in the list if x <= bestiary
- # level
- # <bestiary_type: st> : Define enemy type. ex <bestiary_type: Rare>
- # <bestiary_diff: st> : Define enemy difficulty. ex: <bestiary_diff: Hard>
- # <bestiary_id: x> : Manually Set bestiary ID for an enemy.
- # if you don't set. Bestiary ID will equal to its id from
- # database.
- # <zero_luk> : Allow zero luk for monster.
- #==============================================================================
- module DSIVER144
- module BESTIARY
- COMMAND_NAME = "Bestiary"
- NO_DATA_PIC = "QuestionMark" # Located in Graphics/System Folder
- NO_DATA_TEXT = "NO DATA"
- GENERAL_INFO_TEXT = "General Info"
- DEBUG_MODE = true # Check duplicated bestiary ID
- TOKENS = {}
- TOKENS[1] = /<hide_from_list>/i
- TOKENS[2] = /<bestiary_level:\s*(\d+)>/i
- TOKENS[3] = /<bestiary_type:\s*(.+)>/i
- TOKENS[4] = /<bestiary_diff:\s*(.+)>/i
- TOKENS[5] = /<bestiary_bg:\s*(.+)>/i
- TOKENS[6] = /<add_bestiary_skill:\s*(.+)>/i
- TOKENS[7] = /<bestiary_id:\s*(\d+)>/i
- TOKENS[8] = /<zero_luk>/i
- #------------------------------------------------------------------------
- # * new method: count_bestiary_size
- #------------------------------------------------------------------------
- def self.count_bestiary_size
- return get_bestiary_list.size - 1
- end
- #------------------------------------------------------------------------
- # * new method: get_complete
- #------------------------------------------------------------------------
- def self.get_complete
- list = get_bestiary_list
- size = 0
- list.each do |enemy|
- next if enemy.nil?
- if $game_system.bestiary_list.include?(enemy.id)
- size += 1
- end
- end
- return size
- end
- #------------------------------------------------------------------------
- # * new method: reveal_beast
- #------------------------------------------------------------------------
- def self.reveal_beast(id)
- return if $data_enemies[id].nil?
- return if $game_system.bestiary_list.include?(id)
- $game_system.bestiary_list << id
- end
- #------------------------------------------------------------------------
- # * new method: get_bestiary_list
- #------------------------------------------------------------------------
- def self.get_bestiary_list
- _list = []
- $data_enemies.each do |enemy|
- if enemy && enemy.bestiary_level <= $game_system.bestiary_level && !enemy.hideFromBestiaryList && enemy.name.size > 0
- _list << enemy
- end
- end
- _list.sort! {|a,b| a.bestiaryID <=> b.bestiaryID}
- _list.unshift(nil)
- end
- end # BESTIARY
- end # DSIVER144
- class Game_Interpreter
- alias_method(:dsiver_battle_processing_alias, :command_301)
- #--------------------------------------------------------------------------
- # * new method: reveal_beast
- #--------------------------------------------------------------------------
- def reveal_beast(id)
- DSIVER144::BESTIARY.reveal_beast(id)
- end
- #--------------------------------------------------------------------------
- # * new method: can_upgrade_bestiary?
- #--------------------------------------------------------------------------
- def can_upgrade_bestiary?
- return DSIVER144::BESTIARY.get_complete >= DSIVER144::BESTIARY.count_bestiary_size
- end
- #--------------------------------------------------------------------------
- # * new method: upgrade_bestiary
- #--------------------------------------------------------------------------
- def upgrade_bestiary
- $game_system.bestiary_level += 1 if can_upgrade_bestiary?
- end
- #--------------------------------------------------------------------------
- # * Battle Processing
- #--------------------------------------------------------------------------
- def command_301
- dsiver_battle_processing_alias
- if @params[0] == 0 # Direct designation
- troop_id = @params[1]
- elsif @params[0] == 1 # Designation with variables
- troop_id = $game_variables[@params[1]]
- else # Map-designated troop
- troop_id = $game_player.make_encounter_troop_id
- end
- if $data_troops[troop_id]
- $data_troops[troop_id].members.each do |member|
- DSIVER144::BESTIARY.reveal_beast(member.enemy_id)
- end
- end
- end
- end # Game_Interpreter
- class Scene_DSI_Bestiary < Scene_Base
- #--------------------------------------------------------------------------
- # * Start Processing
- #--------------------------------------------------------------------------
- def start
- super
- create_background
- create_main_windows
- init_cursors
- end
- #--------------------------------------------------------------------------
- # * Termination Processing
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_background
- end
- #--------------------------------------------------------------------------
- # * Create Background
- #--------------------------------------------------------------------------
- def create_background
- @background_sprite = Sprite.new
- @background_sprite.bitmap = SceneManager.background_bitmap
- @background_sprite.color.set(16, 16, 16, 128)
- end
- #--------------------------------------------------------------------------
- # * Free Background
- #--------------------------------------------------------------------------
- def dispose_background
- @background_sprite.dispose
- @beast_sprite.bitmap.dispose
- @beast_sprite.dispose
- end
- #--------------------------------------------------------------------------
- # * new method: create_main_windows
- #--------------------------------------------------------------------------
- def create_main_windows
- @bestiary_list = DSIVER144::BESTIARY.get_bestiary_list
- @current_index = 1
- @title_window = Bestiary_Title_Window.new(0,0,250,48)
- @title_window.z = 10
- @title_window.draw(@current_index)
- ww = Graphics.width - @title_window.width
- wh = Graphics.height
- @info_window = Bestiary_Info_Window.new(@title_window.width,0,ww,wh)
- @info_window.z = 10
- wy = Graphics.height - 48
- ww = Graphics.width - @info_window.width
- @progress_window = Window_Base.new(0,wy,ww,48)
- @progress_window.z = 10
- cw = @progress_window.contents_width
- progress = sprintf("Completed: %03d/%03d", DSIVER144::BESTIARY.get_complete, @bestiary_list.size - 1)
- @progress_window.draw_text(0,0,cw,24,progress,1)
- @beast_sprite = Sprite.new
- @beast_sprite.z = 0
- refresh_windows
- end
- #--------------------------------------------------------------------------
- # * new method: refresh_background
- #--------------------------------------------------------------------------
- def refresh_background # Not use yet!
- if is_revealed?
- enemy = $data_enemies[@current_index]
- end
- end
- #--------------------------------------------------------------------------
- # * new method: refresh_background
- #--------------------------------------------------------------------------
- def is_revealed?
- return false if @bestiary_list[@current_index].nil?
- return $game_system.bestiary_list.include?(@bestiary_list[@current_index].id)
- end
- #--------------------------------------------------------------------------
- # * new method: refresh_sprite
- #--------------------------------------------------------------------------
- def refresh_sprite
- if is_revealed?
- enemy = @bestiary_list[@current_index]
- @beast_sprite.bitmap = Cache.battler(enemy.battler_name,enemy.battler_hue)
- correct_sprite_xy
- else
- @beast_sprite.bitmap = Cache.system(DSIVER144::BESTIARY::NO_DATA_PIC)
- correct_sprite_xy
- end
- end
- #--------------------------------------------------------------------------
- # * new method: init_cursors
- #--------------------------------------------------------------------------
- def init_cursors
- @cursors = {}
- pad = AstoriaMenuAddons::Misc[:eq_cursor][:padding]
- yo = (Graphics.height - 24)*0.5#AstoriaMenuAddons::Misc[:eq_cursor][:y]
- [:left,:right].each_with_index do |type,i|
- @cursors[type] = WinCursor.new(@info_window.windowskin,@info_window.z,type)
- case type
- when :left
- xx = pad
- when :right
- xx = @info_window.x + @info_window.width - @cursors[type].size[:w] - pad
- end
- yy = yo
- @cursors[type].set_ori_pos(xx,yy)
- end
- end
- #--------------------------------------------------------------------------
- # * new method: correct_sprite_xy
- #--------------------------------------------------------------------------
- def correct_sprite_xy
- @sprite_offset_x = @beast_sprite.bitmap.width / 2
- @sprite_offset_y = @beast_sprite.bitmap.height / 2
- @beast_sprite.ox = @sprite_offset_x
- @beast_sprite.oy = @sprite_offset_y
- @beast_sprite.x = (@title_window.width - @beast_sprite.bitmap.width) * 0.5
- @beast_sprite.x += @sprite_offset_x
- y = @title_window.height + ((Graphics.height - 48*2) - @beast_sprite.bitmap.height) * 0.5
- @beast_sprite.y = y
- @beast_sprite.y += @sprite_offset_y
- end
- #--------------------------------------------------------------------------
- # * new method: refresh_windows
- #--------------------------------------------------------------------------
- def refresh_windows
- @title_window.draw(@current_index)
- @info_window.draw(@current_index,is_revealed?,@bestiary_list)
- refresh_sprite
- end
- #--------------------------------------------------------------------------
- # * new method: update_input
- #--------------------------------------------------------------------------
- def update_input
- if Input.repeat?(:RIGHT)
- Sound.play_cursor
- @current_index += 1
- if @current_index > @bestiary_list.size - 1
- @current_index = 1
- end
- refresh_windows
- end
- if Input.repeat?(:LEFT)
- Sound.play_cursor
- @current_index -= 1
- if @current_index < 1
- @current_index = @bestiary_list.size - 1
- end
- refresh_windows
- end
- end
- #--------------------------------------------------------------------------
- # * new method: update
- #--------------------------------------------------------------------------
- def update
- super
- update_input
- @cursors.each_value {|curs| curs.update} if @cursors
- return_scene if Input.trigger?(:B)
- end
- end
- class Bestiary_Info_Window < Window_Base
- attr_accessor :mode
- attr_accessor :toggle_on
- attr_accessor :current_index
- #--------------------------------------------------------------------------
- # * new method: draw
- #--------------------------------------------------------------------------
- def draw(index,revealed,list)
- contents.clear
- @toggle_on = revealed
- @list = list
- @mode = 0
- @current_index = index
- @drop_items = nil
- draw_reveal(index) if revealed
- draw_unreveal if !revealed
- end
- #--------------------------------------------------------------------------
- # * new method: draw_reveal
- #--------------------------------------------------------------------------
- def draw_reveal(index)
- contents.clear
- enemy = @list[index]
- battler = Game_Enemy.new(0,enemy.id)
- cw = contents_width
- change_color(text_color(2))
- draw_text(0,0,cw,24,enemy.name,1)
- x = 0; y = 24;
- draw_param(Vocab.param(0),battler.param_base(0),x,y,cw/2)
- draw_param(Vocab.param(1),battler.param_base(1),cw/2,y,cw/2)
- y += 24
- draw_param(Vocab.param(2),battler.param_base(2),x,y,cw/2)
- draw_param(Vocab.param(3),battler.param_base(3),cw/2,y,cw/2)
- y += 24
- draw_param(Vocab.param(4),battler.param_base(4),x,y,cw/2)
- draw_param(Vocab.param(5),battler.param_base(5),cw/2,y,cw/2)
- y += 24
- draw_param(Vocab.param(6),battler.param_base(6),x,y,cw/2)
- draw_param(Vocab.param(7),battler.param_base(7),cw/2,y,cw/2)
- y += 24
- names = AstoriaMenuAddons::Vocab[:xparams]
- xparam = [7,8,6,1]
- draw_param(names[7],(battler.xparam(7)*100).to_i.to_s + "%",x,y,cw/2)
- draw_param(names[8],(battler.xparam(8)*100).to_i.to_s + "%",cw/2,y,cw/2)
- y += 24
- draw_param(names[6],(battler.xparam(6)*100).to_i.to_s + "%",x,y,cw/2)
- draw_param(names[1],(battler.xparam(1)*100).to_i.to_s + "%",cw/2,y,cw/2)
- count_i = 0
- AstoriaMenuAddons::Vocab[:elements].each_pair do |id,icon_index|
- value = battler.element_rate(id)
- if count_i % 2 == 0
- y += 24
- draw_elements(icon_index,value,x,y,cw/2)
- else
- draw_elements(icon_index,value,cw/2,y,cw/2)
- end
- count_i += 1
- end
- change_color(text_color(2))
- y += 24
- draw_text(x,y+2,cw,24,DSIVER144::BESTIARY::GENERAL_INFO_TEXT,1)
- y += 26
- draw_param("Type: ", enemy.enemyType, x, y, cw)
- y += 24
- draw_param("Difficulty: ", enemy.enemyDifficulty, x, y, cw); y += 24
- if @drop_items
- @drop_items.push(@drop_items.shift) if Graphics.frame_count % 2 == 0
- else
- @drop_items = make_drop_items(enemy,battler)
- end
- if @drop_items && @drop_items.size > 0 && @drop_items[0]
- draw_param("Drops: ", "", x, y, cw)
- x_plus = x + text_size("Drops: ").width
- draw_item(@drop_items[0].icon_index,@drop_items[0].name,x,y,cw)
- else
- draw_param("Drops: ", "None", x, y, cw)
- end
- y += 24;
- draw_param("Gold: ", enemy.gold, x, y, cw/2)
- draw_param("EXP: ", enemy.exp, cw/2, y, cw/2)
- end
- #--------------------------------------------------------------------------
- # * new method: draw_skill
- #--------------------------------------------------------------------------
- def draw_item(icon_index,name,x,y,width)
- change_color(normal_color)
- icon_x = width - text_size(name).width - 24 - 8
- draw_icon(icon_index,icon_x,y)
- draw_text(x+8,y,width - 12,24,name,2)
- end
- #--------------------------------------------------------------------------
- # * Create Array of Dropped Items
- #--------------------------------------------------------------------------
- def make_drop_items(enemy,battler)
- enemy.drop_items.inject([]) do |r, di|
- if di.kind > 0
- r.push(battler.item_object(di.kind, di.data_id))
- else
- r
- end
- end
- end
- #--------------------------------------------------------------------------
- # * new method: update
- #--------------------------------------------------------------------------
- def update
- super
- if @toggle_on && Graphics.frame_count % 60 == 0
- draw_reveal(@current_index)
- @mode = mode == 0 ? 1 : 0
- end
- end
- #--------------------------------------------------------------------------
- # * new method: draw_skill
- #--------------------------------------------------------------------------
- def draw_skill(name,x,y,width,align)
- change_color(normal_color)
- draw_text(x+8,y,width - 12,24,name,align)
- end
- #--------------------------------------------------------------------------
- # * new method: draw_elements
- #--------------------------------------------------------------------------
- def draw_elements(icon_index,value,x,y,width)
- draw_icon(icon_index,x+8,y)
- change_color(normal_color)
- vtxt = sprintf("%1.0f%",(1.0-value)*100)
- draw_text(x+8,y,width - 12,24,vtxt,2)
- end
- #--------------------------------------------------------------------------
- # * new method: draw_param
- #--------------------------------------------------------------------------
- def draw_param(name,value,x,y,width)
- change_color(system_color)
- draw_text(x+8,y,width - 12,24,name,0)
- change_color(normal_color)
- draw_text(x+8,y,width - 12,24,value,2)
- end
- #--------------------------------------------------------------------------
- # * new method: draw_unreveal
- #--------------------------------------------------------------------------
- def draw_unreveal
- contents.clear
- cw = contents_width
- draw_text(0,0,cw,24,"???????",1)
- draw_text(0,0,cw,contents_height,DSIVER144::BESTIARY::NO_DATA_TEXT,1)
- end
- end
- class Bestiary_Title_Window < Window_Base
- #--------------------------------------------------------------------------
- # * new method: draw
- #--------------------------------------------------------------------------
- def draw(index)
- contents.clear
- size = DSIVER144::BESTIARY.count_bestiary_size
- draw_text(0,0,contents_width,24,sprintf("Bestiary %03d/%03d",index,size),1)
- end
- end # Bestiary_Title_Window
- #==============================================================================
- # DataManager
- #==============================================================================
- module DataManager
- #--------------------------------------------------------------------------
- # alias method: load_database
- #--------------------------------------------------------------------------
- class <<self; alias load_database_seal_item load_database; end
- def self.load_database
- load_database_seal_item
- load_notetags_enemy_bestiary
- end
- #--------------------------------------------------------------------------
- # Load Notetag Rental Weapons
- #--------------------------------------------------------------------------
- def self.load_notetags_enemy_bestiary
- index = 0
- if DSIVER144::BESTIARY::DEBUG_MODE && $TEST
- @dup_ids = []
- end
- for enemy in $data_enemies
- next if enemy.nil?
- enemy.load_bestiary_notetags
- next if enemy.bestiaryID < 0
- @dup_ids[enemy.bestiaryID] ||= []
- @dup_ids[enemy.bestiaryID].push([enemy.id,enemy.name])
- end
- if DSIVER144::BESTIARY::DEBUG_MODE && $TEST
- @dup_ids.each do |pack|
- next unless pack
- if pack.size > 1
- str = "[Need correction!] Has same bestiary ID: "
- pack.each do |enemy_info|
- str += "[#{enemy_info[0]} : #{enemy_info[1]}] "
- end
- msgbox_p(str)
- end
- end
- end
- end
- end # DataManager
- class RPG::Enemy
- include DSIVER144
- attr_accessor :hideFromBestiaryList
- attr_accessor :specialSkills
- attr_accessor :enemyType
- attr_accessor :enemyDifficulty
- attr_accessor :bestiary_level
- attr_accessor :bestiary_skills
- attr_accessor :bestiaryID
- attr_accessor :no_luk
- #--------------------------------------------------------------------------
- # * new method: load_bestiary_notetags
- #--------------------------------------------------------------------------
- def load_bestiary_notetags
- @hideFromBestiaryList = false
- @specialSkills = []
- @enemyType = "---"
- @enemyDifficulty = "---"
- @bestiary_level = 1
- @bestiary_bg = []
- @bestiary_skills = []
- @bestiaryID = self.name.size == 0 ? -self.id : self.id
- @no_luk = false
- self.note.split(/[\r\n]+/).each do |line|
- case line
- when BESTIARY::TOKENS[1]
- @hideFromBestiaryList = true
- @bestiaryID = -self.id
- break
- when BESTIARY::TOKENS[2]
- @bestiary_level = $1.to_i
- when BESTIARY::TOKENS[3]
- @enemyType = $1.to_s
- when BESTIARY::TOKENS[4]
- @enemyDifficulty = $1.to_s
- when BESTIARY::TOKENS[5]
- if $1.include?(",")
- $1.split(",").each do |name|
- @bestiary_bg << name
- end
- else
- @bestiary_bg[0] = $1
- end
- when BESTIARY::TOKENS[6]
- name = $1.clone
- if $1 =~ /(\d+)/
- @bestiary_skills << $data_skills[$1.to_i].name
- else
- @bestiary_skills << name
- end
- when BESTIARY::TOKENS[7]
- @bestiaryID = $1.to_i
- when BESTIARY::TOKENS[8]
- @no_luk = true
- end
- end # loop end
- end # load_bestiary_notetags
- end # RPG::Enemy
- class Game_System
- attr_accessor :bestiary_list
- attr_accessor :bestiary_level
- alias_method(:dsi_bestiary_init_z, :initialize)
- #--------------------------------------------------------------------------
- # * new method: initialize
- #--------------------------------------------------------------------------
- def initialize
- @bestiary_list = []
- @bestiary_level = 1
- dsi_bestiary_init_z
- end
- end # Game_System
- class Game_Enemy
- #--------------------------------------------------------------------------
- # * Get Base Value of Parameter
- #--------------------------------------------------------------------------
- def param_base(param_id)
- if $data_enemies[@enemy_id].no_luk && param_id == 7
- return 0
- else
- enemy.params[param_id]
- end
- end
- #--------------------------------------------------------------------------
- # * Get Parameter
- #--------------------------------------------------------------------------
- alias_method(:dsi_param_bestiary, :param)
- def param(param_id)
- return_value = dsi_param_bestiary(param_id)
- if $data_enemies[@enemy_id].no_luk && param_id == 7
- return 0
- end
- return return_value
- end
- end
- class Game_Player
- #--------------------------------------------------------------------------
- # * overwrite method: encounter
- #--------------------------------------------------------------------------
- def encounter
- return false if $game_map.interpreter.running?
- return false if $game_system.encounter_disabled
- return false if @encounter_count > 0
- make_encounter_count
- troop_id = make_encounter_troop_id
- return false unless $data_troops[troop_id]
- $data_troops[troop_id].members.each do |member|
- DSIVER144::BESTIARY.reveal_beast(member.enemy_id)
- end
- BattleManager.setup(troop_id)
- BattleManager.on_encounter
- return true
- end
- end # Game_Player
- class Window_MenuCommand
- alias_method(:dsi_bestiary_add_original_commands, :add_original_commands)
- #--------------------------------------------------------------------------
- # * For Adding Original Commands
- #--------------------------------------------------------------------------
- def add_original_commands
- dsi_bestiary_add_original_commands
- add_command(DSIVER144::BESTIARY::COMMAND_NAME, :bestiary)
- end
- end # Window_Command
- class Scene_Menu
- alias_method(:dsi_bestiary_create_command_window, :create_command_window)
- #--------------------------------------------------------------------------
- # * alias method: create_command_window
- #--------------------------------------------------------------------------
- def create_command_window
- dsi_bestiary_create_command_window
- @command_window.set_handler(:bestiary, method(:command_bestiary))
- end
- #--------------------------------------------------------------------------
- # * new method: command_bestiary
- #--------------------------------------------------------------------------
- def command_bestiary
- SceneManager.call(Scene_DSI_Bestiary)
- end
- end # Scene_Menu
- #===============================================================================
- # * END OF FILE
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement