Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 20th, 2012  |  syntax: None  |  size: 171.90 KB  |  views: 107  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #==============================================================================
  2. # ** TDS Lufia Rise of the Sinistrals CMS
  3. # Version: 1.2
  4. #------------------------------------------------------------------------------
  5. # This script allows for the creation of objects trough a menu using other
  6. # objects and alchemic methods as the base for their creation.
  7. #==============================================================================
  8. # WARNING:
  9. #
  10. # Do not release, distribute or change my work without my expressed written
  11. # consent, doing so violates the terms of use of this work.
  12. #
  13. # * Not Knowing English or understanding these terms will not excuse you in any
  14. #   way from the consequenses.
  15. #
  16. # * This applies to all of my work whether they have thiss notice or not.
  17. #
  18. # Contact Email: Sephirothtds@hotmail.com
  19. #==============================================================================
  20. # This is a system replication in no way meant to be used or distributed in any
  21. # game or for any profit monetary or other.
  22. #==============================================================================
  23.  
  24. #==============================================================================
  25. # ** Window_Base
  26. #------------------------------------------------------------------------------
  27. #  This is a superclass of all windows in the game.
  28. #==============================================================================
  29.  
  30. class Window_Base < Window
  31.   #--------------------------------------------------------------------------
  32.   # * Constants
  33.   #--------------------------------------------------------------------------
  34.   WLH = 24                  # Window Line Height
  35.   #--------------------------------------------------------------------------
  36.   # * Draw HP
  37.   #     actor  : actor
  38.   #     x      : draw spot x-coordinate
  39.   #     y      : draw spot y-coordinate
  40.   #     width  : Width
  41.   #     no_bar : drawing bar flag  
  42.   #--------------------------------------------------------------------------
  43.   def draw_actor_hp(actor, x, y, width = 120, no_bar = false)
  44.     if no_bar == false
  45.       draw_actor_hp_gauge(actor, x, y, width)
  46.     end    
  47.     self.contents.font.color = system_color
  48.     self.contents.draw_text(x, y, 30, WLH, Vocab::hp_a)
  49.     self.contents.font.color = hp_color(actor)
  50.     last_font_size = self.contents.font.size
  51.     xr = x + width
  52.     if width < 120
  53.       self.contents.draw_text(xr - 44, y, 44, WLH, actor.hp, 2)
  54.     else
  55.       self.contents.draw_text(xr - 99, y, 44, WLH, actor.hp, 2)
  56.       self.contents.font.color = normal_color
  57.       self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
  58.       self.contents.draw_text(xr - 44, y, 44, WLH, actor.maxhp, 2)
  59.     end
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # * Draw MP
  63.   #     actor  : actor
  64.   #     x      : draw spot x-coordinate
  65.   #     y      : draw spot y-coordinate
  66.   #     width  : Width
  67.   #     no_bar : drawing bar flag
  68.   #--------------------------------------------------------------------------
  69.   def draw_actor_mp(actor, x, y, width = 120, no_bar = false)
  70.     if no_bar == false    
  71.       draw_actor_mp_gauge(actor, x, y, width)
  72.     end    
  73.     self.contents.font.color = power_up_color
  74.     self.contents.draw_text(x, y, 30, WLH, Vocab::mp_a)
  75.     self.contents.font.color = mp_color(actor)
  76.     last_font_size = self.contents.font.size
  77.     xr = x + width
  78.     if width < 120
  79.       self.contents.draw_text(xr - 44, y, 44, WLH, actor.mp, 2)
  80.     else
  81.       self.contents.draw_text(xr - 99, y, 44, WLH, actor.mp, 2)
  82.       self.contents.font.color = normal_color
  83.       self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
  84.       self.contents.draw_text(xr - 44, y, 44, WLH, actor.maxmp, 2)
  85.     end
  86.   end
  87. end
  88.  
  89.  
  90. #==============================================================================
  91. # ** Window_Selectable
  92. #------------------------------------------------------------------------------
  93. #  This window contains cursor movement and scroll functions.
  94. #==============================================================================
  95.  
  96. class Window_Selectable < Window_Base
  97.   #--------------------------------------------------------------------------
  98.   # * Public Instance Variables
  99.   #--------------------------------------------------------------------------
  100.   attr_reader   :item_max                 # item count
  101.   attr_reader   :column_max               # digit count
  102.   attr_reader   :index                    # cursor position
  103.   attr_reader   :help_window              # help window
  104.   # Custom cursor values
  105.   attr_accessor   :use_custom_cursor      # Custom cursor flag
  106.   attr_accessor   :cursor_visible         # Cursor visibility flag
  107.   attr_accessor   :cursor_offsets         # Cursor offsets values
  108.   attr_accessor   :wait_cursor_offsets    # Cursor offsets values    
  109.   #--------------------------------------------------------------------------
  110.   # * Object Initialization
  111.   #     x           : window X coordinate
  112.   #     y           : window Y coordinate
  113.   #     width       : window width
  114.   #     height      :   window height
  115.   #     spacing     : width of empty space when items are arranged horizontally
  116.   #--------------------------------------------------------------------------
  117.   def initialize(x, y, width, height, spacing = 32)
  118.     @item_max = 1
  119.     @column_max = 1
  120.     @index = -1
  121.     @spacing = spacing    
  122.     # Cursor variables
  123.     @use_custom_cursor = false #true
  124.     @cursor_offsets = [0, 0]
  125.     @wait_cursor_offsets = [0, 0]    
  126.     @cursor_visible = nil    
  127.     super(x, y, width, height)
  128.      create_custom_cursor          
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # * Dispose
  132.   #--------------------------------------------------------------------------
  133.   def dispose
  134.     self.contents.dispose
  135.     @sprite.bitmap.dispose
  136.     @sprite.dispose    
  137.     super
  138.   end  
  139.   #--------------------------------------------------------------------------
  140.   # * Create Custom Cursor
  141.   #--------------------------------------------------------------------------
  142.   def create_custom_cursor
  143.     @sprite = Sprite.new
  144.     @sprite.bitmap = Cache.system("Cursor")
  145.     @sprite.src_rect.width = @sprite.bitmap.width / 6            
  146.     @sprite.x = self.x + 16
  147.     @sprite.y = self.y + 16 + 4
  148.     @sprite.visible = @use_custom_cursor
  149.     @sprite.z = 9999      
  150.     update_cursor_graphic                
  151.   end  
  152.   #--------------------------------------------------------------------------
  153.   # * Frame Update
  154.   #--------------------------------------------------------------------------
  155.   def update
  156.     super
  157.     if cursor_movable?
  158.       last_index = @index
  159.       if Input.repeat?(Input::DOWN)
  160.         cursor_down(Input.trigger?(Input::DOWN))
  161.       end
  162.       if Input.repeat?(Input::UP)
  163.         cursor_up(Input.trigger?(Input::UP))
  164.       end
  165.       if Input.repeat?(Input::RIGHT)
  166.         cursor_right(Input.trigger?(Input::RIGHT))
  167.       end
  168.       if Input.repeat?(Input::LEFT)
  169.         cursor_left(Input.trigger?(Input::LEFT))
  170.       end
  171.       if Input.repeat?(Input::R)
  172.         cursor_pagedown
  173.       end
  174.       if Input.repeat?(Input::L)
  175.         cursor_pageup
  176.       end
  177.       if @index != last_index
  178.         Sound.play_cursor
  179.       end
  180.     end
  181.     update_cursor    
  182.     call_update_help        
  183.     if @use_custom_cursor == true    
  184.       update_cursor_graphic  
  185.     end    
  186.   end
  187.  
  188.   #--------------------------------------------------------------------------
  189.   # * Change cursor visibility
  190.   #    value : true or false visibility
  191.   #--------------------------------------------------------------------------
  192.   def change_cursor_visibility(value)
  193.      @sprite.visible = value
  194.   end  
  195.   #--------------------------------------------------------------------------
  196.   # * Update Cursor Graphic
  197.   #--------------------------------------------------------------------------
  198.   def update_cursor_graphic    
  199.     @sprite.visible = @use_custom_cursor if @cursor_visible == nil
  200.     @sprite.visible = @cursor_visible if @cursor_visible != nil
  201.    
  202.     if @use_custom_cursor == true
  203.       if self.visible == false or @index < 0
  204.         @sprite.opacity = 0
  205.        elsif self.visible == true or @index >= 0
  206.         @sprite.opacity = 255
  207.       end
  208.        
  209.      if self.active
  210.        @sprite.bitmap = Cache.system("Cursor")
  211.        @sprite.src_rect.width = @sprite.bitmap.width / 6              
  212.      else
  213.        @sprite.bitmap = Cache.system("Wait Cursor")
  214.        @sprite.src_rect.width = @sprite.bitmap.width / 7      
  215.      end
  216.      
  217.      if self.active
  218.       dx = self.x + self.cursor_rect.x + 16 + @cursor_offsets[0]
  219.       dy = self.y + self.cursor_rect.y + self.cursor_rect.height / 2 + 3 + @cursor_offsets[1]
  220.     else
  221.       dx = self.x + self.cursor_rect.x + 16 + @wait_cursor_offsets[0]
  222.       dy = self.y + self.cursor_rect.y + self.cursor_rect.height / 2 + 3 + @wait_cursor_offsets[1]
  223.     end    
  224.       @sprite.x = dx
  225.       @sprite.y = dy
  226.       update_cursor_animation      
  227.      end
  228.    end      
  229.   #--------------------------------------------------------------------------
  230.   # * Update Cursor Animation
  231.   #--------------------------------------------------------------------------  
  232.   def update_cursor_animation
  233.     @duration = -1 if @duration == nil
  234.      if self.active    
  235.        @duration += 1
  236.        @duration %= 8    
  237.       if @duration == 8 -1
  238.         @sprite.src_rect.x += 24
  239.         @sprite.src_rect.x %= 6 * 24
  240.       end
  241.     else
  242.        @duration += 1
  243.        @duration %= 8
  244.       if @duration == 8 - 1
  245.         @sprite.src_rect.x -= 24
  246.         @sprite.src_rect.x %= 7 * 24
  247.       end            
  248.     end        
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # * Dispose
  252.   #--------------------------------------------------------------------------
  253.   def dispose
  254.     self.contents.dispose
  255.     @sprite.dispose if @sprite != nil
  256.     super
  257.   end    
  258.   #--------------------------------------------------------------------------
  259.   # * Update cursor
  260.   #--------------------------------------------------------------------------
  261.   def update_cursor
  262.     if @index < 0                   # If the cursor position is less than 0
  263.       self.cursor_rect.empty        # Empty cursor
  264.     else                            # If the cursor position is 0 or more
  265.       row = @index / @column_max    # Get current row
  266.       if row < top_row              # If before the currently displayed
  267.         self.top_row = row          # Scroll up
  268.       end
  269.       if row > bottom_row           # If after the currently displayed
  270.         self.bottom_row = row       # Scroll down
  271.       end
  272.       rect = item_rect(@index)      # Get rectangle of selected item
  273.       rect.y -= self.oy             # Match rectangle to scroll position
  274.       self.cursor_rect = rect       # Refresh cursor rectangle
  275.     end
  276.   end
  277.   #--------------------------------------------------------------------------
  278.   # * Call help window update method
  279.   #--------------------------------------------------------------------------
  280.   def call_update_help
  281.     if self.active and @help_window != nil
  282.        update_help
  283.     end
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # * Update help window (contents are defined by the subclasses)
  287.   #--------------------------------------------------------------------------
  288.   def update_help
  289.   end
  290. end
  291.  
  292.  
  293. #==============================================================================
  294. # ** Window_Command
  295. #------------------------------------------------------------------------------
  296. #  This window deals with general command choices.
  297. #==============================================================================
  298.  
  299. class TDS_Window_Command < Window_Selectable
  300.   #--------------------------------------------------------------------------
  301.   # * Public Instance Variables
  302.   #--------------------------------------------------------------------------
  303.   attr_reader   :commands                 # command
  304.   #--------------------------------------------------------------------------
  305.   # * Object Initialization
  306.   #     width      : window width
  307.   #     commands   : command string array
  308.   #     column_max : digit count (if 2 or more, horizontal selection)
  309.   #     row_max    : row count (0: match command count)
  310.   #     spacing    : blank space when items are arrange horizontally
  311.   #--------------------------------------------------------------------------
  312.   def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
  313.     if row_max == 0
  314.       row_max = (commands.size + column_max - 1) / column_max
  315.     end  
  316.     super(0, 0, width, row_max * WLH + 32, spacing)
  317.     self.windowskin = Cache.system("TDS-Lufia Window")        
  318.     self.back_opacity = 255    
  319.     @use_custom_cursor = true
  320.     @cursor_offsets = [-4, 0]    
  321.     @commands = commands
  322.     @item_max = commands.size
  323.     @column_max = column_max
  324.     refresh
  325.     self.index = 0
  326.   end
  327.   #--------------------------------------------------------------------------
  328.   # * Refresh
  329.   #--------------------------------------------------------------------------
  330.   def refresh
  331.     self.contents.clear
  332.     for i in 0...@item_max
  333.       draw_item(i)
  334.     end
  335.   end  
  336.   #--------------------------------------------------------------------------
  337.   # * Return_Command_Name
  338.   #--------------------------------------------------------------------------
  339.   def return_command_name(index)
  340.     return @commands[index]
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # * Draw Item
  344.   #     index   : item number
  345.   #     enabled : enabled flag. When false, draw semi-transparently.
  346.   #--------------------------------------------------------------------------
  347.   def draw_item(index, enabled = true)
  348.     rect = item_rect(index)
  349.     rect.x += 26
  350.     rect.width -= 8
  351.     self.contents.clear_rect(rect)
  352.     self.contents.font.color = normal_color
  353.     self.contents.font.color.alpha = enabled ? 255 : 128
  354.     self.contents.draw_text(rect, @commands[index])
  355.   end
  356. end
  357.  
  358.  
  359. #============== ================================================================
  360. # ** TDS Lufia Menu
  361. #------------------------------------------------------------------------------
  362. #  This class performs the menu screen processing.
  363. #==============================================================================
  364.  
  365. class Scene_Menu < Scene_Base
  366.   #--------------------------------------------------------------------------
  367.   # * Object Initialization
  368.   #     menu_index : command cursor's initial position
  369.   #--------------------------------------------------------------------------
  370.   def initialize(menu_index = 0)
  371.     @menu_index = menu_index    
  372.     # Flag variables
  373.     @viewing_spell_information_window = false
  374.     @viewing_item_information_window = false    
  375.     @viewing_scenario_information_window = false        
  376.   end
  377.   #--------------------------------------------------------------------------
  378.   # * Start processing
  379.   #--------------------------------------------------------------------------
  380.   def start
  381.     super
  382.     # Create Menu Back Sprite
  383.     @menuback_sprite = Sprite.new
  384.     @menuback_sprite.bitmap = Cache.system("Lufia Menu Back")    
  385.     # Create Scene Header
  386.     @scene_header = Window_Base.new(20, 198, 140, 56)
  387.     @scene_header.windowskin = Cache.system("TDS-Lufia Window")      
  388.     @scene_header.back_opacity = 255
  389.     @scene_header.contents = Bitmap.new(140-32,56-32)
  390.     @scene_header.contents.font.color = @scene_header.text_color(0)    
  391.     @scene_header.contents.draw_text(0,0,140-32, 24, "ITEM",1)                    
  392.     @scene_header.visible = false
  393.     # Create Dummy Help Window
  394.     @dummy_help_window = Window_Base.new(20, 305, 505, 101)        
  395.     @dummy_help_window.windowskin = Cache.system("TDS-Lufia Window")    
  396.     @dummy_help_window.contents = Bitmap.new(505-32,56-32)
  397.     @dummy_help_window.contents.font.color =  @dummy_help_window.text_color(0)    
  398.     @dummy_help_window.contents.draw_text(0, 0 , 505-32, 24, "HELP",1)                            
  399.     @dummy_help_window.back_opacity = 255
  400.     @dummy_help_window.visible = false
  401.     # Create Help Window Header
  402.     @scene_help_header = Window_Base.new(20, 254, 505, 56)
  403.     @scene_help_header.windowskin = Cache.system("TDS-Lufia Window")      
  404.     @scene_help_header.back_opacity = 255
  405.     @scene_help_header.contents = Bitmap.new(505-32,56-32)
  406.     @scene_help_header.contents.font.color = @scene_help_header.text_color(0)    
  407.     @scene_help_header.contents.draw_text(0, 0 , 505-32, 24, "Item name",1)                    
  408.     @scene_help_header.visible = false    
  409.     # Create Scenario header
  410.     @scenario_header = Window_Base.new(20, 198, 300, 56)
  411.     @scenario_header.windowskin = Cache.system("TDS-Lufia Window")      
  412.     @scenario_header.back_opacity = 255
  413.     @scenario_header.contents = Bitmap.new(300-32,56-32)
  414.     @scenario_header.contents.font.color = @scene_header.text_color(0)    
  415.     @scenario_header.contents.draw_text(0,0,300-32, 24, "SCENARIO ITEMS",1)                    
  416.     @scenario_header.visible = false        
  417.     # Create command windows
  418.     create_command_window
  419.     # Create Gold Window
  420.     @gold_time_window = Window_Gold_Time.new(265, 326)
  421.     # Create Main Status Window
  422.     @status_window = Window_MenuStatus.new(0, 0)    
  423.     @status_window.active = false
  424.     # Activate main status window normal mode
  425.     @status_window.change_mode(0, true)    
  426.     # Create Item Window
  427.     @item_window = TDS_Lufia_Window_Item.new(20, 254, 505, 152)    
  428.     @item_window.index = 0
  429.     @item_window.active = false
  430.     @item_window.visible = false        
  431.     # Create Skill Window
  432.     @skill_window = TDS_Lufia_Window_Skill.new(20, 254, 505, 152, $game_party.members[0])
  433.     @skill_window.active = false
  434.     @skill_window.visible = false    
  435.     # Flag variables
  436.     @viewing_item_information_window = false        
  437.     @viewing_spell_information_window = false
  438.     @viewing_scenario_information_window = false
  439.     # Update flag values
  440.     @update_item_processing = false
  441.     @update_spell_processing = false
  442.     @update_scenario_mode_processing = false    
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   # * Create Command Window
  446.   #--------------------------------------------------------------------------
  447.   def create_command_window
  448.     # Create Command Window
  449.     @command_window = TDS_Window_Command.new(390, ["ITEM", "STATUS", "SPELL",
  450.     "EQUIP", "SCENARIO", "SAVE", "END"], 2)    
  451.     # Set command window x position
  452.     @command_window.x = 135
  453.     # Set command window y position
  454.     @command_window.y = 198
  455.     # Set command window index
  456.     @command_window.index = @menu_index
  457.     # If game party size is 0
  458.     if $game_party.members.size == 0          # If number of party members is 0
  459.       @command_window.draw_item(0, false)     # Disable item
  460.       @command_window.draw_item(1, false)     # Disable skill
  461.       @command_window.draw_item(2, false)     # Disable equipment
  462.       @command_window.draw_item(3, false)     # Disable status
  463.     end
  464.     # If saving disable
  465.     if $game_system.save_disabled             # If save is forbidden
  466.       @command_window.draw_item(5, false)     # Disable save
  467.     end
  468.     # Create Item Command Window
  469.     @item_command_window = TDS_Window_Command.new(365, ["USE", "ALL", "DROP"],3)
  470.     # Set item command window x
  471.     @item_command_window.x = 160
  472.     # Set item command window y
  473.     @item_command_window.y = 198
  474.     # Set item command visibility
  475.     @item_command_window.visible = false
  476.     # Set item command window active to false
  477.     @item_command_window.active = false    
  478.     # Create Spell Command Window
  479.     @spell_command_window = TDS_Window_Command.new(365, ["USE", "ALL"],2)
  480.     # Set spell command window x
  481.     @spell_command_window.x = 160
  482.     # Set spell command window y
  483.     @spell_command_window.y = 198
  484.     # Set spell command window visible to false
  485.     @spell_command_window.visible = false
  486.     # Set Spell command window active to false
  487.     @spell_command_window.active = false        
  488.   end  
  489.   #--------------------------------------------------------------------------
  490.   # * Frame Update
  491.   #--------------------------------------------------------------------------
  492.   def update
  493.     super
  494.     # Update command windows
  495.     @command_window.update
  496.     @spell_command_window.update
  497.     @item_command_window.update                    
  498.     # Update windows
  499.     @gold_time_window.update
  500.     @status_window.update
  501.     @item_window.update
  502.     @skill_window.update
  503.     # If command window active
  504.     if @command_window.active
  505.       update_command_selection      
  506.     end    
  507.  
  508.     # If status window is active and it's on normal mode
  509.     if @status_window.active and @status_window.normal_mode
  510.       # Update main menu actor selection
  511.       update_main_actor_selection  
  512.     end
  513.     # If item processing flag is true update item methods
  514.     if @update_item_processing
  515.       # Update Item Choosing if Item window is active or viewing item information
  516.       if @item_window.active == true or @viewing_item_information_window
  517.         update_item_choosing
  518.       end      
  519.       # Update Item Command Arrange Choosing if Item Command window is active
  520.       if @item_command_window.active
  521.         update_item_command_choosing      
  522.       end
  523.       # If status window is active and it's on item mode
  524.       if @status_window.active and @status_window.item_mode
  525.         update_item_target_choosing          
  526.       end
  527.     end
  528.     # If skill prcoessing flag is true update skill methods
  529.     if @update_spell_processing      
  530.       # Update skill arrange choosing if spell command window is active
  531.       if @spell_command_window.active
  532.         update_skill_command_choosing  
  533.       end            
  534.       # Update skill choosing if skill window is active or viewing skill information
  535.       if @skill_window.active or @viewing_spell_information_window
  536.         update_skill_choosing        
  537.       end
  538.       # If status window is active and it's on skill mode
  539.       if @status_window.active and @status_window.skill_mode
  540.         update_skill_target_choosing
  541.       end
  542.     end
  543.    
  544.    # If scenario processing flag is true update Scenario methods
  545.    if @update_scenario_mode_processing
  546.      # Update sceneario item viewing pro
  547.      update_scenario_item_choosing    
  548.    end  
  549.   end
  550.   #--------------------------------------------------------------------------
  551.   # * Update Command Selection
  552.   #--------------------------------------------------------------------------
  553.   def update_command_selection
  554.     if Input.trigger?(Input::B)
  555.       Sound.play_cancel
  556.       $scene = Scene_Map.new
  557.       return
  558.     end    
  559.     # If Input trigger Confirm
  560.     if Input.trigger?(Input::C)    
  561.       case @command_window.return_command_name(@command_window.index)        
  562.       when "ITEM"
  563.         # Play desicion sound
  564.         Sound.play_decision                    
  565.         # Start item scene processing
  566.         start_item_scene  
  567.         # Update input
  568.         Input.update
  569.         return
  570.       when "STATUS"        
  571.         start_main_actor_selection        
  572.       when "SPELL"
  573.         start_main_actor_selection        
  574.       when "EQUIP"
  575.         start_main_actor_selection        
  576.       when "SCENARIO"
  577.         # Play desicion sound
  578.         Sound.play_decision  
  579.         # Start scenario scene processing
  580.         start_scenario_mode  
  581.         return
  582.       when "SAVE"
  583.         if $game_system.save_disabled          
  584.           Sound.play_buzzer
  585.           return          
  586.         end
  587.         # Play desicion sound
  588.         Sound.play_decision                    
  589.         $scene = Scene_File.new(true, false, false)        
  590.        return        
  591.       when "END"
  592.         # Play desicion sound
  593.         Sound.play_decision                    
  594.         $scene = Scene_End.new        
  595.        return        
  596.       end
  597.     end
  598.   end
  599.   #--------------------------------------------------------------------------
  600.   # * Start Main Actor Selection
  601.   #--------------------------------------------------------------------------
  602.   def start_main_actor_selection
  603.     if $game_party.members.size == 0
  604.       Sound.play_buzzer
  605.       return
  606.     end            
  607.     # Play desicion sound
  608.     Sound.play_decision                
  609.     # Deactivate command window
  610.     @command_window.active = false
  611.     # Activate status window and make cursor visible
  612.     @status_window.active = true
  613.     @status_window.index = 0    
  614.     # Input update
  615.     Input.update
  616.     return
  617.   end      
  618.   #--------------------------------------------------------------------------
  619.   # * End Main Actor Selection
  620.   #--------------------------------------------------------------------------  
  621.   def end_main_actor_selection    
  622.     # Deactivate status window and make cursor invisible
  623.     @status_window.active = false
  624.     @status_window.index = -1    
  625.     # Activate command window
  626.     @command_window.active = true
  627.     return    
  628.   end  
  629.   #--------------------------------------------------------------------------
  630.   # * Update Actor Selection
  631.   #--------------------------------------------------------------------------
  632.   def update_main_actor_selection
  633.     # If input trigger is cancel
  634.     if Input.trigger?(Input::B)
  635.       # Play cancel sound
  636.       Sound.play_cancel  
  637.       # End main actor selection
  638.       end_main_actor_selection
  639.       return
  640.     end    
  641.     # If input trigger confirm
  642.     if Input.trigger?(Input::C)            
  643.       # Play desicion sound
  644.       Sound.play_decision            
  645.       case @command_window.return_command_name(@command_window.index)        
  646.        when "STATUS"        
  647.          # Change scene to Scene Status
  648.          $scene = Scene_Status.new(@status_window.index)
  649.          return
  650.        when "SPELL"
  651.          # Start skill methods
  652.          start_skill_scene
  653.        when "EQUIP"    
  654.          # Change scene to Scene Equip
  655.          $scene = Scene_Equip.new(@status_window.index)        
  656.          return
  657.        end
  658.      end
  659.    end
  660.  
  661.  
  662. #==============================================================================
  663. # ** Item Methods
  664. #------------------------------------------------------------------------------
  665. #  These methods performs the item screen processing.
  666. #==============================================================================
  667.  
  668.   #--------------------------------------------------------------------------
  669.   # * Start Item Scene
  670.   #--------------------------------------------------------------------------
  671.   def start_item_scene    
  672.     # Start updating item processing
  673.     @update_item_processing = true    
  674.     # Set intial value for item for information
  675.     @item = nil    
  676.     # Activate main status window normal mode
  677.     @status_window.change_mode(1, true)
  678.     # Deactivate status window
  679.     @status_window.active = false        
  680.     # Set Old Index initial value    
  681.     @old_item_command_index = 0
  682.     # Change item status window visibility
  683.     @command_window.visible = false
  684.     @command_window.active = false    
  685.     # Changing visibily of gold window
  686.     @gold_time_window.visible = false
  687.     # Change scene header text color, text and visibility
  688.     @scene_header.contents.font.color = @scene_header.text_color(0)    
  689.     @scene_header.contents.clear        
  690.     @scene_header.contents.draw_text(0,0,140-32,56-32, "ITEM",1)                        
  691.     @scene_header.visible = true
  692.     # Activate the item command window
  693.     @item_command_window.visible = true
  694.     @item_command_window.index = 0          
  695.     # Determining item index and activity
  696.     if @item_window.item_max == 0
  697.       @item_window.index = -1      
  698.       @item_window.active = false    
  699.       @item_command_window.active = true      
  700.     else
  701.       @item_window.index = 0  
  702.       @item_window.active = true
  703.       @item_command_window.active = false      
  704.     end    
  705.     # Changing command window visibility
  706.     @item_window.visible = true        
  707.   end
  708.   #--------------------------------------------------------------------------
  709.   # * End Item Scene
  710.   #--------------------------------------------------------------------------
  711.   def end_item_scene      
  712.     # Set value for item for information
  713.     @item = nil
  714.     # Activate main status window normal mode
  715.     @status_window.change_mode(0, true)        
  716.     # Set Old Index value    
  717.     @old_item_command_index = 0    
  718.     # Changing item window visibility and active
  719.     @item_command_window.visible = false
  720.     @item_window.active = false
  721.     # Changing command window visibility and active
  722.     @item_window.visible = false    
  723.     @item_window.active = false        
  724.     # Change scene header visibility
  725.     @scene_header.contents.clear        
  726.     @scene_header.visible = false
  727.     # Activating command window
  728.     @command_window.visible = true
  729.     @command_window.active = true
  730.     # Changing visibily of gold window    
  731.     @gold_time_window.visible = true    
  732.     # Deactivate status window and change index
  733.     @status_window.active = false    
  734.     @status_window.index = -1    
  735.     # Change viewing item information flag to false
  736.     @viewing_item_information_window = false    
  737.     # End item processing
  738.     @update_item_processing = false
  739.     # Update Input
  740.     Input.update
  741.     return
  742.   end    
  743.   #--------------------------------------------------------------------------
  744.   # * Update Item Command Choosing
  745.   #--------------------------------------------------------------------------
  746.   def update_item_command_choosing
  747.     # If old index is not equal to item command window idex
  748.     if @old_item_command_index != @item_command_window.index
  749.       # Update window display mode
  750.       update_item_window_display_mode
  751.     end    
  752.     # If Input Trigger Cancel
  753.     if Input.trigger?(Input::B)
  754.       # Play cancel sound      
  755.       Sound.play_cancel
  756.       # End item processing
  757.       end_item_scene        
  758.       # Update Input
  759.       Input.update
  760.       return
  761.     end            
  762.     # If Input trigger Confirm
  763.     if Input.trigger?(Input::C)
  764.       # If item window item max is 0
  765.       if @item_window.item_max == 0
  766.         # Play buzzer sound
  767.         Sound.play_buzzer        
  768.         # Activate item command window
  769.         @item_command_window.active = true
  770.         # Deactivate item window
  771.         @item_window.active = false
  772.         # Update input
  773.         Input.update
  774.         return
  775.       end    
  776.       # PLay desicion sound
  777.       Sound.play_decision            
  778.       # Deactivate the command window
  779.       @item_command_window.active = false      
  780.       # Activate the item window
  781.       @item_window.active = true    
  782.       return
  783.     end    
  784.   end
  785.   #--------------------------------------------------------------------------
  786.   # * Update Item Choosing
  787.   #--------------------------------------------------------------------------
  788.   def update_item_choosing
  789.     # If Input Trigger Cancel    
  790.     if Input.trigger?(Input::B)
  791.       # Play cancel sound
  792.       Sound.play_cancel
  793.       # If viewing item information flag is true
  794.       if @viewing_item_information_window == true
  795.         # View item information
  796.         view_item_information(@item_window.item)            
  797.         return
  798.       end      
  799.       # Deactivate the item window
  800.       @item_window.active = false
  801.       # Set old index value to the item window index value
  802.       @old_item_window_index = @item_window.index      
  803.       # Activate the command window
  804.       @item_command_window.active = true            
  805.       # If item quantity is 0
  806.       if $game_party.item_number(@item) == 0    
  807.         # Refresh item window
  808.         @item_window.refresh
  809.       end
  810.       # Update Input
  811.       Input.update
  812.       return
  813.     end        
  814.     # If Input trigger Confirm not viewing item information
  815.     if Input.trigger?(Input::C) and @viewing_item_information_window == false
  816.       # Item command window index
  817.       case @item_command_window.index
  818.       when 0, 1 # Use or all items
  819.         use_item    
  820.       when 2 # Drop
  821.         drop_item
  822.       end    
  823.     end      
  824.     # If Input Trigger CTRL
  825.     if Input.trigger?(Input::CTRL)                  
  826.       # PLay desicion sound
  827.       Sound.play_decision                  
  828.       # View item information
  829.       view_item_information(@item_window.item)    
  830.       return
  831.     end    
  832.   end  
  833.   #--------------------------------------------------------------------------
  834.   # * Update Item Target Choosing
  835.   #--------------------------------------------------------------------------
  836.   def update_item_target_choosing        
  837.     # If Input Trigger Cancel
  838.     if Input.trigger?(Input::B)
  839.       # Play cancel sound      
  840.       Sound.play_cancel
  841.       # Deactivate status window
  842.       @status_window.active = false
  843.       # Change status window index making it invisible
  844.       @status_window.index = -1
  845.       # Activate the command window
  846.       @item_window.active = true            
  847.       # If item quantity is 0
  848.       if $game_party.item_number(@item) == 0    
  849.         # Refresh item window
  850.         @item_window.refresh
  851.         # Activate item command window
  852.         @item_command_window.active = true
  853.         # Deactivate item window
  854.         @item_window.active = false                  
  855.       end      
  856.       # Set value for item for information
  857.       @item = nil      
  858.       return
  859.     end
  860.     # If Input trigger Confirm
  861.     if Input.trigger?(Input::C)
  862.       if $game_party.item_can_use?(@item) == false
  863.         Sound.play_buzzer
  864.       else
  865.         determine_item_target
  866.         end    
  867.       return
  868.     end
  869.   end      
  870.   #--------------------------------------------------------------------------
  871.   # * Update Item Window Display Mode
  872.   #--------------------------------------------------------------------------
  873.   def update_item_window_display_mode      
  874.     case @item_command_window.index
  875.     when 0
  876.       # Change item window mode to true and to display only use items
  877.       @item_window.only_items_mode(true)                
  878.       # Change item window mode to false and to display all items
  879.       @item_window.all_items_mode(false)  
  880.       # Change item window mode to drop items to false      
  881.       @item_window.drop_items_mode(false)                    
  882.       # Refresh item window
  883.       @item_window.refresh  
  884.       # Change cursor index to 0
  885.       @item_window.index = 0      
  886.     when 1, 2
  887.       # Set old mode value for refresh
  888.       old_mode_value = @item_window.all_mode  
  889.       # Change item window mode to false and to display only use items
  890.       @item_window.only_items_mode(false)                
  891.       # Change item window mode to true and to display all items
  892.       @item_window.all_items_mode(true)        
  893.       # Set item window index to 0 if the items in the window are more
  894.       if old_mode_value == false
  895.         # Refresh item window
  896.         @item_window.refresh
  897.         # Change cursor index to 0
  898.         @item_window.index = 0        
  899.       end      
  900.     end    
  901.     # Set old command index to be the same as the
  902.     @old_item_command_index = @item_command_window.index    
  903.   end    
  904.   #--------------------------------------------------------------------------
  905.   # * Use Item
  906.   #--------------------------------------------------------------------------
  907.   def use_item
  908.     # Set item variable information
  909.     @item = @item_window.item                    
  910.     return Sound.play_buzzer if $game_party.item_can_use?(@item) == false      
  911.     # PLay desicion sound
  912.     Sound.play_decision    
  913.     # Deactivate the item window
  914.     @item_window.active = false            
  915.     # Activate status window
  916.     @status_window.active = true
  917.     # Change status window index making it visible depending on the item scope
  918.     if @item.scope == 8 and $game_party.members.size > 1
  919.       @status_window.index = 100        
  920.      else        
  921.       @status_window.index = 0        
  922.      end                
  923.      # Update input
  924.      Input.update
  925.     return        
  926.   end
  927.   #--------------------------------------------------------------------------
  928.   # * Drop Item
  929.   #--------------------------------------------------------------------------
  930.   def drop_item
  931.     #  If Item window Item max is 0
  932.     if @item_window.item_max == 0
  933.       # Activate item command window
  934.       @item_command_window.active = true
  935.       # Deactivate item window
  936.       @item_window.active = false
  937.     else
  938.       # Set old item index
  939.       old_index = @item_window.index
  940.       # Play equip sound
  941.       Sound.play_equip        
  942.       # Drop item
  943.       @item_window.drop_item(@item_window.item)        
  944.       # Refresh item window
  945.       @item_window.refresh
  946.       # Set old index to the item window index if it's not 0
  947.       old_index %= @item_window.item_max if @item_window.item_max != 0        
  948.       # Set item window index to old index
  949.       @item_window.index = old_index              
  950.       # If item window item max is not 0
  951.       if @item_window.item_max == 0
  952.         # Play cancel sound
  953.         Sound.play_cancel          
  954.         # Activate item command window
  955.         @item_command_window.active = true
  956.       end              
  957.       # Update input
  958.       Input.update
  959.       return
  960.     end  
  961.   end
  962.   #--------------------------------------------------------------------------
  963.   # * Confirm Item Target
  964.   #    If there is no effect (such as using a potion on an incapacitated
  965.   #    character), play a buzzer SE.
  966.   #--------------------------------------------------------------------------
  967.   def determine_item_target
  968.     # Item used is set to false
  969.     used = false
  970.     # if item is for all
  971.     if @item.for_all?
  972.       for target in $game_party.members
  973.         target.item_effect(target, @item)
  974.         used = true unless target.skipped
  975.       end
  976.     else
  977.       $game_party.last_target_index = @status_window.index
  978.       target = $game_party.members[@status_window.index]
  979.       target.item_effect(target, @item)
  980.       used = true unless target.skipped
  981.     end
  982.     # If use is true
  983.     if used
  984.       # Use item
  985.       use_item_nontarget
  986.     else
  987.       # Play buzzer sound
  988.       Sound.play_buzzer
  989.     end
  990.   end  
  991.   #--------------------------------------------------------------------------
  992.   # * Use Item (apply effects to non-ally targets)
  993.   #--------------------------------------------------------------------------
  994.   def use_item_nontarget    
  995.     # Play item use sound
  996.     Sound.play_use_item
  997.     # Consume item
  998.     $game_party.consume_item(@item)
  999.     # Draw used item
  1000.     @item_window.draw_item(@item_window.index)
  1001.     # Refresh status window
  1002.     @status_window.refresh
  1003.     # If the party is all dead
  1004.     if $game_party.all_dead?
  1005.       # Change to scene game over
  1006.       $scene = Scene_Gameover.new
  1007.     # If item common event ID is more than 0
  1008.     elsif @item.common_event_id > 0
  1009.       $game_temp.common_event_id = @item.common_event_id
  1010.       $scene = Scene_Map.new
  1011.     end
  1012.   end  
  1013.   #--------------------------------------------------------------------------
  1014.   # * View Item Information
  1015.   #    item : item from which to read data from
  1016.   #--------------------------------------------------------------------------
  1017.   def view_item_information(item)  
  1018.     # If viewing item information flag is false
  1019.     if @viewing_item_information_window == false    
  1020.       item_info = item
  1021.       # Change item window visibility and active
  1022.       @item_window.visible = false
  1023.       @item_window.active = false    
  1024.       # Change scene help header visibility, add text and change text color
  1025.       @scene_help_header.visible = true
  1026.       @scene_help_header.contents.font.color = @scene_help_header.text_color(0)    
  1027.       @scene_help_header.contents.clear
  1028.       @scene_help_header.contents.draw_text(0, 0 , 505-32, 24, item_info.name,1)                                    
  1029.       # Change dummy help window visibility, add text and color
  1030.       @dummy_help_window.visible = true    
  1031.       @dummy_help_window.contents.font.color =  @dummy_help_window.text_color(0)    
  1032.       @dummy_help_window.contents.clear
  1033.       @dummy_help_window.contents.font.size = 22
  1034.       @dummy_help_window.contents.draw_text(0, -24, 505-32, 100-32,  item_info.description.capitalize)                                            
  1035.       # Change viewing item information flag to true
  1036.       @viewing_item_information_window = true
  1037.     else
  1038.       # Change item window visibility and active
  1039.       @item_window.visible = true
  1040.       @item_window.active = true
  1041.       # Change help header window visibilty and clear text
  1042.       @scene_help_header.visible = false
  1043.       @scene_help_header.contents.clear
  1044.       # Change dummy help window visibily and clear text
  1045.       @dummy_help_window.visible = false
  1046.       @dummy_help_window.contents.clear                
  1047.       # Change viewing item information flag to false
  1048.       @viewing_item_information_window = false
  1049.      return      
  1050.     end
  1051.   end    
  1052.  
  1053.  
  1054. #==============================================================================
  1055. # ** Skill Methods
  1056. #------------------------------------------------------------------------------
  1057. #  These methods performs the Spell screen processing.
  1058. #==============================================================================
  1059.  
  1060.  
  1061.   #--------------------------------------------------------------------------
  1062.   # * Start Skill Scene
  1063.   #--------------------------------------------------------------------------
  1064.   def start_skill_scene  
  1065.     # Start updating spell processing
  1066.     @update_spell_processing = true
  1067.     # Set initial value for skill information
  1068.     @skill = nil    
  1069.     # Activate main status window spell mode
  1070.     @status_window.change_mode(2, true)        
  1071.     # Set old index initia value
  1072.     @old_spell_value_command_index = 0
  1073.     # Change command window visibility and active
  1074.     @command_window.visible = false
  1075.     @command_window.active = false    
  1076.     # Deactivate status window
  1077.     @status_window.active = false            
  1078.     # Change spell command window visibility and active
  1079.     @spell_command_window.visible = true
  1080.     @spell_command_window.active = true
  1081.     # Change spell command window to 0
  1082.     @spell_command_window.index = 0
  1083.     # Change skill window mode to show only usable skills
  1084.     @skill_window.only_use_skill_mode(true)    
  1085.     # Change scene header text, color, visibility and add text
  1086.     @scene_header.contents.font.color = @scene_header.text_color(0)    
  1087.     @scene_header.contents.clear
  1088.     @scene_header.contents.draw_text(0,0,140-32,56-32, "SPELL",1)                    
  1089.     @scene_header.visible = true
  1090.     # Changing visibily of gold window
  1091.     @gold_time_window.visible = false
  1092.     # Refresh window contents
  1093.     @skill_window.refresh($game_party.members[@status_window.index])
  1094.     # Change skill window visibility    
  1095.     @skill_window.visible = true    
  1096.     # Change skill window index to 0
  1097.     @skill_window.index = 0        
  1098.     # Input update
  1099.     Input.update
  1100.     return
  1101.   end  
  1102.   #--------------------------------------------------------------------------
  1103.   # * End Skill Scene
  1104.   #--------------------------------------------------------------------------
  1105.   def end_skill_scene  
  1106.     # End updating spell processing
  1107.     @update_spell_processing = false
  1108.     # Set value for skill information
  1109.     @skill = nil    
  1110.     # Activate main status window normal mode
  1111.     @status_window.change_mode(0, true)        
  1112.     # Set old index initia value
  1113.     @old_spell_value_command_index = 0
  1114.     # Deactivate status window and change index
  1115.     @status_window.active = false    
  1116.     @status_window.index = -1    
  1117.     # Change skill window visibility    
  1118.     @skill_window.visible = false    
  1119.     # Change spell command window visibility and active
  1120.     @spell_command_window.visible = false
  1121.     @spell_command_window.active = false
  1122.     # Change spell command window to 0
  1123.     @spell_command_window.index = 0
  1124.     # Change scene header visibility
  1125.     @scene_header.contents.clear        
  1126.     @scene_header.visible = false    
  1127.     # Change command window visibility and active
  1128.     @command_window.visible = true
  1129.     @command_window.active = true    
  1130.     # Changing visibily of gold window
  1131.     @gold_time_window.visible = true
  1132.     # Update Input
  1133.     Input.update    
  1134.     return
  1135.   end
  1136.   #--------------------------------------------------------------------------
  1137.   # * Update Skill Command Choosing
  1138.   #--------------------------------------------------------------------------  
  1139.   def update_skill_command_choosing      
  1140.     # If old index is not equal to item command window idex
  1141.     if @old_spell_value_command_index != @spell_command_window.index
  1142.       # Update window display mode
  1143.       update_skill_window_display_mode
  1144.     end    
  1145.     # If Input Trigger Cancel
  1146.     if Input.trigger?(Input::B)
  1147.       # Play cancel sound      
  1148.       Sound.play_cancel
  1149.       # End spell processing
  1150.       end_skill_scene        
  1151.       # Update Input
  1152.       Input.update
  1153.       return
  1154.     end    
  1155.     # If not viewing spell information window
  1156.     if @viewing_spell_information_window == false        
  1157.       # If Input trigger R
  1158.       if Input.trigger?(Input::R)
  1159.         # Play cursor sound
  1160.         Sound.play_cursor
  1161.         # Next actor
  1162.         next_spell_actor
  1163.       # If Input trigger L
  1164.       elsif Input.trigger?(Input::L)
  1165.         # Play cursor sound
  1166.         Sound.play_cursor
  1167.         # Previous actor
  1168.         prev_spell_actor
  1169.       end
  1170.     end    
  1171.     # If Input trigger Confirm
  1172.     if Input.trigger?(Input::C)
  1173.       # If item window item max is 0
  1174.       if @skill_window.item_max == 0    
  1175.         # Play buzzer sound
  1176.         Sound.play_buzzer        
  1177.         # Activate spell command window
  1178.         @spell_command_window.active = true
  1179.         # Deactivate skill window
  1180.         @skill_window.active = false
  1181.         # Update input
  1182.         Input.update
  1183.         return
  1184.       end    
  1185.       # Change skill window index to 0 if skill window index is more than skill window item max      
  1186.       @skill_window.index = 0 if @skill_window.index > @skill_window.item_max                              
  1187.       # PLay desicion sound
  1188.       Sound.play_decision            
  1189.       # Deactivate the command window
  1190.       @spell_command_window.active = false      
  1191.       # Activate the skill window
  1192.       @skill_window.active = true    
  1193.       # Update input
  1194.       Input.update
  1195.       return    
  1196.     end
  1197.   end  
  1198.   #--------------------------------------------------------------------------
  1199.   # * Update Skill Choosing
  1200.   #--------------------------------------------------------------------------  
  1201.   def update_skill_choosing      
  1202.     # If Input Trigger Cancel
  1203.     if Input.trigger?(Input::B)
  1204.       # Play cancel sound      
  1205.       Sound.play_cancel
  1206.  
  1207.       if @viewing_spell_information_window == true
  1208.         # View skill information
  1209.         view_skill_information(@skill_window.skill)    
  1210.         return
  1211.       end            
  1212.       # Deactivate the skill window
  1213.       @skill_window.active = false              
  1214.       # Activate spell command window
  1215.       @spell_command_window.active = true
  1216.       # Update Input
  1217.       Input.update      
  1218.       return
  1219.     end
  1220.     # If not viewing spell information window
  1221.     if @viewing_spell_information_window == false        
  1222.       # If Input trigger R
  1223.       if Input.trigger?(Input::R)
  1224.         # Play cursor sound
  1225.         Sound.play_cursor
  1226.         # Next actor
  1227.         next_spell_actor
  1228.       # If Input trigger L
  1229.       elsif Input.trigger?(Input::L)
  1230.         # Play cursor sound
  1231.         Sound.play_cursor
  1232.         # Previous actor
  1233.         prev_spell_actor
  1234.       end
  1235.     end        
  1236.     # If Input trigger Confirm and not viewing skill information
  1237.     if Input.trigger?(Input::C) and @viewing_spell_information_window == false
  1238.       # Use skill
  1239.       use_skill
  1240.       # Update Input
  1241.       Input.update
  1242.       return
  1243.     end                
  1244.      
  1245.    
  1246.     # If Input Trigger CTRL
  1247.     if Input.trigger?(Input::CTRL)                  
  1248.       # PLay desicion sound
  1249.       Sound.play_decision                  
  1250.       # View skill information
  1251.       view_skill_information(@skill_window.skill)    
  1252.       return
  1253.     end    
  1254.   end
  1255.   #--------------------------------------------------------------------------
  1256.   # * Update Skill Target Choosing
  1257.   #--------------------------------------------------------------------------  
  1258.   def update_skill_target_choosing        
  1259.     # If Input Trigger Cancel
  1260.     if Input.trigger?(Input::B)
  1261.       # Play cancel sound      
  1262.       Sound.play_cancel
  1263.       # Deactivate status window
  1264.       @status_window.active = false
  1265.       # Change status window index to the return index
  1266.       @status_window.index = @return_status_index
  1267.       # Activate the skill window
  1268.       @skill_window.active = true      
  1269.       # Set value for skill information
  1270.       @skill = nil
  1271.       # Update input
  1272.       Input.update
  1273.       return
  1274.     end
  1275.     # If input trigger confirm
  1276.     if Input.trigger?(Input::C)          
  1277.       # If actor can use skill
  1278.       if @skill_window.actor.skill_can_use?(@skill)
  1279.         # Determine if skill further usable
  1280.         determine_skill
  1281.       else
  1282.         # Play buzzer sound
  1283.         Sound.play_buzzer
  1284.       end
  1285.     end    
  1286.   end
  1287.   #--------------------------------------------------------------------------
  1288.   # * Update Skill Window Display Mode
  1289.   #--------------------------------------------------------------------------  
  1290.   def update_skill_window_display_mode  
  1291.     case @spell_command_window.index
  1292.     when 0
  1293.       # Change skill window mode to show only usable skills
  1294.       @skill_window.only_use_skill_mode(true)
  1295.       # Change display of all skills mode to false
  1296.       @skill_window.all_skill_display_mode(false)          
  1297.     when 1
  1298.       # Change display of only usable skills to false
  1299.       @skill_window.only_use_skill_mode(false)
  1300.       # Change skill window mode to show all skills
  1301.       @skill_window.all_skill_display_mode(true)  
  1302.     end
  1303.     # Change old spell index value to spell window command index    
  1304.     @old_spell_value_command_index = @spell_command_window.index      
  1305.     # Refresh command window
  1306.     @skill_window.refresh(@skill_window.actor)                            
  1307.     # Change skill window index to 0 if skill window index is more than skill window item max
  1308.     @skill_window.index = 0 if @skill_window.index > @skill_window.item_max                          
  1309.     return
  1310.   end  
  1311.   #--------------------------------------------------------------------------
  1312.   # * Next Spell Actor
  1313.   #--------------------------------------------------------------------------  
  1314.   def next_spell_actor    
  1315.     @actor_index = @status_window.index if @actor_index == nil
  1316.     @actor_index += 1
  1317.     @actor_index %= $game_party.members.size        
  1318.     @status_window.index = @actor_index        
  1319.     @skill_window.index = 0 if @skill_window.item_max != 0    
  1320.     @skill_window.refresh($game_party.members[@actor_index])                                
  1321.     return @skill_window.active = false, @spell_command_window.active = true if @skill_window.actor.dead?        
  1322.     return @skill_window.active = false, @spell_command_window.active = true if @skill_window.item_max == 0    
  1323.   end
  1324.   #--------------------------------------------------------------------------
  1325.   # * Prev Spell Actor
  1326.   #--------------------------------------------------------------------------  
  1327.   def prev_spell_actor
  1328.     @actor_index = @status_window.index if @actor_index == nil
  1329.     @actor_index += $game_party.members.size - 1
  1330.     @actor_index %= $game_party.members.size    
  1331.     @status_window.index = @actor_index    
  1332.     @skill_window.index = 0 if @skill_window.item_max != 0
  1333.     @skill_window.refresh($game_party.members[@actor_index])                            
  1334.     return @skill_window.active = false, @spell_command_window.active = true if @skill_window.actor.dead?    
  1335.     return @skill_window.active = false, @spell_command_window.active = true if @skill_window.item_max == 0
  1336.   end    
  1337.   #--------------------------------------------------------------------------
  1338.   # * Use Skill
  1339.   #--------------------------------------------------------------------------
  1340.   def use_skill
  1341.     # Set skill variable value to the currently used skill
  1342.     @skill = @skill_window.skill
  1343.     # If actor can use the skill
  1344.     if @skill_window.actor.skill_can_use?(@skill)
  1345.       # Play desicion sound
  1346.       Sound.play_decision
  1347.       # Change skill window active to false
  1348.       @skill_window.active = false      
  1349.       # Set return status index to the current status index
  1350.       @return_status_index = @status_window.index      
  1351.       # Change status window active to true
  1352.       @status_window.active = true
  1353.       # If skill scope covers all characters and there are more tnan 1 party members
  1354.       if @skill.scope == 8 and $game_party.members.size > 1
  1355.         # Make cursor select eveveryone
  1356.         @status_window.index = 100
  1357.       else
  1358.         # Change status window index to 1
  1359.         @status_window.index = 0
  1360.        end                
  1361.      else
  1362.       # Play buzzer sound
  1363.       Sound.play_buzzer
  1364.     end
  1365.   end  
  1366.   #--------------------------------------------------------------------------
  1367.   # * Confirm Target
  1368.   #    If there is no effect (such as using a potion on an incapacitated
  1369.   #    character), play a buzzer SE.
  1370.   #--------------------------------------------------------------------------
  1371.   def determine_skill
  1372.     # Set used value to false
  1373.     used = false
  1374.     # If skill is for all
  1375.     if @skill.for_all?
  1376.       for target in $game_party.members
  1377.         target.skill_effect(@skill_window.actor, @skill)
  1378.         used = true unless target.skipped
  1379.       end
  1380.     elsif @skill.for_user?
  1381.       target = $game_party.members[@status_window.index]
  1382.       target.skill_effect(target, @skill)
  1383.       used = true unless target.skipped
  1384.     else
  1385.       $game_party.last_target_index = @status_window.index
  1386.       target = $game_party.members[@status_window.index]
  1387.       target.skill_effect(target, @skill)
  1388.       used = true unless target.skipped
  1389.     end
  1390.     # If used is true
  1391.     if used
  1392.       use_skill_nontarget
  1393.     else
  1394.       # Play buzzer sound
  1395.       Sound.play_buzzer
  1396.     end
  1397.   end
  1398.   #--------------------------------------------------------------------------
  1399.   # * Use Skill (apply effects to non-ally targets)
  1400.   #--------------------------------------------------------------------------
  1401.   def use_skill_nontarget
  1402.     # Play use skill sound
  1403.     Sound.play_use_skill
  1404.     # Detract MP equal to the skill MP cost
  1405.     @skill_window.actor.mp -= @skill_window.actor.calc_mp_cost(@skill)
  1406.     # Refresh status window
  1407.     @status_window.refresh
  1408.     # Refresh skill window
  1409.     @skill_window.refresh(@skill_window.actor)
  1410.     # If the whole party is dead
  1411.     if $game_party.all_dead?
  1412.       $scene = Scene_Gameover.new
  1413.     elsif @skill.common_event_id > 0
  1414.       $game_temp.common_event_id = @skill.common_event_id
  1415.       $scene = Scene_Map.new
  1416.     end
  1417.   end    
  1418.   #--------------------------------------------------------------------------
  1419.   # * View Skill Information
  1420.   #    skill : skill from which to read data from
  1421.   #--------------------------------------------------------------------------
  1422.   def view_skill_information(skill)  
  1423.     # If viewing spell information flag is false
  1424.     if @viewing_spell_information_window == false    
  1425.       skill_info = skill
  1426.       # Change skill window visibility and active
  1427.       @skill_window.visible = false
  1428.       @skill_window.active = false    
  1429.       # Change scene help header visibility, add text and change text color
  1430.       @scene_help_header.visible = true
  1431.       @scene_help_header.contents.font.color = @scene_help_header.text_color(0)    
  1432.       @scene_help_header.contents.clear
  1433.       @scene_help_header.contents.draw_text(0, 0 , 505-32, 24, skill_info.name,1)                                    
  1434.       # Change dummy help window visibility, add text and color
  1435.       @dummy_help_window.visible = true    
  1436.       @dummy_help_window.contents.font.color =  @dummy_help_window.text_color(0)    
  1437.       @dummy_help_window.contents.clear
  1438.       @dummy_help_window.contents.font.size = 22
  1439.       @dummy_help_window.contents.draw_text(0, -24, 505-32, 100-32,  skill_info.description.capitalize)                                            
  1440.       # Change viewing spell information flag to true
  1441.       @viewing_spell_information_window = true
  1442.     else
  1443.       # Change skill window visibility and active
  1444.       @skill_window.visible = true
  1445.       @skill_window.active = true
  1446.       # Change help header window visibilty and clear text
  1447.       @scene_help_header.visible = false
  1448.       @scene_help_header.contents.clear
  1449.       # Change dummy help window visibily and clear text
  1450.       @dummy_help_window.visible = false
  1451.       @dummy_help_window.contents.clear                
  1452.       # Change viewing spell information flag to false
  1453.       @viewing_spell_information_window = false
  1454.      return      
  1455.     end
  1456.   end      
  1457.  
  1458. #==============================================================================
  1459. # ** Scenario Methods
  1460. #------------------------------------------------------------------------------
  1461. #  These methods performs the scenario screen processing.
  1462. #==============================================================================  
  1463.  
  1464.   #--------------------------------------------------------------------------
  1465.   # * Start Scenario Mode
  1466.   #--------------------------------------------------------------------------
  1467.   def start_scenario_mode
  1468.     # Start updating scenario processing
  1469.     @update_scenario_mode_processing = true
  1470.     # Change command window visibility
  1471.     @command_window.visible = false
  1472.     @command_window.active = false        
  1473.     # Deactivate status window
  1474.     @status_window.active = false            
  1475.     # Changing visibily of gold window
  1476.     @gold_time_window.visible = false
  1477.     # Change sceneraio header visibility to true
  1478.     @scenario_header.visible = true
  1479.     # Determining item index and activity
  1480.     if @item_window.item_max == 0
  1481.       @item_window.index = -1      
  1482.       @item_window.active = false    
  1483.     else
  1484.       @item_window.index = 0  
  1485.       @item_window.active = true
  1486.     end            
  1487.     # Change item window mode to display scenenario items
  1488.     @item_window.scenario_items_mode(true)    
  1489.     @item_window.only_items_mode(false)                    
  1490.     @item_window.all_items_mode(false)  
  1491.     # Changing command window visibility
  1492.     @item_window.visible = true            
  1493.     # Refresh item window
  1494.     @item_window.refresh      
  1495.     # Update Input
  1496.     Input.update    
  1497.     return
  1498.   end  
  1499.   #--------------------------------------------------------------------------
  1500.   # * End Scenario Scene
  1501.   #--------------------------------------------------------------------------
  1502.   def end_scenario_scene      
  1503.     # End scenario processing
  1504.     @update_scenario_mode_processing = false
  1505.     # Change sceneraio header visibility to false
  1506.     @scenario_header.visible = false
  1507.     # Change item window mode to display normal items
  1508.     @item_window.active = false    
  1509.     @item_window.only_items_mode(true)                    
  1510.     @item_window.all_items_mode(false)  
  1511.     @item_window.scenario_items_mode(false)        
  1512.     # Change item window index
  1513.     @item_window.index = -1          
  1514.     # Changing command window visibility
  1515.     @item_window.visible = false        
  1516.     # Refresh item window
  1517.     @item_window.refresh          
  1518.     # Change command window visibility
  1519.     @command_window.visible = true
  1520.     @command_window.active = true        
  1521.     # Deactivate status window
  1522.     @status_window.active = false            
  1523.     # Changing visibily of gold window
  1524.     @gold_time_window.visible = true
  1525.     # Update Input
  1526.     Input.update
  1527.     return
  1528.   end
  1529.   #--------------------------------------------------------------------------
  1530.   # * Update Scenario Item Choosing
  1531.   #--------------------------------------------------------------------------
  1532.   def update_scenario_item_choosing
  1533.     # If Input Trigger Cancel    
  1534.     if Input.trigger?(Input::B)
  1535.       # Play cancel sound
  1536.       Sound.play_cancel
  1537.       # If viewing sceneario information flag is true
  1538.       if @viewing_scenario_information_window == true
  1539.         # View scenario_ information
  1540.         view_scenario_item_information(@item_window.item)            
  1541.         return
  1542.       end      
  1543.       # End scenario scene processing
  1544.       end_scenario_scene
  1545.       return
  1546.     end        
  1547.    
  1548.     # If Input Trigger CTRL
  1549.     if Input.trigger?(Input::CTRL)                  
  1550.       # PLay desicion sound
  1551.       Sound.play_decision                  
  1552.       # View item information
  1553.       view_scenario_item_information(@item_window.item)    
  1554.       return
  1555.     end        
  1556.   end  
  1557.   #--------------------------------------------------------------------------
  1558.   # * View Scenario Item Information
  1559.   #    item : item from which to read data from
  1560.   #--------------------------------------------------------------------------
  1561.   def view_scenario_item_information(item)
  1562.     # If viewing scenario information flag is false
  1563.     if @viewing_scenario_information_window == false    
  1564.       item_info = item
  1565.       # Change item window visibility and active
  1566.       @item_window.visible = false
  1567.       @item_window.active = false    
  1568.       # Change scene help header visibility, add text and change text color
  1569.       @scene_help_header.visible = true
  1570.       @scene_help_header.contents.font.color = @scene_help_header.text_color(0)    
  1571.       @scene_help_header.contents.clear
  1572.       @scene_help_header.contents.draw_text(0, 0 , 505-32, 24, item_info.name,1)                                    
  1573.       # Change dummy help window visibility, add text and color
  1574.       @dummy_help_window.visible = true    
  1575.       @dummy_help_window.contents.font.color =  @dummy_help_window.text_color(0)    
  1576.       @dummy_help_window.contents.clear
  1577.       @dummy_help_window.contents.font.size = 22
  1578.       @dummy_help_window.contents.draw_text(0, -24, 505-32, 100-32,  item_info.description.capitalize)                                            
  1579.       # Change viewing item information flag to true
  1580.       @viewing_scenario_information_window = true
  1581.     else
  1582.       # Change item window visibility and active
  1583.       @item_window.visible = true
  1584.       @item_window.active = true
  1585.       # Change help header window visibilty and clear text
  1586.       @scene_help_header.visible = false
  1587.       @scene_help_header.contents.clear
  1588.       # Change dummy help window visibily and clear text
  1589.       @dummy_help_window.visible = false
  1590.       @dummy_help_window.contents.clear                
  1591.       # Change viewing scenario information flag to false
  1592.       @viewing_scenario_information_window = false
  1593.      return      
  1594.     end
  1595.   end      
  1596.   #--------------------------------------------------------------------------
  1597.   # * Termination Processing
  1598.   #--------------------------------------------------------------------------
  1599.   def terminate
  1600.     super
  1601.     # Dipose of back sprite
  1602.     @menuback_sprite.dispose
  1603.     @menuback_sprite.bitmap.dispose                
  1604.     # Dispose command windows
  1605.     @command_window.dispose    
  1606.     @item_command_window.dispose
  1607.     @spell_command_window.dispose    
  1608.     # Dispose of windows
  1609.     @gold_time_window.dispose
  1610.     @status_window.dispose        
  1611.     @item_window.dispose
  1612.     @skill_window.dispose    
  1613.     # Dispose of headers and dummy windows
  1614.     @scene_header.dispose    
  1615.     @dummy_help_window.dispose    
  1616.     @scene_help_header.dispose    
  1617.     @scenario_header.dispose    
  1618.   end
  1619. end  
  1620.  
  1621. #==============================================================================
  1622. # ** Window_MenuStatus
  1623. #------------------------------------------------------------------------------
  1624. #  This window displays party member status on the menu screen.
  1625. #==============================================================================
  1626.  
  1627. class Window_MenuStatus < Window_Selectable
  1628.   #--------------------------------------------------------------------------
  1629.   # * Public Instance Variables
  1630.   #--------------------------------------------------------------------------
  1631.   attr_reader   :normal_mode              #  Normal Mode flag
  1632.   attr_reader   :item_mode                #  Item Mode Flag
  1633.   attr_reader   :skill_mode               #  skill Mode Flag  
  1634.   #--------------------------------------------------------------------------
  1635.   # * Object Initialization
  1636.   #     x : window X coordinate
  1637.   #     y : window Y coordinate
  1638.   #--------------------------------------------------------------------------
  1639.   def initialize(x, y)
  1640.     super(x, y, 544, 416)    
  1641.     self.active = false
  1642.     self.contents.font.size = 18            
  1643.     self.opacity = 0
  1644.     self.index = -1    
  1645.     @normal_mode = true
  1646.     @item_mode = false
  1647.     @skill_mode = false    
  1648.     refresh
  1649.   end
  1650.   #--------------------------------------------------------------------------
  1651.   # * Change Mode
  1652.   #    mode   : mode to modify 0 = Normal, 1 = Item, 2 = Skill
  1653.   #    value  : true or false value
  1654.   #--------------------------------------------------------------------------
  1655.   def change_mode(mode, value)
  1656.     # Modes array
  1657.     @normal_mode = (mode == 0 ? value : false )
  1658.     @item_mode =  (mode == 1 ? value : false )
  1659.     @skill_mode = (mode == 2 ? value : false )
  1660.     return
  1661.   end
  1662.   #--------------------------------------------------------------------------
  1663.   # * Refresh
  1664.   #--------------------------------------------------------------------------
  1665.   def refresh
  1666.     self.contents.clear
  1667.     @item_max = $game_party.members.size
  1668.     @column_max = 2    
  1669.     for actor in $game_party.members
  1670.       y = 0
  1671.      if actor.index > 1      
  1672.       x = 260 #272    
  1673.       draw_actor_graphic(actor, 19 + actor.index * x - actor.index - @column_max * x, 90)      
  1674.       draw_actor_name(actor, 96 + actor.index * x - actor.index - @column_max * x, 90)                  
  1675.       draw_actor_hp(actor, 96 + actor.index * x - actor.index - @column_max * x, y + 84 + WLH * 1 , 120, true)
  1676.       draw_actor_mp(actor, 96 + actor.index * x - actor.index - @column_max * x, y + 84 + WLH * 2 , 120, true)
  1677.       draw_actor_level(actor, 174 + actor.index * x - actor.index - @column_max * x, 90)                      
  1678.     else
  1679.       x = 260 #272
  1680.       draw_actor_graphic(actor, 20 + actor.index * x, 8)  
  1681.      
  1682.       draw_actor_name(actor, 96 + actor.index * x, 10)          
  1683.       draw_actor_hp(actor, 96 + actor.index * x, y + WLH * 1 + 4, 120, true)
  1684.       draw_actor_mp(actor, 96 + actor.index * x, y + WLH * 2 + 4, 120, true)
  1685.       draw_actor_level(actor, 174  + actor.index * x, 10)                  
  1686.     end
  1687.       x = actor.index * 96 + WLH / 2
  1688.       y = 0      
  1689.     end
  1690.   end  
  1691.   #--------------------------------------------------------------------------
  1692.   # * Draw Level
  1693.   #     actor : actor
  1694.   #     x     : draw spot x-coordinate
  1695.   #     y     : draw spot y-coordinate
  1696.   #--------------------------------------------------------------------------
  1697.   def draw_actor_level(actor, x, y)
  1698.     self.contents.font.color = system_color
  1699.     self.contents.draw_text(x, y, 32, WLH, Vocab::level_a)
  1700.     self.contents.font.color = normal_color
  1701.     self.contents.draw_text(x + 18, y, 24, WLH, actor.level, 2)
  1702.   end  
  1703.   #--------------------------------------------------------------------------
  1704.   # * Draw Actor Walking Graphic
  1705.   #     actor : actor
  1706.   #     x     : draw spot x-coordinate
  1707.   #     y     : draw spot y-coordinate
  1708.   #--------------------------------------------------------------------------
  1709.   def draw_actor_graphic(actor, x, y)
  1710.     character_name = actor.character_name
  1711.     bitmap = Cache.character(character_name)
  1712.     sign = character_name[/^[\!\$]./]
  1713.     if sign != nil and sign.include?('$')
  1714.       cw = bitmap.width / 3
  1715.       ch = bitmap.height / 4
  1716.     else
  1717.       cw = bitmap.width / 12
  1718.       ch = bitmap.height / 8
  1719.     end
  1720.     n = actor.character_index
  1721.     src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)    
  1722.     dest_rect = Rect.new(x, y, 80, 80)    
  1723.     dest_rect = Rect.new(x, y, 65, 65)    
  1724.     self.contents.stretch_blt(dest_rect, bitmap, src_rect)
  1725.   end
  1726.   #--------------------------------------------------------------------------
  1727.   # * Draw Name
  1728.   #     actor : actor
  1729.   #     x     : draw spot x-coordinate
  1730.   #     y     : draw spot y-coordinate
  1731.   #--------------------------------------------------------------------------
  1732.   def draw_actor_name(actor, x, y)
  1733.     self.contents.font.color = hp_color(actor)
  1734.     self.contents.draw_text(x, y, 75, WLH, actor.name)
  1735.   end  
  1736.   #--------------------------------------------------------------------------
  1737.   # * Update cursor
  1738.   #--------------------------------------------------------------------------
  1739.   def update_cursor    
  1740.     if @index < 0               # No cursor
  1741.       self.cursor_rect.empty
  1742.     end
  1743.     case @index
  1744.      when 0, 1
  1745.        self.cursor_rect.set(19 + @index * 258, 0, 210, 86)      
  1746.      when 2, 3
  1747.        self.cursor_rect.set(19 + @index * 258 - @index - @column_max * 258, 80, 210, 86)              
  1748.      when 100
  1749.       self.cursor_rect.set(16, 0, contents.width-38, 163)      
  1750.      
  1751.      end
  1752.    end
  1753. end
  1754.  
  1755. #==============================================================================
  1756. # ** Window_Gold & Time
  1757. #------------------------------------------------------------------------------
  1758. #  This window displays the amount of gold and played time.
  1759. #==============================================================================
  1760.  
  1761. class Window_Gold_Time < Window_Base
  1762.   #--------------------------------------------------------------------------
  1763.   # * Object Initialization
  1764.   #     x : window X coordinate
  1765.   #     y : window Y coordinate
  1766.   #--------------------------------------------------------------------------
  1767.   def initialize(x, y, width = 260, height = 80)
  1768.     super(x, y,  width, height)    
  1769.     self.windowskin = Cache.system("TDS-Lufia Window")  
  1770.     self.back_opacity = 255    
  1771.     refresh
  1772.   end
  1773.   #--------------------------------------------------------------------------
  1774.   # * Refresh
  1775.   #--------------------------------------------------------------------------
  1776.   def refresh
  1777.     self.contents.clear
  1778.     self.contents.font.size = 25
  1779.     draw_playtime(0, 0, self.width-32, 0)    
  1780.     draw_currency_value($game_party.gold, 0, 26, self.width-32)
  1781.   end  
  1782.   #--------------------------------------------------------------------------
  1783.   # * Draw Play Time
  1784.   #     x : Draw spot X coordinate
  1785.   #     y : Draw spot Y coordinate
  1786.   #     width : Width
  1787.   #     align : Alignment
  1788.   #--------------------------------------------------------------------------
  1789.   def draw_playtime(x, y, width, align)
  1790.     @total_sec = Graphics.frame_count / Graphics.frame_rate    
  1791.     hour = @total_sec / 60 / 60
  1792.     min = @total_sec / 60 % 60
  1793.     sec = @total_sec % 60
  1794.     time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  1795.     self.contents.font.color = normal_color
  1796.     self.contents.draw_text(x + 12, y, width, WLH, "TIME")    
  1797.     self.contents.draw_text(x, y, width - 12, WLH + 2, time_string, 2)
  1798.   end  
  1799.   #--------------------------------------------------------------------------
  1800.   # * Draw number with currency unit
  1801.   #     value : Number (gold, etc)
  1802.   #     x     : draw spot x-coordinate
  1803.   #     y     : draw spot y-coordinate
  1804.   #     width : Width
  1805.   #--------------------------------------------------------------------------
  1806.   def draw_currency_value(value, x, y, width)
  1807.     cx = contents.text_size(Vocab::gold).width
  1808.     self.contents.font.color = normal_color
  1809.     self.contents.draw_text(x, y, width-12, WLH, value, 2)
  1810.     self.contents.draw_text(x + 12, y, width, WLH, "GOLD")
  1811.   end  
  1812. end
  1813.  
  1814. #==============================================================================
  1815. # ** TDS_Lufia_Window_Item
  1816. #------------------------------------------------------------------------------
  1817. #  This window displays a list of inventory items for the item screen, etc.
  1818. #==============================================================================
  1819.  
  1820. class TDS_Lufia_Window_Item < Window_Selectable
  1821.   #--------------------------------------------------------------------------
  1822.   # * Public Instance Variables
  1823.   #--------------------------------------------------------------------------
  1824.   attr_reader   :drop_mode               # Drop flag
  1825.   attr_reader   :item_mode               # Item display flag
  1826.   attr_reader   :all_mode                # All item display flag  
  1827.   attr_reader   :scenario_mode           # Scenario display flag
  1828.   #--------------------------------------------------------------------------
  1829.   # * Object Initialization
  1830.   #     x      : window x-coordinate
  1831.   #     y      : window y-coordinate
  1832.   #     width  : window width
  1833.   #     height : window height
  1834.   #--------------------------------------------------------------------------
  1835.   def initialize(x, y, width, height)
  1836.     super(x, y, width, height)
  1837.     @use_custom_cursor = true    
  1838.     @column_max = 1
  1839.     self.index = 0
  1840.     self.back_opacity = 255
  1841.     self.windowskin = Cache.system("TDS-Lufia Window")          
  1842.     @drop_mode = false    
  1843.     @item_mode = true
  1844.     @all_mode = false
  1845.     @scenario_mode = false
  1846.     refresh
  1847.   end  
  1848.   #--------------------------------------------------------------------------
  1849.   # * Only Items Mode
  1850.   #--------------------------------------------------------------------------
  1851.   def all_items_mode(value)  
  1852.     @all_mode = value
  1853.   end      
  1854.   #--------------------------------------------------------------------------
  1855.   # * Only Items Mode
  1856.   #--------------------------------------------------------------------------
  1857.   def only_items_mode(value)  
  1858.     @item_mode = value
  1859.   end    
  1860.   #--------------------------------------------------------------------------
  1861.   # * Drop Items Mode
  1862.   #--------------------------------------------------------------------------
  1863.   def drop_items_mode(value)  
  1864.     @drop_mode = value
  1865.   end
  1866.   #--------------------------------------------------------------------------
  1867.   # * Scenario Items Mode
  1868.   #--------------------------------------------------------------------------
  1869.   def scenario_items_mode(value)
  1870.     @scenario_mode = value
  1871.   end  
  1872.   #--------------------------------------------------------------------------
  1873.   # * Get Item
  1874.   #--------------------------------------------------------------------------
  1875.   def item
  1876.     return @data[self.index]
  1877.   end
  1878.   #--------------------------------------------------------------------------
  1879.   # * Whether or not to include in item list
  1880.   #     item : item
  1881.   #--------------------------------------------------------------------------
  1882.   def include?(item)
  1883.     return false if item == nil
  1884.     if $game_temp.in_battle
  1885.       return false unless item.is_a?(RPG::Item)
  1886.     end
  1887.     return true
  1888.   end
  1889.   #--------------------------------------------------------------------------
  1890.   # * Whether or not to display in enabled state
  1891.   #     item : item
  1892.   #--------------------------------------------------------------------------
  1893.   def enable?(item)
  1894.     return $game_party.item_can_use?(item)
  1895.   end  
  1896.   #--------------------------------------------------------------------------
  1897.   # * Drop item
  1898.   #     item : item
  1899.   #--------------------------------------------------------------------------  
  1900.   def drop_item(item)
  1901.     $game_party.lose_item(item, $game_party.item_number(item))    
  1902.   end  
  1903.   #--------------------------------------------------------------------------
  1904.   # * Refresh
  1905.   #--------------------------------------------------------------------------
  1906.   def refresh
  1907.     @data = []
  1908.     for item in $game_party.items
  1909.       next unless include?(item)      
  1910.       next if @item_mode == true and !$game_party.item_can_use?(item)              
  1911.       next if @scenario_mode == true and !item.element_set.include?(17)      
  1912.       if @item_mode == true
  1913.         if $game_party.item_can_use?(item) and !item.element_set.include?(17)              
  1914.           @data.push(item)          
  1915.         end        
  1916.       end      
  1917.       if @scenario_mode == true
  1918.         if item.element_set.include?(17)              
  1919.           @data.push(item)                    
  1920.          end        
  1921.       end
  1922.       if @all_mode
  1923.         if !item.element_set.include?(17)                      
  1924.           @data.push(item)          
  1925.         end        
  1926.       end
  1927.       if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
  1928.         self.index = @data.size - 1
  1929.       end
  1930.     end
  1931.     @data.push(nil) if include?(nil)
  1932.     @item_max = @data.size
  1933.     create_contents
  1934.     if @data.empty?
  1935.       @cursor_visible = false
  1936.     else
  1937.       @cursor_visible = true      
  1938.     end    
  1939.     for i in 0...@item_max
  1940.       draw_item(i)
  1941.     end
  1942.   end
  1943.   #--------------------------------------------------------------------------
  1944.   # * Draw Item
  1945.   #     index : item number
  1946.   #--------------------------------------------------------------------------
  1947.   def draw_item(index)
  1948.     rect = item_rect(index)
  1949.     self.contents.clear_rect(rect)
  1950.     item = @data[index]
  1951.     if item != nil
  1952.       number = $game_party.item_number(item)
  1953.       enabled = enable?(item)
  1954.       rect.width -= 30
  1955.       draw_item_name(item, rect.x += 26, rect.y, enabled)
  1956.       rect.x -= 20
  1957.       self.contents.draw_text(rect, sprintf(":%2d", number), 2)
  1958.     end
  1959.   end  
  1960.   #--------------------------------------------------------------------------
  1961.   # * Draw Item
  1962.   #     index : item number
  1963.   #--------------------------------------------------------------------------
  1964.   def draw_item(index)
  1965.     rect = item_rect(index)
  1966.     self.contents.clear_rect(rect)
  1967.     item = @data[index]
  1968.     if item != nil
  1969.       number = $game_party.item_number(item)
  1970.       enabled = enable?(item)
  1971.       rect.width -= 30
  1972.       draw_item_name(item, rect.x += 26, rect.y, enabled)
  1973.       rect.x -= 20
  1974.       if @scenario_mode != true
  1975.         self.contents.draw_text(rect, sprintf(":%2d", number), 2)
  1976.       end      
  1977.     end
  1978.   end
  1979.   #--------------------------------------------------------------------------
  1980.   # * Update Help Text
  1981.   #--------------------------------------------------------------------------
  1982.   def update_help
  1983.     @help_window.set_text(item == nil ? "" : item.description)
  1984.   end
  1985. end
  1986.  
  1987.  
  1988. #==============================================================================
  1989. # ** TDS_Lufia_Window_Skill
  1990. #------------------------------------------------------------------------------
  1991. #  This window displays a list of usable skills on the skill screen, etc.
  1992. #==============================================================================
  1993.  
  1994. class TDS_Lufia_Window_Skill < Window_Selectable
  1995.   #--------------------------------------------------------------------------
  1996.   # * Public Instance Variables
  1997.   #--------------------------------------------------------------------------
  1998.   attr_reader   :use_skill_mode               # Use skill display flag
  1999.   attr_reader   :all_skill_mode               # All skill display flag  
  2000.   attr_reader   :actor                        # Actor information
  2001.   #--------------------------------------------------------------------------
  2002.   # * Object Initialization
  2003.   #     x      : window x-coordinate
  2004.   #     y      : window y-coordinate
  2005.   #     width  : window width
  2006.   #     height : window height
  2007.   #     actor  : actor
  2008.   #--------------------------------------------------------------------------
  2009.   def initialize(x, y, width, height, actor)
  2010.     super(x, y, width, height)
  2011.     @actor = actor
  2012.     @column_max = 2
  2013.     @use_custom_cursor = true    
  2014.     self.index = 0
  2015.     self.back_opacity = 255
  2016.     self.windowskin = Cache.system("TDS-Lufia Window")          
  2017.     self.index = 0
  2018.     @use_skill_mode = true
  2019.     @all_skill_mode = false
  2020.     refresh(@actor)
  2021.   end
  2022.   #--------------------------------------------------------------------------
  2023.   # * Only Use Skill Mode
  2024.   #--------------------------------------------------------------------------
  2025.   def only_use_skill_mode(value)  
  2026.     @use_skill_mode = value
  2027.   end    
  2028.   #--------------------------------------------------------------------------
  2029.   # * All skill display mode
  2030.   #--------------------------------------------------------------------------
  2031.   def all_skill_display_mode(value)  
  2032.     @all_skill_mode = value    
  2033.   end    
  2034.   #--------------------------------------------------------------------------
  2035.   # * Get Skill
  2036.   #--------------------------------------------------------------------------
  2037.   def skill
  2038.     return @data[self.index]
  2039.   end
  2040.   #--------------------------------------------------------------------------
  2041.   # * Refresh
  2042.   #--------------------------------------------------------------------------
  2043.   def refresh(actor)
  2044.     @item_max = @data.size if @data != nil    
  2045.     @data = []
  2046.     @actor = actor
  2047.     for skill in @actor.skills
  2048.       next if @use_skill_mode == true and skill_can_use?(skill) == false
  2049.       if @use_skill_mode == true
  2050.         @data.push(skill) if skill_can_use?(skill)
  2051.       end            
  2052.       if @all_skill_mode == true
  2053.         @data.push(skill)        
  2054.       end            
  2055.       if skill.id == @actor.last_skill_id
  2056.         self.index = @data.size - 1
  2057.       end
  2058.     end
  2059.     @item_max = @data.size
  2060.     create_contents
  2061.     for i in 0...@item_max
  2062.       draw_item(i)
  2063.     end
  2064.     if @data.empty?
  2065.       @cursor_visible = false
  2066.     else
  2067.       @cursor_visible = true      
  2068.     end            
  2069.   end
  2070.   #--------------------------------------------------------------------------
  2071.   # * Draw Item
  2072.   #     index : item number
  2073.   #--------------------------------------------------------------------------
  2074.   def draw_item(index)
  2075.     rect = item_rect(index)
  2076.     self.contents.clear_rect(rect)
  2077.     skill = @data[index]
  2078.     if skill != nil
  2079.       rect.width -= 4
  2080.       enabled = skill_can_use?(skill, true)  # @actor.skill_can_use?(skill)
  2081.      
  2082.       draw_item_name(skill, rect.x + 26, rect.y, enabled)
  2083.       self.contents.draw_text(rect, @actor.calc_mp_cost(skill), 2)
  2084.     end
  2085.   end
  2086.   #--------------------------------------------------------------------------
  2087.   # * Determine Usable Skills
  2088.   #     skill : skill
  2089.   #--------------------------------------------------------------------------
  2090.   def skill_can_use?(skill,dead = false)
  2091.     skill = @data[index] if skill == nil    
  2092.     return false unless skill.is_a?(RPG::Skill)
  2093.     return false unless @actor.movable? if dead == true    
  2094.     return false if  @actor.silent? and skill.spi_f > 0
  2095.     return false if @actor.calc_mp_cost(skill) >  @actor.mp if dead == true
  2096.     return skill.menu_ok?
  2097.    end
  2098.   #--------------------------------------------------------------------------
  2099.   # * Update Help Text
  2100.   #--------------------------------------------------------------------------
  2101.   def update_help
  2102.     @help_window.set_text(skill == nil ? "" : skill.description)
  2103.   end
  2104. end
  2105.  
  2106. #==============================================================================
  2107. # ** Scene_Status
  2108. #------------------------------------------------------------------------------
  2109. #  This class performs the status screen processing.
  2110. #==============================================================================
  2111.  
  2112. class Scene_Status < Scene_Base
  2113.   #--------------------------------------------------------------------------
  2114.   # * Object Initialization
  2115.   #     actor_index : actor index
  2116.   #--------------------------------------------------------------------------
  2117.   def initialize(actor_index = 0)
  2118.     @actor_index = actor_index
  2119.   end
  2120.   #--------------------------------------------------------------------------
  2121.   # * Start processing
  2122.   #--------------------------------------------------------------------------
  2123.   def start
  2124.     super
  2125.     # Create Menu Back Sprite
  2126.     @menuback_sprite = Sprite.new
  2127.     @menuback_sprite.bitmap = Cache.system("Lufia Menu Back")    
  2128.     @actor = $game_party.members[@actor_index]
  2129.     # Create Status Header Window
  2130.     @status_header = Window_Base.new(14, 330, 140, 56)
  2131.     @status_header.windowskin = Cache.system("TDS-Lufia Window")      
  2132.     @status_header.back_opacity = 255
  2133.     @status_header.contents = Bitmap.new(140-32,56-32)
  2134.     @status_header.contents.font.color = @status_header.text_color(0)    
  2135.     @status_header.contents.draw_text(0,0,140-32,56-32, "STATUS",1)            
  2136.     # Create Status Window
  2137.     @status_window = Window_Status.new(@actor)
  2138.     # Create command window
  2139.     @command_window = TDS_Window_Command.new(370, ["NEXT", "PREVIOUS", "RETURN"],    
  2140.     3, 0)
  2141.     @command_window.active = true
  2142.     @command_window.x = 154 #120 + 14                        
  2143.     @command_window.y = 330
  2144.   end
  2145.   #--------------------------------------------------------------------------
  2146.   # * Termination Processing
  2147.   #--------------------------------------------------------------------------
  2148.   def terminate
  2149.     super
  2150.     @menuback_sprite.dispose
  2151.     @menuback_sprite.bitmap.dispose        
  2152.     @status_window.dispose
  2153.     @status_header.dispose
  2154.     @command_window.dispose
  2155.   end
  2156.   #--------------------------------------------------------------------------
  2157.   # * Return to Original Screen
  2158.   #--------------------------------------------------------------------------
  2159.   def return_scene
  2160.     $scene = Scene_Menu.new(1)
  2161.   end
  2162.   #--------------------------------------------------------------------------
  2163.   # * Switch to Next Actor Screen
  2164.   #--------------------------------------------------------------------------
  2165.   def next_actor
  2166.     @actor_index += 1
  2167.     @actor_index %= $game_party.members.size
  2168.     @status_window.refresh($game_party.members[@actor_index])    
  2169.   end
  2170.   #--------------------------------------------------------------------------
  2171.   # * Switch to Previous Actor Screen
  2172.   #--------------------------------------------------------------------------
  2173.   def prev_actor
  2174.     @actor_index += $game_party.members.size - 1
  2175.     @actor_index %= $game_party.members.size
  2176.     @status_window.refresh($game_party.members[@actor_index])
  2177.   end
  2178.   #--------------------------------------------------------------------------
  2179.   # * Frame Update
  2180.   #--------------------------------------------------------------------------
  2181.   def update
  2182.     @command_window.update
  2183.     @status_window.update
  2184.     if Input.trigger?(Input::B)
  2185.       Sound.play_cancel
  2186.       return_scene
  2187.     end    
  2188.     if Input.trigger?(Input::C)
  2189.       case @command_window.index
  2190.       when 0
  2191.         Sound.play_cursor
  2192.         next_actor        
  2193.       when 1
  2194.         Sound.play_cursor
  2195.         prev_actor        
  2196.       when 2
  2197.         Sound.play_cancel
  2198.         return_scene        
  2199.       end
  2200.     end
  2201.     super
  2202.   end
  2203. end
  2204.  
  2205.  
  2206. #==============================================================================
  2207. # ** Window_Status
  2208. #------------------------------------------------------------------------------
  2209. #  This window displays full status specs on the status screen.
  2210. #==============================================================================
  2211.  
  2212. class Window_Status < Window_Base
  2213.   #--------------------------------------------------------------------------
  2214.   # * Object Initialization
  2215.   #     actor : actor
  2216.   #--------------------------------------------------------------------------
  2217.   def initialize(actor)
  2218.     super(0, 0, 544, 416)
  2219.     self.opacity = 0
  2220.     self.contents.font.size = 20
  2221.     @actor = actor
  2222.     refresh(@actor)
  2223.   end
  2224.   #--------------------------------------------------------------------------
  2225.   # * Refresh
  2226.   #--------------------------------------------------------------------------
  2227.   def refresh(actor)
  2228.     @actor = actor
  2229.     self.contents.clear
  2230.     draw_actor_name(@actor, 78, 24)    
  2231.     self.contents.font.color = system_color
  2232.     self.contents.draw_text(260, 24, 80, WLH, "CLASS")
  2233.     self.contents.draw_text(260, 48, 80, WLH, "STATES")        
  2234.     self.contents.font.color = normal_color    
  2235.     draw_actor_class(@actor, 308 + 30, 24)
  2236.     draw_actor_graphic(@actor, 8, 24)    
  2237.     draw_basic_info(128, 24)
  2238.     draw_parameters(55, 110)
  2239.     draw_exp_info(60, 218)
  2240.     draw_equipments(262, 110)
  2241.   end
  2242.   #--------------------------------------------------------------------------
  2243.   # * Draw Basic Information
  2244.   #     x : Draw spot X coordinate
  2245.   #     y : Draw spot Y coordinate
  2246.   #--------------------------------------------------------------------------
  2247.   def draw_basic_info(x, y)
  2248.     draw_actor_level(@actor, x + 25, y + WLH * 0)
  2249.     draw_actor_state(@actor, x + 180 + 30, y + WLH * 1)    
  2250.     draw_actor_hp(@actor, 78, y + WLH * 2 -24, 120, true)
  2251.     draw_actor_mp(@actor, 78, y + WLH * 3 -24, 120, true)
  2252.   end
  2253.   #--------------------------------------------------------------------------
  2254.   # * Draw Parameters
  2255.   #     x : Draw spot X coordinate
  2256.   #     y : Draw spot Y coordinate
  2257.   #--------------------------------------------------------------------------
  2258.   def draw_parameters(x, y)
  2259.     draw_actor_parameter(@actor, x, y + WLH * 0, 0)
  2260.     draw_actor_parameter(@actor, x, y + WLH * 1, 1)
  2261.     draw_actor_parameter(@actor, x, y + WLH * 2, 2)
  2262.     draw_actor_parameter(@actor, x, y + WLH * 3, 3)
  2263.   end
  2264.   #--------------------------------------------------------------------------
  2265.   # * Draw Experience Information
  2266.   #     x : Draw spot X coordinate
  2267.   #     y : Draw spot Y coordinate
  2268.   #--------------------------------------------------------------------------
  2269.   def draw_exp_info(x, y)
  2270.     s1 = @actor.exp_s
  2271.     s2 = @actor.next_rest_exp_s
  2272.     s_next = sprintf(Vocab::ExpNext, Vocab::level)
  2273.     self.contents.font.color = system_color
  2274.     self.contents.draw_text(x, y + WLH * 0, 180, WLH, "NOW EXP")
  2275.     self.contents.draw_text(x, y + WLH * 2 , 180, WLH, "NEXT LEVEL")
  2276.     self.contents.font.color = normal_color
  2277.     self.contents.draw_text(x - 30, y + WLH * 1, 180, WLH, s1, 2)
  2278.     self.contents.draw_text(x - 30, y + WLH * 3 , 180, WLH, s2, 2)
  2279.   end
  2280.   #--------------------------------------------------------------------------
  2281.   # * Draw Actor Walking Graphic
  2282.   #     actor : actor
  2283.   #     x     : draw spot x-coordinate
  2284.   #     y     : draw spot y-coordinate
  2285.   #--------------------------------------------------------------------------
  2286.   def draw_actor_graphic(actor, x, y)
  2287.     character_name = actor.character_name
  2288.     bitmap = Cache.character(character_name)
  2289.     sign = character_name[/^[\!\$]./]
  2290.     if sign != nil and sign.include?('$')
  2291.       cw = bitmap.width / 3
  2292.       ch = bitmap.height / 4
  2293.     else
  2294.       cw = bitmap.width / 12
  2295.       ch = bitmap.height / 8
  2296.     end
  2297.     n = actor.character_index
  2298.     src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)    
  2299.     dest_rect = Rect.new(x, y, 80, 80)    
  2300.     dest_rect = Rect.new(x, y, 65, 65)    
  2301.     self.contents.stretch_blt(dest_rect, bitmap, src_rect)
  2302.   end
  2303.   #--------------------------------------------------------------------------
  2304.   # * Draw State
  2305.   #     actor : actor
  2306.   #     x     : draw spot x-coordinate
  2307.   #     y     : draw spot y-coordinate
  2308.   #     width : draw spot width
  2309.   #--------------------------------------------------------------------------
  2310.   def draw_actor_state(actor, x, y, width = 96)
  2311.     count = 0
  2312.     if actor.states.empty?
  2313.       self.contents.draw_text(x, y, 80, WLH, "Fine")              
  2314.     end    
  2315.     for state in actor.states
  2316.       draw_icon(state.icon_index, x + 24 * count, y)
  2317.       count += 1
  2318.       break if (24 * count > width - 24)
  2319.     end
  2320.   end  
  2321.   #--------------------------------------------------------------------------
  2322.   # * Draw Level
  2323.   #     actor : actor
  2324.   #     x     : draw spot x-coordinate
  2325.   #     y     : draw spot y-coordinate
  2326.   #--------------------------------------------------------------------------
  2327.   def draw_actor_level(actor, x, y)
  2328.     self.contents.font.color = system_color
  2329.     self.contents.draw_text(x, y, 32, WLH, Vocab::level_a)
  2330.     self.contents.font.color = normal_color
  2331.     self.contents.draw_text(x + 18, y, 24, WLH, actor.level, 2)
  2332.   end    
  2333.   #--------------------------------------------------------------------------
  2334.   # * Draw Name
  2335.   #     actor : actor
  2336.   #     x     : draw spot x-coordinate
  2337.   #     y     : draw spot y-coordinate
  2338.   #--------------------------------------------------------------------------
  2339.   def draw_actor_name(actor, x, y)
  2340.     self.contents.font.color = hp_color(actor)
  2341.     self.contents.draw_text(x, y, 75, WLH, actor.name)
  2342.   end    
  2343.   #--------------------------------------------------------------------------
  2344.   # * Draw Equipment
  2345.   #     x : Draw spot X coordinate
  2346.   #     y : Draw spot Y coordinate
  2347.   #--------------------------------------------------------------------------
  2348.   def draw_equipments(x, y)
  2349.     self.contents.font.color = system_color
  2350.     for i in 0..4
  2351.     self.contents.font.size = 25      
  2352.      if @actor.equips[i] == nil      
  2353.       self.contents.draw_text(x + 37,  y + i * 32, 100, WLH, "No Equip")
  2354.      end    
  2355.       draw_item_name(@actor.equips[i], x , y + i * 32)
  2356.     end
  2357.     self.contents.font.size = 20    
  2358.   end
  2359.   #--------------------------------------------------------------------------
  2360.   # * Draw Item Name
  2361.   #     item    : Item (skill, weapon, armor are also possible)
  2362.   #     x       : draw spot x-coordinate
  2363.   #     y       : draw spot y-coordinate
  2364.   #     enabled : Enabled flag. When false, draw semi-transparently.
  2365.   #--------------------------------------------------------------------------
  2366.   def draw_item_name(item, x, y, enabled = true)
  2367.     if item != nil
  2368.       draw_icon(item.icon_index, x + 2, y, enabled)
  2369.       self.contents.font.color = Color.new(255, 255, 255, 255)                      
  2370.       self.contents.font.color.alpha = enabled ? 255 : 128
  2371.       self.contents.draw_text(x + 31, y, 290, WLH, item.name)
  2372.     end
  2373.   end    
  2374. end
  2375.  
  2376. #==============================================================================
  2377. # ** Scene_Equip
  2378. #------------------------------------------------------------------------------
  2379. #  This class performs the equipment screen processing.
  2380. #==============================================================================
  2381.  
  2382. class Scene_Equip < Scene_Base
  2383.   #--------------------------------------------------------------------------
  2384.   # * Constants
  2385.   #--------------------------------------------------------------------------
  2386.   EQUIP_TYPE_MAX = 5                      # Number of equip region
  2387.   #--------------------------------------------------------------------------
  2388.   # * Object Initialization
  2389.   #     actor_index : actor index
  2390.   #     equip_index : equipment index
  2391.   #--------------------------------------------------------------------------
  2392.   def initialize(actor_index = 0, equip_index = 0, command_index = 0)
  2393.     @actor_index = actor_index
  2394.     @equip_index = equip_index
  2395.     @command_index = command_index
  2396.     @viewing_item_window_info = false
  2397.     @viewing_equip_window_info = false        
  2398.     @remove_item_mode = false
  2399.     @drop_item_mode = false    
  2400.    
  2401.     @item_index_return = 0
  2402.   end
  2403.   #--------------------------------------------------------------------------
  2404.   # * Start processing
  2405.   #--------------------------------------------------------------------------
  2406.   def start
  2407.     super
  2408.     # Create Menu Back Sprite
  2409.     @menuback_sprite = Sprite.new
  2410.     @menuback_sprite.bitmap = Cache.system("Lufia Menu Back")    
  2411.        
  2412.    
  2413.     # Actor information
  2414.     @actor = $game_party.members[@actor_index]            
  2415.     # Create command window
  2416.     @command_window = TDS_Window_Command.new(247, ["EQUIP", "STRONGEST",
  2417.     "REMOVE", "REMOVE ALL", "DROP"])    
  2418.     @command_window.x = 250
  2419.     @command_window.y = 247        
  2420.     @command_window.index = @command_index
  2421.  
  2422.     if @actor.fix_equipment
  2423.       for i in 0...@command_window.commands.size
  2424.         @command_window.draw_item(i, false)
  2425.       end    
  2426.     end          
  2427.  
  2428.     @equip_window = Window_Equip.new(228, 56, @actor)
  2429.     @equip_window.index = @equip_index
  2430.     @equip_window.active = false
  2431.     @equip_window.change_cursor_visibility(false)        
  2432.     @status_window = Window_EquipStatus.new(0, 0, @actor)
  2433.    
  2434.     create_item_windows
  2435.     update_item_windows        
  2436.    
  2437.     # Create Dummy help window
  2438.     @dummy_help_window = Window_Base.new(18, 298, 510, 101)            
  2439.    
  2440.     @dummy_help_window.windowskin = Cache.system("TDS-Lufia Window")    
  2441.     @dummy_help_window.contents = Bitmap.new(510-32,56-32)
  2442.     @dummy_help_window.contents.font.color =  @dummy_help_window.text_color(0)    
  2443.    
  2444.     @dummy_help_window.contents.font.size = 22        
  2445.     @dummy_help_window.contents.draw_text(0, -24, 510-32, 100-32, "Help window text test")                                        
  2446.    
  2447.     @dummy_help_window.back_opacity = 255
  2448.     @dummy_help_window.visible = false
  2449.     @dummy_help_window.z = 5000
  2450.     # Create Help Window Header
  2451.     @scene_help_header = Window_Base.new(18, 247, 510, 56)    
  2452.     @scene_help_header.windowskin = Cache.system("TDS-Lufia Window")      
  2453.     @scene_help_header.back_opacity = 255
  2454.     @scene_help_header.contents = Bitmap.new(510-32,56-32)
  2455.     @scene_help_header.contents.font.color = @scene_help_header.text_color(0)    
  2456.     @scene_help_header.contents.draw_text(0, 0 , 505-32,56-32, "Item name",1)                    
  2457.     @scene_help_header.visible = false    
  2458.     @scene_help_header.z = 5000    
  2459.   end
  2460.   #--------------------------------------------------------------------------
  2461.   # * Termination Processing
  2462.   #--------------------------------------------------------------------------
  2463.   def terminate
  2464.     super
  2465.     @menuback_sprite.dispose
  2466.     @menuback_sprite.bitmap.dispose            
  2467.     @command_window.dispose    
  2468.     @equip_window.dispose
  2469.     @status_window.dispose
  2470.     dispose_item_windows
  2471.     @dummy_help_window.dispose
  2472.     @scene_help_header.dispose
  2473.   end
  2474.   #--------------------------------------------------------------------------
  2475.   # * Update Frame
  2476.   #--------------------------------------------------------------------------
  2477.   def update
  2478.     super
  2479.     # Update windows
  2480.     @command_window.update    
  2481.     @equip_window.update
  2482.     update_status_window    
  2483.     update_item_windows    
  2484.     # If not viewing any info and command window active
  2485.     if @viewing_equip_window_info == false and @viewing_item_window_info == false and
  2486.       @command_window.active == true
  2487.       if Input.trigger?(Input::R)
  2488.         Sound.play_cursor
  2489.         next_actor
  2490.        elsif Input.trigger?(Input::L)
  2491.          Sound.play_cursor
  2492.          prev_actor    
  2493.        end
  2494.      end  
  2495.      # If command Window active
  2496.      if @command_window.active      
  2497.        update_command_selection
  2498.      end    
  2499.      # If equip window active or viewing equip item info
  2500.      if @equip_window.active or @viewing_equip_window_info
  2501.        update_equip_selection
  2502.        @equip_window.change_cursor_visibility(true)
  2503.      else      
  2504.       if @item_window.active == false and @viewing_item_window_info == false
  2505.         @equip_window.change_cursor_visibility(false)          
  2506.       end      
  2507.     end    
  2508.     # If item window active or viewing item window info
  2509.     if @item_window.active or @viewing_item_window_info
  2510.        update_item_selection      
  2511.     end        
  2512.   end
  2513.   #--------------------------------------------------------------------------
  2514.   # * Update Command Selection
  2515.   #--------------------------------------------------------------------------
  2516.   def update_command_selection
  2517.     if Input.trigger?(Input::B)
  2518.       Sound.play_cancel
  2519.       $scene = Scene_Menu.new(3)      
  2520.     end
  2521.     # If input trigger
  2522.     if Input.trigger?(Input::C)                
  2523.       if @actor.fix_equipment
  2524.         Sound.play_buzzer
  2525.         return
  2526.       end            
  2527.       case @command_window.index
  2528.       when 0 # Equip
  2529.         Sound.play_decision        
  2530.         @command_window.active = false
  2531.         @command_window.visible = false
  2532.         @item_window.visible = true
  2533.         @equip_window.active = true
  2534.         @remove_item_mode = false              
  2535.         @drop_item_mode = false          
  2536.         Input.update
  2537.       when 1 # Equip Strongest        
  2538.         Sound.play_equip        
  2539.  
  2540.         for i in 0...3
  2541.           equip_strongest_armor(i, i+1)          
  2542.         end        
  2543.         for i in 0...5
  2544.           @item_windows[i].refresh    
  2545.         end                        
  2546.  
  2547.         equip_strongest_weapon                                        
  2548.        
  2549.         @status_window.refresh
  2550.         Input.update
  2551.         return
  2552.       when 2 # Remove
  2553.         Sound.play_decision                
  2554.         @command_window.active = false
  2555.         @equip_window.active = true    
  2556.         @item_window.visible = false                
  2557.         @remove_item_mode = true              
  2558.         Input.update        
  2559.       when 3 # Remove all
  2560.       Sound.play_equip
  2561.       old_equip_index = @equip_window.index
  2562.       for i in 0...5
  2563.         @actor.change_equip(i, nil)      
  2564.         @equip_window.index = i        
  2565.         @item_windows[i].refresh              
  2566.         if @equip_window.item != nil
  2567.           equip_redraw_index = @item_windows[i].return_item_index(@equip_window.item)                    
  2568.           if equip_redraw_index != nil                    
  2569.             @item_windows[i].draw_item(equip_redraw_index)                        
  2570.           end
  2571.         end        
  2572.         @status_window.refresh        
  2573.       end
  2574.       @equip_window.index = old_equip_index
  2575.       @equip_window.refresh
  2576.       when 4 # Drop
  2577.         Sound.play_decision                        
  2578.         @command_window.active = false
  2579.         @equip_window.active = true    
  2580.         @item_window.visible = false                    
  2581.         @drop_item_mode = true  
  2582.         Input.update                
  2583.      end                
  2584.       return
  2585.     end
  2586.   end      
  2587.   #--------------------------------------------------------------------------
  2588.   # * Update Equip Region Selection
  2589.   #--------------------------------------------------------------------------
  2590.   def update_equip_selection
  2591.     if Input.trigger?(Input::B)
  2592.       Sound.play_cancel
  2593.       if @viewing_equip_window_info            
  2594.         if @drop_item_mode == true or @remove_item_mode == true
  2595.           @dummy_help_window.visible = false    
  2596.           @scene_help_header.visible = false        
  2597.           @command_window.visible = true        
  2598.           @equip_window.active = true
  2599.           @scene_help_header.contents.clear
  2600.           @viewing_equip_window_info = false                
  2601.           return      
  2602.         end            
  2603.         @dummy_help_window.visible = false    
  2604.         @scene_help_header.visible = false        
  2605.         @item_window.visible = true
  2606.         @equip_window.active = true        
  2607.         @scene_help_header.contents.clear
  2608.         @viewing_equip_window_info = false              
  2609.         @remove_item_mode = false      
  2610.         @drop_item_mode = false          
  2611.         return
  2612.       end      
  2613.       @item_window.visible = false
  2614.       @equip_window.active = false        
  2615.       @equip_window.change_cursor_visibility(false)      
  2616.       @command_window.active = true
  2617.       @command_window.visible = true
  2618.       @remove_item_mode = false            
  2619.       @drop_item_mode = false          
  2620.     end        
  2621.    
  2622.     if Input.trigger?(Input::C) and @viewing_equip_window_info == false                  
  2623.       if @remove_item_mode == true
  2624.         if @actor.fix_equipment or @equip_window.item == nil
  2625.           Sound.play_buzzer
  2626.           Input.update                  
  2627.           return
  2628.         else        
  2629.           Sound.play_equip        
  2630.           draw_index = @item_window.return_item_index(@equip_window.item)                    
  2631.           @actor.change_equip(@equip_window.index, nil)        
  2632.           if draw_index != nil
  2633.             @item_window.draw_item(draw_index)        
  2634.           end                          
  2635.           @item_window.refresh
  2636.           @equip_window.refresh    
  2637.           @status_window.refresh                            
  2638.           Input.update        
  2639.         return
  2640.         end          
  2641.       end
  2642.      
  2643.       if @drop_item_mode == true
  2644.         if @actor.fix_equipment or @equip_window.item == nil
  2645.           Sound.play_buzzer
  2646.           Input.update                  
  2647.           return
  2648.         else        
  2649.           Sound.play_equip        
  2650.           draw_index = @item_window.return_item_index(@equip_window.item)
  2651.           @actor.change_equip(@equip_window.index, nil)                  
  2652.           $game_party.lose_item(@equip_window.item, 1, true)                    
  2653.           @equip_window.refresh                  
  2654.           if draw_index != nil
  2655.             @item_window.draw_item(draw_index)        
  2656.           end          
  2657.           @item_window.refresh
  2658.           @status_window.refresh                  
  2659.           Input.update        
  2660.         return
  2661.         end          
  2662.       end
  2663.      
  2664.       if @actor.fix_equipment or @item_window.item_max == 0
  2665.         Sound.play_buzzer
  2666.       else
  2667.         Sound.play_decision
  2668.         @equip_window.active = false
  2669.         @item_window.active = true
  2670.         @item_window.index = 0
  2671.         Input.update
  2672.       end
  2673.     end
  2674.  
  2675.     if Input.trigger?(Input::CTRL)    
  2676.       if @viewing_equip_window_info == false    
  2677.         return Sound.play_buzzer if @equip_window.item == nil
  2678.         Sound.play_decision                
  2679.         if @drop_item_mode == true or @remove_item_mode == true              
  2680.           @command_window.active = false
  2681.           @command_window.visible = false    
  2682.           @equip_window.active = false          
  2683.           @dummy_help_window.visible = true      
  2684.           @scene_help_header.visible = true      
  2685.           @scene_help_header.contents.font.color = @scene_help_header.text_color(0)    
  2686.           @scene_help_header.contents.clear
  2687.           @scene_help_header.contents.draw_text(0, 0 , 510-32,56-32, @equip_window.item.name,1)                                    
  2688.           @dummy_help_window.contents.font.color =  @dummy_help_window.text_color(0)    
  2689.           @dummy_help_window.contents.clear
  2690.           @dummy_help_window.contents.font.size = 22
  2691.           @dummy_help_window.contents.draw_text(0, -24, 510-32, 100-32,   @equip_window.item.description.capitalize)                                              
  2692.           @viewing_equip_window_info = true          
  2693.           return
  2694.         end
  2695.         @dummy_help_window.visible = true      
  2696.         @scene_help_header.visible = true
  2697.         @item_window.visible = false
  2698.         @equip_window.active = false
  2699.         @item_index_return = @item_window.index  
  2700.         @scene_help_header.contents.font.color = @scene_help_header.text_color(0)    
  2701.         @scene_help_header.contents.clear
  2702.         @scene_help_header.contents.draw_text(0, 0 , 510-32,56-32, @equip_window.item.name,1)                                    
  2703.         @dummy_help_window.contents.font.color =  @dummy_help_window.text_color(0)    
  2704.         @dummy_help_window.contents.clear
  2705.         @dummy_help_window.contents.font.size = 22
  2706.         @dummy_help_window.contents.draw_text(0, -24, 510-32, 100-32,   @equip_window.item.description.capitalize)                                    
  2707.         @item_window.index = -1                    
  2708.         @viewing_equip_window_info = true
  2709.       else        
  2710.         if @drop_item_mode == true or @remove_item_mode == true
  2711.           Sound.play_decision        
  2712.           @dummy_help_window.visible = false    
  2713.           @scene_help_header.visible = false        
  2714.           @command_window.visible = true        
  2715.           @equip_window.active = true        
  2716.           @scene_help_header.contents.clear
  2717.           @viewing_equip_window_info = false                
  2718.           return      
  2719.         end      
  2720.         Sound.play_decision        
  2721.         @dummy_help_window.visible = false    
  2722.         @scene_help_header.visible = false        
  2723.         @item_window.visible = true
  2724.         @equip_window.active = true        
  2725.         @scene_help_header.contents.clear
  2726.         @viewing_equip_window_info = false      
  2727.         end
  2728.       return
  2729.     end                    
  2730.   end  
  2731.   #--------------------------------------------------------------------------
  2732.   # * Update Item Selection
  2733.   #--------------------------------------------------------------------------
  2734.   def update_item_selection
  2735.     if Input.trigger?(Input::B)
  2736.       Sound.play_cancel
  2737.       if @viewing_item_window_info
  2738.         @dummy_help_window.visible = false    
  2739.         @scene_help_header.visible = false
  2740.         @item_window.active = true
  2741.         @item_window.visible = true
  2742.         @item_window.index = @item_index_return                
  2743.         @scene_help_header.contents.clear
  2744.         @viewing_item_window_info = false      
  2745.         return                
  2746.       end
  2747.       @equip_window.active = true
  2748.       @item_window.active = false
  2749.       @item_window.index = -1      
  2750.     end
  2751.  
  2752.     if Input.trigger?(Input::C) and @viewing_item_window_info == false                
  2753.       Sound.play_equip
  2754.       @actor.change_equip(@equip_window.index, @item_window.item)
  2755.       @equip_window.active = true
  2756.       @item_window.active = false
  2757.       @item_window.index = -1
  2758.       @equip_window.refresh
  2759.       for item_window in @item_windows
  2760.         item_window.refresh
  2761.       end
  2762.     end
  2763.    
  2764.     if Input.trigger?(Input::CTRL)    
  2765.       Sound.play_decision              
  2766.       if @viewing_item_window_info == false    
  2767.         @dummy_help_window.visible = true      
  2768.         @scene_help_header.visible = true
  2769.         @item_window.visible = false
  2770.         @item_window.active = false        
  2771.         @item_index_return = @item_window.index  
  2772.         @scene_help_header.contents.font.color = @scene_help_header.text_color(0)    
  2773.         @scene_help_header.contents.clear
  2774.         @scene_help_header.contents.draw_text(0, 0 , 510-32,56-32, @item_window.item.name,1)                                    
  2775.         @dummy_help_window.contents.font.color =  @dummy_help_window.text_color(0)    
  2776.         @dummy_help_window.contents.clear
  2777.         @dummy_help_window.contents.font.size = 22
  2778.         @dummy_help_window.contents.draw_text(0, -24, 510-32, 100-32,  @item_window.item.description.capitalize)                                    
  2779.         @item_window.index = -1                    
  2780.         @viewing_item_window_info = true
  2781.        else
  2782.         @dummy_help_window.visible = false    
  2783.         @scene_help_header.visible = false
  2784.         @item_window.active = true
  2785.         @item_window.visible = true
  2786.         @item_window.index = @item_index_return        
  2787.        
  2788.         @scene_help_header.contents.clear
  2789.         @viewing_item_window_info = false      
  2790.         end
  2791.       return
  2792.     end                
  2793.   end  
  2794.   #--------------------------------------------------------------------------
  2795.   # * Update Status Window
  2796.   #--------------------------------------------------------------------------
  2797.   def update_status_window
  2798.     if @equip_window.active
  2799.       @status_window.set_new_parameters(nil, nil, nil, nil)
  2800.     elsif @item_window.active
  2801.       temp_actor = @actor.clone
  2802.       temp_actor.change_equip(@equip_window.index, @item_window.item, true)
  2803.       new_atk = temp_actor.atk
  2804.       new_def = temp_actor.def
  2805.       new_spi = temp_actor.spi
  2806.       new_agi = temp_actor.agi
  2807.       @status_window.set_new_parameters(new_atk, new_def, new_spi, new_agi)
  2808.     end
  2809.     @status_window.update
  2810.   end
  2811.   #--------------------------------------------------------------------------
  2812.   # * Equip Strongest Weapon
  2813.   #--------------------------------------------------------------------------
  2814.   def equip_strongest_weapon
  2815.     # Owned weapons array
  2816.     weapons = []    
  2817.     # Actor class weapon set
  2818.     weapon_set = @actor.class.weapon_set    
  2819.     # Block
  2820.     weapon_set.each do |i|
  2821.       next if $game_party.has_item?($data_weapons[i]) == false      
  2822.       next if @actor.equippable?($data_weapons[i]) == false      
  2823.       # Push weapon values into weapons variable
  2824.       weapons << $data_weapons[i]
  2825.     end            
  2826.     # Return if weaponsa array is empty
  2827.     return if weapons == []    
  2828.     # If actors currently equiped weapon is nil
  2829.     if @actor.weapons[0] == nil
  2830.       ver_weapon = weapons[0]
  2831.     else
  2832.       ver_weapon = @actor.weapons[0]
  2833.     end
  2834.    
  2835.     for weapon in weapons
  2836.       next if weapon.two_handed      
  2837.       if ver_weapon.atk < weapon.atk        
  2838.         ver_weapon = weapon
  2839.       end            
  2840.     end        
  2841.     # Equip Strongest Weapon
  2842.     @actor.change_equip(0, ver_weapon)            
  2843.     # Reresh equip window    
  2844.     @equip_window.refresh            
  2845.    
  2846.   end
  2847.  
  2848.   #--------------------------------------------------------------------------
  2849.   # * Equip Strongest Armor
  2850.   #--------------------------------------------------------------------------
  2851.   def equip_strongest_armor(armor_kind , index)
  2852.  
  2853.     # Owned armors array
  2854.     armors = []    
  2855.     # Actor class armor set
  2856.     armor_set = @actor.class.armor_set
  2857.     # Block
  2858.     armor_set.each do |i|    
  2859.       next if $data_armors[i].kind == 3
  2860.       next if $game_party.has_item?($data_armors[i]) == false
  2861.       next if @actor.armors[armor_kind] == $data_armors[i]  
  2862.      
  2863.       if $data_armors[i].kind == armor_kind
  2864.         armors << $data_armors[i]
  2865.       end
  2866.     end
  2867.     # Return if armors array is empty
  2868.     return if armors == []
  2869.    
  2870.     # If actor armor is nil
  2871.     if @actor.armors[armor_kind] == nil
  2872.       ver_armor = armors[0]
  2873.     else
  2874.       ver_armor = @actor.armors[armor_kind]
  2875.     end
  2876.  
  2877.     for armor in armors    
  2878.       if ver_armor.def < armor.def      
  2879.         ver_armor = armor
  2880.       end      
  2881.     end
  2882.     # Equip strongest armor
  2883.     @actor.change_equip(index, ver_armor)              
  2884.     # Reresh equip window
  2885.     @equip_window.refresh
  2886.   end    
  2887.   #--------------------------------------------------------------------------
  2888.   # * Create Item Window
  2889.   #--------------------------------------------------------------------------
  2890.   def create_item_windows
  2891.     @item_windows = []
  2892.     for i in 0...EQUIP_TYPE_MAX
  2893.       @item_windows[i] = Window_EquipItem.new(18, 247, 510, 152, @actor, i)
  2894.       @item_windows[i].visible = (@equip_index == i)
  2895.       @item_windows[i].active = false
  2896.       @item_windows[i].visible = false      
  2897.       @item_windows[i].index = -1
  2898.     end
  2899.   end
  2900.   #--------------------------------------------------------------------------
  2901.   # * Dispose of Item Window
  2902.   #--------------------------------------------------------------------------
  2903.   def dispose_item_windows
  2904.     for window in @item_windows
  2905.       window.dispose
  2906.     end
  2907.   end
  2908.   #--------------------------------------------------------------------------
  2909.   # * Switch to Next Actor Screen
  2910.   #--------------------------------------------------------------------------
  2911.   def next_actor
  2912.     @actor_index += 1
  2913.     @actor_index %= $game_party.members.size
  2914.     @actor = $game_party.members[@actor_index]                
  2915.     @status_window.refresh(@actor)
  2916.     @equip_window.refresh(@actor)
  2917.  
  2918.  
  2919.     create_item_windows
  2920.     update_item_windows
  2921.    
  2922.     @viewing_item_window_info = false
  2923.     @viewing_equip_window_info = false        
  2924.     @remove_item_mode = false
  2925.     @drop_item_mode = false    
  2926.   end
  2927.   #--------------------------------------------------------------------------
  2928.   # * Switch to Previous Actor Screen
  2929.   #--------------------------------------------------------------------------
  2930.   def prev_actor
  2931.     @actor_index += $game_party.members.size - 1
  2932.     @actor_index %= $game_party.members.size
  2933.     @actor = $game_party.members[@actor_index]            
  2934.     @status_window.refresh(@actor)
  2935.     @equip_window.refresh(@actor)
  2936.    
  2937.     create_item_windows
  2938.     update_item_windows
  2939.    
  2940.     @viewing_item_window_info = false
  2941.     @viewing_equip_window_info = false        
  2942.     @remove_item_mode = false
  2943.     @drop_item_mode = false    
  2944.   end
  2945.   #--------------------------------------------------------------------------
  2946.   # * Update Item Window
  2947.   #--------------------------------------------------------------------------
  2948.   def update_item_windows
  2949.     for i in 0...EQUIP_TYPE_MAX
  2950.       @item_windows[i].visible = false if @command_window.active == true
  2951.       if @command_window.active == false and @remove_item_mode == false and
  2952.         @drop_item_mode == false
  2953.         @item_windows[i].visible = (@equip_window.index == i)
  2954.         @item_windows[i].update
  2955.       end      
  2956.     end    
  2957.     @item_window = @item_windows[@equip_window.index]
  2958.   end  
  2959. end
  2960.  
  2961. #==============================================================================
  2962. # ** Window_Equip
  2963. #------------------------------------------------------------------------------
  2964. #  This window displays items the actor is currently equipped with on the
  2965. # equipment screen.
  2966. #==============================================================================
  2967.  
  2968. class Window_Equip < Window_Selectable
  2969.   #--------------------------------------------------------------------------
  2970.   # * Object Initialization
  2971.   #     x     : window X coordinate
  2972.   #     y     : window Y corrdinate
  2973.   #     actor : actor
  2974.   #--------------------------------------------------------------------------
  2975.   def initialize(x, y, actor)
  2976.     super(x, y, 290, 200)
  2977.     @actor = actor
  2978.     @use_custom_cursor = true
  2979.     self.windowskin = Cache.system("TDS-Lufia Window")      
  2980.     self.contents.font.color = Color.new(255, 255, 255, 255)    
  2981.     self.opacity = 0
  2982.     refresh
  2983.     self.index = 0
  2984.   end
  2985.   #--------------------------------------------------------------------------
  2986.   # * Get Item
  2987.   #--------------------------------------------------------------------------
  2988.   def item
  2989.     return @data[self.index]
  2990.   end
  2991.   #--------------------------------------------------------------------------
  2992.   # * Refresh
  2993.   #--------------------------------------------------------------------------
  2994.   def refresh(actor = nil)
  2995.     self.contents.clear
  2996.     @actor = actor if actor != nil
  2997.     @data = []
  2998.     for item in @actor.equips do @data.push(item) end
  2999.     @item_max = @data.size
  3000.  
  3001.     for i in 0...@data.size
  3002.       if @data[i] == nil
  3003.         self.contents.font.color = Color.new(255, 255, 255, 255)                
  3004.         self.contents.draw_text(48, 32 * i , 172, 24, "No Equip")
  3005.       end      
  3006.       self.contents.font.color = Color.new(255, 255, 255, 255)              
  3007.       draw_item_name(@data[i], 24, 32 * i)        
  3008.     end
  3009.   end
  3010.   #--------------------------------------------------------------------------
  3011.   # * Draw Item Name
  3012.   #     item    : Item (skill, weapon, armor are also possible)
  3013.   #     x       : draw spot x-coordinate
  3014.   #     y       : draw spot y-coordinate
  3015.   #     enabled : Enabled flag. When false, draw semi-transparently.
  3016.   #--------------------------------------------------------------------------
  3017.   def draw_item_name(item, x, y, enabled = true)
  3018.     if item != nil
  3019.       draw_icon(item.icon_index, x + 2, y, enabled)
  3020.       self.contents.font.color = Color.new(255, 255, 255, 255)                      
  3021.       self.contents.font.color.alpha = enabled ? 255 : 128
  3022.       self.contents.draw_text(x + 31, y, 290, WLH, item.name)
  3023.     end
  3024.   end
  3025.   #--------------------------------------------------------------------------
  3026.   # * Get rectangle for displaying items
  3027.   #     index : item number
  3028.   #--------------------------------------------------------------------------
  3029.   def item_rect(index)
  3030.     rect = Rect.new(0, 0, 0, 0)
  3031.     rect.width = (contents.width + @spacing) / @column_max - @spacing
  3032.     rect.height = 25
  3033.     rect.x = index % @column_max * (rect.width + @spacing)
  3034.     rect.y = index / @column_max * 32
  3035.     return rect
  3036.   end  
  3037. end
  3038.  
  3039. #==============================================================================
  3040. # ** Window_EquipItem
  3041. #------------------------------------------------------------------------------
  3042. #  This window displays choices when opting to change equipment on the
  3043. # equipment screen.
  3044. #==============================================================================
  3045.  
  3046. class Window_EquipItem < Window_Item
  3047.   #--------------------------------------------------------------------------
  3048.   # * Object Initialization
  3049.   #     x          : sindow X coordinate
  3050.   #     y          : sindow Y corrdinate
  3051.   #     width      : sindow width
  3052.   #     height     : sindow height
  3053.   #     actor      : actor
  3054.   #     equip_type : equip region (0-4)
  3055.   #--------------------------------------------------------------------------
  3056.   def initialize(x, y, width, height, actor, equip_type)
  3057.     @actor = actor
  3058.     if equip_type == 1 and actor.two_swords_style
  3059.       equip_type = 0                              # Change shield to weapon
  3060.     end
  3061.     @equip_type = equip_type
  3062.     super(x, y, width, height)
  3063.     @column_max = 1    
  3064.     @use_custom_cursor = true      
  3065.     @normal_color = normal_color    
  3066.     self.contents.font.color = @normal_color
  3067.     self.windowskin = Cache.system("TDS-Lufia Window")      
  3068.     self.back_opacity = 255
  3069.     refresh
  3070.   end
  3071.  
  3072.   #--------------------------------------------------------------------------
  3073.   # * Whether to include item in list
  3074.   #     item : item
  3075.   #--------------------------------------------------------------------------
  3076.   def return_item_index(item)
  3077.     item_index = item
  3078.     item_index = @data.index(item)    
  3079.     return item_index
  3080.   end  
  3081.   #--------------------------------------------------------------------------
  3082.   # * Whether to include item in list
  3083.   #     item : item
  3084.   #--------------------------------------------------------------------------
  3085.   def include?(item)
  3086.     return true if item == nil
  3087.     if @equip_type == 0
  3088.       return false unless item.is_a?(RPG::Weapon)
  3089.     else
  3090.       return false unless item.is_a?(RPG::Armor)
  3091.       return false unless item.kind == @equip_type - 1
  3092.     end
  3093.     return @actor.equippable?(item)
  3094.   end
  3095.   #--------------------------------------------------------------------------
  3096.   # * Draw Item
  3097.   #     index : item number
  3098.   #--------------------------------------------------------------------------
  3099.   def draw_item(index)
  3100.     @item_max = @data.size-1    
  3101.     rect = item_rect(index)
  3102.     self.contents.clear_rect(rect)
  3103.     self.contents.font.color = normal_color    
  3104.     item = @data[index]
  3105.     if item != nil
  3106.       number = $game_party.item_number(item)
  3107.       enabled = enable?(item)
  3108.       rect.width -= 14
  3109.       draw_item_name(item, rect.x + 26, rect.y, enabled)
  3110.       self.contents.draw_text(rect, sprintf(":%2d", number), 2)
  3111.     end
  3112.   end  
  3113.  
  3114.   #--------------------------------------------------------------------------
  3115.   # * Whether to display item in enabled state
  3116.   #     item : item
  3117.   #--------------------------------------------------------------------------
  3118.   def enable?(item)
  3119.     return true
  3120.   end
  3121. end
  3122.  
  3123. #==============================================================================
  3124. # ** Window_EquipStatus
  3125. #------------------------------------------------------------------------------
  3126. #  This window displays actor parameter changes on the equipment screen, etc.
  3127. #==============================================================================
  3128.  
  3129. class Window_EquipStatus < Window_Base
  3130.   #--------------------------------------------------------------------------
  3131.   # * Object Initialization
  3132.   #     x     : window X coordinate
  3133.   #     y     : window Y corrdinate
  3134.   #     actor : actor
  3135.   #--------------------------------------------------------------------------
  3136.   def initialize(x, y, actor)
  3137.     super(x, y, 290, 300)
  3138.     @actor = actor    
  3139.     self.opacity = 0    
  3140.     self.contents.font.size = 20    
  3141.     refresh
  3142.   end
  3143.   #--------------------------------------------------------------------------
  3144.   # * Refresh
  3145.   #--------------------------------------------------------------------------
  3146.   def refresh(actor = nil)
  3147.     self.contents.clear
  3148.     @actor = actor if actor != nil
  3149.     x = 128
  3150.     y = 24
  3151.     draw_actor_name(@actor, 78, y)    
  3152.     draw_actor_graphic(@actor, 8, y)
  3153.  
  3154.     draw_actor_level(@actor, x + 25, y + WLH * 0)
  3155.     draw_actor_state(@actor, x + 180 + 30, y + WLH * 1)    
  3156.     draw_actor_hp(@actor, 78, y + WLH * 2 -24, 120, true)
  3157.     draw_actor_mp(@actor, 78, y + WLH * 3 -24, 120, true)    
  3158.    
  3159.     draw_parameter(55, 90 + WLH * 1, 0)
  3160.     draw_parameter(55, 90 + WLH * 2, 1)
  3161.     draw_parameter(55, 90 + WLH * 3, 2)
  3162.     draw_parameter(55, 90 + WLH * 4, 3)
  3163.    
  3164.     if self.active == false
  3165.      
  3166.     end
  3167.   end
  3168.   #--------------------------------------------------------------------------
  3169.   # * Set Parameters After Equipping
  3170.   #     new_atk : attack after equipping
  3171.   #     new_def : defense after equipping
  3172.   #     new_spi : spirit after equipping
  3173.   #     new_agi : agility after equipping
  3174.   #--------------------------------------------------------------------------
  3175.   def set_new_parameters(new_atk, new_def, new_spi, new_agi)
  3176.     if @new_atk != new_atk or @new_def != new_def or
  3177.        @new_spi != new_spi or @new_agi != new_agi
  3178.       @new_atk = new_atk
  3179.       @new_def = new_def
  3180.       @new_spi = new_spi
  3181.       @new_agi = new_agi
  3182.       refresh
  3183.     end
  3184.   end
  3185.   #--------------------------------------------------------------------------
  3186.   # * Get Post Equip Parameter Drawing Color
  3187.   #     old_value : parameter before equipment change
  3188.   #     new_value : parameter after equipment change
  3189.   #--------------------------------------------------------------------------
  3190.   def new_parameter_color(old_value, new_value)
  3191.     if new_value > old_value      # Get stronger
  3192.       return power_up_color
  3193.     elsif new_value == old_value  # No change
  3194.       return normal_color
  3195.     else                          # Get weaker
  3196.       return power_down_color
  3197.     end
  3198.   end
  3199.   #--------------------------------------------------------------------------
  3200.   # * Draw Parameters
  3201.   #     x    : draw spot x-coordinate
  3202.   #     y    : draw spot y-coordinate
  3203.   #     type : type of parameter (0 - 3)
  3204.   #--------------------------------------------------------------------------
  3205.   def draw_parameter(x, y, type)
  3206.     case type
  3207.     when 0
  3208.       name = Vocab::atk
  3209.       value = @actor.atk
  3210.       new_value = @new_atk
  3211.     when 1
  3212.       name = Vocab::def
  3213.       value = @actor.def
  3214.       new_value = @new_def
  3215.     when 2
  3216.       name = Vocab::spi
  3217.       value = @actor.spi
  3218.       new_value = @new_spi
  3219.     when 3
  3220.       name = Vocab::agi
  3221.       value = @actor.agi
  3222.       new_value = @new_agi
  3223.     end
  3224.     self.contents.font.color = system_color
  3225.     self.contents.draw_text(x + 4, y, 80, WLH, name)
  3226.     self.contents.font.color = normal_color
  3227.     self.contents.draw_text(x + 50, y, 30, WLH, value, 2)
  3228.     self.contents.font.color = system_color
  3229.  
  3230.  
  3231.     stat_icons_positive = [120, 121, 122, 123]
  3232.     stat_icons_negative = [124, 125, 126, 127]    
  3233.     if new_value != nil    
  3234.       if new_value > value
  3235.         draw_icon(stat_icons_positive[type], x + 84, y-4, enabled = true)          
  3236.       elsif new_value < value
  3237.         draw_icon(stat_icons_negative[type], x + 84, y, enabled = true)                  
  3238.       else
  3239.         draw_equal_icon(x + 84, y-2, enabled = true)          
  3240.       end
  3241.     end    
  3242.        
  3243.     if new_value != nil
  3244.       self.contents.font.color = new_parameter_color(value, new_value)
  3245.       self.contents.draw_text(x + 110, y, 30, WLH, new_value, 2)
  3246.     end
  3247.   end
  3248.   #--------------------------------------------------------------------------
  3249.   # * Draw Actor Walking Graphic
  3250.   #     actor : actor
  3251.   #     x     : draw spot x-coordinate
  3252.   #     y     : draw spot y-coordinate
  3253.   #--------------------------------------------------------------------------
  3254.   def draw_actor_graphic(actor, x, y)
  3255.     character_name = actor.character_name
  3256.     bitmap = Cache.character(character_name)
  3257.     sign = character_name[/^[\!\$]./]
  3258.     if sign != nil and sign.include?('$')
  3259.       cw = bitmap.width / 3
  3260.       ch = bitmap.height / 4
  3261.     else
  3262.       cw = bitmap.width / 12
  3263.       ch = bitmap.height / 8
  3264.     end
  3265.     n = actor.character_index
  3266.     src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)    
  3267.     dest_rect = Rect.new(x, y, 80, 80)    
  3268.     dest_rect = Rect.new(x, y, 65, 65)    
  3269.     self.contents.stretch_blt(dest_rect, bitmap, src_rect)
  3270.   end
  3271.   #--------------------------------------------------------------------------
  3272.   # * Draw Equal Icon
  3273.   #     x     : draw spot x-coordinate
  3274.   #     y     : draw spot y-coordinate
  3275.   #     enabled    : Enabled flag. When false, draw semi-transparently.
  3276.   #--------------------------------------------------------------------------
  3277.   def draw_equal_icon(x, y, enabled = true)    
  3278.     bitmap = Cache.system("Equal Icon")
  3279.     rect = Rect.new(0, 0, 24, 24)
  3280.     self.contents.blt(x, y, bitmap, rect, enabled ? 255 : 128)
  3281.   end  
  3282.   #--------------------------------------------------------------------------
  3283.   # * Draw Name
  3284.   #     actor : actor
  3285.   #     x     : draw spot x-coordinate
  3286.   #     y     : draw spot y-coordinate
  3287.   #--------------------------------------------------------------------------
  3288.   def draw_actor_name(actor, x, y)
  3289.     self.contents.font.color = hp_color(actor)
  3290.     self.contents.draw_text(x, y, 75, WLH, actor.name)
  3291.   end    
  3292.   #--------------------------------------------------------------------------
  3293.   # * Draw Level
  3294.   #     actor : actor
  3295.   #     x     : draw spot x-coordinate
  3296.   #     y     : draw spot y-coordinate
  3297.   #--------------------------------------------------------------------------
  3298.   def draw_actor_level(actor, x, y)
  3299.     self.contents.font.color = system_color
  3300.     self.contents.draw_text(x, y, 32, WLH, Vocab::level_a)
  3301.     self.contents.font.color = normal_color
  3302.     self.contents.draw_text(x + 18, y, 24, WLH, actor.level, 2)
  3303.   end      
  3304. end
  3305.  
  3306. #==============================================================================
  3307. # ** Scene_File
  3308. #------------------------------------------------------------------------------
  3309. #  This class performs the save and load screen processing.
  3310. #==============================================================================
  3311.  
  3312. class Scene_File < Scene_Base
  3313.   #--------------------------------------------------------------------------
  3314.   # * Object Initialization
  3315.   #     saving       : save flag (if false, load screen)
  3316.   #     from_title   : flag: it was called from "Continue" on the title screen
  3317.   #     from_event   : flag: it was called from the "Call Save Screen" event
  3318.   #     return_index : value index when returning to the scene  
  3319.   #--------------------------------------------------------------------------
  3320.   def initialize(saving, from_title, from_event, return_index = nil)
  3321.     @saving = saving
  3322.     @from_title = from_title
  3323.     @from_event = from_event
  3324.     @return_index = return_index
  3325.     @updating_exit = false        
  3326.   end
  3327.   #--------------------------------------------------------------------------
  3328.   # * Start processing
  3329.   #--------------------------------------------------------------------------
  3330.   def start
  3331.     super    
  3332.     # Create Menu Back Sprite
  3333.     @menuback_sprite = Sprite.new
  3334.     @menuback_sprite.bitmap = Cache.system("Lufia Menu Back")        
  3335.     if @saving == false
  3336.       load_database                     # Load databasee
  3337.     else
  3338.       # Create Scene Header
  3339.       @scene_header = Window_Base.new(18, 32, 140, 56)
  3340.       @scene_header.windowskin = Cache.system("TDS-Lufia Window")      
  3341.       @scene_header.back_opacity = 255
  3342.       @scene_header.contents = Bitmap.new(140-32,56-32)
  3343.       @scene_header.contents.font.color = @scene_header.text_color(0)    
  3344.       @scene_header.contents.draw_text(0,0,140-32,56-32, "SAVE",1)                          
  3345.     end        
  3346.     create_savefile_windows    
  3347.     # Create Scene Header
  3348.     @first_save_header = Window_Base.new(137, 32, 389, 56)
  3349.     @first_save_header.windowskin = Cache.system("TDS-Lufia Window")      
  3350.     @first_save_header.back_opacity = 255
  3351.     @first_save_header.contents = Bitmap.new(140-32,56-32)
  3352.     @first_save_header.contents.font.color = @first_save_header.text_color(0)    
  3353.     @first_save_header.contents.draw_text(0,0,140-32,56-32, "Game Saved.",0)                          
  3354.     @first_save_header.visible = false        
  3355.     if @saving
  3356.       @index = $game_temp.last_file_index
  3357.     else
  3358.       @index = self.latest_file_index
  3359.     end    
  3360.     if @return_index != nil
  3361.       @index = @return_index
  3362.     end    
  3363.     @savefile_windows[@index].selected = true
  3364.   end
  3365.   #--------------------------------------------------------------------------
  3366.   # * Load Database
  3367.   #--------------------------------------------------------------------------
  3368.   def load_database
  3369.     $data_actors        = load_data("Data/Actors.rvdata")
  3370.     $data_classes       = load_data("Data/Classes.rvdata")
  3371.     $data_skills        = load_data("Data/Skills.rvdata")
  3372.     $data_items         = load_data("Data/Items.rvdata")
  3373.     $data_weapons       = load_data("Data/Weapons.rvdata")
  3374.     $data_armors        = load_data("Data/Armors.rvdata")
  3375.     $data_enemies       = load_data("Data/Enemies.rvdata")
  3376.     $data_troops        = load_data("Data/Troops.rvdata")
  3377.     $data_states        = load_data("Data/States.rvdata")
  3378.     $data_animations    = load_data("Data/Animations.rvdata")
  3379.     $data_common_events = load_data("Data/CommonEvents.rvdata")
  3380.     $data_system        = load_data("Data/System.rvdata")
  3381.     $data_areas         = load_data("Data/Areas.rvdata")
  3382.   end  
  3383.   #--------------------------------------------------------------------------
  3384.   # * Command: New Game
  3385.   #--------------------------------------------------------------------------
  3386.   def command_new_game
  3387.     confirm_player_location
  3388.     Sound.play_decision
  3389.     $game_party.setup_starting_members            # Initial party
  3390.     $game_map.setup($data_system.start_map_id)    # Initial map position
  3391.     $game_player.moveto($data_system.start_x, $data_system.start_y)
  3392.     $game_player.refresh
  3393.     $scene = Scene_Map.new
  3394.     RPG::BGM.fade(1500)
  3395.     Graphics.fadeout(60)
  3396.     Graphics.wait(40)
  3397.     Graphics.frame_count = 0
  3398.     RPG::BGM.stop
  3399.     $game_map.autoplay
  3400.   end
  3401.   #--------------------------------------------------------------------------
  3402.   # * Check Player Start Location Existence
  3403.   #--------------------------------------------------------------------------
  3404.   def confirm_player_location
  3405.     if $data_system.start_map_id == 0
  3406.       print "Player start location not set."
  3407.       exit
  3408.     end
  3409.   end  
  3410.   #--------------------------------------------------------------------------
  3411.   # * Termination Processing
  3412.   #--------------------------------------------------------------------------
  3413.   def terminate
  3414.     super
  3415.     dispose_item_windows
  3416.     if @saving == true
  3417.       @scene_header.dispose
  3418.     end    
  3419.     @menuback_sprite.dispose
  3420.     @menuback_sprite.bitmap.dispose                
  3421.     @first_save_header.dispose
  3422.   end
  3423.   #--------------------------------------------------------------------------
  3424.   # * Return to Original Screen
  3425.   #--------------------------------------------------------------------------
  3426.   def return_scene    
  3427.     if @from_event
  3428.       $scene = Scene_Map.new
  3429.     else
  3430.       if @saving == true
  3431.         $scene = Scene_Menu.new(5)
  3432.       end
  3433.     end    
  3434.   end
  3435.   #--------------------------------------------------------------------------
  3436.   # * Frame Update
  3437.   #--------------------------------------------------------------------------
  3438.   def update
  3439.     super
  3440.  
  3441.     update_savefile_windows    
  3442.     if @updating_exit
  3443.       updating_first_time_save_exit      
  3444.       return
  3445.     end
  3446.     update_savefile_selection    
  3447.   end
  3448.   #--------------------------------------------------------------------------
  3449.   # * Create Save File Window
  3450.   #--------------------------------------------------------------------------
  3451.   def create_savefile_windows
  3452.     @savefile_windows = []
  3453.     for i in 0..4      
  3454.       next if @saving == true and i == 0
  3455.       @savefile_windows.push(Window_SaveFile.new(i, "Save#{i}.rvdata"))      
  3456.     end
  3457.     @item_max = (@saving == true ? 4 : 5 )
  3458.   end  
  3459.   #--------------------------------------------------------------------------
  3460.   # * Dispose of Save File Window
  3461.   #--------------------------------------------------------------------------
  3462.   def dispose_item_windows
  3463.     for window in @savefile_windows
  3464.       window.dispose
  3465.     end
  3466.   end
  3467.   #--------------------------------------------------------------------------
  3468.   # * Update Save File Window
  3469.   #--------------------------------------------------------------------------
  3470.   def update_savefile_windows
  3471.     for window in @savefile_windows
  3472.       window.update
  3473.       window.update_cursor_graphic    
  3474.       window.update_cursor_animation
  3475.     end
  3476.   end
  3477.   #--------------------------------------------------------------------------
  3478.   # * Update Save File Selection
  3479.   #--------------------------------------------------------------------------
  3480.   def update_savefile_selection
  3481.     if Input.trigger?(Input::C)
  3482.       determine_savefile
  3483.       elsif Input.trigger?(Input::B)
  3484.       if @saving == false
  3485.         return      
  3486.       end      
  3487.       Sound.play_cancel
  3488.       return_scene
  3489.     else
  3490.       last_index = @index
  3491.      
  3492.      
  3493.       return if @updating_exit
  3494.      
  3495.       if Input.repeat?(Input::DOWN)
  3496.         cursor_down(Input.trigger?(Input::DOWN))
  3497.       end
  3498.       if Input.repeat?(Input::UP)
  3499.         cursor_up(Input.trigger?(Input::UP))
  3500.       end
  3501.      
  3502.       if Input.repeat?(Input::LEFT)
  3503.         cursor_up(Input.trigger?(Input::LEFT))
  3504.       end      
  3505.      
  3506.       if Input.repeat?(Input::RIGHT)
  3507.         cursor_down(Input.trigger?(Input::RIGHT))
  3508.       end
  3509.      
  3510.       if @index != last_index
  3511.         Sound.play_cursor
  3512.         @savefile_windows[last_index].selected = false
  3513.         @savefile_windows[@index].selected = true                
  3514.       end
  3515.     end
  3516.   end  
  3517.   #--------------------------------------------------------------------------
  3518.   # * Updating first time save exit
  3519.   #--------------------------------------------------------------------------
  3520.   def updating_first_time_save_exit    
  3521.     # Exit frame count
  3522.     @frames = 0 if @frames == nil    
  3523.     @frames += 1 if @frames < 70    
  3524.     if @frames == 70
  3525.       return_scene      
  3526.     end    
  3527.   end
  3528.   #--------------------------------------------------------------------------
  3529.   # * Confirm Save File
  3530.   #--------------------------------------------------------------------------
  3531.   def determine_savefile
  3532.     if @saving
  3533.       if @savefile_windows[@index].file_exist == false
  3534.         @first_save_header.visible = true
  3535.         Sound.play_save
  3536.         do_save
  3537.       else
  3538.         Sound.play_decision        
  3539.         $scene = Scene_File_II.new(@savefile_windows[@index].filename, @saving,
  3540.         @index, @from_event)
  3541.         return
  3542.        end
  3543.      else
  3544.       if @savefile_windows[0].selected == true
  3545.         command_new_game
  3546.         return
  3547.       end      
  3548.       if @savefile_windows[@index].file_exist
  3549.          Sound.play_decision
  3550.          $scene = Scene_File_II.new(@savefile_windows[@index].filename, @saving,
  3551.          @index, @from_event)  
  3552.       else
  3553.         Sound.play_buzzer
  3554.         return
  3555.       end
  3556.     end
  3557.     $game_temp.last_file_index = @index
  3558.   end
  3559.   #--------------------------------------------------------------------------
  3560.   # * Move cursor down
  3561.   #     wrap : Wraparound allowed
  3562.   #--------------------------------------------------------------------------
  3563.   def cursor_down(wrap)
  3564.     if @index < @item_max - 1 or wrap
  3565.       @index = (@index + 1) % @item_max
  3566.     end
  3567.   end
  3568.   #--------------------------------------------------------------------------
  3569.   # * Move cursor up
  3570.   #     wrap : Wraparound allowed
  3571.   #--------------------------------------------------------------------------
  3572.   def cursor_up(wrap)
  3573.     if @index > 0 or wrap
  3574.       @index = (@index - 1 + @item_max) % @item_max
  3575.     end
  3576.   end
  3577.   #--------------------------------------------------------------------------
  3578.   # * Create Filename
  3579.   #     file_index : save file index (0-4)
  3580.   #--------------------------------------------------------------------------
  3581.   def make_filename(file_index)
  3582.     return if file_index == 0
  3583.     return "Save#{file_index}.rvdata"
  3584.   end
  3585.   #--------------------------------------------------------------------------
  3586.   # * Select File With Newest Timestamp
  3587.   #--------------------------------------------------------------------------
  3588.   def latest_file_index
  3589.     index = 0
  3590.     latest_time = Time.at(0)
  3591.     for i in 1...@savefile_windows.size
  3592.       if @savefile_windows[i].time_stamp > latest_time
  3593.         latest_time = @savefile_windows[i].time_stamp
  3594.         index = i
  3595.       end
  3596.     end
  3597.     return index
  3598.   end
  3599.   #--------------------------------------------------------------------------
  3600.   # * Execute Save
  3601.   #--------------------------------------------------------------------------
  3602.   def do_save
  3603.     file = File.open(@savefile_windows[@index].filename, "wb")
  3604.     write_save_data(file)
  3605.     file.close
  3606.     @savefile_windows[@index].redraw_new_save_infofmation
  3607.     @updating_exit = true  
  3608.     return    
  3609.   end
  3610.   #--------------------------------------------------------------------------
  3611.   # * Write Save Data
  3612.   #     file : write file object (opened)
  3613.   #--------------------------------------------------------------------------
  3614.   def write_save_data(file)
  3615.     characters = []
  3616.     for actor in $game_party.members
  3617.       characters.push([actor.character_name, actor.character_index])
  3618.     end
  3619.     $game_system.save_count += 1
  3620.     $game_system.version_id = $data_system.version_id
  3621.     @last_bgm = RPG::BGM::last
  3622.     @last_bgs = RPG::BGS::last
  3623.     Marshal.dump(characters,           file)
  3624.     Marshal.dump(Graphics.frame_count, file)
  3625.     Marshal.dump(@last_bgm,            file)
  3626.     Marshal.dump(@last_bgs,            file)
  3627.     Marshal.dump($game_system,         file)
  3628.     Marshal.dump($game_message,        file)
  3629.     Marshal.dump($game_switches,       file)
  3630.     Marshal.dump($game_variables,      file)
  3631.     Marshal.dump($game_self_switches,  file)
  3632.     Marshal.dump($game_actors,         file)
  3633.     Marshal.dump($game_party,          file)
  3634.     Marshal.dump($game_troop,          file)
  3635.     Marshal.dump($game_map,            file)
  3636.     Marshal.dump($game_player,         file)
  3637.   end
  3638.   #--------------------------------------------------------------------------
  3639.   # * Read Save Data
  3640.   #     file : file object for reading (opened)
  3641.   #--------------------------------------------------------------------------
  3642.   def read_save_data(file)
  3643.     characters           = Marshal.load(file)
  3644.     Graphics.frame_count = Marshal.load(file)
  3645.     @last_bgm            = Marshal.load(file)
  3646.     @last_bgs            = Marshal.load(file)
  3647.     $game_system         = Marshal.load(file)
  3648.     $game_message        = Marshal.load(file)
  3649.     $game_switches       = Marshal.load(file)
  3650.     $game_variables      = Marshal.load(file)
  3651.     $game_self_switches  = Marshal.load(file)
  3652.     $game_actors         = Marshal.load(file)
  3653.     $game_party          = Marshal.load(file)
  3654.     $game_troop          = Marshal.load(file)
  3655.     $game_map            = Marshal.load(file)
  3656.     $game_player         = Marshal.load(file)
  3657.     if $game_system.version_id != $data_system.version_id
  3658.       $game_map.setup($game_map.map_id)
  3659.       $game_player.center($game_player.x, $game_player.y)
  3660.     end
  3661.   end
  3662. end
  3663.  
  3664. #==============================================================================
  3665. # ** Scene_File_II
  3666. #------------------------------------------------------------------------------
  3667. #  This class performs the save and load screen processing when rewriting.
  3668. #==============================================================================
  3669.  
  3670. class Scene_File_II < Scene_Base
  3671.   #--------------------------------------------------------------------------
  3672.   # * Object Initialization
  3673.   #     file          : Save file to load data from
  3674.   #     saving        : save flag (if false, load screen)
  3675.   #     return_index  : index to return
  3676.   #--------------------------------------------------------------------------
  3677.   def initialize(file, saving, return_index, from_event)    
  3678.     @file = file
  3679.     @saving = saving
  3680.     @return_index = return_index  
  3681.     @from_event = from_event
  3682.     load_saved_game_data(@file)
  3683.   end
  3684.   #--------------------------------------------------------------------------
  3685.   # * Start processing
  3686.   #--------------------------------------------------------------------------
  3687.   def start
  3688.     # Create Menu Back Sprite
  3689.     @menuback_sprite = Sprite.new
  3690.     @menuback_sprite.bitmap = Cache.system("Lufia Menu Back")        
  3691.     # Create Status window
  3692.     @status_window = Window_File_MenuStatus.new(0, 0, @game_party)    
  3693.     @status_window.active = false        
  3694.     # Get map information
  3695.     map_info = load_data("Data/MapInfos.rvdata")
  3696.     # Get map name
  3697.     map_name = map_info[@game_map.map_id].name        
  3698.     # Create map name window header
  3699.     @map_name_header = Window_Base.new(18, 198, 505, 76)
  3700.     @map_name_header.windowskin = Cache.system("TDS-Lufia Window")      
  3701.     @map_name_header.back_opacity = 255
  3702.     @map_name_header.contents = Bitmap.new(505-32, 76-32)
  3703.     @map_name_header.contents.font.size = 37
  3704.     @map_name_header.contents.font.color = @map_name_header.text_color(0)    
  3705.     @map_name_header.contents.draw_text(18, 7 , 505-32, 37, map_name.to_s, 0)                        
  3706.     # Create dummy command window header
  3707.     @dummy_command_window_header = Window_Base.new(358, 274, 165, 135)
  3708.     @dummy_command_window_header.windowskin = Cache.system("TDS-Lufia Window")      
  3709.     @dummy_command_window_header.back_opacity = 255
  3710.     @dummy_command_window_header.contents = Bitmap.new(180-32, 130-32)
  3711.     @dummy_command_window_header.contents.font.size = 20
  3712.     @dummy_command_window_header.contents.font.color = @dummy_command_window_header.text_color(0)    
  3713.     if @saving == true
  3714.       @dummy_command_window_header.contents.draw_text(3, 0 , 165-32, 24, "Save over this")                        
  3715.       @dummy_command_window_header.contents.draw_text(3, 24 , 165-32, 24, "file?")                                  
  3716.     else    
  3717.       @dummy_command_window_header.contents.draw_text(3, 0 , 165-32, 24, "Start the game")                        
  3718.       @dummy_command_window_header.contents.draw_text(3, 24 , 165-32, 24, "from this file?")                              
  3719.     end        
  3720.     @dummy_command_window_header.contents.font.size = 25        
  3721.     # Create command window
  3722.     @command_window = TDS_Window_Command.new(165, ["YES", "NO"])    
  3723.     @command_window.x = 370
  3724.     @command_window.y = 332    
  3725.     @command_window.opacity = 0
  3726.     # Create gold & time window
  3727.     @gold_time_header = Window_Base.new(18, 274, 340, 78)
  3728.     @gold_time_header.windowskin = Cache.system("TDS-Lufia Window")      
  3729.     @gold_time_header.back_opacity = 255
  3730.     @gold_time_header.contents = Bitmap.new(340-32, 78-32)
  3731.     @gold_time_header.contents.font.size = 25
  3732.     @gold_time_header.contents.font.color = @gold_time_header.text_color(0)        
  3733.     @gold_time_header.contents.draw_text(18, 0, 340-32, 24, "TIME", 0)                            
  3734.     @gold_time_header.contents.draw_text(18, 24 , 340-32, 24, "GOLD", 0)                                    
  3735.     @gold_time_header.contents.draw_text(18, 24 , 300-32, 24, @game_party.gold , 2)                                    
  3736.     # Calculate playtime
  3737.     total_sec = Graphics.frame_count / Graphics.frame_rate    
  3738.     hour = total_sec / 60 / 60
  3739.     min = total_sec / 60 % 60
  3740.     sec = total_sec % 60
  3741.     time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  3742.     @gold_time_header.contents.draw_text(18, 0 , 300-32, 24, time_string , 2)                                        
  3743.     # Create save cofirmation header
  3744.     @save_confirmation_header = Window_Base.new(18, 352, 340, 57)
  3745.     @save_confirmation_header.windowskin = Cache.system("TDS-Lufia Window")      
  3746.     @save_confirmation_header.back_opacity = 255
  3747.     @save_confirmation_header.contents = Bitmap.new(340-32, 78-32)
  3748.     @save_confirmation_header.contents.font.size = 25
  3749.     @save_confirmation_header.contents.font.color = @save_confirmation_header.text_color(0)        
  3750.     @save_confirmation_header.contents.draw_text(18, 0, 340-32, 24, "Game saved.", 0)                            
  3751.     @save_confirmation_header.visible = false        
  3752.     # Save process flag
  3753.     @saving_process = false
  3754.   end
  3755.   #--------------------------------------------------------------------------
  3756.   # * Load Saved Game Data
  3757.   #     file : Save file to load data from  
  3758.   #--------------------------------------------------------------------------
  3759.   def load_saved_game_data(file = nil)
  3760.     filename = file
  3761.     file = File.open(filename, "r")        
  3762.     @characters          = Marshal.load(file)
  3763.     Graphics.frame_count = Marshal.load(file)
  3764.     @last_bgm            = Marshal.load(file)
  3765.     @last_bgs            = Marshal.load(file)
  3766.     @game_system         = Marshal.load(file)
  3767.     @game_message        = Marshal.load(file)
  3768.     @game_switches       = Marshal.load(file)
  3769.     @game_variables      = Marshal.load(file)
  3770.     @game_self_switches  = Marshal.load(file)
  3771.     @game_actors         = Marshal.load(file)
  3772.     @game_party          = Marshal.load(file)
  3773.     @game_troop          = Marshal.load(file)
  3774.     @game_map            = Marshal.load(file)
  3775.     @game_player         = Marshal.load(file)
  3776.     return    
  3777.   end
  3778.   #--------------------------------------------------------------------------
  3779.   # * Frame Update
  3780.   #--------------------------------------------------------------------------
  3781.   def update
  3782.     # Update command window
  3783.     @command_window.update    
  3784.     # If saving process flag is true
  3785.     if @saving_process
  3786.       update_save_process
  3787.       return
  3788.     end        
  3789.     # If input trigger cancel
  3790.     if Input.trigger?(Input::B)
  3791.       Sound.play_cancel        
  3792.       $scene = Scene_File.new(@saving, false, false, @return_index)                
  3793.       return      
  3794.     end    
  3795.    
  3796.     # If input is confirm
  3797.     if Input.trigger?(Input::C)
  3798.       case @command_window.index
  3799.       when 0
  3800.         if @saving
  3801.           Sound.play_save          
  3802.           @command_window.active = false          
  3803.           @save_confirmation_header.visible = true
  3804.           @saving_process = true
  3805.           $game_temp.last_file_index          
  3806.           return          
  3807.         else
  3808.           Sound.play_load          
  3809.           @command_window.active = false                    
  3810.           do_load          
  3811.           return
  3812.         end
  3813.       when 1        
  3814.         Sound.play_cancel        
  3815.         $scene = Scene_File.new(@saving, false, false, @return_index)                
  3816.         return
  3817.       end
  3818.     end    
  3819.   end
  3820.   #--------------------------------------------------------------------------
  3821.   # * Update save process
  3822.   #--------------------------------------------------------------------------
  3823.   def update_save_process
  3824.     # Exit frame count
  3825.     @frames = 0 if @frames == nil    
  3826.     @frames += 1 if @frames < 70    
  3827.     if @frames == 70
  3828.       do_save
  3829.     end    
  3830.   end  
  3831.   #--------------------------------------------------------------------------
  3832.   # * Execute Load
  3833.   #--------------------------------------------------------------------------
  3834.   def do_load
  3835.     file = File.open(@file, "rb")
  3836.     read_save_data(file)
  3837.     file.close
  3838.     $scene = Scene_Map.new
  3839.     RPG::BGM.fade(1500)
  3840.     Graphics.fadeout(60)
  3841.     Graphics.wait(40)
  3842.     @last_bgm.play
  3843.     @last_bgs.play
  3844.   end  
  3845.   #--------------------------------------------------------------------------
  3846.   # * Execute Save
  3847.   #--------------------------------------------------------------------------
  3848.   def do_save
  3849.     file = File.open(@file, "wb")
  3850.     write_save_data(file)
  3851.     file.close    
  3852.     if @from_event
  3853.       $scene = Scene_Map.new
  3854.     else
  3855.       $scene = Scene_Menu.new(5)
  3856.     end        
  3857.     return    
  3858.   end
  3859.   #--------------------------------------------------------------------------
  3860.   # * Write Save Data
  3861.   #     file : write file object (opened)
  3862.   #--------------------------------------------------------------------------
  3863.   def write_save_data(file)
  3864.     characters = []
  3865.     for actor in $game_party.members
  3866.       characters.push([actor.character_name, actor.character_index])
  3867.     end
  3868.     $game_system.save_count += 1
  3869.     $game_system.version_id = $data_system.version_id
  3870.     @last_bgm = RPG::BGM::last
  3871.     @last_bgs = RPG::BGS::last
  3872.     Marshal.dump(characters,           file)
  3873.     Marshal.dump(Graphics.frame_count, file)
  3874.     Marshal.dump(@last_bgm,            file)
  3875.     Marshal.dump(@last_bgs,            file)
  3876.     Marshal.dump($game_system,         file)
  3877.     Marshal.dump($game_message,        file)
  3878.     Marshal.dump($game_switches,       file)
  3879.     Marshal.dump($game_variables,      file)
  3880.     Marshal.dump($game_self_switches,  file)
  3881.     Marshal.dump($game_actors,         file)
  3882.     Marshal.dump($game_party,          file)
  3883.     Marshal.dump($game_troop,          file)
  3884.     Marshal.dump($game_map,            file)
  3885.     Marshal.dump($game_player,         file)
  3886.   end
  3887.   #--------------------------------------------------------------------------
  3888.   # * Read Save Data
  3889.   #     file : file object for reading (opened)
  3890.   #--------------------------------------------------------------------------
  3891.   def read_save_data(file)
  3892.     characters           = Marshal.load(file)
  3893.     Graphics.frame_count = Marshal.load(file)
  3894.     @last_bgm            = Marshal.load(file)
  3895.     @last_bgs            = Marshal.load(file)
  3896.     $game_system         = Marshal.load(file)
  3897.     $game_message        = Marshal.load(file)
  3898.     $game_switches       = Marshal.load(file)
  3899.     $game_variables      = Marshal.load(file)
  3900.     $game_self_switches  = Marshal.load(file)
  3901.     $game_actors         = Marshal.load(file)
  3902.     $game_party          = Marshal.load(file)
  3903.     $game_troop          = Marshal.load(file)
  3904.     $game_map            = Marshal.load(file)
  3905.     $game_player         = Marshal.load(file)
  3906.     if $game_system.version_id != $data_system.version_id
  3907.       $game_map.setup($game_map.map_id)
  3908.       $game_player.center($game_player.x, $game_player.y)
  3909.     end
  3910.   end
  3911.   #--------------------------------------------------------------------------
  3912.   # * Termination Processing
  3913.   #--------------------------------------------------------------------------
  3914.   def terminate
  3915.     @menuback_sprite.dispose
  3916.     @menuback_sprite.bitmap.dispose              
  3917.     @status_window.dispose      
  3918.     @map_name_header.dispose
  3919.     @dummy_command_window_header.dispose
  3920.     @command_window.dispose    
  3921.     @gold_time_header.dispose    
  3922.     @save_confirmation_header.dispose
  3923.   end
  3924. end
  3925.  
  3926. #==============================================================================
  3927. # ** Window_File_MenuStatus
  3928. #------------------------------------------------------------------------------
  3929. #  This window displays party member status on the save and load screen.
  3930. #==============================================================================
  3931.  
  3932. class Window_File_MenuStatus < Window_Base
  3933.   #--------------------------------------------------------------------------
  3934.   # * Object Initialization
  3935.   #     x : window X coordinate
  3936.   #     y : window Y coordinate
  3937.   #--------------------------------------------------------------------------
  3938.   def initialize(x, y, party_data)
  3939.     super(x, y, 544, 416)    
  3940.     self.active = false
  3941.     self.contents.font.size = 18                
  3942.     self.opacity = 0
  3943.     @party_data = party_data
  3944.     @column_max = 2
  3945.     refresh
  3946.   end
  3947.   #--------------------------------------------------------------------------
  3948.   # * Refresh
  3949.   #--------------------------------------------------------------------------
  3950.   def refresh
  3951.     self.contents.clear    
  3952.     @item_max = @party_data.members.size    
  3953.     for actor in @party_data.members      
  3954.       actor_index = @party_data.members.index(actor)
  3955.       y = 0
  3956.       if actor_index > 1      
  3957.         x = 260
  3958.         draw_actor_graphic(actor, 19 + actor_index * x - actor_index - @column_max * x, 90)      
  3959.         draw_actor_name(actor, 96 + actor_index * x - actor_index - @column_max * x, 90)                  
  3960.         draw_actor_hp(actor, 96 + actor_index * x - actor_index - @column_max * x, y + 84 + WLH * 1 , 120, true)
  3961.         draw_actor_mp(actor, 96 + actor_index * x - actor_index - @column_max * x, y + 84 + WLH * 2 , 120, true)
  3962.         draw_actor_level(actor, 174 + actor_index * x - actor_index - @column_max * x, 90)                      
  3963.       else
  3964.         x = 260
  3965.         draw_actor_graphic(actor, 20 + actor_index * x, 8)          
  3966.         draw_actor_name(actor, 96 + actor_index * x, 10)          
  3967.         draw_actor_hp(actor, 96 + actor_index * x, y + WLH * 1 + 4, 120, true)
  3968.         draw_actor_mp(actor, 96 + actor_index * x, y + WLH * 2 + 4, 120, true)
  3969.         draw_actor_level(actor, 174  + actor_index * x, 10)                  
  3970.       end
  3971.         x = actor_index * 96 + WLH / 2
  3972.         y = 0      
  3973.     end    
  3974.   end  
  3975.   #--------------------------------------------------------------------------
  3976.   # * Draw Level
  3977.   #     actor : actor
  3978.   #     x     : draw spot x-coordinate
  3979.   #     y     : draw spot y-coordinate
  3980.   #--------------------------------------------------------------------------
  3981.   def draw_actor_level(actor, x, y)
  3982.     self.contents.font.color = system_color
  3983.     self.contents.draw_text(x, y, 32, WLH, Vocab::level_a)
  3984.     self.contents.font.color = normal_color
  3985.     self.contents.draw_text(x + 18, y, 24, WLH, actor.level, 2)
  3986.   end  
  3987.   #--------------------------------------------------------------------------
  3988.   # * Draw Actor Walking Graphic
  3989.   #     actor : actor
  3990.   #     x     : draw spot x-coordinate
  3991.   #     y     : draw spot y-coordinate
  3992.   #--------------------------------------------------------------------------
  3993.   def draw_actor_graphic(actor, x, y)
  3994.     character_name = actor.character_name
  3995.     bitmap = Cache.character(character_name)
  3996.     sign = character_name[/^[\!\$]./]
  3997.     if sign != nil and sign.include?('$')
  3998.       cw = bitmap.width / 3
  3999.       ch = bitmap.height / 4
  4000.     else
  4001.       cw = bitmap.width / 12
  4002.       ch = bitmap.height / 8
  4003.     end
  4004.     n = actor.character_index
  4005.     src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)    
  4006.     dest_rect = Rect.new(x, y, 80, 80)    
  4007.     dest_rect = Rect.new(x, y, 65, 65)    
  4008.     self.contents.stretch_blt(dest_rect, bitmap, src_rect)
  4009.   end
  4010.   #--------------------------------------------------------------------------
  4011.   # * Draw Name
  4012.   #     actor : actor
  4013.   #     x     : draw spot x-coordinate
  4014.   #     y     : draw spot y-coordinate
  4015.   #--------------------------------------------------------------------------
  4016.   def draw_actor_name(actor, x, y)
  4017.     self.contents.font.color = hp_color(actor)
  4018.     self.contents.draw_text(x, y, 75, WLH, actor.name)
  4019.   end  
  4020. end
  4021.  
  4022. #==============================================================================
  4023. # ** Window_SaveFile
  4024. #------------------------------------------------------------------------------
  4025. #  This window displays save files on the save and load screens.
  4026. #==============================================================================
  4027.  
  4028. class Window_SaveFile < Window_Base
  4029.   #--------------------------------------------------------------------------
  4030.   # * Public Instance Variables
  4031.   #--------------------------------------------------------------------------
  4032.   attr_reader   :filename                 # filename
  4033.   attr_reader   :file_exist               # file existence flag
  4034.   attr_reader   :time_stamp               # timestamp
  4035.   attr_reader   :selected                 # selected
  4036.   #--------------------------------------------------------------------------
  4037.   # * Object Initialization
  4038.   #     file_index : save file index (0-3)
  4039.   #     filename   : filename
  4040.   #--------------------------------------------------------------------------
  4041.   def initialize(file_index, filename, saving = false)
  4042.     window_values = [
  4043.     # Start
  4044.     values = [18, 32, 140, 56 ],
  4045.     # Save files
  4046.     values = [18, 88, 254, 160 ],        
  4047.     values = [272, 88, 254, 160 ],  
  4048.     values = [18, 248, 254, 160 ],
  4049.     values = [272, 248, 254, 160 ],            
  4050.     ]
  4051.    
  4052.     v_x = window_values[file_index][0]
  4053.     v_y = window_values[file_index][1]
  4054.     v_height = window_values[file_index][2]    
  4055.     v_width = window_values[file_index][3]          
  4056.     super(v_x, v_y, v_height, v_width)            
  4057.     self.windowskin = Cache.system("TDS-Lufia Window")  
  4058.     self.back_opacity = 255        
  4059.     create_custom_cursor    
  4060.     @file_index = file_index
  4061.     @filename = filename
  4062.     @saving = saving
  4063.     load_gamedata
  4064.     refresh
  4065.     @selected = false
  4066.    
  4067. #    self.visible = false
  4068.   end
  4069.   #--------------------------------------------------------------------------
  4070.   # * Load Partial Game Data
  4071.   #    By default, switches and variables are not used (for expansion use,
  4072.   #    such as displaying place names)
  4073.   #--------------------------------------------------------------------------
  4074.   def load_gamedata
  4075.     @time_stamp = Time.at(0)
  4076.     @file_exist = FileTest.exist?(@filename)
  4077.     if @file_exist
  4078.       file = File.open(@filename, "r")
  4079.       @time_stamp = file.mtime
  4080.       begin
  4081.         @characters     = Marshal.load(file)
  4082.         @frame_count    = Marshal.load(file)
  4083.         @last_bgm       = Marshal.load(file)
  4084.         @last_bgs       = Marshal.load(file)
  4085.         @game_system    = Marshal.load(file)
  4086.         @game_message   = Marshal.load(file)
  4087.         @game_switches  = Marshal.load(file)
  4088.         @game_variables = Marshal.load(file)        
  4089.         # Reads self switches
  4090.         Marshal.load(file)
  4091.         @game_actors = Marshal.load(file)                      
  4092.         @game_party = Marshal.load(file)
  4093.         Marshal.load(file)
  4094.         @total_sec = @frame_count / Graphics.frame_rate        
  4095.       rescue
  4096.         @file_exist = false
  4097.       ensure
  4098.         file.close
  4099.       end
  4100.     end
  4101.   end
  4102.   #--------------------------------------------------------------------------
  4103.   # * Refresh
  4104.   #--------------------------------------------------------------------------
  4105.   def refresh
  4106.     self.contents.clear
  4107.     self.contents.font.color = normal_color
  4108.     if @file_index == 0
  4109.       name = "    START    "      
  4110.       self.contents.draw_text(4, 0, 200, WLH, name)      
  4111.     end    
  4112.     if @file_exist == false and @file_index != 0
  4113.       self.contents.draw_text(30, 0, 200, WLH, "FREE")            
  4114.     end    
  4115.     @name_width = contents.text_size(name).width
  4116.     if @file_exist      
  4117.       draw_party_characters(35, 105)            
  4118.       draw_playtime(-35, 34, contents.width - 4, 2)
  4119.       draw_party_leader_name(30, 0)      
  4120.     end
  4121.   end
  4122.  
  4123.   #--------------------------------------------------------------------------
  4124.   # * Redraw New Save Information
  4125.   #--------------------------------------------------------------------------
  4126.   def redraw_new_save_infofmation
  4127.     self.contents.clear
  4128.     self.contents.font.color = normal_color
  4129.  
  4130.     @time_stamp = Time.at(0)
  4131.     @file_exist = FileTest.exist?(@filename)
  4132.     if @file_exist
  4133.       file = File.open(@filename, "r")
  4134.       @time_stamp = file.mtime
  4135.       begin
  4136.         @characters     = Marshal.load(file)
  4137.         @frame_count    = Marshal.load(file)
  4138.         @last_bgm       = Marshal.load(file)
  4139.         @last_bgs       = Marshal.load(file)
  4140.         @game_system    = Marshal.load(file)
  4141.         @game_message   = Marshal.load(file)
  4142.         @game_switches  = Marshal.load(file)
  4143.         @game_variables = Marshal.load(file)        
  4144.         # Reads self switches
  4145.         Marshal.load(file)
  4146.         @game_actors = Marshal.load(file)                      
  4147.         @game_party = Marshal.load(file)
  4148.         Marshal.load(file)
  4149.         @total_sec = @frame_count / Graphics.frame_rate        
  4150.       rescue
  4151.         @file_exist = false
  4152.       ensure
  4153.         file.close
  4154.       end
  4155.     end  
  4156.  
  4157.  
  4158.     draw_party_characters(35, 105)            
  4159.     draw_playtime(-35, 34, contents.width - 4, 2)
  4160.     draw_party_leader_name(30, 0)      
  4161.  
  4162.   end
  4163.  
  4164.   #--------------------------------------------------------------------------
  4165.   # * Draw Party Characters
  4166.   #     x : Draw spot X coordinate
  4167.   #     y : Draw spot Y coordinate
  4168.   #--------------------------------------------------------------------------
  4169.   def draw_party_characters(x, y)
  4170.     for i in 0...@characters.size
  4171.       name = @characters[i][0]
  4172.       index = @characters[i][1]
  4173.       draw_character(name, index, x + i * 51, y)
  4174.       self.contents.font.size = 18
  4175.       self.contents.draw_text(-11 + x + i * 51, 105, 24, 24, @game_party.members[i].level, 1)          
  4176.       self.contents.font.size = 25
  4177.     end
  4178.   end  
  4179.   #--------------------------------------------------------------------------
  4180.   # * Draw Play Time
  4181.   #     x : Draw spot X coordinate
  4182.   #     y : Draw spot Y coordinate
  4183.   #     width : Width
  4184.   #     align : Alignment
  4185.   #--------------------------------------------------------------------------
  4186.   def draw_playtime(x, y, width, align)
  4187.     hour = @total_sec / 60 / 60
  4188.     min = @total_sec / 60 % 60
  4189.     sec = @total_sec % 60
  4190.     time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  4191.     self.contents.font.color = normal_color
  4192.     self.contents.draw_text(x, y, width, WLH, "TIME     " + time_string, 2)
  4193.   end
  4194.   #--------------------------------------------------------------------------
  4195.   # * Draw Party Leader Name
  4196.   #     x : Draw spot X coordinate
  4197.   #     y : Draw spot Y coordinate
  4198.   #--------------------------------------------------------------------------
  4199.   def draw_party_leader_name(x, y)
  4200.     self.contents.draw_text(x, y, 100, WLH, "NAME")        
  4201.     self.contents.draw_text(x + 77 , y, 85, WLH, @game_party.members[0].name, 0)        
  4202.   end  
  4203.   #--------------------------------------------------------------------------
  4204.   # * Set Selected
  4205.   #     selected : new selected (true = selected, false = unselected)
  4206.   #--------------------------------------------------------------------------
  4207.   def selected=(selected)
  4208.     @selected = selected
  4209.     update_cursor
  4210.   end  
  4211.   #--------------------------------------------------------------------------
  4212.   # * Dispose
  4213.   #--------------------------------------------------------------------------
  4214.   def dispose
  4215.     self.contents.dispose
  4216.     @sprite.bitmap.dispose
  4217.     @sprite.dispose    
  4218.     super
  4219.   end  
  4220.   #--------------------------------------------------------------------------
  4221.   # * Create Custom Cursor
  4222.   #--------------------------------------------------------------------------
  4223.   def create_custom_cursor
  4224.     @sprite = Sprite.new
  4225.     @sprite.bitmap = Cache.system("Cursor")
  4226.     @sprite.src_rect.width = @sprite.bitmap.width / 6            
  4227.     if @file_index == 0
  4228.       @sprite.x = self.x + 16
  4229.       @sprite.y = self.y + 16 #+ 4
  4230.     else
  4231.       @sprite.x = self.x + 16
  4232.       @sprite.y = self.y + 14 #+ 4      
  4233.     end    
  4234.     @sprite.visible = @selected
  4235.     @sprite.z = 9999      
  4236.     update_cursor_graphic                
  4237.   end        
  4238.   #--------------------------------------------------------------------------
  4239.   # * Update Cursor Graphic
  4240.   #--------------------------------------------------------------------------
  4241.   def update_cursor_graphic    
  4242.      @sprite.visible = @selected
  4243.   end  
  4244.   #--------------------------------------------------------------------------
  4245.   # * Update Cursor Animation
  4246.   #--------------------------------------------------------------------------  
  4247.   def update_cursor_animation
  4248.     @duration = -1 if @duration == nil
  4249.      if @selected  
  4250.        @duration += 1
  4251.        @duration %= 8    
  4252.       if @duration == 8 -1
  4253.         @sprite.src_rect.x += 24
  4254.         @sprite.src_rect.x %= 6 * 24
  4255.       end
  4256.     else
  4257.        @duration += 1
  4258.        @duration %= 8
  4259.       if @duration == 8 - 1
  4260.         @sprite.src_rect.x -= 24
  4261.         @sprite.src_rect.x %= 7 * 24
  4262.       end            
  4263.     end        
  4264.   end  
  4265.   #--------------------------------------------------------------------------
  4266.   # * Update cursor
  4267.   #--------------------------------------------------------------------------
  4268.   def update_cursor
  4269.     if @selected
  4270.       self.cursor_rect.set(0, 0, @name_width + 8, WLH)
  4271.       update_cursor_graphic        
  4272.     else
  4273.       self.cursor_rect.empty
  4274.     end
  4275.   end
  4276. end
  4277.  
  4278. #==============================================================================
  4279. # ** Scene_End
  4280. #------------------------------------------------------------------------------
  4281. #  This class performs game end screen processing.
  4282. #==============================================================================
  4283.  
  4284. class Scene_End < Scene_Base
  4285.   #--------------------------------------------------------------------------
  4286.   # * Start processing
  4287.   #--------------------------------------------------------------------------
  4288.   def start
  4289.     super
  4290.     # Create Menu Back Sprite
  4291.     @menuback_sprite = Sprite.new
  4292.     @menuback_sprite.bitmap = Cache.system("Lufia Menu Back")            
  4293.     create_command_window
  4294.   end
  4295.   #--------------------------------------------------------------------------
  4296.   # * Post-Start Processing
  4297.   #--------------------------------------------------------------------------
  4298.   def post_start
  4299.     super
  4300.     open_command_window
  4301.   end
  4302.   #--------------------------------------------------------------------------
  4303.   # * Pre-termination Processing
  4304.   #--------------------------------------------------------------------------
  4305.   def pre_terminate
  4306.     super
  4307.     close_command_window
  4308.   end
  4309.   #--------------------------------------------------------------------------
  4310.   # * Termination Processing
  4311.   #--------------------------------------------------------------------------
  4312.   def terminate
  4313.     super
  4314.     dispose_command_window
  4315.     @menuback_sprite.dispose
  4316.     @menuback_sprite.bitmap.dispose                
  4317.   end
  4318.   #--------------------------------------------------------------------------
  4319.   # * Return to Original Screen
  4320.   #--------------------------------------------------------------------------
  4321.   def return_scene
  4322.     $scene = Scene_Menu.new(6)
  4323.   end
  4324.   #--------------------------------------------------------------------------
  4325.   # * Frame Update
  4326.   #--------------------------------------------------------------------------
  4327.   def update
  4328.     super
  4329.     @command_window.update
  4330.     if @command_window.active == false and @command_window.openness == 255
  4331.       @command_window.active = true
  4332.       @command_window.index = 0      
  4333.       @command_window.change_cursor_visibility(false)          
  4334.     end
  4335.    
  4336.     if Input.trigger?(Input::B)
  4337.       Sound.play_cancel
  4338.       @command_window.index = -1              
  4339.       return_scene
  4340.     elsif Input.trigger?(Input::C) and @command_window.active
  4341.       case @command_window.index
  4342.       when 0  # to title
  4343.         command_to_title
  4344.       when 1  # shutdown
  4345.         command_shutdown
  4346.       when 2  # quit
  4347.         command_cancel
  4348.       end
  4349.     end
  4350.   end
  4351.   #--------------------------------------------------------------------------
  4352.   # * Create Command Window
  4353.   #--------------------------------------------------------------------------
  4354.   def create_command_window
  4355.     s1 = Vocab::to_title
  4356.     s2 = Vocab::shutdown
  4357.     s3 = Vocab::cancel
  4358.     @command_window = TDS_Window_Command.new(172, [s1, s2, s3])
  4359.     @command_window.x = (544 - @command_window.width) / 2
  4360.     @command_window.y = (416 - @command_window.height) / 2
  4361.     @command_window.index = -1            
  4362.     @command_window.active = false
  4363.     @command_window.openness = 0
  4364.   end
  4365.   #--------------------------------------------------------------------------
  4366.   # * Dispose of Command Window
  4367.   #--------------------------------------------------------------------------
  4368.   def dispose_command_window
  4369.     @command_window.dispose
  4370.   end
  4371.   #--------------------------------------------------------------------------
  4372.   # * Open Command Window
  4373.   #--------------------------------------------------------------------------
  4374.   def open_command_window
  4375.     @command_window.open
  4376.     begin
  4377.       @command_window.update
  4378.       Graphics.update
  4379.     end until @command_window.openness == 255
  4380.   end
  4381.   #--------------------------------------------------------------------------
  4382.   # * Close Command Window
  4383.   #--------------------------------------------------------------------------
  4384.   def close_command_window
  4385.     @command_window.close
  4386.     begin
  4387.       @command_window.update
  4388.       Graphics.update
  4389.     end until @command_window.openness == 0
  4390.   end
  4391.   #--------------------------------------------------------------------------
  4392.   # * Process When Choosing [To Title] Command
  4393.   #--------------------------------------------------------------------------
  4394.   def command_to_title
  4395.     @command_window.index = -1        
  4396.     Sound.play_decision
  4397.     RPG::BGM.fade(800)
  4398.     RPG::BGS.fade(800)
  4399.     RPG::ME.fade(800)
  4400.     close_command_window
  4401.     Graphics.fadeout(60)
  4402.     $scene = Scene_File.new(false, true, false)            
  4403.     Audio.bgm_play("Audio/BGM/Lufia II - Title Loading Screen", 100, 100)  
  4404.   end
  4405.   #--------------------------------------------------------------------------
  4406.   # * Process When Choosing [Shutdown] Command
  4407.   #--------------------------------------------------------------------------
  4408.   def command_shutdown
  4409.     @command_window.index = -1            
  4410.     Sound.play_decision
  4411.     RPG::BGM.fade(800)
  4412.     RPG::BGS.fade(800)
  4413.     RPG::ME.fade(800)
  4414.     $scene = nil
  4415.     exit
  4416.   end
  4417.   #--------------------------------------------------------------------------
  4418.   # *  Process When Choosing [Cancel] Command
  4419.   #--------------------------------------------------------------------------
  4420.   def command_cancel
  4421.     @command_window.index = -1            
  4422.     Sound.play_decision
  4423.     return_scene
  4424.   end
  4425. end
clone this paste RAW Paste Data