Fanron Newbie
Posts : 24 Thanked : 0 Engine : RMVX Skill : Beginner Type : Event Designer
| Subyek: Re: Mau minta bestiary yang kayak gini 2012-12-09, 09:39 | |
| ini juga sama. dari game nevanoid - Spoiler:
#============================================================================== # Section I: Album Classes #==============================================================================
#============================================================================== # ** Game_Album #------------------------------------------------------------------------------ # This class handles the Bestairy. #==============================================================================
class Game_Album #-------------------------------------------------------------------------- # * Constant: Add or remove enemy ID's you want to have hidden in the Album #-------------------------------------------------------------------------- BLACK_LIST = [] #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :seen # Array of enemies seen but not killed attr_reader :killed # Array of enemies actually killed in battle attr_reader :rank # String to contain rank title attr_reader :percent # Percent of Album completion attr_reader :test_enemy_id # ID of enemy to be tested in battle attr_reader :black_list # Array of enemy ID's to be hidden attr_accessor :battle_test # Whether the impending fight is album related #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize # Set seen & killed variables to blank arrays for new album @seen = [] @killed = [] for i in 1...$data_enemies.size @killed.push(nil) @seen.push(nil) end @rank = 'Kosong' @percent = 0 @test_enemy_id = 0 @battle_test = false end #-------------------------------------------------------------------------- # * add_enemy_seen #-------------------------------------------------------------------------- def add_enemy_seen(enemy) # Use enemy ID - 1 for correct index placement in the array index = enemy.id - 1 # The following replaces the nil object with the enemy at the index @seen.insert(index, enemy) @seen.delete_at(enemy.id) determine_rank end #-------------------------------------------------------------------------- # * add_enemy_killed #-------------------------------------------------------------------------- def add_enemy_killed(enemy) # Use enemy ID - 1 for correct index placement in the array index = enemy.id - 1 # The following replaces the nil object with the enemy at the index @killed.insert(index, enemy) @killed.delete_at(enemy.id) determine_rank end #-------------------------------------------------------------------------- # * Determine party's rank title for album completion #-------------------------------------------------------------------------- def determine_rank # First check to see if the player has seen more enemies than killed if @seen.nitems > @killed.nitems # Assign rank and end rank check @rank = 'Pengamat' return end # Get percent of enemies killed over total amount of enemies in game # -1 to make up for nil in $data_enemies array @percent = ((@killed.nitems * 100) / ($data_enemies.size - 1)) # Change player rank according to percent case @percent when 1..25 # When up to 25% @rank = 'Lemah' when 26..50 # When 26% to 50% @rank = 'Biasa' when 51..75 # When 51% to 75% @rank = 'Hebat' when 76..99 # When 76% to 99% @rank = 'Sangat Kuat' when 100 # When 100% @rank = 'Legenda' end end #-------------------------------------------------------------------------- # * has_seen_enemy? Checks if enemy is included in the @seen array #-------------------------------------------------------------------------- def has_seen_enemy?(enemy) return @seen.include?(enemy) end #-------------------------------------------------------------------------- # * has_killed_enemy? Checks if enemy is included in the @killed array #-------------------------------------------------------------------------- def has_killed_enemy?(enemy) return @killed.include?(enemy) end #-------------------------------------------------------------------------- # * enemy_blacklisted? Checks if ID is included among the enemy ID's to hide #-------------------------------------------------------------------------- def enemy_blacklisted?(enemy_id) return BLACK_LIST.include?(enemy_id) end #-------------------------------------------------------------------------- # * Simple search algorithym # Checks all the troops for the latest one that contains the given enemy ID #-------------------------------------------------------------------------- def soul_searcher(id) # Set ID of enemy to be 'singled out' for battle later @test_enemy_id = id # Look through all the $data_troops array for i in 1...$data_troops.size # In current troop, look through all the members for the enemy ID for j in 0...$data_troops[i].members.size # If the enemy ID being searched is within this troop if $data_troops[i].members[j].enemy_id == id # Set this variable to that troop ID to be returned & Break the search troop = $data_troops[i] break end end end return troop.id end #-------------------------------------------------------------------------- # * Initiates a combat #-------------------------------------------------------------------------- def start_battle(id) # Start battle with the troop results from soul searcher $game_troop.setup(soul_searcher(id)) # if this battle is a album test fight, single out the enemy being tested $game_troop.single_out_enemy(id) # Set album battle test flag to true @battle_test = true # Play battle start SE $game_temp.map_bgm = RPG::BGM.last $game_temp.map_bgs = RPG::BGS.last RPG::BGM.stop RPG::BGS.stop Sound.play_battle_start $game_system.battle_bgm.play $game_temp.next_scene = nil $scene = Scene_Battle.new end end
#============================================================================== # ** Scene_Album #------------------------------------------------------------------------------ # This class handles the monster album windows. #==============================================================================
class Scene_Album < Scene_Base #-------------------------------------------------------------------------- # * Start processing #-------------------------------------------------------------------------- def start super # Set up windows used in this scene # Set window of monster names currently known @monster_list_window = Window_Album_List.new # Get monster currently selected in window list @monster = @monster_list_window.monster # Make window that shows current selected monster's stats @monster_info_window = Window_Album_Right.new(@monster) # Make info window of album completion @total_window = Window_Total.new # Make monster window @monster_window = Window_Monster_Picture.new(@monster) @monster_window.visible = false # Make monster command window @command_window = Window_Album_Command.new(['Elemen', 'Status', 'Kemampuan', 'Serang']) @command_window.visible = false @command_window.active = false end #-------------------------------------------------------------------------- # * Termination Processing #-------------------------------------------------------------------------- def terminate super # Dispose of windows @monster_info_window.dispose @monster_list_window.dispose @total_window.dispose @monster_window.dispose @command_window.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Update windows conditionally # If monster list window is active: call update_list if @monster_list_window.active update_list return end # If monster command window is active: call update_command if @command_window.visible update_command return end end #-------------------------------------------------------------------------- # * Frame Update (when monster list window is active) #-------------------------------------------------------------------------- def update_list @monster_list_window.update # Set the variable @monster equal to the currently selected monster @monster = @monster_list_window.monster # Set info window's monster to the selected monster @monster_info_window.set_new_monster(@monster) # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE Sound.play_cancel # Switch to menu screen @monster_list_window.active = false $scene = Scene_Menu.new(0) return end # If C button was pressed if Input.trigger?(Input::C) if @monster != nil # Play decision SE Sound.play_decision # Activate monster window @monster_list_window.active = false @monster_list_window.visible = false @monster_info_window.visible = false @total_window.visible = false @monster_window.visible = true @monster_window.get_new_monster(@monster) @monster_window.draw_enemy_elementals @command_window.visible = true @command_window.active = true end return end end #-------------------------------------------------------------------------- # * Frame Update (when monster command window is active) #-------------------------------------------------------------------------- def update_command @command_window.update # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE Sound.play_cancel # Go back to monster list @monster_list_window.active = true @monster_list_window.visible = true @monster_window.visible = false @monster_info_window.visible = true @total_window.visible = true @command_window.index = 0 @command_window.active = false @command_window.visible = false return end # If C button was pressed if Input.trigger?(Input::C) # Branch by command window cursor position Sound.play_decision # Play decision SE case @command_window.index when 0 # Elementals # Draw enemy elemental attributes @monster_window.draw_enemy_elementals when 1 # States # Draw enemy states info @monster_window.draw_enemy_states when 2 # Abilities # Draw enemy abilitites @monster_window.draw_enemy_actions when 3 # Battle # Call an album test battle process $game_album.start_battle(@monster.id) end return end # If L button was pressed if Input.trigger?(Input::L) prev_monster return end # If R button was pressed if Input.trigger?(Input::R) next_monster return end end #-------------------------------------------------------------------------- # * Next enemy #-------------------------------------------------------------------------- def next_monster # Don't let the index go past the enemy list unless @monster_list_window.index == $game_album.killed.size - 1 @monster_list_window.index += 1 end # Set the variable @monster equal to the currently selected monster @monster = @monster_list_window.monster # Set info window's monster to the selected monster @monster_info_window.set_new_monster(@monster) if @monster != nil # Play decision SE Sound.play_decision # Inform Monster window of new monster and redraw stats @monster_window.get_new_monster(@monster) @monster_window.draw_enemy_elementals end end #-------------------------------------------------------------------------- # * previous enemy #-------------------------------------------------------------------------- def prev_monster # Don't let the index go above the enemy list unless @monster_list_window.index == 0 @monster_list_window.index -= 1 end # Set the variable @monster equal to the currently selected monster @monster = @monster_list_window.monster # Set info window's monster to the selected monster @monster_info_window.set_new_monster(@monster) if @monster != nil # Play decision SE Sound.play_decision # Inform Monster window of new monster and redraw stats @monster_window.get_new_monster(@monster) @monster_window.draw_enemy_elementals end end end
#============================================================================== # ** Window_Album_List #------------------------------------------------------------------------------ # The list of monster names. #==============================================================================
class Window_Album_List < Window_Selectable #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 56, 214, 360) @column_max = 1 refresh self.index = 0 end #-------------------------------------------------------------------------- # * Monster Acquisition #-------------------------------------------------------------------------- def monster return @data[self.index] end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh #if self.contents != nil #self.contents.dispose #self.contents = nil #end @data = [] # For every enemy in the album, a address of them to @data for i in 0...$game_album.killed.size @data.push($game_album.killed[i]) end @item_max = @data.size create_contents for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # * Draw Item #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect(index) self.contents.clear_rect(rect) monster = @data[index] rect.width -= 4 draw_monster_name(monster, rect.x, rect.y) end end
#============================================================================== # ** Window_Album_Right #------------------------------------------------------------------------------ # This window shows monster attributes. #==============================================================================
class Window_Album_Right < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(enemy) super(214, 56, 330, 360) self.contents = Bitmap.new(width - 32, height - 32) @enemy = enemy self.opacity = 0 # Increase this if you want to see the window refresh end #-------------------------------------------------------------------------- # * Set parameters for monster #-------------------------------------------------------------------------- def set_new_monster(new_monster) if @enemy != new_monster @enemy = new_monster refresh end end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear if @enemy != nil draw_enemy_picture(@enemy, 185, 208) draw_enemy_exp(@enemy, 4, 50) draw_enemy_gold(@enemy, 4, 75) draw_enemy_name(@enemy, 2, 0, normal_color) draw_enemy_stats(@enemy, 4, 220, $game_album.enemy_blacklisted?(@enemy.id)) end end end
#============================================================================== # ** Window_Monster_Total 544×416 #------------------------------------------------------------------------------ # Shows album completion. #==============================================================================
class Window_Total < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 0, 544, 56) self.contents = Bitmap.new(width - 32, height - 32) refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.font.color = system_color self.contents.draw_text(4, 0, 200, 32, "Total Moster :") self.contents.draw_text(370, 0, 200, 32, "Rank :") self.contents.font.color = normal_color self.contents.draw_text(200, 0, 200, 32, $game_album.killed.nitems.to_s + ' / ') self.contents.draw_text(240, 0, 200, 32, ($data_enemies.size - 1).to_s + " : ") self.contents.draw_text(295, 0, 200, 32, $game_album.percent.to_s + "%") self.contents.draw_text(430, 0, 200, 32, $game_album.rank) end end
#============================================================================== # ** Window_Monster_Picture #------------------------------------------------------------------------------ # This window shows a bigger picture of the monster with name. #==============================================================================
class Window_Monster_Picture < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(enemy) super(0, 0, 544, 370) self.contents = Bitmap.new(width - 32, height - 32) @enemy = enemy refresh end #-------------------------------------------------------------------------- # * Set parameters for monster #-------------------------------------------------------------------------- def get_new_monster(new_monster) if @enemy != new_monster @enemy = new_monster end end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear if @enemy != nil draw_enemy_picture2(@enemy) draw_enemy_name(@enemy, 4, 4, system_color) end end #-------------------------------------------------------------------------- # * Draws enemy's elementals chart #-------------------------------------------------------------------------- def draw_enemy_elementals refresh x = 4 y = 4 # Change color and font size self.contents.font.color = system_color #self.contents.font.size = 20 # Draw text #self.contents.draw_text(x, y + 32, 100, 22, "Elements:") self.contents.font.size = 18 self.contents.draw_text(x, y + 25, 50, 22, "Serap:") self.contents.draw_text(x + 75, y + 25, 50, 22, "Kuat:") self.contents.draw_text(x + 150, y + 25, 50, 22, "Lemah:") self.contents.draw_text(x + 225, y + 25, 50, 22, "Buruk:") # Change color and font size self.contents.font.color = normal_color self.contents.font.size = 16 # unless the enemy info is hidden unless $game_album.enemy_blacklisted?(@enemy.id) # Draw the attributes names in position determined by attribute strength for i in 1...@enemy.element_ranks.xsize if @enemy.element_ranks[i] == 6 self.contents.font.color = Colors::GREEN self.contents.draw_text(x, 16 * i + 34, 120, 16, $data_system.elements[i]) end if @enemy.element_ranks[i] == 5 self.contents.font.color = Colors::INDIGO self.contents.draw_text(x + 75, 16 * i + 34, 120, 16, $data_system.elements[i]) end if @enemy.element_ranks[i] == 2 self.contents.font.color = Colors::ORANGE self.contents.draw_text(x + 150, 16 * i + 34, 120, 16, $data_system.elements[i]) end if @enemy.element_ranks[i] == 1 self.contents.font.color = Colors::RED self.contents.draw_text(x + 225, 16 * i + 34, 120, 16, $data_system.elements[i]) end end end end #-------------------------------------------------------------------------- # * Draws enemy's States chart #-------------------------------------------------------------------------- def draw_enemy_states refresh x = 4#300 y = 4 # Change color and font size self.contents.font.color = system_color #self.contents.font.size = 18 # Draw text #self.contents.draw_text(x, y + 25, 100, 22, "States:") self.contents.font.size = 18 self.contents.draw_text(x, y + 25, 50, 22, "Gagal:") self.contents.draw_text(x + 75, y + 25, 50, 22, "Kuat:") self.contents.draw_text(x + 150, y + 25, 50, 22, "Lemah:") self.contents.draw_text(x + 225, y + 25, 50, 22, "Buruk:") # Change color and font size self.contents.font.color = normal_color self.contents.font.size = 16 # unless the enemy info is hidden unless $game_album.enemy_blacklisted?(@enemy.id) # Draw the state names in position determined by attribute strength for i in 1...@enemy.state_ranks.xsize if @enemy.state_ranks[i] == 6 self.contents.font.color = Colors::BLACK self.contents.draw_text(x, 16 * i + 34, 75, 16, $data_states[i].name) end if @enemy.state_ranks[i] == 5 self.contents.font.color = Colors::VIOLET self.contents.draw_text(x + 75, 16 * i + 34, 75, 16, $data_states[i].name) end if @enemy.state_ranks[i] == 2 self.contents.font.color = Colors::YELLOW self.contents.draw_text(x + 150, 16 * i + 34, 75, 16, $data_states[i].name) end if @enemy.state_ranks[i] == 1 self.contents.font.color = Colors::RED self.contents.draw_text(x + 225, 16 * i + 34, 75, 16, $data_states[i].name) end end end end #-------------------------------------------------------------------------- # * Draws enemy's States chart #-------------------------------------------------------------------------- def draw_enemy_actions refresh x = 4 y = 4 # Change color and font size self.contents.font.color = system_color self.contents.font.size = 20 # Draw text self.contents.draw_text(x, y + 32, 100, 22, "Aksi:") # Change color and font size self.contents.font.color = normal_color # unless the enemy info is hidden unless $game_album.enemy_blacklisted?(@enemy.id) # Draw the names of the actions the enemy can perform for i in 0...@enemy.actions.size # If the action is not a skill if @enemy.actions[i].kind == 0 # Draw text that corresponds to action basic type case @enemy.actions[i].basic when 0 self.contents.draw_text(x, 24 * i + 76, 200, 24, 'Serang') when 1 self.contents.draw_text(x, 24 * i + 76, 200, 24, 'Bertahan') when 2 self.contents.draw_text(x, 24 * i + 76, 200, 24, 'Kabur') when 3 self.contents.draw_text(x, 24 * i + 76, 200, 24, 'Diam') end # Other wise if actions is a skill, draw the name of the skill elsif @enemy.actions[i].kind = 1 ability = $data_skills[@enemy.actions[i].skill_id].name self.contents.draw_text(x, 24 * i + 76, 200, 24, ability) end end end end end
#============================================================================== # ** Window_Album_Command #==============================================================================
class Window_Album_Command < Window_Selectable #-------------------------------------------------------------------------- # * Object Initialization # width : window width # commands : command text string array #-------------------------------------------------------------------------- def initialize(commands) super(0, 360, 544, 56) @item_max = commands.size @commands = commands @column_max = 4 self.contents = Bitmap.new(width - 32, height - 32) refresh self.index = 0 end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@item_max draw_item(i, normal_color) end end #-------------------------------------------------------------------------- # * Draw Item # index : item number #-------------------------------------------------------------------------- def draw_item(index, color) self.contents.font.color = color x = 4 + index * 136 self.contents.draw_text(x, 0, 160, 32, @commands[index]) end #-------------------------------------------------------------------------- # * Disable Item # index : item number #-------------------------------------------------------------------------- def disable_item(index) draw_item(index, disabled_color) end end
#============================================================================== # Section II: Dependancy WIndows #==============================================================================
#============================================================================== # ** Window_Base #==============================================================================
class Window_Base < Window # def draw_monster_name(monster, x, y, enabled = true) self.contents.font.color = normal_color if monster == nil self.contents.draw_text(x+50, y, 204, 32, '????????', 0) self.contents.font.color = system_color self.contents.draw_text(x, y, 204, 32, '???', 0) else self.contents.draw_text(x+50, y, 204, 32, monster.name, 0) self.contents.font.color = system_color self.contents.draw_text(x, y, 204, 32, sprintf("%03d", monster.id.to_s), 0) end end #-------------------------------------------------------------------------- # * Draws enemy's picture #-------------------------------------------------------------------------- def draw_enemy_picture(enemy, x, y) bitmap = Cache.battler(enemy.battler_name, enemy.battler_hue) x2 = bitmap.width y2 = bitmap.height x3 = x2 / 2 y3 = y2 - 120 src_rect = Rect.new(0, 0, x2, y2) # If enemy height is greater than 220, draw the picture lower on the screen if bitmap.height > 220 self.contents.blt(x - x3, y - y3, bitmap, src_rect) else self.contents.blt(x - x3, y - y2, bitmap, src_rect) end end #-------------------------------------------------------------------------- # * Draws enemy's large picture #-------------------------------------------------------------------------- def draw_enemy_picture2(enemy) bitmap = Cache.battler(enemy.battler_name, enemy.battler_hue) x2 = bitmap.width y2 = bitmap.height x3 = 398 - bitmap.width y3 = 398 - bitmap.height src_rect = Rect.new(0, 0, x2, y2) if x3 <= y3 new_rect = Rect.new(160, 10, x2 + x3, y2 + x3) else new_rect = Rect.new(160, 10, x2 + y3, y2 + y3) end self.contents.stretch_blt(new_rect, bitmap, src_rect, 100) end #-------------------------------------------------------------------------- # * Draws enemy's name #-------------------------------------------------------------------------- def draw_enemy_name(enemy, x, y, color) self.contents.font.color = color self.contents.font.size = 24 self.contents.draw_text(x, y, 400, 32, enemy.name) end #-------------------------------------------------------------------------- # * Draws enemy's gold #-------------------------------------------------------------------------- def draw_enemy_gold(enemy, x, y) self.contents.font.color = system_color self.contents.draw_text(x, y, 100, 32, "Rp") self.contents.font.color = normal_color self.contents.draw_text(x + 24, y, 84, 32, enemy.gold.to_s, 2) end #-------------------------------------------------------------------------- # * Draws enemy's exp #-------------------------------------------------------------------------- def draw_enemy_exp(enemy, x, y) self.contents.font.color = system_color self.contents.draw_text(x, y, 32, 32, "EXP") self.contents.font.color = normal_color self.contents.draw_text(x + 24, y, 84, 32, enemy.exp.to_s, 2) end #-------------------------------------------------------------------------- # * Draws enemy's statistics #-------------------------------------------------------------------------- def draw_enemy_stats(enemy, x, y, hidden) # Change color self.contents.font.color = system_color # Draw text self.contents.draw_text(x, y, 32, 32, "HP") self.contents.draw_text(x + 150, y, 32, 32, "MP") self.contents.draw_text(x, y + 26, 32, 32, "SRG") self.contents.draw_text(x + 150, y + 26, 32, 32, "KUAT") self.contents.draw_text(x, y + 52, 60, 32, "THN") self.contents.draw_text(x + 150, y + 78, 32, 32, "PTR") self.contents.draw_text(x, y + 104, 32, 32, "CPT") self.contents.draw_text(x + 150, y + 104, 32, 32, "HDR") self.contents.draw_text(x, y - 120, 125, 32, "BARANG :") #self.contents.draw_text(x, y - 65, 100, 32, "Drop Rate :") # Change color self.contents.font.color = normal_color # Draw stats, draw ?'s if enemy is hidden if hidden self.contents.draw_text(x + 40, y, 84, 32, '???', 2) self.contents.draw_text(x + 190, y, 84, 32, '???', 2) self.contents.draw_text(x + 40, y + 26, 84, 32, '???', 2) self.contents.draw_text(x + 190, y + 26, 84, 32, '???', 2) self.contents.draw_text(x + 40, y + 52, 84, 32, '???', 2) self.contents.draw_text(x + 190, y + 52, 84, 32, '???', 2) self.contents.draw_text(x + 40, y + 78, 84, 32, '???', 2) self.contents.draw_text(x + 190, y + 78, 84, 32, '???', 2) else self.contents.draw_text(x + 40, y, 84, 32, enemy.maxhp.to_s, 2) self.contents.draw_text(x + 190, y, 84, 32, enemy.maxmp.to_s, 2) self.contents.draw_text(x + 40, y + 26, 84, 32, enemy.atk.to_s, 2) self.contents.draw_text(x + 190, y + 26, 84, 32, enemy.def.to_s, 2) self.contents.draw_text(x + 40, y + 52, 84, 32, enemy.hit.to_s, 2) self.contents.draw_text(x + 190, y + 52, 84, 32, enemy.spi.to_s, 2) self.contents.draw_text(x + 40, y + 78, 84, 32, enemy.agi.to_s, 2) self.contents.draw_text(x + 190, y + 78, 84, 32, enemy.eva.to_s, 2) end # If enemy has an item, draw its name and icon if enemy.drop_item1.kind == 1 draw_item_name($data_items[enemy.drop_item1.item_id], x, y - 85) end # If enemy has a weapon, draw its name and icon if enemy.drop_item1.kind == 2 draw_item_name($data_weapons[enemy.drop_item1.weapon_id], x, y - 85) #self.contents.draw_text(x + 95, y - 75, 50, 32, enemy.drop_item1.denominator.to_s + "%", 2) end # If enemy has a piece armor, draw its name and icon if enemy.drop_item1.kind == 3 draw_item_name($data_armors[enemy.drop_item1.armor_id], x, y - 85) end # If enemy has an item, draw its name and icon if enemy.drop_item2.kind == 1 draw_item_name($data_items[enemy.drop_item2.item_id], x, y - 50) end # If enemy has a weapon, draw its name and icon if enemy.drop_item2.kind == 2 draw_item_name($data_weapons[enemy.drop_item2.weapon_id], x, y - 50) end # If enemy has a piece armor, draw its name and icon if enemy.drop_item2.kind == 3 draw_item_name($data_armors[enemy.drop_item2.armor_id], x, y - 50) end end end
#============================================================================== # Section III: Dependancy Classes #==============================================================================
#============================================================================== # ** Game_Troop #==============================================================================
class Game_Troop #-------------------------------------------------------------------------- # * enemy single out algorithym # Filters out a single enemy of the specified ID #-------------------------------------------------------------------------- def single_out_enemy(id) # Set variable to false. # Later this will be set to true when the first enemy ID is found has_been_singled = false # Sort out array yo make it easlier to search @enemies.sort! {|a, z| a.id <=> z.id} # Reverse the sorted array if first index is greater than ID to be searched if @enemies[0].id > id @enemies.reverse! end # Scroll through all the enemies in the array and check the following for each in @enemies # Do the next check if the current enemy isn't hidden or dead unless each.hidden or each.dead? # Find one enemy of the specified ID, and get rid of the rest if each.enemy.id != id or (each.enemy.id == id and has_been_singled) each.escape else has_been_singled = true end end end end #-------------------------------------------------------------------------- # * Adds defeated enemies to the Album #-------------------------------------------------------------------------- def process_album_enemies for each in dead_members # If the bestairy doesn't already have this monster, then add it if !$game_album.killed.include?(each.enemy) $game_album.add_enemy_killed(each.enemy) end end end end
#============================================================================== # ** Scene_Battle #==============================================================================
class Scene_Battle #-------------------------------------------------------------------------- # * Escape Processing #-------------------------------------------------------------------------- def process_escape @info_viewport.visible = false @message_window.visible = true text = sprintf(Vocab::EscapeStart, $game_party.name) $game_message.texts.push(text) if $game_troop.preemptive success = true else success = (rand(100) < @escape_ratio) end Sound.play_escape if success wait_for_message # Call method that collects monsters and sends them to the album $game_troop.process_album_enemies battle_end(1) else @escape_ratio += 10 $game_message.texts.push('\.' + Vocab::EscapeFailure) wait_for_message $game_party.clear_actions start_main end end #-------------------------------------------------------------------------- # * Victory Processing #-------------------------------------------------------------------------- def process_victory @info_viewport.visible = false @message_window.visible = true RPG::BGM.stop $game_system.battle_end_me.play unless $BTEST $game_temp.map_bgm.play $game_temp.map_bgs.play end # Call method that collects monsters and sends them to the album $game_troop.process_album_enemies if $game_album.battle_test $game_album.battle_test = false else display_exp_and_gold display_drop_items display_level_up end battle_end(0) end end
#============================================================================== # ** Scene_Menu #==============================================================================
class Scene_Menu #-------------------------------------------------------------------------- # * Create Command Window #-------------------------------------------------------------------------- def create_command_window s1 = Vocab::item s2 = Vocab::skill s3 = Vocab::equip s4 = Vocab::status s5 = Vocab::album s6 = Vocab::save s7 = Vocab::game_end @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7]) @command_window.index = @menu_index if $game_party.members.size == 0 # If number of party members is 0 @command_window.draw_item(0, false) # Disable item @command_window.draw_item(1, false) # Disable skill @command_window.draw_item(2, false) # Disable equipment @command_window.draw_item(3, false) # Disable status end if $game_system.save_disabled # If save is forbidden @command_window.draw_item(5, false) # Disable save end end #-------------------------------------------------------------------------- # * Update Command Selection #-------------------------------------------------------------------------- def update_command_selection if Input.trigger?(Input::B) Sound.play_cancel $scene = Scene_Map.new elsif Input.trigger?(Input::C) if $game_party.members.size == 0 and @command_window.index < 5 Sound.play_buzzer return elsif $game_system.save_disabled and @command_window.index == 5 Sound.play_buzzer return end Sound.play_decision case @command_window.index when 0 # Item $scene = Scene_Item.new when 1,2,3 # Skill, equipment, status start_actor_selection when 4 # Album $scene = Scene_Album.new when 5 # Save $scene = Scene_File.new(true, false, false) when 6 # End Game $scene = Scene_End.new end end end end
#============================================================================== # Section IV: Data_Management #------------------------------------------------------------------------------ # This bundle of code is just the Scene Title, Save and Load classes with some # modified methods to handle, store, and retrieve the Bestairy data #==============================================================================
#============================================================================== # ** Scene_Title #==============================================================================
class Scene_Title #-------------------------------------------------------------------------- # * Create Game Objects #-------------------------------------------------------------------------- def create_game_objects $game_temp = Game_Temp.new $game_message = Game_Message.new $game_system = Game_System.new $game_switches = Game_Switches.new $game_variables = Game_Variables.new $game_self_switches = Game_SelfSwitches.new $game_actors = Game_Actors.new $game_party = Game_Party.new $game_troop = Game_Troop.new $game_map = Game_Map.new $game_player = Game_Player.new # Added code. Creates a new Album for new game $game_album = Game_Album.new end end
#============================================================================== # ** Scene_Save #==============================================================================
class Scene_File #-------------------------------------------------------------------------- # * Write Save Data # file : write file object (opened) #-------------------------------------------------------------------------- def write_save_data(file) characters = [] for actor in $game_party.members characters.push([actor.character_name, actor.character_index]) end $game_system.save_count += 1 $game_system.version_id = $data_system.version_id @last_bgm = RPG::BGM::last @last_bgs = RPG::BGS::last Marshal.dump(characters, file) Marshal.dump(Graphics.frame_count, file) Marshal.dump(@last_bgm, file) Marshal.dump(@last_bgs, file) Marshal.dump($game_system, file) Marshal.dump($game_message, file) Marshal.dump($game_switches, file) Marshal.dump($game_variables, file) Marshal.dump($game_self_switches, file) Marshal.dump($game_actors, file) Marshal.dump($game_party, file) Marshal.dump($game_troop, file) Marshal.dump($game_map, file) Marshal.dump($game_player, file) # Added code. Stores the Album data on save command Marshal.dump($game_album, file) end #-------------------------------------------------------------------------- # * Read Save Data # file : file object for reading (opened) #-------------------------------------------------------------------------- def read_save_data(file) characters = Marshal.load(file) Graphics.frame_count = Marshal.load(file) @last_bgm = Marshal.load(file) @last_bgs = Marshal.load(file) $game_system = Marshal.load(file) $game_message = Marshal.load(file) $game_switches = Marshal.load(file) $game_variables = Marshal.load(file) $game_self_switches = Marshal.load(file) $game_actors = Marshal.load(file) $game_party = Marshal.load(file) $game_troop = Marshal.load(file) $game_map = Marshal.load(file) $game_player = Marshal.load(file) # Added code. Retrieves the Album data on load command $game_album = Marshal.load(file) if $game_system.version_id != $data_system.version_id $game_map.setup($game_map.map_id) $game_player.center($game_player.x, $game_player.y) end end end
#============================================================================== # ** Section V: Modules #==============================================================================
#============================================================================== # ** Module Colors #------------------------------------------------------------------------------ # Contains various defined colors for use in projects. #==============================================================================
module Colors # CONSTANTS
GREEN = Color.new(50, 200, 50, 255) RED = Color.new(200, 50, 50, 255) YELLOW = Color.new(200, 200, 0, 255) ORANGE = Color.new(220, 150, 0, 255) INDIGO = Color.new(50, 50, 200, 110) VIOLET = Color.new(120, 50, 180, 110) BLACK = Color.new(0, 0, 0, 255) end
#============================================================================== # ** Vocab #------------------------------------------------------------------------------ # This module defines terms and messages. It defines some data as constant # variables. Terms in the database are obtained from $data_system. #==============================================================================
module Vocab # Monster Album def self.album return 'Album' end end
| |
|